/* Octibook: notebook-style, mobile-first. Colors come from the octopus plushies. */
:root {
  --accent: #A62C8C;
  --accent-ink: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--bg));
  --accent-text: var(--accent); /* accent used for words; lighter in dark mode */
  --bg: #FBF6FA;          /* paper */
  --surface: #FFFFFF;
  --surface-2: #FDF9FC;
  --ink: #2A2130;
  --muted: #6D6374;
  --line: #E9DCE6;
  --rule: #D6EAF6;        /* notebook ruled lines */
  --gap: #FFE45C;         /* bright gap cards */
  --gap-ink: #4A3B00;
  --gap-edge: #F5B700;
  --danger: #C62828;
  --ok: #2E7D32;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --radius: 14px;
  --tap: 48px;
  --c-flight: #1E88E5;
  --c-car: #00897B;
  --c-train: #6D4C41;
  --c-bus: #8E24AA;
  --c-ferry: #0097A7;
  --c-other: #546E7A;
  --c-hotel: #5E35B1;
  --c-restaurant: #EF6C00;
  --c-activity: #43A047;
  --c-rental: #C2185B;
  font-size: 16px;
}
[data-theme="dark"] {
  --bg: #1A151E;
  --surface: #251E2A;
  --surface-2: #2C2432;
  --ink: #F0EAF1;
  --muted: #B0A5B6;
  --line: #3F3547;
  --rule: #28313F;
  --gap: #FFD43B;
  --gap-ink: #2E2500;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}
/* Dark accents are hard to read as text on a dark page, so lighten them. */
@supports (color: color-mix(in srgb, red, blue)) {
  [data-theme="dark"] { --accent-text: color-mix(in srgb, var(--accent) 55%, #fff); }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent-text); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.center { text-align: center; }
.break { overflow-wrap: anywhere; }

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: inherit;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 600;
  touch-action: manipulation;
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-small { min-height: 44px; padding: 6px 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.icon-btn { padding: 0; width: var(--tap); font-size: 1.25rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input, select, textarea {
  font: inherit;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
input[type="checkbox"] { width: 26px; height: 26px; min-height: 0; accent-color: var(--accent); margin: 0; flex: none; }
input[type="color"] { padding: 4px; width: 56px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid2[hidden] { display: none; }
@media (max-width: 360px) { .grid2 { grid-template-columns: 1fr; } }
.check-row { display: flex; align-items: center; gap: 12px; min-height: var(--tap); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 10px) 0 8px;
}
.topbar .wrap { display: flex; align-items: center; gap: 8px; }
.topbar h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- home: notebook covers ---------- */
.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; padding: 8px 0 32px; }
.cover {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: 6px 16px 16px 6px;
  background: var(--c);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow), inset 14px 0 0 rgba(0,0,0,.16), inset 16px 0 0 rgba(255,255,255,.12);
  padding: 16px 14px 14px 28px;
  overflow: hidden;
  border: 0;
  text-align: left;
  width: 100%;
  font-weight: 400;
  align-items: stretch;
  flex-direction: column;
  justify-content: space-between;
}
.cover::after { /* elastic band */
  content: ""; position: absolute; top: 0; bottom: 0; right: 18px; width: 6px; background: rgba(0,0,0,.18);
}
.cover .label {
  position: relative; z-index: 1;
  display: block;
  background: rgba(255,255,255,.92);
  color: #222;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.cover .dest { font-weight: 800; font-size: 1.15rem; display: block; overflow-wrap: anywhere; }
.cover .dates { font-size: .85rem; color: #555; display: block; margin-top: 2px; }
.cover .meta { position: absolute; left: 28px; right: 30px; bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.9); color: #222;
}
.chip-gap { background: var(--gap); color: var(--gap-ink); }
.cover.archived { filter: saturate(.35); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- notebook ---------- */
.notebook-head { background: var(--accent); color: var(--accent-ink); padding: calc(env(safe-area-inset-top) + 8px) 0 0; }
.notebook-head .wrap { display: flex; align-items: center; gap: 6px; }
.notebook-head h1 { font-size: 1.2rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notebook-head .sub { font-size: .85rem; opacity: .9; }
.notebook-head .btn-ghost { color: var(--accent-ink); }
.tabs {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  padding: 10px 6px 0; max-width: 760px; margin: 0 auto;
}
.tab {
  min-height: 50px; padding: 6px 2px;
  border-radius: 12px 12px 0 0;
  border: 0;
  background: color-mix(in srgb, var(--accent-ink) 22%, var(--accent));
  color: var(--accent-ink);
  font-size: .82rem; font-weight: 700;
  flex-direction: column; gap: 0;
}
.tab .ti { font-size: 1.1rem; line-height: 1; }
.tab[aria-selected="true"] { background: var(--bg); color: var(--accent-text); }
.page {
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--rule) 31px, var(--rule) 32px);
  min-height: calc(100vh - 140px);
  padding: 14px 0 80px;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.section-head h2 { flex: 1; }
.section-head h2::before { /* small octopus in the trip's color */
  content: ""; display: inline-block; width: 1.35em; height: 1.28em; vertical-align: -.28em; margin-right: 8px;
  background: /* black eyes */
    radial-gradient(circle .11em at 35% 38%, #1D1420 90%, transparent),
    radial-gradient(circle .11em at 65% 38%, #1D1420 90%, transparent), var(--accent-text);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 4 200 190'%3E%3Cmask id='m'%3E%3Cpath d='M68 104Q32 112 21 139M78 110Q58 136 54 160M90 112Q88 144 86 170M132 104Q168 112 179 139M122 110Q142 136 146 160M110 112Q112 144 114 170' fill='none' stroke='%23fff' stroke-width='28' stroke-linecap='round'/%3E%3Cpath d='M100 14C58 14 31 40 31 72C31 102 60 124 100 124C140 124 169 102 169 72C169 40 142 14 100 14Z' fill='%23fff'/%3E%3C/mask%3E%3Crect width='200' height='200' mask='url(%23m)'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 4 200 190'%3E%3Cmask id='m'%3E%3Cpath d='M68 104Q32 112 21 139M78 110Q58 136 54 160M90 112Q88 144 86 170M132 104Q168 112 179 139M122 110Q142 136 146 160M110 112Q112 144 114 170' fill='none' stroke='%23fff' stroke-width='28' stroke-linecap='round'/%3E%3Cpath d='M100 14C58 14 31 40 31 72C31 102 60 124 100 124C140 124 169 102 169 72C169 40 142 14 100 14Z' fill='%23fff'/%3E%3C/mask%3E%3Crect width='200' height='200' mask='url(%23m)'/%3E%3C/svg%3E") center / contain no-repeat;
}
.list > * + * { margin-top: 10px; }

.item { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; text-align: left; width: 100%; font-weight: 400; padding: 12px 14px; min-height: 64px; }
.item .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex: none; color: #fff; background: var(--tc, var(--accent)); }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 700; overflow-wrap: anywhere; }
.item .lines { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.item .right { text-align: right; flex: none; font-size: .9rem; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; border: 1px solid transparent; }
.pill-idea { background: #ECEFF1; color: #455A64; }
.pill-booked { background: #E3F2FD; color: #1565C0; }
.pill-paid { background: #E8F5E9; color: #2E7D32; }
[data-theme="dark"] .pill-idea { background: #37474F; color: #CFD8DC; }
[data-theme="dark"] .pill-booked { background: #0D3C61; color: #BBDEFB; }
[data-theme="dark"] .pill-paid { background: #1B4620; color: #C8E6C9; }

.gap-card {
  background: var(--gap);
  color: var(--gap-ink);
  border: 2px dashed var(--gap-edge);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.gap-card .title { font-weight: 800; }
.gap-card .hint { font-size: .85rem; margin-top: 2px; }
.gap-card .row { margin-top: 8px; display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; }
.gap-card .row button { padding: 6px 8px; }
.gap-card button { background: rgba(255,255,255,.75); border-color: rgba(0,0,0,.12); color: var(--gap-ink); }
.gap-card.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { transform: scale(1.02); box-shadow: 0 0 0 6px color-mix(in srgb, var(--gap-edge) 50%, transparent); } }

.banner {
  display: flex; gap: 10px; align-items: center; width: 100%;
  background: var(--gap); color: var(--gap-ink);
  border: 0; border-radius: var(--radius);
  padding: 12px 14px; text-align: left; font-weight: 700;
  box-shadow: var(--shadow);
}
.banner .go { margin-left: auto; font-size: 1.3rem; }

.costs { display: grid; gap: 10px; }
.cost-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cost-table th, .cost-table td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.cost-table th:first-child, .cost-table td:first-child { text-align: left; }
.cost-table th { font-size: .8rem; color: var(--muted); font-weight: 700; }
.budget-bar { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 6px; }
.budget-bar > div { height: 100%; background: var(--accent); }
.budget-bar.over > div { background: var(--danger); }

/* ---------- itinerary ---------- */
.daystrip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.daystrip::-webkit-scrollbar { display: none; }
.daychip { flex: none; min-width: 54px; flex-direction: column; gap: 0; padding: 6px 8px; font-size: .8rem; }
.daychip b { font-size: 1.05rem; }
.daychip[aria-current="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.daychip.today { box-shadow: inset 0 -4px 0 var(--gap-edge); }
.day-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.day-head .grow { text-align: center; }
.day-head h2 { font-size: 1.25rem; }
.hotel-banner { display: flex; gap: 10px; align-items: center; }
.timeline { position: relative; margin-top: 14px; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; background: var(--accent); opacity: .5; }
.tl-entry { position: relative; }
.tl-entry::before { content: ""; position: absolute; left: -17px; top: 22px; width: 13px; height: 13px; border-radius: 50%; background: var(--tc); border: 3px solid var(--bg); }
.tl-entry + .tl-entry { margin-top: 10px; }
.tl-entry .item { border-left: 5px solid var(--tc); }
.tl-time { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3.2em; }

/* ---------- ideas / packing / tips ---------- */
.check-item { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 4px 6px 4px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.check-item + .check-item { margin-top: 6px; }
.check-item .grow { overflow-wrap: anywhere; }
.check-item.done .grow .name { text-decoration: line-through; color: var(--muted); }
.check-item.dropped .grow .name { text-decoration: line-through; color: var(--muted); font-style: italic; }
.star { color: var(--muted); font-size: 1.3rem; }
.star[aria-pressed="true"] { color: #F9A825; }
.progress { height: 12px; background: var(--line); border-radius: 8px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }
.addbar { display: flex; gap: 8px; margin-top: 8px; }
.addbar input { flex: 1; min-width: 0; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
details.fold > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 700; color: var(--muted); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--bg);
  width: 100%; max-width: 640px;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  overscroll-behavior: contain;
}
@media (min-width: 700px) { .modal-backdrop { align-items: center; } .modal { border-radius: 20px; } }
.modal-head { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; gap: 8px; padding: 12px 0 10px; z-index: 1; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.modal-head h2 { flex: 1; }
.modal-foot { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal-foot > * { flex: 1 1 120px; }
.kv { display: grid; grid-template-columns: minmax(90px, 35%) 1fr; gap: 6px 10px; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.attach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.attach { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); aspect-ratio: 1; display: grid; place-items: center; text-align: center; font-size: .75rem; padding: 4px; text-decoration: none; color: var(--ink); }
.attach img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.attach .x { position: absolute; top: 2px; right: 2px; min-width: 36px; min-height: 36px; padding: 0; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; }

.draft { border-left: 6px solid var(--accent); }
.draft.saved { opacity: .7; border-left-color: var(--ok); }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.login .logo { width: 150px; margin: 0 auto 4px; }
.login .tagline { margin: 2px 0 14px; }

/* ---------- toast & spinner ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%);
  background: #222; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 100;
  max-width: calc(100vw - 32px); transition: transform .25s; font-weight: 600;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast:empty { display: none; }
#toast.error { background: var(--danger); }
.spinner { width: 52px; margin: 20px auto; animation: bob .9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) scale(1.04, .97); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: pulse 1.6s ease-in-out infinite; } }

/* ---------- Octibook octopus (js/octo.js) ---------- */
.octo { display: block; width: 100%; height: auto; }
.wordmark { font-family: ui-rounded, "SF Pro Rounded", Nunito, "Varela Round", system-ui, sans-serif; font-weight: 800; letter-spacing: -.01em; color: var(--accent-text); }
.login .wordmark { font-size: 2rem; }
.topbar .brand-octo { width: 44px; flex: none; }
.empty-octo { width: 130px; margin: 0 auto 8px; }
/* One octopus per notebook, in that trip's color, peeking over the label. */
/* Negative side margins: it uses the empty edges of its neighbours, so the dates keep their room. */
.head-octo { flex: none; align-self: flex-end; width: 52px; margin: 0 -15px -23px -8px; pointer-events: none; }
.tabs { position: relative; } /* the header octopus peeks out from behind the tabs */
.head-octo .octo-body { fill: color-mix(in srgb, var(--accent) 45%, #fff); }
.head-octo .octo-arms { stroke: color-mix(in srgb, var(--accent) 45%, #fff); }
.head-octo .octo-under { stroke: color-mix(in srgb, var(--accent) 70%, #000); }
.trip-octo .octo-body { fill: color-mix(in srgb, var(--accent) 82%, #fff); }
.trip-octo .octo-arms { stroke: color-mix(in srgb, var(--accent) 82%, #fff); }
.octo-note { text-align: center; margin-top: 36px; }
.octo-note .octo { width: 120px; margin: 0 auto; }
.octo-note p { display: inline-block; margin: 8px 0 0; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.banner-octo { width: 46px; flex: none; }
.swim { position: relative; padding-top: 30px; }
.swim .swimmer { position: absolute; top: 2px; width: 36px; margin-left: -18px; transition: left .2s; }
.swim .budget-bar { margin-top: 0; }
.cover-octo { position: absolute; right: 34px; top: 8px; width: 64px; }
.cover .label { background: #fff; margin-top: 20px; }
.cover-octo .octo-body { fill: color-mix(in srgb, var(--c) 45%, #fff); }
.cover-octo .octo-arms { stroke: color-mix(in srgb, var(--c) 45%, #fff); }
.cover-octo .octo-under { stroke: color-mix(in srgb, var(--c) 70%, #000); }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 10;
  width: 60px; height: 60px; border-radius: 50%; font-size: 1.8rem;
  background: var(--accent); color: var(--accent-ink); border: 0; box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 48px; height: 48px; min-width: 48px; border-radius: 50%; background: var(--c); border: 3px solid transparent; padding: 0; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 3px var(--bg); }

/* Option sets: compare option A vs B for one flight or hotel need. */
.option-set { border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; }
.option-set .title { font-weight: 800; }
.option-set .hint { font-size: .85rem; }
.option-set .options { display: grid; gap: 10px; }
.option-set .option { display: grid; gap: 6px; }
.option-set .option-tag { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.option-set.pending { background: var(--gap); color: var(--gap-ink); border: 2px dashed var(--gap-edge); }
.option-set.pending > .row button, .option-set.pending .option > button { background: rgba(255,255,255,.75); border-color: rgba(0,0,0,.12); color: var(--gap-ink); }
.option-set.pending .card.item { color: var(--ink); }
.option-set.decided { border: 1px solid var(--line); background: color-mix(in srgb, var(--line) 25%, transparent); }
.option-set.decided .option.chosen .option-tag { color: #2E7D32; }
.option-set.flash { animation: flash 1.2s ease 2; }

/* ---------- booking capture ---------- */
.error-text { color: var(--danger); font-weight: 600; }
.with-cam { display: flex; gap: 6px; align-items: stretch; }
.with-cam > input, .with-cam > textarea, .with-cam > select { flex: 1 1 auto; min-width: 0; }
.cam-btn {
  flex: none; width: 44px; min-width: 44px; min-height: 44px; padding: 0;
  font-size: 1.15rem; border-radius: 10px;
}
.field.from-image input, .cap-field.from-image input { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.capture-card { margin-top: 12px; }
.capture-progress { padding: 18px 0; }

.ocr-stage { position: relative; width: 100%; margin: 10px 0 4px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; touch-action: pan-x pan-y pinch-zoom; }
.ocr-stage img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.ocr-chip {
  position: absolute; min-height: 0; padding: 0; margin: 0;
  background: rgba(79,124,172,.16); border: 1.5px solid rgba(79,124,172,.7); /* older iOS without color-mix */
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--accent) 70%, transparent);
  border-radius: 4px; box-shadow: none;
}
.ocr-chip:hover, .ocr-chip:focus-visible { background: color-mix(in srgb, var(--accent) 32%, transparent); }
.ocr-chip.used { background: color-mix(in srgb, var(--ok) 28%, transparent); border-color: var(--ok); }
/* Small text lines still get a comfortable tap area. */
.ocr-chip::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: max(100%, 28px); transform: translateY(-50%); }

.ocr-lines, .piece-list, .field-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.ocr-lines { max-height: 40vh; overflow: auto; padding: 6px 0; }
.tchip {
  min-height: 40px; padding: 6px 12px; border-radius: 999px; font-size: .92rem; font-weight: 500;
  background: var(--surface); border: 1.5px solid var(--line); text-align: left; overflow-wrap: anywhere;
}
.tchip.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.tchip.used { border-color: var(--ok); }
.field-picks .btn-small { flex: 1 1 140px; }

.cap-fields { display: grid; gap: 10px; margin-top: 8px; }
.cap-field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.sugg { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.sugg-chip {
  padding: 6px 10px; border-radius: 999px; font-size: .88rem;
  border: 1.5px dashed var(--muted); color: var(--muted); background: transparent; opacity: .85;
}
.sugg .btn-small { min-height: 44px; }

/* ---------- source panel ---------- */
.src-card { margin-top: 12px; }
.src-header { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.src-grid { display: grid; gap: 12px; }
@media (min-width: 700px) { .src-grid { grid-template-columns: 3fr 2fr; align-items: start; } }
.src-fields { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.src-field { width: 100%; display: flex; gap: 8px; align-items: flex-start; text-align: left; font-weight: 400; min-height: 44px; }
.src-field .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--hc); flex: none; margin-top: 5px; }
.src-field.active { border-color: var(--hc); box-shadow: 0 0 0 2px var(--hc); }
.hl {
  position: absolute; min-height: 0; padding: 0; border-radius: 3px;
  background: rgba(30,136,229,.3); /* older iOS without color-mix */
  background: color-mix(in srgb, var(--hc) 30%, transparent); border: 2px solid var(--hc); box-shadow: none;
}
.src-view.focus .hl:not(.active) { opacity: .25; }
.hl.active { background: color-mix(in srgb, var(--hc) 45%, transparent); }
.src-text { font-family: ui-monospace, monospace; font-size: .85rem; white-space: normal; overflow-wrap: anywhere; max-height: 50vh; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; }
.hl-text { display: inline; min-height: 0; padding: 0 2px; border-radius: 3px; font: inherit; background: color-mix(in srgb, var(--hc) 25%, transparent); border: 1px solid var(--hc); }
.src-view.focus .hl-text:not(.active) { opacity: .4; }
.linkish { background: none; border: 0; color: var(--accent-text); padding: 4px 0; min-height: 0; text-decoration: underline; }
.flash { animation: flash 1.2s ease 2; }
.grid2 > .field { min-width: 0; }
/* Date-and-time inputs plus a camera button don't fit two per row on a phone. */
@media (max-width: 560px) { .grid2:has(input[type="datetime-local"]) { grid-template-columns: 1fr; } }

/* ---------- date range picker (rangepicker.js) ---------- */
.date-btn {
  width: 100%; justify-content: flex-start; gap: 8px; padding: 10px 12px;
  border-radius: 10px; font-weight: 600; text-align: left; white-space: nowrap; overflow: hidden;
}
.with-cam > .date-btn { flex: 1 1 auto; min-width: 0; }
.date-btn .date-btn-val { overflow: hidden; text-overflow: ellipsis; }
.date-btn.empty .date-btn-val { color: var(--muted); font-weight: 500; }
.date-btn.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.field.from-image .date-btn { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }

.rp {
  margin: -4px 0 14px; padding: 10px 8px 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  user-select: none; -webkit-user-select: none; touch-action: pan-y;
}
.rp-status { margin: 0 4px 6px; font-weight: 700; text-align: center; min-height: 1.4em; }
.rp-body { position: relative; }
.rp-nav { position: absolute; top: 0; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; font-size: 1.6rem; line-height: 1; border-color: transparent; background: transparent; z-index: 1; }
.rp-prev { left: 0; }
.rp-next { right: 0; }
.rp-months { display: grid; grid-template-columns: repeat(var(--rp-n, 1), minmax(0, 1fr)); gap: 0 20px; }
.rp-title { height: 44px; line-height: 44px; text-align: center; font-weight: 800; }
.rp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.rp-wd { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); padding: 2px 0 4px; }
.rp-day {
  position: relative; min-width: 0; min-height: 44px; height: 44px; width: 100%; padding: 0;
  border: 0; border-radius: 0; background: transparent; font-weight: 500; color: var(--ink);
}
.rp-day:active { transform: none; }
.rp-day .n {
  position: relative; z-index: 1; display: grid; place-items: center;
  width: 40px; height: 40px; max-width: 100%; margin: 0 auto; border-radius: 50%;
}
/* The band between start and end. Endpoints get half a band so it joins the circle. */
.rp-day.in-range::before, .rp-day.has-range.is-start::before, .rp-day.has-range.is-end::before {
  content: ""; position: absolute; top: 2px; bottom: 2px; left: 0; right: 0;
  background: rgba(79,124,172,.18); /* older iOS without color-mix */
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.rp-day.has-range.is-start::before { left: 50%; }
.rp-day.has-range.is-end::before { right: 50%; }
.rp-day.is-start .n, .rp-day.is-end .n { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.rp-day.is-today .n { box-shadow: inset 0 0 0 2px var(--muted); }
.rp-day.is-today.is-start .n, .rp-day.is-today.is-end .n { box-shadow: inset 0 0 0 2px var(--accent-ink); }
.rp-day.in-hint .n::after, .rp-key-dot {
  content: ""; position: absolute; left: 50%; bottom: 3px; width: 5px; height: 5px; margin-left: -2.5px;
  border-radius: 50%; background: var(--c-hotel);
}
.rp-day.in-hint.is-start .n::after, .rp-day.in-hint.is-end .n::after { background: var(--accent-ink); }
@media (hover: hover) { .rp-day:hover .n { outline: 2px solid var(--accent); outline-offset: -2px; } }
.rp-day:focus-visible { outline: none; }
.rp-day:focus-visible .n { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); }
.rp-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.rp-foot > :first-child { flex: 1; }
.rp-key { display: inline-flex; align-items: center; gap: 6px; }
.rp-key-dot { position: static; display: inline-block; margin: 0; }
/* How a photo is read: whole image automatically, or areas the person selects. */
.seg { display: flex; gap: 0; margin-top: 10px; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 0; background: var(--surface); font-size: .85rem; font-weight: 500; box-shadow: none; }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--accent-soft); color: inherit; font-weight: 700; box-shadow: inset 0 -3px 0 var(--accent); }

/* Drawing boxes on a capture (select regions / re-read an area). */
.region-bar { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.region-bar .on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.ocr-stage.drawing { outline: 3px solid var(--accent); outline-offset: -3px; }
.region-layer { position: absolute; inset: 0; z-index: 3; cursor: crosshair; touch-action: none; }
.region-draft { position: absolute; border: 2px dashed var(--accent); background: rgba(79,124,172,.15); background: color-mix(in srgb, var(--accent) 15%, transparent); pointer-events: none; }
.region-mark { position: absolute; z-index: 2; border: 2px solid #E08A00; border-radius: 3px; pointer-events: none; min-height: 6px; }
.region-mark span { position: absolute; right: -2px; bottom: 100%; opacity: .9; min-width: 18px; padding: 0 4px; border-radius: 4px; background: #E08A00; color: #fff; font: 700 12px/18px system-ui, sans-serif; text-align: center; }
.region-mark.reading { border-style: dashed; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.region-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.region-list .tchip b { color: #E08A00; margin-right: 4px; }
.region-mark.low span { bottom: auto; top: 100%; }

/* ---------- connecting legs (travel form) ---------- */
.legs { display: grid; gap: 10px; margin-bottom: 8px; }
fieldset.leg { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 4px; margin: 0; min-width: 0; }
fieldset.leg.only { border: 0; padding: 0; }
fieldset.leg legend { width: 100%; padding: 0; margin-bottom: 4px; }
.add-leg { margin-bottom: 14px; }

/* ---------- itinerary: tap-to-call, hand-ordered cards ---------- */
.tonight { display: flex; gap: 8px; align-items: stretch; }
.tonight > .item { flex: 1 1 auto; min-width: 0; }
.call-btn { flex: none; width: 52px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; text-decoration: none; }
.order-note { margin-top: 12px; }
.tl-entry { display: flex; gap: 6px; align-items: stretch; }
.tl-entry > .item { flex: 1 1 auto; min-width: 0; }
.drag-handle {
  flex: none; order: 2; width: 44px; min-width: 44px; min-height: 44px; padding: 0;
  font-size: 1.3rem; line-height: 1; cursor: grab; touch-action: none; user-select: none;
  background: transparent; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted, inherit);
}
.tl-entry.dragging { z-index: 5; }
.tl-entry.dragging > .item { box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.tl-entry.dragging .drag-handle { cursor: grabbing; }

/* Several bookings from one photo. */
.region-mark.day { border: 2px dashed var(--ok); }
.region-mark.day span { background: var(--ok); right: auto; left: -2px; }
.region-rm { min-width: 44px; padding: 6px; }
.mc-list { display: grid; gap: 8px; margin: 10px 0; }
.mc-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 10px; border: 1.5px solid var(--line); border-radius: 10px; }
.mc-row.day { border-color: var(--ok); }
.mc-row .grow { flex: 1; }
.mc-row input[type=date] { flex: 1 1 150px; width: auto; }
.mc-row .mc-wide { flex: 1 0 100%; }
.mc-card { display: grid; gap: 8px; margin-top: 10px; padding: 10px; border: 1.5px solid var(--line); border-radius: 10px; }
.mc-card.off > :not(label) { opacity: .45; }
.mc-card input[type=checkbox] { width: 22px; height: 22px; min-height: 0; flex: none; }
.mc-crop { position: relative; width: 100%; overflow: hidden; border-radius: 8px; background: #fff; }
.mc-crop img { position: absolute; max-width: none; height: auto; }
