/* GreenMagpie — warm, elegant, joyful ledger UI. Built on tokens.css. */

@font-face {
  font-family: "Inter Variable";
  src: url("/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces Soft";
  src: url("/fonts/Fraunces72ptSoft-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces Soft";
  src: url("/fonts/Fraunces72ptSoft-Black.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  transition: background-color var(--duration-base) var(--ease-standard);
}

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
  /* Browsers default unstyled <button> text to a system color (near-black), not inherited from
     the page — invisible-low-contrast on any custom-colored dark surface. Every classed button
     (.btn, .link, .icon-btn) sets its own color anyway, so this only changes plain inline-styled
     buttons like the itemiser's participant chips, which is exactly the case that broke. */
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

/* -------- App shell -------- */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
}

.brand .mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--highlight));
}

.topbar .actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  padding: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
}

.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; }

main#screen {
  flex: 1;
  padding: var(--space-5) var(--space-5) calc(var(--tab-bar-h, 76px) + var(--space-6) + env(safe-area-inset-bottom, 0px));
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

/* -------- Tab bar -------- */

.tabbar {
  --tab-bar-h: 76px;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tab-bar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 20;
}

.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  transition: color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
}

.tabbar button:active { transform: scale(0.94); }

.tabbar button svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
}

.tabbar button.active { color: var(--accent); }

.tabbar .fab { position: relative; color: var(--text-faint); }

.tabbar .fab .fab-circle {
  position: absolute;
  top: -22px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--leaf-500));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.tabbar .fab:active .fab-circle { transform: scale(0.92); }
.tabbar .fab .fab-circle svg { stroke: #fff; }
.tabbar .fab span { margin-top: 34px; }

/* -------- Cards / surfaces -------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: var(--space-3); }

.section-label {
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  margin: var(--space-6) 0 var(--space-2);
}

.section-label:first-child { margin-top: 0; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--space-6) 0 var(--space-2);
}
.section-header:first-child { margin-top: 0; }
.section-header .section-label { margin: 0; }
/* min-height/inline-flex give every .link button a >=44px touch target without growing its
   visible text — every usage in the app is a real button (Copy/Revoke/Restore/Delete/toggle),
   never inline prose, so expanding the hit area doesn't affect text flow. */
.link { color: var(--accent); background: none; border: none; font-weight: 500; padding: 0; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; }
.section-header .link { font-size: var(--text-sm); }

/* -------- Ledger rows -------- */

.ledger-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.ledger-row:last-child { border-bottom: none; }

.ledger-row .avatar-slot { flex-shrink: 0; }

.ledger-row .body { flex: 1; min-width: 0; }

.ledger-row .desc {
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
  /* Wraps rather than clips — the activity feed's descriptions ("You added X ($Y) in Z") run
     long, and a hard ellipsis truncation was silently cutting off the group name on many rows. */
  overflow-wrap: break-word;
}

.ledger-row .amount {
  flex-shrink: 0;
  font-size: var(--text-base);
  font-weight: 600;
}

.ledger-row .meta {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-top: 1px;
}

.amount.credit { color: var(--credit); }
.amount.debt { color: var(--debt); }

/* -------- Skeleton loading -------- */
/* Shaped like the real content it stands in for, so nothing jumps when data arrives — never a
   spinner. The global prefers-reduced-motion rule (tokens.css) already collapses the shimmer's
   animation-duration to ~0, so this needs no separate reduced-motion handling of its own. */

.skeleton {
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--border) 50%, var(--surface-2) 70%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

.skeleton-line { height: 14px; margin: 4px 0; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-100 { width: 100%; }

.skeleton-avatar { width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0; }
.skeleton-avatar.round { border-radius: 50%; }

.skeleton-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; }
.skeleton-row .skeleton-body { flex: 1; min-width: 0; }

.skeleton-hero { height: 56px; width: 70%; margin: 8px auto; }
.skeleton-chart { height: 140px; width: 100%; border-radius: var(--radius-md); }

/* -------- List items (friends/groups) -------- */

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}

.list-item[data-open], .list-item[data-group], .list-item[data-friend], .list-item[data-suggest] { cursor: pointer; }
.list-item:active { transform: scale(0.98); }

.list-item .name { font-weight: 600; }
.list-item .detail { font-size: var(--text-xs); color: var(--text-faint); margin-top: 2px; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .right { text-align: right; flex-shrink: 0; }

/* -------- Buttons -------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 13px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  width: 100%;
  min-height: 44px;
  transition: transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}

.btn:active { transform: scale(0.97); }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--leaf-500));
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

.btn.danger { background: transparent; color: var(--debt); border-color: var(--debt-subtle); }
.btn.ghost { background: transparent; border-color: transparent; }

.btn-row { display: flex; gap: var(--space-2); }
.btn-row .btn { width: auto; flex: 1; }

/* -------- Forms -------- */

label {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: var(--space-2);
  margin-top: var(--space-4);
}

label:first-child { margin-top: 0; }

/* Excludes checkbox/radio/file/range — those get their own rules below. Night-2 bug: this used
   to apply to every input unconditionally, which stretched checkboxes to 100% width/44px
   height with padding and a border, turning them into giant broken boxes wherever a form used
   one (payer/participant selection). Caught by actually looking at a rendered form with
   checkboxes in it, not by reading the CSS. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-body);
  min-height: 44px;
  transition: border-color var(--duration-fast) var(--ease-standard);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):focus,
select:focus,
textarea:focus { border-color: var(--accent); outline: none; }

input[type="checkbox"], input[type="radio"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

input[type="file"] {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) 0;
  color: var(--text-dim);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
}

.split-toggle {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.split-toggle button {
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: capitalize;
}

.split-toggle button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* -------- Sheet / modal -------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 30, 32, 0.45);
  backdrop-filter: blur(2px);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  animation: fade-in var(--duration-fast) var(--ease-standard);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-4) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  animation: sheet-up var(--duration-base) var(--ease-standard);
  box-shadow: var(--shadow-lg);
}

@keyframes sheet-up {
  from { transform: translateY(28px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  margin: var(--space-1) auto var(--space-4);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.sheet-header h2 { font-size: var(--text-lg); }

.sheet-header .close {
  background: var(--surface-2);
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* -------- Calculator (receipt adding machine, GM.openCalculatorSheet) -------- */

.calc-total {
  font-size: var(--text-2xl);
  font-weight: 700;
  text-align: right;
}

.calc-tape {
  max-height: 30vh;
  overflow-y: auto;
  margin-top: var(--space-3);
}

.calc-tape:empty { margin-top: 0; }

.calc-tape-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.calc-tape-row:last-child { border-bottom: none; }
.calc-tape-row .calc-tape-op { font-weight: 700; width: 1.2em; }
.calc-tape-row .calc-tape-op.credit { color: var(--credit); }
.calc-tape-row .calc-tape-op.debt { color: var(--debt); }
.calc-tape-row .num { flex: 1; }
.calc-tape-row .calc-tape-remove { color: var(--text-faint); flex-shrink: 0; }

.calc-entry {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-lg);
  text-align: right;
  min-height: 1.4em;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.calc-key {
  min-height: 56px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-md);
  font-weight: 600;
}

.calc-key:active { transform: scale(0.96); }
.calc-key:disabled { opacity: 0.35; }

.calc-key-op {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
  color: var(--accent);
  /* + and − are the last two keys in an 18-key grid (4 columns) — spanning 2 columns each fills
     the final row cleanly instead of leaving it half-empty, and gives the "commit to tape"
     action visual weight over plain digits. */
  grid-column: span 2;
}

.calc-key-fn {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text-dim);
  font-weight: 700;
}

/* -------- Trip dashboard (Night 11 W2) -------- */

.trip-dashboard { margin-top: 16px; }

.trip-hero {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.trip-ring-wrap { position: relative; flex-shrink: 0; }

.trip-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trip-ring-pct { font-size: var(--text-lg); font-weight: 700; }

.trip-hero-body { flex: 1; min-width: 0; }
.trip-hero-spent { font-size: var(--text-lg); font-weight: 600; }
.trip-hero-plain { font-size: var(--text-lg); font-weight: 600; }

.trip-verdict { font-size: var(--text-sm); font-weight: 600; margin-top: 12px; }

/* -------- Trips (Night 11 W1) -------- */

.trip-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#trip-world-map {
  scroll-margin-top: 80px;
}

.trip-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  /* Night 12, W2 — tapping a country on the choropleth scrolls its stats card into view; without
     this, the sticky .topbar can cover a card scrolled flush to the top of the viewport. */
  scroll-margin-top: 80px;
}

.trip-card-cover {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  flex-shrink: 0;
  object-fit: cover;
}

.trip-card-body { flex: 1; min-width: 0; }
.trip-card-name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); }
.trip-card-meta { font-size: var(--text-sm); color: var(--text-faint); margin-top: 2px; }
.trip-card-flags { font-size: var(--text-md); margin-top: 4px; letter-spacing: 2px; }
.trip-card-budget { font-size: var(--text-sm); color: var(--text-dim); margin-top: 4px; font-weight: 500; }

/* -------- Country picker (search + chips) -------- */

.country-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}

.country-chip svg { width: 12px; height: 12px; }

.country-results {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.country-results:not(:empty) {
  border: 1.5px solid var(--border);
  margin-top: -1px;
}

.country-result {
  padding: 10px 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.country-result:last-child { border-bottom: none; }
.country-result:hover, .country-result:active { background: var(--surface-2); }

/* -------- Destination editor (a leg of a trip: place + optional dates) -------- */

.dest-list { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-2); }

.dest-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  background: var(--surface-2);
}

.dest-row-head { display: flex; align-items: center; gap: var(--space-2); }
.dest-flag { font-size: var(--text-lg); line-height: 1; }

/* The label sits unadorned until touched — a leg is usually just its country, and a full input
   box around an empty optional field reads as a form to fill in rather than a name to change. */
.dest-label {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  font-size: var(--text-md);
  font-weight: 500;
  padding: 6px 8px;
}
.dest-label:hover { border-color: var(--border); }
.dest-label:focus { border-color: var(--accent-border); background: var(--surface); }

.dest-remove {
  flex: none;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--text-faint);
}
.dest-remove:hover, .dest-remove:active { color: var(--debt); }

.dest-row-dates { display: flex; align-items: center; gap: var(--space-2); margin-top: 6px; }
.dest-row-dates input {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.dest-dash { flex: none; color: var(--text-faint); font-size: var(--text-sm); }

.dest-search { margin-bottom: 0; }

/* Advisory, not an error — overlapping legs are usually a travel day, so this is toned as a note
   rather than a failure. */
.dest-warning {
  margin-top: var(--space-2);
  padding: 8px 10px;
  border-left: 2px solid var(--accent-border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: var(--text-sm);
}

/* -------- Trip agenda (the day-by-day timeline) -------- */

/* The days are the skeleton, so the rail is drawn once down the whole column rather than per
   card — it's the thing that makes this read as a sequence instead of a list. */
.agenda-timeline {
  position: relative;
  padding-left: 14px;
  border-left: 1.5px solid var(--border);
  margin-top: var(--space-3);
}

.agenda-day { padding: var(--space-2) 0 var(--space-3); }
.agenda-day-head { display: flex; align-items: center; justify-content: space-between; }

.agenda-day-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* An empty day is information, not an error — it stays quiet rather than looking unfinished. */
.agenda-day.empty .agenda-day-label { color: var(--text-faint); font-weight: 500; }
.agenda-free { font-size: var(--text-sm); color: var(--text-faint); padding: 4px 0; }

.agenda-add {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text-faint);
}
.agenda-add:hover, .agenda-add:active { color: var(--accent); }

/* Destination bands mark where a leg begins, so the timeline can say "you're in Kyoto now"
   without repeating it on all six days. */
.agenda-band {
  display: flex; align-items: center; gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-2) -15px;
  padding: 8px 12px;
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.agenda-band-flag { font-size: var(--text-md); }
.agenda-band-name { font-weight: 600; }
.agenda-band-dates { margin-left: auto; font-size: var(--text-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }

.agenda-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: var(--space-2);
  margin-top: var(--space-2);
  cursor: pointer;
}
.agenda-card:hover, .agenda-card:active { border-color: var(--accent-border); }
.agenda-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Cancelled stays legible rather than being hidden — "we decided not to" is worth seeing. */
.agenda-card.cancelled { opacity: 0.55; }
.agenda-card.cancelled .agenda-title { text-decoration: line-through; }

.agenda-card-main { display: flex; align-items: flex-start; gap: var(--space-2); }
.agenda-type { font-size: var(--text-md); line-height: 1.3; flex: none; }
.agenda-card-body { flex: 1; min-width: 0; }
.agenda-title { font-weight: 500; }
.agenda-place, .agenda-span { font-size: var(--text-xs); color: var(--text-faint); margin-top: 2px; }
.agenda-card-right { flex: none; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.agenda-time { font-size: var(--text-sm); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.agenda-cost { font-size: var(--text-sm); color: var(--text-dim); }
.agenda-cost.linked { color: var(--accent); }

.agenda-card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  margin-top: 6px;
}
.agenda-card-meta:empty { display: none; }

.agenda-chip {
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-dim);
}
.agenda-chip.locked { background: var(--accent-subtle); color: var(--accent); }
.agenda-chip.needed { background: var(--surface-2); color: var(--debt); }
.agenda-votes, .agenda-comments { font-size: var(--text-xs); color: var(--text-faint); }

/* A multi-day item renders once, on its first day; the days it covers get this instead of a
   duplicate card. A 5-night hotel repeated five times would drown the week it spans. */
.agenda-continuation {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-faint);
  padding: 4px 0 4px var(--space-2);
  border-left: 2px solid var(--border);
  margin-top: var(--space-2);
  cursor: pointer;
}

.agenda-budget {
  display: flex; align-items: baseline; gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: var(--space-2);
}
.agenda-budget-split { margin-left: auto; }

.agenda-section { margin-top: var(--space-3); }
.agenda-desc { white-space: pre-wrap; }
.agenda-empty-hint { color: var(--text-faint); font-size: var(--text-sm); margin-top: var(--space-3); }

.vote-row { display: flex; gap: var(--space-2); }
/* Borders on all three, not just the chosen one: a ghost button with no outline reads as a label
   rather than something you can press, and the whole point of this row is that it's pressable. */
.vote-row .vote-btn {
  width: auto; flex: 1;
  border-color: var(--border);
  white-space: nowrap;
  font-size: var(--text-sm);
  padding-left: 8px; padding-right: 8px;
}
.vote-btn.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle); }

.agenda-comment { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.agenda-comment:last-child { border-bottom: none; }
.agenda-comment-head { display: flex; justify-content: space-between; font-size: var(--text-xs); margin-bottom: 2px; }

/* -------- Agenda: drag, stays, map links, half-days -------- */

/* touch-action:none is what makes the drag possible at all — without it the browser claims the
   gesture for scrolling before a single pointermove reaches us. Scoped to the handle so the rest
   of the card still scrolls normally. */
.agenda-drag {
  flex: none;
  width: 28px;
  min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  margin-left: -6px;
  background: none; border: none; cursor: grab;
  color: var(--text-faint);
  touch-action: none;
}
.agenda-drag:active { cursor: grabbing; }
.agenda-drag:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* The original stays in place, dimmed, so the day doesn't reflow under your finger mid-drag. */
.agenda-dragging { opacity: 0.35; }

.agenda-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transform: rotate(-1deg);
  opacity: 0.95;
}

.agenda-day.drop-target {
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
  outline: 1.5px dashed var(--accent-border);
}

/* Where you're sleeping, above the day's plans. Quieter than a card on purpose: it's context you
   glance at, not a plan you act on. */
.agenda-stay {
  display: flex; align-items: center; gap: 6px;
  margin-top: var(--space-2);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-xs);
  color: var(--text-dim);
}
.agenda-stay-name { font-weight: 500; }
.agenda-stay-place { margin-left: auto; }

.agenda-place-link {
  color: var(--accent);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 3px;
}
.agenda-place-link:hover { text-decoration: underline; }
.agenda-place-link svg { flex: none; opacity: 0.7; }

/* The `hidden` attribute only sets display:none at user-agent priority, so ANY explicit display
   rule beats it — .row's display:flex left the time fields visible on activities even though the
   markup said hidden.
   Scoped to these four wrappers rather than a global `[hidden] { display: none !important }`.
   The global version fixed this and broke the avatar upload: #avatar-file is a deliberately
   hidden file input that a styled label drives, and !important overrode the rule keeping it
   reachable. A blanket !important is exactly the kind of specificity sledgehammer that fixes one
   thing and silently disables another. */
#itin-end-date-wrap[hidden],
#itin-end-date-hint[hidden],
#itin-daypart-wrap[hidden],
#itin-time-wrap[hidden] { display: none; }

.daypart-row { display: flex; gap: var(--space-2); }
.daypart-row .daypart-btn { width: auto; flex: 1; border-color: var(--border); }
.daypart-btn.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle); }

/* -------- Auth screen -------- */

.auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-6) var(--space-5);
  max-width: 420px;
  margin: 0 auto;
  background:
    radial-gradient(circle at 15% 8%, var(--accent-subtle), transparent 45%),
    radial-gradient(circle at 85% 92%, var(--highlight-subtle), transparent 40%);
}

.auth-screen .brand-mark {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.auth-screen .brand-mark .mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--highlight));
  box-shadow: var(--shadow-md);
}

.auth-screen h1 { font-size: var(--text-2xl); }
.auth-screen .tagline { color: var(--text-faint); font-size: var(--text-sm); margin-top: var(--space-1); }
.auth-switch { text-align: center; margin-top: var(--space-4); font-size: var(--text-sm); color: var(--text-dim); }
.auth-switch button { background: none; border: none; color: var(--accent); font-size: var(--text-sm); font-weight: 600; }

.error-banner {
  background: var(--debt-subtle);
  border: 1px solid var(--debt);
  color: var(--debt);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-top: var(--space-4);
}

.toast-banner {
  background: var(--credit-subtle);
  border: 1px solid var(--credit);
  color: var(--credit);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-top: var(--space-4);
}

/* -------- Empty state -------- */

.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--text-faint);
}

.empty-state .illo { margin: 0 auto var(--space-4); display: block; }
.empty-state .title { font-family: var(--font-display); font-size: var(--text-md); color: var(--text); margin-bottom: var(--space-1); }
.empty-state .sub { font-size: var(--text-sm); max-width: 280px; margin: 0 auto var(--space-4); }

/* -------- Big balance figure -------- */

.balance-hero {
  text-align: center;
  padding: var(--space-6) var(--space-5);
}

.balance-hero .label {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
}

.balance-hero .figure {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--text-3xl);
  margin-top: var(--space-2);
}

.balance-hero .figure.credit { color: var(--credit); }
.balance-hero .figure.debt { color: var(--debt); }

/* -------- Pending sync badge -------- */
/* Night 3's own "least happy" item — was a static text pill with no visual language tying it to
   anything else in the system. Redesigned to read as "in progress," consistent with the
   skeleton shimmer's motion language: a small pulsing dot instead of static text alone. */

.pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  color: var(--highlight);
  background: var(--highlight-subtle);
  border-radius: var(--radius-pill);
  padding: 2px 8px 2px 6px;
  margin-left: var(--space-2);
}

.pending-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--highlight);
  animation: pending-pulse 1.4s ease-in-out infinite;
}

@keyframes pending-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

/* -------- Stat tiles -------- */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.stat-tile .label { font-size: var(--text-xs); color: var(--text-faint); font-weight: 600; }
.stat-tile .value { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; margin-top: var(--space-1); }
.stat-tile .delta { font-size: var(--text-xs); margin-top: 2px; font-weight: 600; }
.stat-tile .delta.up { color: var(--debt); }
.stat-tile .delta.down { color: var(--credit); }

/* -------- Reactions & comments -------- */


/* -------- Utility -------- */

.stack { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }

/* -------- Night 8: trust / pending approval -------- */

/* Gentle breathing animation on the hourglass badge — a pending expense is waiting, not urgent,
   so this is a slow ambient pulse, never a flashing alert. Static under reduced-motion via the
   global rule in tokens.css (animation-duration collapses to ~0). */
@keyframes pending-breathe {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
.pending-hourglass { animation: pending-breathe 2.4s var(--ease-standard) infinite; }
