/* Japan · City Drawer — mobile-first, one-handed, sunlight-legible. */
:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --ink: #14130f;
  --ink-2: #52514e;
  --ink-3: #898781;
  --line: #e1e0d9;
  --accent: #c73e3a;           /* torii red — app identity, not a data color */
  --good: #0ca30c;
  --warn-bg: #fff3d6;
  --warn-ink: #6b4d00;
  --fail-bg: #ffe1e1;
  --fail-ink: #8a1f1f;
  /* categorical city slots (dataviz palette, fixed order) */
  --city-1: #2a78d6;  /* Osaka */
  --city-2: #eb6834;  /* Kyoto */
  --city-3: #1baf7a;  /* Tokyo */
  --city-air: #898781;
  --tap: 48px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --line: #2c2c2a;
    --accent: #e05d59;
    --warn-bg: #3a2f10;
    --warn-ink: #ffd977;
    --fail-bg: #401717;
    --fail-ink: #ff9d9d;
    --city-1: #3987e5;
    --city-2: #d95926;
    --city-3: #199e70;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

/* top bar */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px calc(10px) 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-name { font-weight: 800; letter-spacing: .12em; color: var(--accent); }
.sync-chip { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-chip.stale { color: var(--fail-ink); font-weight: 600; }
.filter-pill { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.filter-pill button {
  border: 0; background: none; color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 12px; min-height: 40px; cursor: pointer;
}
.filter-pill button.on { background: var(--ink); color: var(--bg); }

/* banner */
.banner { padding: 10px 14px; font-size: 14px; font-weight: 600; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.fail { background: var(--fail-bg); color: var(--fail-ink); }

/* main */
#view { padding: 14px; max-width: 640px; margin: 0 auto; }
h1 { font-size: 22px; margin: 6px 0 12px; }
h2 { font-size: 15px; color: var(--ink-2); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .06em; }

/* city band */
.cityband { display: flex; gap: 2px; margin: 10px 0 4px; }
.cityband .seg {
  border-radius: 6px; color: #fff; font-size: 11px; font-weight: 700;
  padding: 6px 4px 5px; text-align: center; overflow: hidden; white-space: nowrap;
  display: flex; flex-direction: column; gap: 1px; justify-content: center;
  min-height: 40px; border: 0; cursor: pointer; font-family: inherit;
}
.cityband .seg small { font-weight: 500; opacity: .9; font-size: 10px; }
.seg.c1 { background: var(--city-1); }
.seg.c2 { background: var(--city-2); }
.seg.c3 { background: var(--city-3); }
.seg.air { background: var(--city-air); }
.cityband-days { display: flex; gap: 2px; margin-bottom: 12px; }
.cityband-days button {
  flex: 1; border: 0; background: none; font: inherit; font-size: 10px; color: var(--ink-3);
  padding: 3px 0; border-radius: 4px; cursor: pointer; min-width: 0;
}
.cityband-days button.today { outline: 2px solid var(--accent); font-weight: 800; color: var(--ink); }
.cityband-days button.sel { background: var(--ink); color: var(--bg); font-weight: 700; }

/* hero (Now) */
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin-bottom: 14px;
}
.hero .kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero .big { font-size: 24px; font-weight: 800; line-height: 1.2; margin: 4px 0; }
.hero .sub { color: var(--ink-2); font-size: 14px; }
.clock { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 13px; margin-bottom: 10px; }

/* day nav */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.daynav button { min-width: var(--tap); min-height: var(--tap); border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; font-size: 20px; cursor: pointer; }
.daynav .dn-title { text-align: center; }
.daynav .dn-title .d { font-weight: 800; font-size: 17px; }
.daynav .dn-title .h { color: var(--ink-2); font-size: 13px; }

/* 3D flyover link */
.link3d {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 6px 0 0; padding: 8px 12px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-2);
  font-size: 13px; font-weight: 700; text-decoration: none;
}

/* timeline */
.timeline { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.now-line { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 12px; font-weight: 700; }
.now-line::before, .now-line::after { content: ""; flex: 1; border-top: 2px solid var(--accent); }
.entry {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; cursor: pointer;
}
.entry.cancelled { opacity: .55; }
.entry.cancelled .e-title { text-decoration: line-through; }
.entry .e-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.entry .e-time { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; white-space: nowrap; }
.entry .e-tz { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.entry .e-badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 6px; background: var(--line); color: var(--ink-2); }
.badge.idea { background: var(--warn-bg); color: var(--warn-ink); }
.badge.pending { background: var(--warn-bg); color: var(--warn-ink); }
.badge.hh { background: var(--ink); color: var(--bg); }
.badge.lock { background: transparent; border: 1px solid var(--line); }
.entry .e-title { font-weight: 700; font-size: 17px; margin: 2px 0; }
.entry .e-sub { color: var(--ink-2); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.flags { display: flex; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.flags span { display: inline-flex; gap: 3px; align-items: center; }
.e-detail { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.e-detail .row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.e-detail .label { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: 15px;
  text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:active { transform: scale(.98); }
.copyable { font-variant-numeric: tabular-nums; font-weight: 700; }

/* search */
.searchbox { width: 100%; min-height: var(--tap); font: inherit; font-size: 17px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.result-day { margin: 14px 0 6px; font-weight: 800; font-size: 14px; color: var(--ink-2); }

/* budget */
.seg-toggle { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 8px 0; }
.seg-toggle button { flex: 1; border: 0; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 700; min-height: 40px; cursor: pointer; }
.seg-toggle button.on { background: var(--ink); color: var(--bg); }
.btable { width: 100%; border-collapse: collapse; font-size: 14px; }
.btable th { text-align: right; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.btable th:first-child, .btable td:first-child { text-align: left; }
.btable td { padding: 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.btable td:first-child { font-weight: 600; }
.btable .total td { font-weight: 800; border-top: 2px solid var(--ink); }
.var-over { color: #d03b3b; font-weight: 700; }
.var-under { color: var(--good); font-weight: 700; }
.table-scroll { overflow-x: auto; }

/* settings */
.setting { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.setting .label { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }

/* tab bar */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar button {
  flex: 1; min-height: 56px; border: 0; background: none; color: var(--ink-3);
  font: inherit; font-size: 11px; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 8px;
}
#tabbar button .ico { font-size: 20px; line-height: 1; }
#tabbar button.on { color: var(--accent); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: flex; align-items: flex-end; }
.modal { background: var(--bg); width: 100%; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.modal h3 { margin: 0 0 8px; }
.modal input[type=password], .modal input[type=text] { width: 100%; min-height: var(--tap); font: inherit; font-size: 17px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); margin: 8px 0; }
.modal .error { color: var(--fail-ink); font-size: 14px; font-weight: 600; }

.muted { color: var(--ink-3); font-size: 13px; }
.ptr-hint { text-align: center; color: var(--ink-3); font-size: 12px; padding: 4px 0; }

/* Places browser: horizontally scrollable filter chip rows */
.seg-toggle.scroll-x { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
.seg-toggle.scroll-x button { flex: 0 0 auto; white-space: nowrap; }
.entry .flags a { color: inherit; }

/* Map tab */
.mapbox { height: min(62vh, 560px); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.map-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--ink-2); font-size: 13px; }
#tabbar button { min-width: 0; }

/* Places browser: thumbnail cards */
.entry.place.has-img { display: flex; gap: 11px; align-items: flex-start; }
.p-body { flex: 1; min-width: 0; }
.p-thumb { flex: 0 0 88px; width: 88px; height: 88px; border-radius: 10px; overflow: hidden; display: block; background: var(--surface-2, #1b2028); }
.p-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 26px; opacity: .45; }
@media (max-width: 380px) { .p-thumb { flex-basis: 68px; width: 68px; height: 68px; } }

/* Places / Map: prominent tally at the top */
.count-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 2px 0 8px; }
.count-big { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.count-big small { font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.count-sub { font-size: 12.5px; color: var(--ink-2); text-align: right; }

.e-title .lens { font-size: 12px; opacity: .6; margin-left: 4px; }
