:root {
  --bg: #f6f6f3;
  --ink: #161616;
  --ink2: #5d5d5a;
  --ink3: #9a9a96;
  --rule: #d6d6d1;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter', 'Noto Sans TC', 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
html[lang="zh-Hant-TW"] body { --sans: 'Noto Sans TC', 'Inter', sans-serif; }
canvas#c { position: fixed; inset: 0; display: block; cursor: grab; touch-action: none; }
canvas#c:active { cursor: grabbing; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.mono { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink2); }

.brand {
  position: fixed; left: 28px; top: 22px; margin: 0; pointer-events: none;
  font-family: 'Anton', 'Impact', sans-serif; font-weight: 400; font-size: 52px; line-height: .86;
  letter-spacing: -.01em; transform: scaleY(1.04); transform-origin: top left;
}

.bldg {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px;
  max-width: calc(100vw - 520px); z-index: 2;
}
.bldg .groups, .bldg .chips { display: flex; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.bldg .groups::-webkit-scrollbar, .bldg .chips::-webkit-scrollbar { display: none; }
.gtab {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink3); white-space: nowrap;
  padding: 4px 9px; border-radius: 999px; transition: color .15s, background .15s;
}
.gtab i { font-style: normal; font-size: 8.5px; margin-left: 4px; opacity: .7; }
.gtab:hover { color: var(--ink); }
.gtab.cur { color: var(--ink2); }
.gtab.on { color: var(--bg); background: var(--ink); }
.chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--ink2); white-space: nowrap;
  padding: 6px 10px; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s;
}
.chip i { font-style: normal; color: var(--ink3); margin-right: 5px; font-size: 9px; }
.chip:hover { color: var(--ink); }
.chip.on { color: var(--ink); border-bottom-color: var(--ink); }
.tagline { position: fixed; right: 28px; top: 26px; text-align: right; font-size: 12px; line-height: 1.5; }
.tagline b { display: block; font-weight: 500; }
.tagline span { display: block; color: var(--ink2); font-size: 11px; }
.tagline .link { margin-top: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: var(--ink2); border-bottom: 1px solid var(--rule); padding: 2px 0; }
.tagline .link:hover { color: var(--ink); border-color: var(--ink); }

.panel {
  position: fixed; right: 60px; top: 50%; transform: translateY(-50%); width: 300px;
  transition: opacity .22s ease, transform .22s ease;
}
.panel.swap { opacity: 0; transform: translateY(calc(-50% + 6px)); }
.panel .rule { height: 1px; background: var(--rule); margin-bottom: 16px; }
.eyebrow { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink2); }
.panel h2 { font-weight: 300; font-size: 30px; line-height: 1.12; letter-spacing: -.015em; margin: 12px 0 14px; }
.panel p { font-size: 12.5px; line-height: 1.72; color: var(--ink2); margin: 0 0 18px; }
.meta { font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; color: var(--ink2); margin-bottom: 18px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav .mono { margin-left: 12px; }
.sq { width: 38px; height: 38px; border: 1px solid var(--rule); background: rgba(255,255,255,.5); font-size: 15px; transition: background .15s, border-color .15s; }
.sq:hover { background: #fff; border-color: var(--ink); }

.bar { position: fixed; left: 24px; right: 24px; bottom: 16px; }
.bar-top { display: flex; justify-content: space-between; border-top: 1px solid var(--rule); padding: 7px 0 9px; }
.bar-top .mono { font-size: 9px; }
.bar-row { display: flex; justify-content: space-between; align-items: center; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  height: 34px; padding: 0 16px; border: 1px solid var(--rule); background: rgba(255,255,255,.6);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .03em; display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s, color .15s, border-color .15s; white-space: nowrap;
}
.btn i { font-style: normal; font-size: 11px; }
.btn:hover { border-color: var(--ink); background: #fff; }
.btn.dark { background: var(--ink); color: #f4f4f1; border-color: var(--ink); min-width: 140px; }
.btn.dark:hover { background: #333; }
.btn.dark.on i { transform: rotate(180deg); }
.btn.outline { border-color: var(--ink); }
.btn.ghost:disabled { color: var(--ink3); border-color: transparent; background: transparent; cursor: default; }
.btn.off { color: var(--ink3); text-decoration: line-through; }
.btn .dot { width: 8px; height: 8px; border-radius: 50%; background: #c33; display: inline-block; }
.btn.rec { background: var(--ink); color: #f4f4f1; }
.btn.rec .dot { border-radius: 1px; background: #f4f4f1; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

#tip {
  position: fixed; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: var(--ink); color: #f4f4f1; font-family: var(--mono); font-size: 10px; letter-spacing: .06em;
  padding: 5px 8px; white-space: nowrap;
}
#tip.show { opacity: 1; }

#loading {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%);
  font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink2);
  transition: opacity .5s; pointer-events: none;
}
#loading::after { content: '…'; }
body.ready #loading { opacity: 0; }

.panel p { cursor: default; }

/* ---------- phone, portrait: compact bottom sheet under the model ---------- */
@media (max-width: 859px) and (orientation: portrait) {
  .bldg { left: 12px; right: 12px; max-width: none; transform: none; top: calc(74px + env(safe-area-inset-top)); align-items: stretch; gap: 2px; }
  .chip { padding: 5px 7px; font-size: 10px; }
  .gtab { padding: 3px 8px; font-size: 9.5px; }
  .brand { left: 16px; top: calc(14px + env(safe-area-inset-top)); font-size: 30px; }
  .tagline { right: 16px; top: calc(16px + env(safe-area-inset-top)); font-size: 10.5px; line-height: 1.4; }
  .tagline span { font-size: 9.5px; }
  .tagline .link { margin-top: 4px; }
  #loading { top: auto; bottom: 40%; }
  .panel {
    left: 16px; right: 16px; width: auto; top: auto; transform: none;
    bottom: calc(96px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center;
  }
  .panel.swap { transform: translateY(6px); }
  .panel .rule { grid-column: 1 / -1; margin-bottom: 10px; }
  .eyebrow { grid-column: 1 / -1; font-size: 9px; }
  .panel h2 { grid-column: 1; font-size: 21px; margin: 6px 0 6px; }
  .nav { grid-column: 2; grid-row: 3; justify-self: end; }
  .nav .mono { margin-left: 8px; font-size: 9.5px; }
  .panel p {
    grid-column: 1 / -1; font-size: 11.5px; line-height: 1.6; margin: 0 0 2px; cursor: pointer;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  }
  .panel.open p { -webkit-line-clamp: 12; }
  .meta { display: none; }
  .sq { width: 34px; height: 34px; }
  .bar { left: 16px; right: 16px; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .bar-top { padding: 6px 0 8px; }
  .bar-row { gap: 6px; }
  .btns { gap: 5px; flex-wrap: nowrap; }
  .btn { height: 34px; padding: 0 10px; font-size: 10px; gap: 5px; }
  .btn.dark { min-width: 0; }
  #btnCam span, #btnLook span, #btnRec span { display: none; }
  #btnRec.rec span { display: inline; }
}
@media (max-width: 359px) and (orientation: portrait) {
  .btn { padding: 0 8px; }
  #btnPeople span { display: none; }
}

/* ---------- phone, landscape: model on the left, slim info column on the right ---------- */
@media (max-height: 519px) and (orientation: landscape) {
  .bldg { top: 4px; max-width: calc(100vw - 420px); gap: 0; }
  .chip { padding: 3px 6px; font-size: 9.5px; }
  .gtab { padding: 2px 7px; font-size: 9px; }
  .brand { left: max(14px, env(safe-area-inset-left)); top: 10px; font-size: 22px; }
  .tagline { right: max(14px, env(safe-area-inset-right)); top: 8px; }
  .tagline b, .tagline span { display: none; }
  .tagline .link { margin-top: 0; }
  #loading { top: 12px; }
  .panel {
    right: max(14px, env(safe-area-inset-right)); top: 40px; bottom: 54px; width: 236px;
    transform: none; overflow-y: auto; scrollbar-width: none;
  }
  .panel::-webkit-scrollbar { display: none; }
  .panel.swap { transform: translateY(4px); }
  .panel .rule { margin-bottom: 8px; }
  .eyebrow { font-size: 8.5px; }
  .panel h2 { font-size: 18px; margin: 6px 0 6px; }
  .panel p {
    font-size: 11px; line-height: 1.5; margin-bottom: 8px; cursor: pointer;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
  }
  .panel.open p { -webkit-line-clamp: 20; }
  .meta { font-size: 8.5px; margin-bottom: 8px; }
  .sq { width: 30px; height: 30px; font-size: 13px; }
  .bar { left: max(14px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right)); bottom: 8px; }
  .bar-top { display: none; }
  .btns { gap: 5px; flex-wrap: nowrap; }
  .btn { height: 30px; padding: 0 10px; font-size: 10px; gap: 5px; }
  .btn.dark { min-width: 0; }
  #btnCam span, #btnLook span { display: none; }
}

/* film mode: clean frames for the video renderer */
body.film .brand, body.film .tagline, body.film .panel, body.film .bar, body.film #tip, body.film #loading { display: none; }
