/* ==========================================================================
   Trip Companion — design system
   Direction: airport departure board meets paper ticket stub.
   Times and money are always set in mono, like a board. Everything else
   stays quiet so the stubs carry the personality.
   ========================================================================== */

:root {
  --ink:        #0E1116;
  --board:      #161C24;
  --board-2:    #1E2632;
  --line:       #2A3441;
  --text:       #E8EDF3;
  --text-dim:   #93A1B2;
  --amber:      #FFB627;
  --jade:       #2FBF9C;
  --rose:       #FF6B6B;
  --violet:     #A78BFA;
  --bg:         var(--ink);
  --surface:    var(--board);
  --surface-2:  var(--board-2);
  --radius:     14px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "PingFang TC",
          "Noto Sans HK", "Noto Sans TC", "Microsoft JhengHei", "Hiragino Sans CNS",
          Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
  --ink:        #F7F5F0;
  --board:      #FFFFFF;
  --board-2:    #F0EEE8;
  --line:       #DDD8CE;
  --text:       #16202B;
  --text-dim:   #6B7787;
  --amber:      #B87A00;
  --jade:       #0E8F72;
  --rose:       #C64545;
  --violet:     #6D4FD0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(72px + var(--safe-b)); }

button, input, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--jade); }

/* ---------- App bar ------------------------------------------------------ */

.appbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px 10px;
}
.appbar-row { display: flex; align-items: center; gap: 10px; }
.appbar h1 {
  margin: 0; font-size: 17px; font-weight: 700;
  letter-spacing: -0.01em; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-dim);
}
.appbar .eyebrow { display: block; margin-bottom: 2px; }

.iconbtn {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 17px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.iconbtn:active { transform: scale(0.94); }

/* ---------- Layout ------------------------------------------------------- */

main { padding: 16px 16px 24px; max-width: 720px; margin: 0 auto; }
@media (min-width: 900px) { main { max-width: 860px; } }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 0 10px;
}
.section-head:first-child { margin-top: 4px; }
.section-head h2 { margin: 0; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
  font-family: var(--mono); color: var(--text-dim); font-weight: 500; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.row { display: flex; gap: 10px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: grid; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* ---------- Departure board (home hero) ---------------------------------- */

.board {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.board-top {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.board-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.board-dot.live { animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.board-rows { padding: 4px 0; }
.board-row {
  display: grid; grid-template-columns: 62px 1fr auto;
  gap: 12px; align-items: center;
  padding: 11px 14px; border-bottom: 1px dashed var(--line);
}
.board-row:last-child { border-bottom: none; }
.board-row .t { font-family: var(--mono); font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.board-row .n { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row.now { background: color-mix(in srgb, var(--amber) 12%, transparent); }
.board-row.now .t { color: var(--amber); }

.countdown {
  padding: 16px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.countdown .big {
  font-family: var(--mono); font-size: 34px; font-weight: 700;
  letter-spacing: -0.03em; line-height: 1;
}

/* ---------- Ticket stub (the signature) ---------------------------------- */

.stub {
  position: relative; display: grid; grid-template-columns: 68px 1fr;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 10px;
}
.stub::before, .stub::after {
  content: ""; position: absolute; left: 68px; width: 12px; height: 12px;
  background: var(--bg); border-radius: 50%; transform: translateX(-50%);
}
.stub::before { top: -6px; }
.stub::after  { bottom: -6px; }

.stub-rail {
  background: var(--surface-2);
  border-right: 1px dashed var(--line);
  padding: 12px 8px; text-align: center;
  display: flex; flex-direction: column; gap: 4px; justify-content: center;
}
.stub-rail .time {
  font-family: var(--mono); font-size: 16px; font-weight: 700; letter-spacing: -0.03em;
}
.stub-rail .end { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

.stub-body { padding: 12px 14px; min-width: 0; }
.stub-title { font-weight: 600; font-size: 15px; margin: 0 0 4px; }
.stub-meta { font-size: 13px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 8px; }
.stub-note { font-size: 13px; color: var(--text-dim); margin-top: 6px; }

.chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px;
  border: 1px solid currentColor; opacity: 0.9;
}
.c-flight { color: var(--amber); }
.c-hotel { color: var(--violet); }
.c-food, .c-cafe { color: var(--rose); }
.c-transport { color: var(--text-dim); }
.c-spa, .c-massage { color: var(--jade); }
.c-attraction, .c-hiking { color: var(--jade); }
.c-shopping { color: var(--violet); }
.c-free, .c-other { color: var(--text-dim); }

.daybar {
  display: flex; align-items: baseline; gap: 10px;
  margin: 22px 0 10px; padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}
.daybar .d { font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--amber); }
.daybar .w { font-size: 13px; color: var(--text-dim); }
.daybar .sum { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-dim); }

/* ---------- Day chips scroller ------------------------------------------ */

.dayscroll { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px;
  scrollbar-width: none; }
.dayscroll::-webkit-scrollbar { display: none; }
.daychip {
  flex: 0 0 auto; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
}
.daychip.on { background: var(--amber); color: #0E1116; border-color: var(--amber); font-weight: 700; }

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

.btn {
  padding: 11px 14px; border-radius: 11px; font-size: 14px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--amber); color: #0E1116; border-color: var(--amber); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 45%, var(--line)); }
.btn.full { width: 100%; }
.btn.sm { padding: 7px 10px; font-size: 13px; }

.fab {
  position: fixed; right: 16px; bottom: calc(84px + var(--safe-b)); z-index: 45;
  width: 54px; height: 54px; border-radius: 18px;
  background: var(--amber); color: #0E1116; font-size: 26px; font-weight: 500;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

/* ---------- Bottom nav --------------------------------------------------- */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav button {
  padding: 9px 0 10px; display: grid; gap: 3px; justify-items: center;
  color: var(--text-dim); font-size: 10px; letter-spacing: 0.06em;
  font-family: var(--mono); text-transform: uppercase;
}
.nav button .ic { font-size: 19px; line-height: 1; }
.nav button.on { color: var(--amber); }

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

.sheet-wrap {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55); display: flex; align-items: flex-end;
}
.sheet {
  width: 100%; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  padding: 8px 16px calc(24px + var(--safe-b));
  animation: rise .22s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 720px) {
  .sheet-wrap { align-items: center; justify-content: center; }
  .sheet { max-width: 560px; border-radius: 18px; }
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.grabber { width: 38px; height: 4px; border-radius: 2px; background: var(--line);
  margin: 6px auto 14px; }

label.f { display: block; margin-bottom: 12px; }
label.f > span {
  display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 5px;
}
.f input, .f select, .f textarea, .inp {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.f textarea { min-height: 74px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .inp:focus {
  outline: 2px solid var(--amber); outline-offset: 1px;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 7px 11px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-dim);
}
.pill.on { background: var(--jade); border-color: var(--jade); color: #06110D; font-weight: 600; }

/* ---------- Money / expenses -------------------------------------------- */

.amt { font-family: var(--mono); font-weight: 700; letter-spacing: -0.02em; }
.amt.pos { color: var(--jade); }
.amt.neg { color: var(--rose); }

.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #0E1116; flex: 0 0 auto;
}

.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; }

.settle {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
.settle:last-child { border-bottom: none; }
.settle .arrow { font-family: var(--mono); font-size: 12px; color: var(--amber); text-align: center; }

/* ---------- Misc --------------------------------------------------------- */

.empty { text-align: center; padding: 46px 20px; color: var(--text-dim); }
.empty .mark { font-size: 34px; margin-bottom: 10px; opacity: .5; }

.offline-bar {
  background: var(--rose); color: #fff; font-size: 12px; font-family: var(--mono);
  text-align: center; padding: 5px; letter-spacing: 0.08em;
}
.sync-bar {
  background: var(--amber); color: #0E1116; font-size: 12px; font-family: var(--mono);
  text-align: center; padding: 5px; letter-spacing: 0.08em;
}

.check { width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface-2); display: grid; place-items: center; flex: 0 0 auto; font-size: 13px; }
.check.on { background: var(--jade); border-color: var(--jade); color: #06110D; }
.done-txt { text-decoration: line-through; color: var(--text-dim); }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 200; animation: rise .2s;
}
