/* Trip app - phone first. Light + dark theme (follows the phone's setting). */
:root {
  --bg: #f1f5f9; --card: #ffffff; --field: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #0b7a75; --brand-2: #0a5c63; --brand-3: #14a38b; --soft: #e6f6f3; --accent: #f59e0b;
  --up: #15803d; --down: #dc2626; --warn: #b45309;
  --head: linear-gradient(120deg, #0a4f5c 0%, #0b7a75 55%, #14a38b 100%);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 18px; --nav-h: 66px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #121b2d; --field: #0f1726; --ink: #e6edf6; --muted: #94a3b8; --line: #23304a;
    --soft: #10323a; --up: #4ade80; --down: #f87171; --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--down); min-height: 1em; margin: 6px 0 0; }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
a { color: var(--brand-3); }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; }
h2 { font-size: 19px; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 18px 0 8px; }

/* buttons + inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px;
  padding: 10px 15px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-3)); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(11, 122, 117, .28); }
.btn.danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 35%, transparent); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; margin: 4px 0 12px; padding: 12px; }
.btn:disabled { opacity: .5; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 2px 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--field);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-3); outline-offset: -1px; }
/* iPhone zooms into any text box smaller than 16px - keep all of them at 16px */
input, select, textarea, .sort, .map-bar select { font-size: 16px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 12px; }
label > input, label > select, label > textarea, label > .row-form { margin-top: 5px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 500; font-size: 15px; }
label.check input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; padding: 6px 12px 0; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-form { display: flex; gap: 8px; }
.row-form input { flex: 1; min-width: 0; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--head); }
.login-card { width: 100%; max-width: 370px; text-align: center; padding: 26px 22px; }
.login-card label { text-align: left; }
.login-card .btn { width: 100%; padding: 13px; }
.login-card h1 { margin: 8px 0 18px; letter-spacing: -.02em; }
.login-card img { border-radius: 16px; box-shadow: var(--shadow); }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--head); color: #fff;
  box-shadow: 0 2px 12px rgba(10, 79, 92, .25);
}
.topbar h1 { font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.topbar .btn { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .18); color: #fff; box-shadow: none; }
.people { display: flex; cursor: pointer; padding-left: 6px; }
.people .ava { margin-left: -7px; border: 2px solid rgba(255, 255, 255, .9); }
main { max-width: 760px; margin: 0 auto; padding: 14px 12px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border-radius: var(--radius); padding: 15px; margin-bottom: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card.empty { color: var(--muted); text-align: center; padding: 28px 16px; }
.ava {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  color: #fff; font-style: normal; font-weight: 700; font-size: 13px; position: relative;
}
.ava.on::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }

/* footer: frosted bar, line icons, active tab in a pill */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 0 6px env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1; max-width: 120px; height: var(--nav-h); border: 0; background: none; font: inherit; font-size: 11.5px; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; position: relative;
}
.bottom-nav .ico {
  display: grid; place-items: center; width: 54px; height: 30px; border-radius: 16px; transition: background .2s, color .2s;
}
.bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button.on { color: var(--brand); }
.bottom-nav button.on .ico { background: var(--soft); }
@media (prefers-color-scheme: dark) { .bottom-nav button.on { color: #5eead4; } }
.dot { position: absolute; top: 9px; right: calc(50% - 22px); width: 10px; height: 10px; border-radius: 50%; background: #ef4444; border: 2px solid var(--card); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 15;
  width: 58px; height: 58px; border-radius: 18px; border: 0; background: linear-gradient(135deg, var(--brand), var(--brand-3)); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: 0 8px 20px rgba(11, 122, 117, .4); cursor: pointer;
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); z-index: 60;
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 14px; max-width: 90vw; font-size: 14px; box-shadow: var(--shadow);
}

/* plan */
.hero { background: var(--head); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero::after { /* soft mountains */
  content: ""; position: absolute; right: -10px; bottom: -6px; width: 180px; height: 70px; opacity: .14; pointer-events: none;
  background: linear-gradient(135deg, transparent 49%, #fff 50%) 0 100% / 90px 70px no-repeat,
    linear-gradient(225deg, transparent 49%, #fff 50%) 90px 100% / 90px 70px no-repeat;
}
.hero .muted { color: #cdeee9; }
.hero .big { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.hero .next { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .22); }
.hero .btn { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .2); color: #fff; margin-left: 4px; box-shadow: none; }
.hero .soon { color: #fde68a; }
.done-days > summary { list-style: none; cursor: pointer; font-weight: 600; }
.done-days > summary::-webkit-details-marker { display: none; }
.day { padding: 13px 15px; scroll-margin-top: 70px; }
.day.today { border: 2px solid var(--brand-3); }
.day.past { opacity: .62; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.day-head b { font-size: 16px; }
.wx { font-size: 13px; background: var(--soft); border-radius: 20px; padding: 3px 11px; white-space: nowrap; }
.stay { font-size: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--card)); border-radius: 12px; padding: 8px 11px; margin: 8px 0; }
.stay .btn { margin-left: 6px; }
.item { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.day-head + .item { border-top: 0; }
.item.past { opacity: .55; }
.item-icon {
  font-size: 19px; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: var(--soft);
}
.item-icon.k-hotel { background: color-mix(in srgb, #8b5cf6 16%, var(--card)); }
.item-icon.k-drive { background: color-mix(in srgb, #14b8a6 18%, var(--card)); }
.item-icon.k-flight, .item-icon.k-car { background: color-mix(in srgb, #3b82f6 16%, var(--card)); }
.item-icon.k-visit { background: color-mix(in srgb, #f43f5e 14%, var(--card)); }
.item-icon.k-food { background: color-mix(in srgb, #f59e0b 18%, var(--card)); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 700; }
.time { color: var(--brand-3); font-variant-numeric: tabular-nums; font-weight: 800; }
.item-sub { font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.item-notes { font-size: 13px; color: var(--muted); margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.road-wx { font-size: 13px; background: color-mix(in srgb, #3b82f6 10%, var(--card)); border-radius: 10px; padding: 6px 9px; margin-top: 7px; line-height: 1.8; }
.road-wx span { white-space: nowrap; }

/* live drive */
.live { background: linear-gradient(135deg, #0f172a, #1e293b); color: #fff; border-radius: var(--radius); padding: 14px 15px; margin-bottom: 12px; box-shadow: var(--shadow); }
.live .muted { color: #cbd5e1; }
.live .big { font-size: 19px; font-weight: 800; }
.live .btn { background: rgba(255, 255, 255, .14); border-color: transparent; color: #fff; box-shadow: none; }
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; margin-right: 7px; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .7); } 100% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } }

/* map */
.map-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.map-bar select { flex: 1 1 120px; padding: 9px 11px; }
.map-bar label.check { margin: 0; white-space: nowrap; font-size: 14px; }
.map { height: 52vh; min-height: 280px; border-radius: var(--radius); overflow: hidden; background: var(--soft); margin-bottom: 12px; scroll-margin-top: 66px; box-shadow: var(--shadow); }
.map-note { padding: 30px 20px; text-align: center; color: var(--muted); }
.map-me {
  width: 44px; height: 44px; margin: 0 10px 14px 0; border: 0; border-radius: 50%; background: #fff; color: #2563eb; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.map-start {
  margin-top: 10px; border: 0; border-radius: 26px; padding: 12px 30px; font: inherit; font-size: 17px; font-weight: 800; cursor: pointer;
  background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; box-shadow: 0 6px 18px rgba(22, 163, 74, .45);
}
.map-start.on { background: linear-gradient(135deg, #dc2626, #ef4444); box-shadow: 0 6px 18px rgba(220, 38, 38, .45); }
.map-me svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.typing {
  position: fixed; left: 0; right: 0; max-width: 760px; margin: 0 auto; z-index: 17; bottom: calc(var(--nav-h) + 64px + env(safe-area-inset-bottom));
  font-size: 13px; color: var(--muted); padding: 3px 18px; font-style: italic;
}
.typing:empty { display: none; }
.chat-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.pin {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  background: #fff; border: 2px solid var(--brand); font-size: 17px; box-shadow: 0 3px 8px rgba(0, 0, 0, .3);
}
.pin > span { transform: rotate(45deg); line-height: 1; }
.pin.kind-hotel { border-color: #7c3aed; }
.pin.kind-drive { border-color: #0f766e; }
.pin.kind-car, .pin.kind-flight { border-color: #2563eb; }
.pin.friend > span, .pin.found > span { transform: none; }
.pin.friend { transform: none; border-radius: 50%; color: #fff; font-weight: 800; font-size: 15px; border: 3px solid #fff; width: 34px; height: 34px; }
.pin.found { transform: none; border-radius: 50%; width: 26px; height: 26px; background: #dc2626; border-color: #fff; color: #fff; font-size: 12px; font-weight: 700; }
.info { font: 14px/1.4 system-ui, sans-serif; max-width: 240px; color: #0f172a; }
.info div { color: #555; margin-top: 2px; }
.info a { display: inline-block; margin-top: 6px; font-weight: 600; }
.explore { padding: 13px; }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--brand-3); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
#exDrive { margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip:active { background: var(--soft); }
.list { list-style: none; margin: 0; padding: 0; }
.place { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.place-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sort { width: auto; padding: 6px 9px; }
#days { padding-bottom: 76px; } /* room for the ＋ button */
.fuel { font-size: 13px; color: var(--ink); }
.journal { font-size: 14px; background: var(--soft); border-radius: 12px; padding: 9px 11px; margin: 8px 0 2px; }
.journal ul { margin: 4px 0 0; padding-left: 18px; }
.journal .btn { margin-top: 6px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.cats span { background: var(--bg); border-radius: 20px; padding: 4px 11px; font-size: 13px; }

/* chat */
.chat-list { list-style: none; margin: 0; padding: 0 0 76px; }
.msg { display: flex; margin: 7px 0; }
.msg.mine { justify-content: flex-end; }
.bubble { max-width: 82%; background: var(--card); border: 1px solid var(--line); border-radius: 18px 18px 18px 6px; padding: 8px 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); overflow-wrap: anywhere; }
.mine .bubble { background: linear-gradient(135deg, var(--brand), var(--brand-3)); color: #fff; border-color: transparent; border-radius: 18px 18px 6px 18px; }
.mine .bubble a, .mine .bubble .t { color: #e0f5f2; }
.mine .bubble .btn { background: rgba(255, 255, 255, .18); color: #fff; border-color: transparent; }
.who { display: block; font-size: 13px; }
.txt { white-space: pre-wrap; }
.bubble .btn { margin-top: 6px; }
.bubble .t { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; }
.chat-form, .ask-form {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 18;
  display: flex; gap: 8px; padding: 9px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  max-width: 760px; margin: 0 auto;
}
.chat-form input { flex: 1; min-width: 0; border-radius: 22px; padding-left: 16px; }
.ask-form textarea { flex: 1; resize: none; min-width: 0; border-radius: 16px; }
.ask-btns { display: flex; flex-direction: column; gap: 4px; }
#askMic.on { background: #ef4444; border-color: #ef4444; color: #fff; animation: blink 1.2s infinite; }
.say { float: right; margin: -4px -6px 0 6px; }
.stop-voice {
  position: fixed; top: calc(62px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 70;
  border: 0; border-radius: 30px; padding: 11px 22px; background: #dc2626; color: #fff; font: inherit; font-size: 16px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(220, 38, 38, .45); cursor: pointer;
}
/* in-app route */
.nav { border: 2px solid #3b82f6; }
.nav .big { font-size: 19px; font-weight: 800; margin: 4px 0; }
.next-turn { background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; border-radius: 14px; padding: 11px 13px; font-size: 16px; margin: 8px 0; }
.warn { color: var(--warn); font-weight: 600; font-size: 14px; }
.steps { margin: 8px 0 0; padding-left: 22px; font-size: 14px; }
.steps li { padding: 3px 0; }
.steps li.done { color: var(--muted); text-decoration: line-through; }
.pin.me { transform: none; width: 18px; height: 18px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 7px rgba(37, 99, 235, .25); }

/* money */
.balances { list-style: none; padding: 0; margin: 10px 0; }
.balances li { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.balances li span { margin-left: auto; }
.settle { background: var(--soft); border-radius: 12px; padding: 9px 11px; font-size: 14px; }
.settle div { margin-top: 2px; }
.exp { display: flex; justify-content: space-between; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.exp-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }

/* ask */
.ask-list { list-style: none; margin: 0; padding: 0 0 96px; }
.ask-list .q { margin: 16px 0 5px; padding: 0 4px; }
.ask-list .q .link-btn { float: right; }
.ask-list .a { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 15px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.ask-list .a p { margin: 0 0 8px; }
.ask-list .a p:last-child { margin: 0; }
.ask-list .a ul { margin: 0 0 8px; padding-left: 20px; }
.ask-list .a.err { color: var(--down); }
.thinking { color: var(--muted); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
#askChips { margin-top: 12px; }

/* pop-up (bottom sheet on phones) */
dialog {
  width: min(560px, 100vw); max-width: 100vw; max-height: 92vh; margin: auto auto 0; border: 0; padding: 0;
  border-radius: 24px 24px 0 0; background: var(--card); color: var(--ink); box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
}
dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
@media (min-width: 600px) { dialog { margin: auto; border-radius: 24px; } }
#modalForm { padding: 10px 18px calc(16px + env(safe-area-inset-bottom)); }
#modalForm::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; position: sticky; bottom: 0; background: var(--card); padding-top: 10px; }
#modalForm .only-drive, #modalForm .only-end { display: none; }
#modalForm[data-kind="drive"] .only-drive { display: block; }
#modalForm[data-kind="hotel"] .only-end, #modalForm[data-kind="car"] .only-end { display: grid; }
.place-field { margin-bottom: 4px; }
.place-field [data-addr] { margin: -6px 0 8px; }
.picks { list-style: none; margin: -4px 0 10px; padding: 0; }
.picks button { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 9px 11px; margin-bottom: 6px; font: inherit; cursor: pointer; }
.people-list { list-style: none; padding: 0; margin: 0; }
.people-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.add-friend { margin: 12px 0; }
.add-friend summary { list-style: none; margin-bottom: 10px; }
.add-friend summary::-webkit-details-marker { display: none; }
.howto { padding-left: 22px; line-height: 1.9; }

@media (min-width: 760px) {
  .map { height: 60vh; }
}
