/* Packing — wayfinding yellow for the trip header, quiet everywhere else. */
:root {
  --paper: #F4F6F8;
  --surface: #FFFFFF;
  --ink: #1C2430;
  --muted: #5B6676;
  --line: #D9DFE6;
  --signal: #FFC72C;
  --signal-ink: #1C2430;
  --focus: #1D5FA8;
  --danger: #B42318;

  --bag-0: #0F7B6C;   /* first main bag */
  --bag-1: #5A4FCF;
  --bag-2: #1D5FA8;
  --bag-3: #9A5B00;
  --bag-4: #A23B72;
  --bag-5: #3F6212;
  --bag-none: #7A8494;

  --st-Decide: #7C3AED;
  --st-Acquire: #1D5FA8;
  --st-Prepare: #B45309;
  --st-Pack: #0F7B6C;
  --st-Exclude: #7A8494;

  --radius-s: 6px;
  --radius-m: 10px;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161D;
    --surface: #1B212B;
    --ink: #E8ECF1;
    --muted: #9AA5B4;
    --line: #2E3744;
    --focus: #7FB2F0;
    --danger: #F97066;
    --bag-0: #3CC3AE;
    --bag-1: #A39BFF;
    --bag-2: #6FA8EE;
    --bag-3: #E0A040;
    --bag-4: #E58BBE;
    --bag-5: #9BC45A;
    --bag-none: #8C96A6;
    --st-Decide: #B28CFF;
    --st-Acquire: #6FA8EE;
    --st-Prepare: #E8A04A;
    --st-Pack: #3CC3AE;
    --st-Exclude: #8C96A6;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
}
body.has-sheet { overflow: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { max-width: 34rem; margin: 20vh auto; padding: 0 16px; text-align: center; }
.error { color: var(--danger); }
.spacer { flex: 1; }

.display {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.25rem, 9vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 0;
}
.h1 { font-family: var(--display); font-weight: 700; font-size: 2rem; line-height: 1.1; margin: 0; }
.h2 { font-family: var(--display); font-weight: 600; font-size: 1.4rem; line-height: 1.2; margin: 1.5rem 0 0.25rem; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner {
  max-width: 760px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-family: var(--display); font-weight: 700; font-size: 1.35rem; }
.home { font-size: 0.875rem; color: var(--muted); text-decoration: none; padding-right: 10px; border-right: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
@media (max-width: 520px) {
  .topbar-inner { row-gap: 4px; padding-bottom: 6px; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; }
  .tab { flex: 1; text-align: center; }
}
.tab { padding: 6px 10px; border-radius: var(--radius-s); text-decoration: none; color: var(--muted); white-space: nowrap; }
.tab[aria-current="page"] { color: var(--ink); background: var(--paper); font-weight: 700; }

/* ---------- the yellow band ---------- */
.band { background: var(--signal); color: var(--signal-ink); }
.band-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px 18px; }
.band-links { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.band .back { font-size: 0.875rem; text-decoration: none; opacity: 0.85; }
.band-edit { background: none; border: 1.5px solid var(--signal-ink); color: var(--signal-ink); border-radius: var(--radius-s); padding: 3px 10px; font-size: 0.875rem; font-weight: 700; cursor: pointer; }
.band .back::before { content: "‹ "; }
.band-sub { margin: 6px 0 0; font-weight: 700; }
.progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.progress-text { white-space: nowrap; }
.meter { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--st-Pack); }
.meter-band { flex: 1; height: 12px; border-radius: 6px; background: rgba(28, 36, 48, 0.15); }
.meter-band > span { background: var(--signal-ink); transition: width 300ms ease; }
@media (prefers-reduced-motion: reduce) { .meter-band > span { transition: none; } }

/* ---------- pages ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 96px; }
.page-trip { padding-top: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.page > p { max-width: 62ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); text-decoration: none; cursor: pointer; font-weight: 700;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { border-color: var(--ink); opacity: 0.9; }
.btn-quiet { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { border-color: var(--danger); }
.btn-big { min-height: 52px; padding: 12px 22px; font-size: 1.1rem; }
.link { background: none; border: 0; padding: 4px; cursor: pointer; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; }

/* ---------- sign-in ---------- */
.signin .band-hero { padding: 18vh 16px 28px; }
.signin .band-hero > * { max-width: 30rem; margin-left: auto; margin-right: auto; }
.signin .band-hero p { margin-top: 12px; font-size: 1.1rem; }
.signin-body { max-width: 30rem; margin: 0 auto; padding: 28px 16px; }

/* ---------- trip stats ---------- */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 8px 10px; border: 1px solid var(--line); border-left: 4px solid var(--c, var(--line));
  border-radius: var(--radius-s); background: var(--surface); cursor: pointer; text-align: left;
}
.stat[data-stage="Decide"] { --c: var(--st-Decide); }
.stat[data-stage="Acquire"] { --c: var(--st-Acquire); }
.stat[data-stage="Prepare"] { --c: var(--st-Prepare); }
.stat[data-stage="ToPack"] { --c: var(--st-Pack); }
.stat[data-stage="Packed"] { --c: var(--st-Pack); }
.stat[data-stage="Exclude"] { --c: var(--st-Exclude); }
.stat[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); border-left-color: var(--c); }
.stat-n { font-family: var(--display); font-weight: 700; font-size: 1.6rem; line-height: 1; }
.stat-l { font-size: 0.8rem; }

.attention {
  display: flex; width: 100%; justify-content: space-between; gap: 12px; margin-top: 10px;
  padding: 10px 14px; border: 1px solid var(--st-Decide); border-radius: var(--radius-s);
  background: var(--surface); color: var(--st-Decide); cursor: pointer; text-align: left;
}
.attention span { text-decoration: underline; text-underline-offset: 3px; }
.attention[aria-pressed="true"] { background: var(--st-Decide); color: var(--paper); }

/* ---------- toolbars ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 6px; }
.toolbar-2 { margin-top: 4px; }
.toolbar select, .toolbar .search, .form input, .form select, .form textarea, .lk-row input, .lk-row select, .lk-add input, .lk-add select {
  min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface);
}
.toolbar .search { flex: 1 1 14rem; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }

/* ---------- grouped rows ---------- */
.group { margin-top: 18px; }
.group-head {
  font-family: var(--display); font-weight: 600; font-size: 1.2rem; margin: 0 0 6px;
  display: flex; gap: 8px; align-items: baseline;
}
.group-head .muted { font-family: var(--body); font-weight: 400; font-size: 0.875rem; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.row { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-open, .pick {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 10px 12px; background: none; border: 0; text-align: left; cursor: pointer;
}
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 700; }
.row-meta { font-size: 0.875rem; color: var(--muted); }
.row-note { font-size: 0.8125rem; color: var(--muted); font-style: italic; }
.pick input { width: 20px; height: 20px; flex: none; }

.is-packed .row-title { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.is-excluded .row-title { color: var(--muted); }

/* The tick: one big target per row. Its ring takes the stage colour. */
.tick {
  flex: none; width: 52px; display: grid; place-items: center;
  background: none; border: 0; border-right: 1px solid var(--line); cursor: pointer;
}
.tick::before {
  content: ""; width: 24px; height: 24px; border-radius: 50%;
  border: 2.5px solid var(--st-Pack); background: transparent;
}
.tick[data-stage="Decide"]::before { border-color: var(--st-Decide); }
.tick[data-stage="Acquire"]::before { border-color: var(--st-Acquire); }
.tick[data-stage="Prepare"]::before { border-color: var(--st-Prepare); }
.tick[aria-pressed="true"]::before {
  background: var(--st-Pack) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/18px no-repeat;
}
.tick-off::before { border-style: dashed; border-color: var(--st-Exclude); }

/* Luggage tag: notched label in the bag's colour. */
.tag {
  flex: none; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.75rem; font-weight: 700; color: var(--bc);
  padding: 2px 8px 2px 12px; border: 1.5px solid var(--bc); border-radius: 3px 6px 6px 3px; position: relative;
}
.tag::before { content: ""; position: absolute; left: 4px; top: 50%; width: 4px; height: 4px; margin-top: -2px; border-radius: 50%; background: var(--bc); }
.tag[data-bag="0"] { --bc: var(--bag-0); }
.tag[data-bag="1"] { --bc: var(--bag-1); }
.tag[data-bag="2"] { --bc: var(--bag-2); }
.tag[data-bag="3"] { --bc: var(--bag-3); }
.tag[data-bag="4"] { --bc: var(--bag-4); }
.tag[data-bag="5"] { --bc: var(--bag-5); }
.tag[data-bag="none"] { --bc: var(--bag-none); border-style: dashed; }

.status, .prio, .flag { font-size: 0.75rem; padding: 0 6px; border-radius: 3px; white-space: nowrap; }
.status { border: 1px solid currentColor; }
.status[data-stage="Decide"] { color: var(--st-Decide); }
.status[data-stage="Acquire"] { color: var(--st-Acquire); }
.status[data-stage="Prepare"] { color: var(--st-Prepare); }
.status[data-stage="Exclude"] { color: var(--st-Exclude); }
.flag { background: var(--st-Decide); color: #fff; }
.prio { background: var(--paper); color: var(--muted); }
.prio[data-p="Essential"] { color: var(--ink); font-weight: 700; }

/* ---------- trips list ---------- */
.trip-list { display: grid; gap: 10px; margin-top: 12px; }
.trip-card {
  display: grid; gap: 4px; padding: 14px 16px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--signal); border-radius: var(--radius-m);
}
.trip-card:hover { border-color: var(--muted); border-left-color: var(--signal); }
.trip-card-name { font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: 1.1; }
.trip-card .meter { margin-top: 6px; }
.archived { margin-top: 24px; }
.archived summary { cursor: pointer; color: var(--muted); }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 0.875rem; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; }
.wide { grid-column: 1 / -1; }
@media (max-width: 340px) { .form { grid-template-columns: 1fr; } }

.sticky-actions {
  position: sticky; bottom: 0; margin: 20px -16px -96px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-top: 1px solid var(--line);
}

/* ---------- sheet (dialog) ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(12, 16, 22, 0.45); }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 14px 14px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: rise 180ms ease-out;
}
@media (min-width: 700px) {
  #sheet { align-items: center; }
  .sheet { border-radius: 14px; }
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.sheet-head .h2 { margin: 0; }
.sheet-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.sheet .rows { max-height: 52vh; overflow-y: auto; }

/* ---------- settings ---------- */
.lookup { margin-top: 12px; padding: 0; }
.lookup > summary { padding: 14px 16px; cursor: pointer; display: flex; align-items: baseline; gap: 8px; }
.lookup > summary .h2 { margin: 0; }
.lookup > :not(summary) { margin-left: 16px; margin-right: 16px; }
.lookup > form { margin-bottom: 16px; }
.lk-rows { list-style: none; margin-top: 10px; margin-bottom: 10px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.lk-row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.lk-row input { width: 0; }
.lk-row input { flex: 1; min-width: 0; }
.lk-row select { flex: 0 1 auto; min-width: 0; max-width: 45%; }
.lk-row input[readonly] { background: var(--paper); }
.lk-lock, .lk-row .link { flex: none; width: 4.25rem; text-align: right; }
.lk-add { display: flex; gap: 8px; flex-wrap: wrap; }
.lk-add input { flex: 1 1 10rem; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30;
  max-width: min(92vw, 30rem); padding: 10px 16px; border-radius: var(--radius-s);
  background: var(--ink); color: var(--paper); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}
#toast[data-kind="error"] { background: var(--danger); color: #fff; }
@media (max-width: 520px) {
  .lk-row:has(select) { flex-wrap: wrap; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .lk-row:has(select) input { flex: 1 1 100%; }
  .lk-row:has(select) select { flex: 1 1 auto; max-width: none; }
}
