:root {
  --bg: #F7F4EE; --surface: #EDE8DF; --raised: #FFFFFF; --line: #DED7CB; --ink: #1B2430; --muted: #5E6672;
  --accent: #B7472A; --on-accent: #FFFFFF; --warn: #A33A1F; --warn-bg: #F7E3DB; --ok: #2D6A4F;
  /* Item types: each has a colour and an icon, never colour alone. */
  --t-flight: #2F5D9E; --t-hotel: #6E4C9C; --t-transport: #5E6672; --t-meal: #B26A12; --t-activity: #2D7A57; --t-buffer: #A39E95;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --pad: 16px; --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161D; --surface: #1B222C; --raised: #212934; --line: #2C3542; --ink: #ECEFF3; --muted: #A2ABB7;
    --accent: #F08A6C; --on-accent: #11161D; --warn: #F4A58C; --warn-bg: #3A2320; --ok: #7CCBA2;
    --t-flight: #7FA8E8; --t-hotel: #B79BE3; --t-transport: #A2ABB7; --t-meal: #E7A65A; --t-activity: #74C69D; --t-buffer: #5F6670;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scrollbar-color: var(--line) transparent; }
html, body { margin: 0; height: 100%; }
body { font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; color: var(--ink); background: var(--bg); accent-color: var(--accent); caret-color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
a { color: var(--accent); text-underline-offset: 3px; }
.ic { width: 20px; height: 20px; flex: none; display: block; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h1.display { font-size: 44px; letter-spacing: -0.035em; margin-top: 12vh; }
h2 { font-size: 20px; margin: 8px 0 4px; letter-spacing: -0.01em; }
h3 { font-size: 17px; margin: 12px 0 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
p { margin: 0; text-wrap: pretty; }
.lead { font-size: 19px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.warn { color: var(--warn); font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#app { height: 100dvh; display: flex; flex-direction: column; }
.page { flex: 1; overflow-y: auto; overscroll-behavior: contain; width: 100%; max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) max(var(--pad), env(safe-area-inset-right)) 32px max(var(--pad), env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 16px; }
.page.narrow { justify-content: flex-start; gap: 20px; }
.enter .page { animation: rise 240ms var(--ease) both; }
.footer { display: flex; gap: 10px; padding: 12px var(--pad) calc(env(safe-area-inset-bottom, 0px) + 12px); border-top: 1px solid var(--line); background: var(--bg); }
.footer > * { flex: 1; }

/* controls */
.primary, .secondary { display: grid; place-items: center; min-height: 50px; padding: 0 16px; border-radius: var(--r); font-weight: 600; text-align: center; width: 100%; transition: transform 120ms var(--ease), opacity 150ms; }
.primary { background: var(--ink); color: var(--bg); }
.secondary { box-shadow: inset 0 0 0 1px var(--line); background: var(--raised); }
.danger { color: var(--warn); }
.primary:active, .secondary:active { transform: scale(0.98); }
.primary:disabled, .secondary:disabled { opacity: 0.45; cursor: not-allowed; }
.file-btn { cursor: pointer; }
.field { width: 100%; min-height: 48px; padding: 12px 14px; border: 0; border-radius: 12px; background: var(--surface); appearance: none; -webkit-appearance: none; }
.field:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.field-sm { width: auto; min-height: 44px; padding: 8px 10px; font-size: 15px; }
textarea.field { resize: vertical; line-height: 1.4; }
.lbl { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.chip { min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--surface); font-weight: 600; font-size: 15px; flex: none; }
.chip[aria-pressed="true"] { background: var(--t-meal); color: var(--bg); }
.round { width: 44px; height: 44px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; flex: none; }
.round:disabled { opacity: 0.3; }
.x { width: 44px; height: 44px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; flex: none; color: var(--muted); }
.linkish { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); }
.seg button { min-height: 44px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.14); }
.progress { height: 6px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width 300ms var(--ease); }

/* type marks */
.ti { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; background: var(--tc); }
.ti .ic { width: 18px; height: 18px; }
.t-flight { --tc: var(--t-flight); } .t-hotel { --tc: var(--t-hotel); } .t-transport { --tc: var(--t-transport); }
.t-meal { --tc: var(--t-meal); } .t-activity { --tc: var(--t-activity); } .t-buffer { --tc: var(--t-buffer); }
@media (prefers-color-scheme: dark) { .ti { color: var(--bg); } }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 14px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .ti { width: 22px; height: 22px; border-radius: 6px; }
.legend .ti .ic { width: 13px; height: 13px; }
.tag { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; margin-right: 6px; padding: 1px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface); color: var(--muted); }
.tag .ic { width: 13px; height: 13px; }
.tag-warn { background: var(--warn-bg); color: var(--warn); }

/* import preview */
.day-h { position: sticky; top: -16px; background: var(--bg); padding: 8px 0 4px; z-index: 1; }
.prow { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.prow b { display: block; font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.prow .small { display: block; }
.time { width: 44px; flex: none; font-size: 14px; color: var(--muted); }

/* overview */
.head { display: flex; flex-direction: column; gap: 4px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats > * { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--r); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); text-align: left; }
.stats b { font-size: 19px; }
.stat-btn.alert { background: var(--warn-bg); box-shadow: none; color: var(--warn); }
.grid { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; scroll-snap-type: x proximity; }
.grid::-webkit-scrollbar { display: none; }
.gcol { flex: 1 0 44px; max-width: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px; scroll-snap-align: start; }
.glabel { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.1; }
.glabel b { display: block; font-size: 17px; color: var(--ink); }
.gcol.today .glabel b { color: var(--on-accent); background: var(--accent); border-radius: 999px; padding: 0 6px; }
.gbar { position: relative; width: 100%; height: 300px; border-radius: 10px; background: var(--surface); overflow: hidden; }
.gbar .b { position: absolute; left: 4px; right: 4px; border-radius: 3px; background: var(--tc); }
.gbar .b.t-buffer { background: repeating-linear-gradient(135deg, var(--t-buffer) 0 2px, transparent 2px 7px); opacity: 0.45; }
.gcol:active .gbar { box-shadow: inset 0 0 0 2px var(--accent); }

/* day */
.dayhead { display: flex; align-items: center; gap: 10px; text-align: center; }
.dayhead > div { flex: 1; }
.dayhead h1 { font-size: 24px; }
.timeline { display: flex; flex-direction: column; }
.item { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 0; border-bottom: 1px solid var(--line); text-align: left; }
.item .ti { margin-top: 2px; }
.when { width: 64px; flex: none; display: flex; flex-direction: column; line-height: 1.2; }
.when b { font-size: 21px; letter-spacing: -0.01em; }
.when span { font-size: 14px; color: var(--muted); }
.item .title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item .small { display: block; }
.item.faded { opacity: 0.55; }
.item:active { background: var(--surface); }
.leg { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 0 6px 76px; border-bottom: 1px dashed var(--line); font-size: 14px; color: var(--muted); }
.leg-main { display: flex; align-items: center; gap: 6px; min-height: 36px; text-align: left; }
.leg-main .ic { width: 16px; height: 16px; }
.leg-links { display: flex; gap: 12px; }
.leg-links a { min-height: 36px; display: inline-flex; align-items: center; font-weight: 600; }
.now { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: var(--accent); font-weight: 700; font-size: 14px; }
.now::after { content: ""; flex: 1; height: 2px; background: var(--accent); border-radius: 2px; }

/* item sheet */
.scrim { position: fixed; inset: 0; z-index: 10; background: rgb(10 14 20 / 0.45); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-width: 640px; margin: 0 auto; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / 0.2); padding: 14px var(--pad) calc(env(safe-area-inset-bottom, 0px) + 12px); }
.sheet.opening { animation: up 300ms var(--ease) both; }
.scrim:has(+ .sheet.opening) { animation: fade 200ms both; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 10px; }
.sheet-head h2 { margin: 0; overflow-wrap: anywhere; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.big { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.row-link { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; }
.row-link .small { display: block; }
.row-link .ic:last-child { color: var(--muted); width: 16px; height: 16px; }
.note { padding: 10px 12px; border-radius: 12px; background: var(--surface); color: var(--muted); }
.costs, .facts { margin: 0; display: grid; gap: 8px; }
.costs { grid-template-columns: 1fr 1fr; }
.costs div, .facts div { padding: 8px 12px; border-radius: 12px; background: var(--surface); }
.costs dt, .facts dt { font-size: 13px; color: var(--muted); }
.costs dd, .facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts dd { font-weight: 500; }
.tips { margin: 0; padding-left: 20px; }
.alert-row { display: flex; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.pick { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pick .small { display: block; }
.pick.chosen b { color: var(--t-meal); }
.sources summary, .topic summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; }
.sources { font-size: 14px; }
.sources ul { margin: 0; padding-left: 18px; }
.sources li { overflow-wrap: anywhere; }

/* bookings */
.blist { display: flex; flex-direction: column; }
.bk { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); text-align: left; width: 100%; }
.bk .title { display: block; font-weight: 600; }
.bk .small { display: block; }
.status { flex: none; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.s-to-book { background: var(--warn-bg); color: var(--warn); }
.s-booked, .s-paid { color: var(--ok); }

/* guide and offline */
.topic { border-bottom: 1px solid var(--line); padding: 4px 0 8px; }
.topic summary { font-weight: 600; }
.topic ul { margin: 4px 0; padding-left: 20px; }
.topic li { margin: 4px 0; }
.topic .secondary { margin-top: 8px; }
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { display: flex; justify-content: space-between; gap: 12px; min-height: 48px; align-items: center; border-bottom: 1px solid var(--line); }
.status-list span { color: var(--muted); text-align: right; }
section { display: flex; flex-direction: column; gap: 8px; }

/* tabs and toast */
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); padding: 4px max(4px, env(safe-area-inset-left)) calc(env(safe-area-inset-bottom, 0px) + 4px); border-top: 1px solid var(--line); background: var(--bg); }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tab .ic { width: 23px; height: 23px; }
.tab[aria-current="page"] { color: var(--accent); }
.count { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--warn); color: var(--bg); font-size: 11px; line-height: 18px; text-align: center; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 78px); transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 8px 24px -8px rgb(0 0 0 / 0.4); animation: rise 220ms var(--ease) both; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.toast { animation-name: toast-in; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; } }
@media (hover: hover) and (pointer: fine) {
  .item:hover, .bk:hover, .gcol:hover .gbar { background: color-mix(in srgb, var(--surface) 70%, transparent); }
  .secondary:hover { background: var(--surface); }
}
@media (min-width: 700px) {
  .sheet { inset: 0; margin: auto; height: fit-content; max-height: 86dvh; border-radius: 22px; width: min(600px, calc(100vw - 48px)); }
  .tabs { max-width: 640px; margin: 0 auto; width: 100%; border-top: 0; }
}
