:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --line-soft: #f0f0f2;
  --accent: #2563eb;
  --danger: #dc2626;
  --warn-bg: #fffbeb;
  --warn-fg: #92400e;
  --flight: #2563eb;
  --lodging: #c2410c;
  --train: #059669;
  --ferry: #0e7490;
  --car_rental: #7c3aed;
  --transfer: #be185d;
  --activity: #b45309;
  --restaurant: #e11d48;
  --checkout: #a1a1aa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
code { background: var(--surface-2); padding: 0 .3rem; border-radius: 4px; }

.icon { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; flex-shrink: 0; }
.icon.kind-flight { color: var(--flight); } .icon.kind-lodging { color: var(--lodging); } .icon.kind-train { color: var(--train); }
.icon.kind-restaurant { color: var(--restaurant); } .icon.kind-ferry { color: var(--ferry); } .icon.kind-car_rental { color: var(--car_rental); } .icon.kind-transfer { color: var(--transfer); } .icon.kind-activity { color: var(--activity); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1040px; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.logo { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.topnav { display: flex; gap: 1rem; align-items: center; font-size: .9rem; }
.container { max-width: 1040px; margin: 0 auto; padding: 1rem 1rem 4rem; }

.btn { display: inline-block; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; line-height: 1.3; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linklike:hover { text-decoration: underline; }
.linklike.tiny { font-size: .8rem; }
.linklike.danger { color: var(--danger); }
.linklike.muted { color: var(--muted); }

.form { display: flex; flex-direction: column; gap: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.form.narrow { max-width: 360px; margin: 3rem auto; }
.form.compact { padding: .6rem; gap: .4rem; margin-top: .4rem; }
.form label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); flex: 1; }
.form label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
.form input, .form select, .form textarea { font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
.form input[type=checkbox] { width: auto; }
.form input[type=color] { padding: 0; width: 2.4rem; height: 2rem; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem .8rem; margin: 0; }
.form legend { font-size: .8rem; color: var(--muted); padding: 0 .3rem; }
.row { display: flex; gap: .8rem; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > label { min-width: 12rem; }
.row > label { min-width: 0; }
.actions { display: flex; gap: .6rem; align-items: center; margin-top: .3rem; flex-wrap: wrap; }
.inline-form { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.inline-form > * { flex: 1; min-width: 8rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.panel p { margin: .2rem 0 .5rem; }
@media (max-width: 640px) { .row { flex-direction: column; gap: .5rem; } .row.wrap { flex-direction: row; } }

.trip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.trip-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; color: var(--text); box-shadow: var(--shadow); }
.trip-card:hover { text-decoration: none; border-color: var(--accent); }
.trip-card-name { font-weight: 600; font-size: 1.1rem; }
.trip-card-dates { color: var(--muted); font-size: .9rem; margin: .2rem 0 .5rem; }

.trip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.trip-name { margin: 0; }
.trip-dates { color: var(--muted); }
.trip-actions { display: flex; gap: .5rem; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin: .8rem 0 1rem; overflow-x: auto; }
.tabs a { padding: .45rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

.chips { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .02em; flex-shrink: 0; }
.chip.small { width: 1.35rem; height: 1.35rem; font-size: .6rem; }
.chip.tiny { width: 1.1rem; height: 1.1rem; font-size: .5rem; }
.chip.arrive { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #16a34a; }
.chip.depart { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #dc2626; }
.chip.arrive.depart { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #ca8a04; }
.chip-name { display: inline-flex; align-items: center; gap: .35rem; margin-right: .8rem; font-size: .85rem; color: var(--muted); }
.legend { margin: 0 0 .8rem; display: flex; flex-wrap: wrap; }
.badge { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .68rem; font-weight: 600; background: var(--surface-2); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.status-tentative { background: #fef3c7; color: #92400e; }
.badge.status-idea { background: #e0e7ff; color: #3730a3; }
.badge.status-cancelled { background: #fee2e2; color: #991b1b; }
.badge.bib { background: #fee2e2; color: #b91c1c; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.key { background: #fef3c7; color: #92400e; }
.mstars { color: #dc2626; letter-spacing: .05em; font-size: .9rem; }
.hstars { color: #b45309; letter-spacing: .05em; font-size: .8rem; }

.share-link { font-family: ui-monospace, monospace; }
.warnings { color: var(--warn-fg); font-size: .85rem; margin: -.3rem 0 .8rem; }
.warnings summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .3rem; }
.warnings summary::-webkit-details-marker { display: none; }
.warnings ul { margin: .4rem 0 0; padding: .5rem 1.2rem; background: var(--warn-bg); border-radius: 8px; }

/* Itinerary: stays are sections, days and items are rows inside them. */
.timeline { display: flex; flex-direction: column; gap: 1.1rem; }
.block { border-radius: var(--radius); }
.stay-head { position: sticky; top: 3.1rem; z-index: 2; background: #fff; border-radius: var(--radius); }
.stay-head summary, .stay-head.plain { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .55rem .8rem; border-radius: var(--radius); background: #f1f3f6; color: var(--text); list-style: none; font-size: .95rem; }
.block.stay .stay-head .icon { color: var(--lodging); }
.stay-head summary::-webkit-details-marker { display: none; }
.stay-head .icon { width: 1.25rem; height: 1.25rem; }
.stay-name { font-weight: 700; }
.stay-span { color: var(--muted); font-size: .85rem; margin-left: auto; white-space: nowrap; }
.stay-head[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.stay-body { background: #fff4ee; padding: 0 .8rem .6rem 2.55rem; border-radius: 0 0 var(--radius) var(--radius); font-size: .88rem; }
.stay-body .card-meta { color: var(--text); }
.block.transit .stay-head.plain { background: #eff4ff; color: var(--flight); cursor: default; }
.block.nostay .stay-head.plain { background: transparent; color: var(--muted); border: 1px dashed var(--line); cursor: default; }
.block-days { margin: .2rem 0 0 .8rem; padding-left: .9rem; border-left: 2px solid #dfe3e8; }
.block.transit .block-days { border-left-color: #d6e3ff; }
.block.nostay .block-days { border-left-color: var(--line); }
.day { padding: .35rem 0 .2rem; }
.day + .day { border-top: 1px solid var(--line); margin-top: .15rem; padding-top: .5rem; }
.day.free { padding: .25rem 0; }
.day-head { display: flex; align-items: center; gap: .7rem; min-height: 1.6rem; }
.day-date { display: flex; align-items: baseline; gap: .3rem; min-width: 5.8rem; cursor: pointer; }
.dow { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.dom { font-size: 1.15rem; font-weight: 700; }
.dom.run { font-size: .95rem; font-weight: 600; color: var(--muted); }
.day.free .dom { font-size: .95rem; font-weight: 600; color: var(--muted); }
.day.today .dom { color: var(--accent); }
.day.outside { opacity: .7; }
.mon { color: var(--muted); font-size: .78rem; }
.day-who { display: flex; gap: .25rem; flex-wrap: wrap; }
.free-tag { color: var(--muted); font-size: .78rem; font-style: italic; }
.day-add { margin-left: auto; color: var(--line); font-size: 1.1rem; padding: 0 .3rem; line-height: 1; }
.day:hover .day-add { color: var(--accent); }
.day-add:hover { text-decoration: none; }
.daynotes:empty { display: none; }
.daynotes[hx-get] { cursor: pointer; }
.note { font-size: .86rem; white-space: pre-wrap; padding: .3rem .6rem; border-radius: 6px; margin: .25rem 0; }
.note.plan { background: var(--surface-2); }
.note.review { background: transparent; border-left: 3px solid var(--activity); font-style: italic; color: var(--muted); padding-left: .6rem; }
.stars { color: var(--activity); font-style: normal; }

.item { display: flex; gap: .55rem; align-items: flex-start; padding: .3rem 0; position: relative; }
.item + .item { border-top: 0; }
.row-time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2.7rem; font-size: .85rem; padding-top: .1rem; }
.row-icon { width: 1.2rem; height: 1.2rem; margin-top: .1rem; color: var(--muted); }
.item.kind-flight .row-icon { color: var(--flight); } .item.kind-lodging .row-icon { color: var(--lodging); } .item.kind-train .row-icon { color: var(--train); }
.item.kind-ferry .row-icon { color: var(--ferry); } .item.kind-car_rental .row-icon { color: var(--car_rental); } .item.kind-transfer .row-icon { color: var(--transfer); }
.item.kind-activity .row-icon { color: var(--activity); } .item.kind-restaurant .row-icon { color: var(--restaurant); }
.item.checkout .row-icon { color: var(--checkout); }
.item.status-cancelled .row-body { opacity: .55; text-decoration: line-through; }
.item.status-idea .title, .item.status-tentative .title { font-weight: 500; }
.row-body { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.row-title .title { font-weight: 600; }
.item.checkout .row-title .title { font-weight: 400; }
.item.has-notes { cursor: pointer; }
.card-who { display: inline-flex; gap: .15rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: .1rem .8rem; font-size: .82rem; color: var(--muted); margin-top: .05rem; }
.card-meta .ref, .table .ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 0 .35rem; border-radius: 4px; color: var(--text); }
.card-notes { display: none; }
.detail-line { font-size: .84rem; margin: .15rem 0; }
.detail-line .muted { display: inline-block; min-width: 7rem; }
.item.expanded .card-notes { display: block; }
.note-mark { color: var(--muted); width: 1em; height: 1em; }
.item.expanded .note-mark, .stay-head[open] .note-mark { color: var(--accent); }
.card-warn { color: var(--warn-fg); background: var(--warn-bg); font-size: .8rem; padding: .2rem .5rem; border-radius: 4px; margin-top: .3rem; }
.row-actions { display: flex; gap: .8rem; margin-top: .4rem; }

.menu { position: relative; margin-left: .2rem; }
.menu summary { list-style: none; cursor: pointer; color: var(--muted); padding: 0 .35rem; border-radius: 6px; font-weight: 700; line-height: 1.3; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { background: var(--surface-2); color: var(--text); }
.menu-items { position: absolute; right: 0; top: 1.6rem; z-index: 3; display: flex; flex-direction: column; min-width: 7rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.08); padding: .25rem; }
.menu-items a, .menu-items button { text-align: left; background: none; border: 0; font: inherit; font-size: .88rem; padding: .35rem .6rem; border-radius: 6px; color: var(--text); cursor: pointer; }
.menu-items a:hover, .menu-items button:hover { background: var(--surface-2); text-decoration: none; }
.menu-items .danger { color: var(--danger); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr.status-cancelled td { opacity: .5; text-decoration: line-through; }

.traveler-list { display: flex; flex-direction: column; gap: .4rem; }
.traveler-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; }
.traveler-row input:not([type]), .traveler-row input[type=text] { font: inherit; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
.traveler-row input[name=name] { flex: 1; min-width: 8rem; }
.traveler-row .check { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); }
.traveler-row.add { border-style: dashed; margin-top: .5rem; }

/* Ingestion */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.2rem; text-align: center; color: var(--muted); cursor: pointer; background: var(--surface); }
.dropzone.over { border-color: var(--accent); background: #eff4ff; }
.dropzone ul { text-align: left; margin: .5rem 0 0; padding-left: 1.2rem; color: var(--text); }
.source-list { display: flex; flex-direction: column; gap: .4rem; }
.source-row { display: flex; gap: .8rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .8rem; flex-wrap: wrap; }
.source-row .status-ready { color: var(--warn-fg); }
.source-row .status-error { color: var(--danger); }
.source-row .status-committed { color: #16a34a; }
.spinner { display: inline-block; width: .9rem; height: .9rem; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
pre.raw { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .8rem; white-space: pre-wrap; word-break: break-word; font-size: .8rem; max-height: 60vh; overflow: auto; }
.source-preview img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.source-preview iframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.review-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .8rem; border-left: 4px solid var(--muted); }
.review-row.skipped { opacity: .5; }
.review-row.kind-flight { border-left-color: var(--flight); }
.review-row.kind-lodging { border-left-color: var(--lodging); }
.review-row.kind-train { border-left-color: var(--train); }
.review-row.kind-ferry { border-left-color: var(--ferry); }
.review-row.kind-car_rental { border-left-color: var(--car_rental); }
.review-row.kind-transfer { border-left-color: var(--transfer); }
.review-row.kind-activity { border-left-color: var(--activity); }
.review-row.kind-restaurant { border-left-color: var(--restaurant); }
.review-head { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.review-head .headline { font-weight: 600; flex: 1; }
.review-row .row { margin-top: .4rem; }
.dup { background: var(--warn-bg); color: var(--warn-fg); padding: .3rem .6rem; border-radius: 6px; font-size: .85rem; margin: .3rem 0; }
.summary-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.summary-box ul.warnings { margin: .4rem 0 0; }

@media (max-width: 720px) {
  .block-days { margin-left: .3rem; padding-left: .6rem; }
  .day-date { min-width: 5.2rem; }
  .row-time { min-width: 2.5rem; }
  .stay-span { margin-left: 0; width: 100%; padding-left: 1.75rem; }
}
@media print {
  .topbar, .tabs, .trip-actions, .menu, .day-add, .warnings { display: none !important; }
  .item, .stay-head { break-inside: avoid; }
  .container { max-width: none; padding: 0; }
}
