:root {
  --ink: #111;
  --mute: #8c8c8c;
  --line: #e7e7e7;
  --accent: #7DC242;
  --kraft: #C99E6B;
  --pine: #ECD8B1;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #fff; }
body {
  color: var(--ink);
  font: 12px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

/* stage */
#stage { position: fixed; inset: 0; }
#board3d {
  display: block; width: 100%; height: 100%;
  touch-action: none; outline: none; cursor: grab;
  -webkit-tap-highlight-color: transparent;
}
#board3d.is-dragging { cursor: grabbing; }
#board3d.is-over { cursor: pointer; }
#board3d:focus-visible { outline: 1.5px solid var(--ink); outline-offset: -8px; }
#app.is-loading #board3d { opacity: 0; }
#board3d { transition: opacity .5s ease; }

#tip {
  position: fixed; left: 0; top: 0; z-index: 3;
  pointer-events: none; white-space: nowrap;
  font-size: 11px; padding: 3px 7px;
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  opacity: 0; transition: opacity .12s;
}
#tip.on { opacity: 1; }

/* side switch */
#bar {
  position: fixed; left: 50%; z-index: 2;
  bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
#sides {
  display: flex; padding: 2px; gap: 2px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
}
#sides button {
  border: 0; background: none; cursor: pointer;
  font-size: 11px; letter-spacing: .02em; color: var(--mute);
  padding: 5px 13px; border-radius: 999px;
}
#sides button:hover { color: var(--ink); }
#sides button[aria-pressed="true"] { background: var(--ink); color: #fff; }
#sideLabel { margin: 0; font-size: 10px; color: var(--mute); padding: 0 7px; border-radius: 999px; background: rgba(255, 255, 255, .88); }
#sideLabel:empty { display: none; }

#indexBtn {
  position: fixed; z-index: 2;
  top: calc(14px + env(safe-area-inset-top)); right: 16px;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  font-size: 11px; padding: 5px 12px; cursor: pointer;
}
#indexBtn:hover, #indexBtn[aria-expanded="true"] { border-color: var(--ink); }

#signoff {
  position: fixed; left: 16px; right: 16px; z-index: 1;
  bottom: calc(9px + env(safe-area-inset-bottom));
  width: fit-content; max-width: calc(100% - 32px); margin: 0 auto;
  padding: 0 7px; border-radius: 999px; background: rgba(255, 255, 255, .88);
  text-align: center; font-size: 10px; color: var(--mute);
  pointer-events: none;
}
#signoff:empty { display: none; }
#signoff.is-error { color: #FC204A; }

button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }

/* index drawer */
#index {
  position: fixed; z-index: 4; top: 0; right: 0; bottom: 0;
  width: min(340px, 100vw);
  background: #fff; border-left: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
  padding: calc(52px + env(safe-area-inset-top)) 16px 32px;
}
.ix-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px;
  width: 32px; height: 32px; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--ink);
}
.ix-date { margin: 0 0 18px; font-size: 10px; color: var(--mute); }
.face { margin: 0 0 22px; }
.face-h { margin: 0 0 8px; font-size: 11px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.face-h span { font-weight: 400; color: var(--mute); }
.face-hdr, .face-screen { display: none; }
.items { list-style: none; margin: 0; padding: 0; }
.it {
  width: 100%; display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
  border: 0; border-top: 1px solid var(--line); background: none;
  padding: 7px 0; text-align: left; cursor: pointer;
}
.it:hover .it-t { text-decoration: underline; text-underline-offset: 2px; }
.it-th { width: 44px; height: 34px; object-fit: cover; background: #f2efe9; }
canvas.it-th { object-fit: contain; background: #fff; }
.it-card {
  width: 44px; height: 34px; padding: 4px; overflow: hidden;
  background: #fff; border: 1px solid var(--line);
  font-size: 5px; line-height: 1.3; color: #555;
}
.it-t { font-size: 12px; }
.it-k { font-size: 10px; color: var(--mute); }

/* lightbox */
#lightbox {
  position: fixed; inset: 0; z-index: 10;
  background: #fff;
  display: grid; place-items: center;
  padding: calc(52px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.lb-inner { width: min(1100px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lb-media { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lb-media img, .lb-media video {
  max-width: 100%; max-height: calc(100svh - 170px);
  width: auto; height: auto; object-fit: contain; background: #f6f4f0;
}
.lb-media video { background: #000; }
.lb-meta { text-align: center; max-width: 640px; }
#lbTitle { margin: 0; font-size: 12px; font-weight: 600; }
.lb-cap { margin: 3px 0 0; font-size: 11px; color: var(--mute); }
.lb-close {
  position: fixed; z-index: 11;
  top: calc(10px + env(safe-area-inset-top)); right: 10px;
  width: 40px; height: 40px; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--ink);
}
.lb-pages { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 11px; color: var(--mute); }
.lb-pages button {
  width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; cursor: pointer; display: grid; place-items: center;
}
.lb-pages button:hover:not(:disabled) { border-color: var(--ink); }
.lb-pages button:disabled { opacity: .3; cursor: default; }
.lb-open {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 14px;
  padding: 7px 16px; border-radius: 999px; background: var(--ink); color: #fff;
  text-decoration: none; font-size: 12px;
}
.lb-host { margin-top: 6px; font-size: 10px; color: var(--mute); }
.lb-words { max-width: 560px; text-align: left; }
.lb-text { margin: 0; font-size: 20px; line-height: 1.45; white-space: pre-line; }
.lb-text.is-quote::before { content: "\201C"; display: block; color: var(--accent); font-size: 52px; line-height: .8; height: 30px; }
.lb-by { margin: 14px 0 0; font-size: 11px; color: var(--mute); }

/* disc */
.disc { width: min(640px, 100%, calc(100svh - 230px)); min-width: 260px; }
.disc svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: manipulation; }
.disc svg:focus { outline: none; }
.disc svg:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 4px; border-radius: 50%; }
.disc .dot { cursor: pointer; transition: r .12s; }
.disc-info { min-height: 72px; max-width: 520px; margin: 6px auto 0; font-size: 11px; text-align: left; }
.disc-info .di-st { display: inline-flex; align-items: center; gap: 5px; color: var(--mute); font-size: 10px; }
.disc-info .di-st i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.disc-info .di-t { margin: 2px 0 0; font-weight: 600; font-size: 12px; }
.disc-info .di-q { margin: 3px 0 0; }
.disc-info .di-m { margin: 3px 0 0; color: var(--mute); font-size: 10px; }
.disc-info img { width: 120px; margin-top: 6px; }
.disc-info .di-hint { color: var(--mute); text-align: center; }
.legend { display: flex; justify-content: center; gap: 14px; margin-top: 8px; font-size: 10px; color: var(--mute); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; color: var(--mute); }

/* flat boards, used when 3D is not available */
body.flat { overflow: auto; }
body.flat #stage, body.flat #bar, body.flat #indexBtn, body.flat .ix-close { display: none !important; }
body.flat #index {
  position: static; display: grid !important; width: auto; border: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px;
  max-width: 1180px; margin: 0 auto; padding: 28px 16px 56px;
  overflow: visible;
}
body.flat .ix-date { grid-column: 1 / -1; margin: 0; text-align: center; }
body.flat .face {
  margin: 0; padding: 14px;
  border: 10px solid var(--pine); border-radius: 2px;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .025) 0 3px, rgba(255, 255, 255, .03) 3px 7px),
    var(--kraft);
}
body.flat .face-h { color: #3b2a16; }
body.flat .face-h span { color: #6b5233; }
body.flat .face-hdr {
  display: grid; grid-template-columns: 56px 1fr 56px; gap: 12px; align-items: center;
  background: #fff; padding: 8px; margin-bottom: 14px;
}
body.flat .face-hdr img { width: 56px; height: 56px; object-fit: cover; }
body.flat .face-hdr b { display: block; font-size: 16px; }
body.flat .face-hdr span { color: #555; font-size: 11px; }
body.flat .face-screen { display: block; margin-bottom: 14px; border: 8px solid #111; background: #000; }
body.flat .face-screen video { width: 100%; display: block; }
body.flat .items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; }
body.flat .it {
  grid-template-columns: 1fr; gap: 5px; padding: 6px 6px 8px;
  background: #fff; border: 0; box-shadow: 0 1px 3px rgba(60, 40, 10, .25);
}
body.flat .it-th { width: 100%; height: 92px; }
body.flat .it-card { width: 100%; height: 92px; font-size: 9px; border: 0; padding: 4px 2px; }
body.flat .it-k { display: none; }
body.flat .ix-screen { display: none; }
body.flat canvas.it-th { height: auto; aspect-ratio: 1; }
@media (max-width: 700px) { body.flat #index { grid-template-columns: minmax(0, 1fr); } }
body.flat .it-t { font-size: 11px; }
body.flat #signoff { position: static; padding: 0 16px 24px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
