/* ── Google Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif:ital,wght@0,400;0,600;0,700;1,400&family=Inter:wght@400;500;600;700&display=swap');

/* ── Design tokens — warm Indian palette ──────────────────────────────────── */
:root {
  /* ── Colour palette ── */
  --bg:           #fdf6ec;
  --surface:      #fffdf8;
  --surface-warm: #fef3e2;
  --border:       #e8d5b7;
  --border-soft:  #f0e4cc;
  --text:         #1c1108;
  --text-soft:    #7a5c3a;

  --accent:        #c2690a;
  --accent-bright: #e07b0a;
  --accent-hover:  #a35608;
  --accent-bg:     #fef0dc;
  --accent-rgb:    194, 105, 10;  /* for rgba(var(--accent-rgb), α) */

  --green:       #1a5c3a;
  --green-light: #d1fae5;
  --green-rgb:   26, 92, 58;

  --danger:       #b91c1c;
  --danger-light: #fee2e2;
  --danger-rgb:   185, 28, 28;

  --income:    #15803d;
  --done-text: #9e8060;  /* darkened: 3.6:1 on surface — meets WCAG AA */
  --white:     #fff;

  /* ── Primary button — separate tokens so bg can be darker than --accent ──
     --accent (#c2690a) gives only 3.8:1 with white text (fails WCAG AA).
     These dedicated shades achieve 5.2:1 ✓                                */
  --btn-primary-bg:       #a35608;
  --btn-primary-bg-hover: #8a4606;
  --btn-primary-color:    var(--white);

  /* ── Layout ── */
  --tab-h: 64px;
  --radius: 0px;   /* sharp edges throughout */

  /* ── Elevation ── */
  --shadow:    0 1px 4px  rgba(100,60,10,.10);
  --shadow-md: 0 4px 16px rgba(100,60,10,.12);

  /* ── Motion ── */
  --transition: .15s;

  /* ── Typography scale (rem at 16px base) ──
     7 steps; --text-2xs / --text-chip / --text-ms removed (merged into
     adjacent steps — differences of 1–2px were imperceptible).           */
  --text-xs:   .625rem;   /* 10px — tab labels, micro            */
  --text-sm:   .75rem;    /* 12px — tags, chips, captions, meta  */
  --text-md:   .875rem;   /* 14px — secondary body, meta         */
  --text-base: .9375rem;  /* 15px — primary body                 */
  --text-lg:   1.125rem;  /* 18px — subheadings                  */
  --text-xl:   1.25rem;   /* 20px — section titles               */
  --text-2xl:  1.875rem;  /* 30px — page title                   */

  /* ── Letter spacing ── */
  --ls-tight: .05em;  /* tags, chips */
  --ls-caps:  .07em;  /* uppercase labels */

  /* ── Tricolor stripe — saffron | forest | sindoor ──
     Fixed colours: represents the Indian flag palette.
     Intentionally does NOT adapt to dark mode.          */
  --stripe: linear-gradient(90deg, #e07b0a 0% 33%, #1a5c3a 33% 66%, #b91c1c 66% 100%);
}

/* ── Dark mode: follows system preference unless overridden ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #120d06;
    --surface:      #1d1509;
    --surface-warm: #251a0b;
    --border:       #3a2810;
    --border-soft:  #2e1f0c;
    --text:         #f5e9d5;
    --text-soft:    #a8875a;

    --accent:        #f59e0b;
    --accent-bright: #fbbf24;
    --accent-hover:  #d97706;
    --accent-bg:     #2a1f08;
    --accent-rgb:    245, 158, 11;

    --green:       #34d399;
    --green-light: #064e3b;
    --green-rgb:   52, 211, 153;

    --danger:       #f87171;
    --danger-light: #450a0a;
    --danger-rgb:   248, 113, 113;

    --income:    #4ade80;
    --done-text: #7a6045;  /* lightened: 3.3:1 on dark surface — meets WCAG AA */

    /* Primary button — dark amber, white text 4.65:1 ✓ */
    --btn-primary-bg:       #b45d06;
    --btn-primary-bg-hover: #9a4e05;
    --btn-primary-color:    var(--white);

    --shadow:    0 1px 4px  rgba(0,0,0,.40);
    --shadow-md: 0 4px 16px rgba(0,0,0,.50);
  }
}

/* ── Explicit dark mode override ── */
:root[data-theme="dark"] {
  --bg:           #120d06;
  --surface:      #1d1509;
  --surface-warm: #251a0b;
  --border:       #3a2810;
  --border-soft:  #2e1f0c;
  --text:         #f5e9d5;
  --text-soft:    #a8875a;

  --accent:        #f59e0b;
  --accent-bright: #fbbf24;
  --accent-hover:  #d97706;
  --accent-bg:     #2a1f08;
  --accent-rgb:    245, 158, 11;

  --green:       #34d399;
  --green-light: #064e3b;
  --green-rgb:   52, 211, 153;

  --danger:       #f87171;
  --danger-light: #450a0a;
  --danger-rgb:   248, 113, 113;

  --income:    #4ade80;
  --done-text: #7a6045;  /* lightened: 3.3:1 on dark surface — meets WCAG AA */

  /* Primary button — dark amber, white text 4.65:1 ✓ */
  --btn-primary-bg:       #b45d06;
  --btn-primary-bg-hover: #9a4e05;
  --btn-primary-color:    var(--white);

  --shadow:    0 1px 4px  rgba(0,0,0,.40);
  --shadow-md: 0 4px 16px rgba(0,0,0,.50);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
input, button, select, textarea { font: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); }

/* ── Accessibility utilities ───────────────────────────────────────────────── */

/* Visually hidden but available to screen readers */
.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;
}

/* Focus ring — shown only on keyboard navigation, not on mouse click */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Item text used as an edit trigger — make it clear it's interactive */
.item-text[role="button"] {
  cursor: pointer;
  border-radius: var(--radius);
}
.item-text[role="button"]:focus-visible {
  outline-offset: -2px;
}

/* ── Material Icons ────────────────────────────────────────────────────────── */
.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga';
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
  background: var(--bg);
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem calc(var(--tab-h) + 1.5rem);
}

.section-title {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
  color: var(--text);
}

.trip-items-panel {
  padding: 0 1rem 1rem;
  background: var(--surface-warm);
  border-top: 1px solid var(--border);
}
.trip-items-panel.hidden { display: none; }

.finance-summary {
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

/* ══════════════════════════════════════════════════════════════════════════════
   MOTIF 4 — PHULKARI ACTIVE-TAB INDICATOR (Punjab)
   In phulkari, colorful beads and knots mark intersections of the lattice.
   The active tab gets a small saffron diamond — a bead of embroidery thread.
══════════════════════════════════════════════════════════════════════════════ */

.tab-btn[aria-selected="true"] { color: var(--accent); }
.tab-btn[aria-selected="true"]::after {
  content: '';
  position: absolute;
  top: -5px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  transform: rotate(45deg);
}

.trip-card-header {
  padding: .875rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  cursor: pointer;
  user-select: none;
}

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-container {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-md);
  border-top: 4px solid transparent;
  border-image: var(--stripe) 1;
  border-image-slice: 1;
}

.login-title {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  text-align: center;
  margin-bottom: .25rem;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.login-title .material-icons { font-size: 1.75rem; color: var(--accent); }

.login-subtitle {
  font-size: var(--text-md);
  text-align: center;
  color: var(--text-soft);
  margin-bottom: 1.75rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.login-form label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  margin-bottom: -.25rem;
}
.form-error {
  color: var(--danger);
  font-size: var(--text-md);
  margin: 0;
}

/* ── App shell ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid transparent;
  border-image: var(--stripe) 1;
  border-image-slice: 1;
  padding: .75rem 1.125rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.app-header h1 {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: .375rem;
}
.app-header h1 .material-icons { font-size: var(--text-lg); }

.app-header .user-chip {
  font-size: var(--text-md);
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: .25rem;
}

/* ── Bottom tab bar ────────────────────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--tab-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-soft);
  transition: color var(--transition);
  padding-bottom: env(safe-area-inset-bottom, 0);
  position: relative;
}

.tab-btn .tab-icon { font-size: 1.375rem; line-height: 1; }
.tab-btn:disabled { opacity: .35; cursor: not-allowed; }


/* ── Tab panels ────────────────────────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Add form ──────────────────────────────────────────────────────────────── */
.add-form {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.add-form input, .add-form select {
  flex: 1;
  min-width: 0;
}

/* ── Inputs ────────────────────────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
select {
  display: block;
  width: 100%;
  padding: .625rem .875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  padding: .625rem 1.125rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--text-base);
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-color);
}
.btn-primary:hover { background: var(--btn-primary-bg-hover); }
.btn-primary:active { opacity: .85; }

.btn-icon {
  font-size: 1rem;
  color: var(--text-soft);
  padding: .25rem .375rem;
  min-width: 44px;   /* WCAG 2.5.5 minimum touch target */
  min-height: 44px;
  border-radius: var(--radius);
  transition: color var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { color: var(--danger); }
/* Close icons inside btn-icon use a slightly larger size for tap comfort */
.btn-icon .material-icons { font-size: var(--text-lg); }

/* ── List items ────────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: .5rem; }

.list-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--border);
  transition: border-left-color var(--transition);
}
/* ══════════════════════════════════════════════════════════════════════════════
   MOTIF 8 — PHULKARI COLOUR BLOOM (Punjab)
   On hover, the left border cycles through saffron → forest green → sindoor
   before settling on the accent — like a thread tightening into a stitch.
══════════════════════════════════════════════════════════════════════════════ */
.list-item:not(.done):hover {
  animation: phulkari-bloom .55s ease forwards;
}
@keyframes phulkari-bloom {
  0%   { border-left-color: var(--accent-bright); }
  35%  { border-left-color: var(--green); }
  70%  { border-left-color: var(--danger); }
  100% { border-left-color: var(--accent); }
}
.list-item.done {
  opacity: .7;
  border-left-color: var(--border);
}
.list-item.done .item-text {
  text-decoration: line-through;
  color: var(--done-text);
}

.item-text { flex: 1; font-size: var(--text-base); }
.item-meta { font-size: var(--text-sm); color: var(--text-soft); }


.item-check {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Finance specifics ─────────────────────────────────────────────────────── */
.expense-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.expense-amount.income { color: var(--income); }
.expense-amount.expense { color: var(--danger); }

.summary-label {
  font-size: var(--text-xs);
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  font-weight: 600;
}
.summary-value {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: .125rem;
}
.balance-positive { color: var(--income); }
.balance-negative { color: var(--danger); }

/* ── Trips ─────────────────────────────────────────────────────────────────── */
.trip-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  overflow: hidden;
  border-top: 3px solid var(--accent);
}

.trip-card-header:active { background: var(--surface-warm); }
.trip-info { flex: 1; }
.trip-name {
  font-family: 'Noto Serif', Georgia, serif;
  font-weight: 700;
  font-size: var(--text-base);
}
.trip-dates {
  font-size: var(--text-md);
  color: var(--text-soft);
  margin-top: .125rem;
  display: flex;
  align-items: center;
  gap: .25rem;
}
.trip-dates .material-icons { font-size: var(--text-md); }

.trip-add-item {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
}
.trip-add-item input { flex: 1; }
.trip-add-item select { width: 90px; flex-shrink: 0; }
.trip-items-list { display: flex; flex-direction: column; gap: .375rem; }

/* ── Empty state ───────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════════════════
   MOTIF 9 — GIDDHA DOT RINGS (Punjab)
   Giddha dancers form concentric circles. Empty states carry three dashed
   rings in saffron, forest green, and sindoor red as a faint watermark.
   Note: SVG data URL — CSS custom properties cannot be used inside data: URIs.
══════════════════════════════════════════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-soft);
  font-size: var(--text-base);
  position: relative;
}
.empty::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -58%);
  width: 160px;
  height: 160px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Ccircle cx='80' cy='80' r='35' fill='none' stroke='rgba(194,105,10,.16)' stroke-width='1.5' stroke-dasharray='4 4'/%3E%3Ccircle cx='80' cy='80' r='55' fill='none' stroke='rgba(26,92,58,.11)' stroke-width='1.5' stroke-dasharray='5 5'/%3E%3Ccircle cx='80' cy='80' r='73' fill='none' stroke='rgba(185,28,28,.07)' stroke-width='1.5' stroke-dasharray='6 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 160px 160px;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   MOTIF 7 — NAKSHI KANTHA FISH (Bengal)
   The maach (fish) is the most auspicious Bengali motif — prosperity,
   abundance. A stylized fish watermark behind the grocery empty state.
   Note: SVG data URL — CSS custom properties cannot be used inside data: URIs.
══════════════════════════════════════════════════════════════════════════════ */
#grocery-list .empty::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 80'%3E%3Cellipse cx='60' cy='40' rx='38' ry='24' fill='none' stroke='rgba(194,105,10,.13)' stroke-width='2'/%3E%3Cpolygon points='98,40 118,22 118,58' fill='none' stroke='rgba(194,105,10,.13)' stroke-width='2'/%3E%3Ccircle cx='34' cy='36' r='3.5' fill='rgba(194,105,10,.15)'/%3E%3Cpath d='M48,16 Q68,5 82,24' fill='none' stroke='rgba(194,105,10,.1)' stroke-width='1.5'/%3E%3Cpath d='M52,52 Q64,62 78,56' fill='none' stroke='rgba(194,105,10,.08)' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 180px 100px;
  width: 180px;
  height: 100px;
}

/* ── Form layout helpers ───────────────────────────────────────────────────── */
#expense-form { flex-wrap: wrap; }
#expense-desc     { flex: 1 1 140px; }
#expense-amount   { flex: 0 1 100px; }
#expense-type     { flex: 0 1 100px; }
#expense-category { flex: 1 1 120px; }

#trip-form  { flex-wrap: wrap; }
#trip-name  { flex: 1 1 120px; }
#trip-dest  { flex: 1 1 120px; }
#trip-start { flex: 0 1 140px; }
#trip-end   { flex: 0 1 140px; }

#grocery-qty { max-width: 80px; }

.trip-item-row { padding: .5rem .75rem; }
.trip-item-row .item-text { font-size: var(--text-md); }
.trip-item-placeholder { width: 22px; display: inline-block; }
/* Type chip inside trip item rows */
.trip-item-type { margin-right: .375rem; }

/* ── Toast notifications ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--tab-h) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: .5rem 1.25rem;
  border-radius: var(--radius);
  font-size: var(--text-md);
  font-weight: 500;
  z-index: 100;
  white-space: nowrap;
  pointer-events: none;
  animation: toast-in .2s ease;
}
.toast-error { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0);   }
}

/* ── Tags ──────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-tight);
  padding: 0.125rem 0.4375rem;
  border-radius: var(--radius);
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), .2);
}

.tag-assignee {
  background: var(--green-light);
  color: var(--green);
  border-color: rgba(var(--green-rgb), .2);
}

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  margin-bottom: 1rem;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  padding: 0.2rem 0.625rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active          { background: var(--accent); color: var(--white); border-color: var(--accent); }
.filter-chip.active-assignee { background: var(--green);  color: var(--white); border-color: var(--green); }

/* ── Todo form (fixed above tab bar, visible only on todos tab) ─────────────── */
#todo-form,
#grocery-form {
  display: none;
  flex-direction: column-reverse;  /* tag row sits above the input */
  position: fixed;
  bottom: var(--tab-h);
  left: 0;
  right: 0;
  z-index: 15;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(100,60,10,.08);  /* lift form above tab bar */
  padding: .75rem 1rem;
}
body.todos-active #todo-form { display: flex; }
body.groceries-active #grocery-form { display: flex; }

/* Extra bottom padding so content isn't hidden behind the fixed form.
   Todos expanded form (~150px) + tab bar (64px) → 9rem.
   Groceries form with tag row (~100px) + tab bar (64px) → 7rem.     */
body.todos-active #panel-todos         { padding-bottom: 9rem; }
body.groceries-active #panel-groceries { padding-bottom: 7rem; }

.todo-form-main {
  display: flex;
  gap: .5rem;
  align-items: stretch;
}
.todo-form-main #todo-input,
.todo-form-main #grocery-input { flex: 1; min-width: 0; }
.todo-form-main #grocery-qty   { width: 4.5rem; flex-shrink: 0; }

.todo-expand-btn {
  border: 1px solid var(--border);
  padding: .5rem .625rem;
  color: var(--text-soft);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.todo-expand-btn[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
}

.todo-form-details {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;  /* sits above the input row (column-reverse) */
  padding: .625rem .75rem;
  background: var(--surface-warm);
  border: 1px solid var(--border-soft);
  border-bottom: 2px solid var(--accent);
  animation: todo-details-in var(--transition) ease;
}
.todo-form-details[hidden] { display: none; }
#todo-tag      { flex: 1 1 90px; }
#todo-assignee { flex: 1 1 100px; }
#todo-due      { flex: 1 1 140px; }

/* Grocery tag row sits just above the input (column-reverse) */
#grocery-tag-selector { margin-bottom: .375rem; }

@keyframes todo-details-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Todo controls row (filter bar + sort) ─────────────────────────────────── */
.todo-controls {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: 1rem;
}
.todo-controls .filter-bar { flex: 1; margin-bottom: 0; }
.todo-sort-select {
  flex-shrink: 0;
  width: auto;
  padding: 0.2rem 0.5rem;
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
}
.todo-sort-select:focus { border-color: var(--accent); box-shadow: none; }

/* ── Overdue / due date tag variants ───────────────────────────────────────── */
.tag-due {
  background: var(--surface-warm);
  color: var(--text-soft);
  border-color: var(--border-soft);
}
.tag-overdue {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(var(--danger-rgb), .2);
}

/* ── Todo card layout ──────────────────────────────────────────────────────── */

/* Assignee avatar — circular letter badge */
.todo-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.todo-avatar--accent {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), .25);
}
.todo-avatar--green {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid rgba(var(--green-rgb), .25);
}

/* Date + tag on one line below the title */
.todo-meta-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .25rem;
}
.todo-due {
  font-size: var(--text-sm);
  color: var(--text-soft);
}
.todo-due.overdue {
  color: var(--danger);
  font-weight: 600;
}

/* Strikethrough on title text only */
.list-item.done .todo-title {
  text-decoration: line-through;
  color: var(--done-text);
}

/* ── Group-by section headers ──────────────────────────────────────────────── */
.todo-group-header {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-soft);
  padding-bottom: .375rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
/* Kantha-stitch dashed rule extending to the right */
.todo-group-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(
    90deg,
    var(--border) 0, var(--border) 4px,
    transparent 4px, transparent 8px
  );
}
.todo-group-header--gap { margin-top: 1.25rem; }

/* Completed section header — slightly muted vs regular group headers */
.todo-done-header { opacity: .65; }

/* "Show / Hide completed" toggle link */
.todo-done-toggle {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: .5rem 0;
  font-size: var(--text-sm);
  color: var(--text-soft);
  text-align: center;
  border-top: 1px solid var(--border-soft);
  background: none;
  cursor: pointer;
  transition: color var(--transition);
}
.todo-done-toggle:hover { color: var(--accent); }

/* ── Tag selector ──────────────────────────────────────────────────────────── */
.tag-selector {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
}
.tag-chip {
  padding: 0.2rem 0.5rem;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-tight);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.selected {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}
.tag-chip-add {
  border-style: dashed;
  padding: 0.2rem 0.5rem;
  font-size: var(--text-md);
  line-height: 1;
}
.tag-chip-input {
  width: 80px;
  padding: 0.2rem 0.375rem;
  font-size: var(--text-xs);
  border: 1px solid var(--accent);
}
/* tag selector inside the edit form sits between title and assignee/date */
.todo-edit-tag-selector { margin-bottom: .25rem; }

/* ── Grocery inline edit ───────────────────────────────────────────────────── */
.grocery-edit-name { flex: 1; }
.grocery-edit-qty  { width: 5rem; }

/* ── Hide add form + tab bar while a list item is being edited ─────────────── */
/* Uses :has() so no JS is needed. The keyboard takes that space instead.       */
body:has(#todo-list    .list-item.editing) #todo-form,
body:has(#todo-list    .list-item.editing) .tab-bar,
body:has(#grocery-list .list-item.editing) #grocery-form,
body:has(#grocery-list .list-item.editing) .tab-bar { display: none; }

body:has(#todo-list    .list-item.editing).todos-active     #panel-todos,
body:has(#grocery-list .list-item.editing).groceries-active #panel-groceries { padding-bottom: 1.5rem; }

/* ── Todo inline edit ──────────────────────────────────────────────────────── */
.list-item.editing {
  align-items: stretch;
  cursor: default;
  border-left-color: var(--accent);
}
.todo-edit-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: 0;
}
.todo-edit-title {
  font-size: var(--text-base);
  font-weight: 500;
  width: 100%;
}
.todo-edit-meta {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.todo-edit-meta input,
.todo-edit-meta select { flex: 1 1 90px; }
.todo-edit-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}
.todo-edit-actions .btn {
  padding: .3rem .75rem;
  font-size: var(--text-sm);
}

/* ── Trip items empty state ────────────────────────────────────────────────── */
.trip-items-list .empty { padding: .5rem 0; }

/* ── Reduced motion ────────────────────────────────────────────────────────── */
/* Respect system preference — disables all animations/transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:       .01ms !important;
    animation-iteration-count: 1    !important;
    transition-duration:      .01ms !important;
  }
}
