:root {
  --bg: #ffffff;
  --surface: #f6f3ee;
  --surface-2: #efe9df;
  --ink: #161513;
  --ink-2: #3b3833;
  --muted: #77726a;
  --line: #e8e3da;
  --accent: #d9622b;       /* apricot */
  --accent-ink: #ffffff;
  --raisin: #6e2f2a;
  --oat: #e9dcc4;
  --src-gm: #2f6f6a;
  --src-bc: #7a3f6e;
  --src-wp: #5b5b5b;
  --radius: 18px;
  --radius-sm: 12px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Georgia", "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1d1b19;
    --surface-2: #26231f;
    --ink: #f3efe8;
    --ink-2: #d6d0c6;
    --muted: #9d968b;
    --line: #2f2b27;
    --accent: #ec7a43;
    --raisin: #d38b7f;
    --oat: #3a3226;
    --src-gm: #6fb8b0;
    --src-bc: #c895bb;
    --src-wp: #a8a8a8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.brand { display: flex; align-items: center; gap: 8px; }
.wordmark { font: 700 23px/1 var(--font-display); letter-spacing: -0.02em; }
.pill {
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 99px;
  background: var(--surface); color: var(--muted);
}
.pill.ok { background: color-mix(in srgb, var(--src-gm) 14%, transparent); color: var(--src-gm); }

main { max-width: 640px; margin: 0 auto; outline: none; }
.pad { padding: 0 16px; }

/* ---------- Type ---------- */
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
.h-display { font: 700 32px/1.08 var(--font-display); letter-spacing: -0.02em; }
.h-title { font: 700 28px/1.12 var(--font-display); }
.h-section { font: 700 20px/1.2 var(--font); margin: 28px 16px 12px; display: flex; align-items: baseline; justify-content: space-between; }
.h-section a { font-size: 14px; font-weight: 600; color: var(--accent); }
.kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Home hero ---------- */
.hero { display: block; position: relative; margin: 4px 16px 0; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); aspect-ratio: 4 / 3.4; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.62)); }
.hero-text { position: absolute; left: 18px; right: 18px; bottom: 16px; z-index: 1; color: #fff; }
.hero-text .kicker { color: rgba(255,255,255,.82); }
.hero-text .h-display { color: #fff; margin-top: 4px; }

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 16px 0; }
.action {
  display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); min-height: 112px; justify-content: space-between;
}
.action.primary { background: var(--ink); color: var(--bg); }
.action b { font-size: 17px; line-height: 1.2; }
.action small { color: inherit; opacity: .7; font-size: 13px; }

/* ---------- Carousels and cards ---------- */
.rail { display: flex; gap: 12px; overflow-x: auto; padding: 0 16px 4px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.tourcard { flex: 0 0 72%; max-width: 300px; scroll-snap-align: start; }
.tourcard .img { aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.tourcard img { width: 100%; height: 100%; object-fit: cover; }
.tourcard h3 { font-size: 16px; line-height: 1.25; margin-top: 8px; }
.tourcard p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; padding: 0 16px; }
.card { min-width: 0; }
.card .img { aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); position: relative; }
.card img { width: 100%; height: 100%; object-fit: cover; }
.card h3 { font-size: 15px; line-height: 1.25; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card p { margin: 2px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-audio { position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; border-radius: 99px; display: grid; place-items: center; background: rgba(0,0,0,.55); color: #fff; }
.badge-audio svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }

/* ---------- List rows ---------- */
.list { padding: 0 16px; }
.row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row .thumb { flex: none; width: 60px; height: 60px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.row .txt { min-width: 0; flex: 1; }
.row h3 { font-size: 15px; line-height: 1.3; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row p { margin: 1px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stopnum { flex: none; width: 34px; height: 34px; border-radius: 99px; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; }

/* ---------- Search ---------- */
.searchbox { position: sticky; top: 58px; z-index: 10; padding: 6px 16px 10px; background: var(--bg); }
.field {
  width: 100%; padding: 13px 16px 13px 44px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2377726a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4 4'/%3E%3C/svg%3E") no-repeat 16px 50% / 20px;
  color: var(--ink); font: 16px var(--font); outline: none;
}
.field:focus { border-color: var(--ink-2); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 99px; background: var(--surface); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); }
.count { padding: 4px 16px 0; font-size: 13px; color: var(--muted); }

/* ---------- Object page ---------- */
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; background: var(--surface); }
.gallery::-webkit-scrollbar { display: none; }
.gallery figure { margin: 0; flex: 0 0 100%; scroll-snap-align: center; position: relative; aspect-ratio: 1; display: grid; place-items: center; }
.gallery img { max-width: 100%; max-height: 100%; object-fit: contain; }
.gallery figcaption { position: absolute; left: 12px; bottom: 10px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: rgba(0,0,0,.5); color: #fff; }
.dots { display: flex; justify-content: center; gap: 6px; padding: 8px 0 0; }
.dots i { width: 6px; height: 6px; border-radius: 9px; background: var(--line); }
.dots i.on { background: var(--ink); }
.obj-head { padding: 18px 16px 0; }
.obj-head .h-title { margin-top: 6px; }
.obj-meta { margin-top: 6px; color: var(--ink-2); }
.obj-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 8px; background: var(--surface); color: var(--ink-2); }
.tag.acc { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 500; }
.obj-actions { display: flex; gap: 10px; margin: 16px 16px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 99px; font-weight: 700; font-size: 15px;
  background: var(--surface); color: var(--ink);
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.btn.saved svg { fill: var(--accent); stroke: var(--accent); }

.tracks { margin: 16px 16px 0; display: grid; gap: 8px; }
.track { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface); text-align: left; width: 100%; }
.track .play { flex: none; width: 40px; height: 40px; border-radius: 99px; background: var(--ink); color: var(--bg); display: grid; place-items: center; }
.track .play svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.track b { display: block; font-size: 15px; line-height: 1.25; }
.track span { font-size: 13px; color: var(--muted); }
.langs { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 16px 0; }

.claims { margin: 0 16px; display: grid; gap: 14px; }
.claim { border-left: 3px solid var(--c, var(--line)); padding: 2px 0 2px 14px; }
.claim[data-src="gm"] { --c: var(--src-gm); }
.claim[data-src="bc"] { --c: var(--src-bc); }
.claim[data-src="wp"] { --c: var(--src-wp); }
.claim .who { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--c); }
.claim .who span { color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }
.claim .body { margin-top: 4px; white-space: pre-line; color: var(--ink-2); }
.claim .body.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.claim .more { margin-top: 4px; font-size: 14px; font-weight: 700; color: var(--accent); }
.hidden-note { margin: 4px 16px 0; font-size: 13px; color: var(--muted); }
.hidden-note a { color: var(--accent); font-weight: 600; }

.links { margin: 0 16px; display: grid; }
.links a { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.links a span { font-size: 13px; color: var(--muted); font-weight: 500; }

.notes { margin: 0 16px; }
textarea.field { border-radius: var(--radius-sm); padding: 12px 14px; min-height: 90px; background-image: none; resize: vertical; font-size: 16px; }

/* ---------- Tour page ---------- */
.tour-hero { aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; }
.tour-hero img { width: 100%; height: 100%; object-fit: cover; }
.prose { margin: 12px 16px 0; color: var(--ink-2); white-space: pre-line; }

/* ---------- Scan ---------- */
.scan-stage { position: relative; margin: 6px 16px 0; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.scan-stage video, .scan-stage canvas { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 8%; right: 8%; top: 38%; height: 24%; border: 2px solid rgba(255,255,255,.95); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.42); }
.scan-hint { position: absolute; left: 0; right: 0; top: calc(38% - 34px); text-align: center; color: #fff; font-weight: 600; font-size: 14px; }
.scan-status { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; color: #fff; font-size: 14px; font-weight: 600; }
.scan-empty { display: grid; place-items: center; height: 100%; color: #fff; text-align: center; padding: 24px; }
.segment { display: flex; margin: 0 16px 12px; background: var(--surface); border-radius: 99px; padding: 4px; }
.segment button { flex: 1; padding: 9px; border-radius: 99px; font-weight: 700; font-size: 14px; color: var(--muted); }
.segment button.on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 16px 0; }
.keypad button { padding: 16px 0; border-radius: var(--radius-sm); background: var(--surface); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.numdisplay { margin: 10px 16px 0; padding: 16px; border-radius: var(--radius); background: var(--surface); font: 600 30px/1.1 ui-monospace, "SF Mono", Menlo, monospace; text-align: center; min-height: 66px; letter-spacing: .02em; }
.numdisplay .ph { color: var(--muted); font: 500 16px var(--font); }

/* ---------- Visit / settings ---------- */
.panel { margin: 0 16px; padding: 16px; border-radius: var(--radius); background: var(--surface); }
.panel + .panel { margin-top: 12px; }
.panel h3 { font-size: 17px; }
.panel p { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); }
.opt { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.opt:last-child { border-bottom: 0; }
.opt input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.opt b { display: block; font-size: 15px; }
.opt span { font-size: 13px; color: var(--muted); }
.progress { height: 8px; border-radius: 9px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.srcdot { display: inline-block; width: 10px; height: 10px; border-radius: 9px; background: var(--c); margin-right: 6px; vertical-align: 1px; }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.spacer { height: 28px; }

/* ---------- Player ---------- */
.player {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border-radius: 16px;
  background: var(--ink); color: var(--bg); box-shadow: 0 8px 28px rgba(0,0,0,.25);
  max-width: 624px; margin: 0 auto;
}
.player-toggle { flex: none; width: 40px; height: 40px; border-radius: 99px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.player-toggle svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.player .i-pause { display: none; }
.player.playing .i-pause { display: block; }
.player.playing .i-play { display: none; }
.player-meta { flex: 1; min-width: 0; }
.player-title { display: block; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar { height: 3px; border-radius: 3px; background: rgba(255,255,255,.2); margin-top: 6px; overflow: hidden; }
.player-bar div { height: 100%; width: 0; background: var(--accent); }
.player-close { flex: none; width: 32px; height: 32px; display: grid; place-items: center; opacity: .7; }
.player-close svg { width: 18px; height: 18px; }
body.has-player { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 72px); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabbar a.on { color: var(--ink); }
.tabbar svg { width: 24px; height: 24px; }
.tab-scan .scan-disc { width: 52px; height: 52px; margin-top: -22px; border-radius: 99px; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); }
.tab-scan .scan-disc svg { width: 26px; height: 26px; }

@media (hover: hover) {
  .row:hover h3, .card:hover h3, .tourcard:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery figure { aspect-ratio: 4 / 3; }
}
@media (prefers-reduced-motion: no-preference) {
  main.enter { animation: enter .18s ease-out; }
  @keyframes enter { from { opacity: 0; transform: translateY(4px); } }
}
