@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;600;700&family=Space+Grotesk:wght@600;700&display=swap');

:root {
  --brand-50: #fff7ed;
  --brand-100: #ffedd5;
  --brand-300: #fdba74;
  --brand-500: #f97316;
  --brand-600: #ea580c;
  --brand-700: #c2410c;
  --ink-900: #111827;
  --ink-700: #374151;
  --surface: #ffffff;
  --surface-soft: #fffaf5;
  --bg: #fff9f4;
  --card: var(--surface);
  --text: var(--ink-900);
  --muted: var(--ink-700);
  --grey: #9ca3af;
  --green: #22c55e;
  --red: #ef4444;
  --border: #e8d7c6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Source Sans 3', 'Avenir Next', 'Helvetica Neue', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, var(--brand-100) 0%, #fff5ea 38%, var(--bg) 78%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  backdrop-filter: blur(6px);
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  font-family: 'Space Grotesk', 'Avenir Next', sans-serif;
  letter-spacing: 0.2px;
}

nav {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  background: #fff;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.nav-link.active {
  color: var(--brand-700);
  border-color: var(--brand-500);
  background: var(--brand-100);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1rem 4.5rem;
}

.date-label {
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: var(--muted);
}

.today-hero {
  margin-bottom: 1rem;
}

.mode-toggle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.mode-toggle-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  margin-right: 0.2rem;
}

.mode-option {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.mode-option.active {
  color: var(--brand-700);
  border-color: var(--brand-500);
  background: var(--brand-100);
}

.mode-option[disabled] {
  opacity: 0.5;
}

.mode-locked {
  color: var(--muted);
  font-size: 0.76rem;
}

.mode-message {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
}

.mode-message.info {
  background: #fff5e8;
  color: var(--brand-700);
}

.mode-message.success {
  background: #ecfdf5;
  color: #166534;
}

.mode-message.error {
  background: #fef2f2;
  color: #991b1b;
}

.celebration-banner {
  position: relative;
  overflow: hidden;
  border: 1px solid #f0cfaa;
  background: linear-gradient(145deg, #fff4e7, #fffdf9);
  color: var(--brand-700);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.9rem;
  box-shadow: 0 6px 14px rgba(194, 65, 12, 0.08);
}

.confetti-lite {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti-dot {
  position: absolute;
  top: -6px;
  left: var(--x);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0;
  background: var(--brand-500);
  animation: confetti-lite-fall 1.3s ease-out var(--delay) infinite;
}

.confetti-dot:nth-child(3n) {
  background: #fb923c;
}

.confetti-dot:nth-child(4n) {
  background: #fdba74;
}

@keyframes confetti-lite-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    transform: translateY(38px) rotate(240deg);
    opacity: 0;
  }
}

.progress-summary {
  background: linear-gradient(145deg, var(--brand-50) 0%, var(--card) 70%);
  border: 1px solid #f0cfaa;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  box-shadow: 0 7px 18px rgba(194, 65, 12, 0.08);
}

.progress-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.progress-line + .progress-line {
  margin-top: 0.25rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #f5dfc9;
  overflow: hidden;
  margin-top: 0.65rem;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-500) 0%, var(--brand-600) 100%);
  transition: width 180ms ease-out;
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.task-list form {
  margin: 0;
}

.task-button {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
  position: relative;
}

.task-button:active {
  transform: scale(0.985);
  filter: brightness(0.96);
}

.task-button.state-grey {
  background: #f0f3f8;
  color: var(--ink-900);
}

.task-button.state-green {
  color: #fff;
}

.task-label {
  font-weight: 700;
  text-align: left;
  line-height: 1.2;
}

.task-left {
  max-width: 72%;
}

.task-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}

.task-time {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.98;
}

.task-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.1rem 0.42rem;
}

.badge-done {
  background: rgba(255, 255, 255, 0.2);
}

.badge-pending {
  background: rgba(17, 24, 39, 0.12);
}

.day-summary-sticky {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
  background: linear-gradient(90deg, var(--brand-700), #7c2d12);
  color: #f9fafb;
  backdrop-filter: blur(4px);
}

.history-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.history-table {
  border-collapse: collapse;
  min-width: 860px;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.8rem;
}

.history-table tbody tr:nth-child(odd) td,
.history-table tbody tr:nth-child(odd) th.task-column {
  background: var(--surface-soft);
}

.task-column {
  text-align: left;
  min-width: 180px;
  position: sticky;
  left: 0;
  background: var(--card);
}

.history-cell {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: #fff;
  font-size: 0.72rem;
  line-height: 22px;
  font-weight: 700;
  text-align: center;
}

.cell-marker {
  display: inline-block;
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.state-grey {
  background: var(--grey);
}

.state-green {
  background: var(--green);
}

.state-red {
  background: var(--red);
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.stat-card {
  background: var(--surface-soft);
  border: 1px solid #f2d3b1;
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  box-shadow: 0 2px 8px rgba(194, 65, 12, 0.06);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(194, 65, 12, 0.1);
}

.stat-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-value {
  margin: 0.15rem 0 0;
  font-family: 'Space Grotesk', 'Avenir Next', sans-serif;
  font-size: 1.05rem;
  color: var(--brand-700);
}

.legend {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.7rem;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 0.3rem;
  vertical-align: middle;
}

.mode-minimum {
  background: var(--brand-500);
  color: #fff;
  font-size: 0.63rem;
  line-height: 12px;
  text-align: center;
}

@media (min-width: 768px) {
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  nav {
    margin-top: 0;
  }

  .container {
    padding-bottom: 1.5rem;
  }

  .history-stats {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .day-summary-sticky {
    left: auto;
    right: 1rem;
    bottom: 1rem;
    border-radius: 999px;
    width: auto;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
