@font-face { font-family: Rubik; src: url(/fonts/Rubik-Regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Rubik; src: url(/fonts/Rubik-Bold.ttf) format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --ink: #1E1A1C;
  --muted: #6E6468;
  --line: #EADFDC;
  --brand: #D62D6A;
  --brand-ink: #FFFFFF;
  --brand-soft: #F8D7D0;
  --good: #1F7A4D; --good-bg: #E3F4EA;
  --warn: #8A5A00; --warn-bg: #FFF1D6;
  --bad: #B42318;  --bad-bg: #FDE7E4;
  --busy: #3D4FC4; --busy-bg: #E7EAFE;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 26, 28, .06), 0 4px 16px rgba(30, 26, 28, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Rubik, system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.45; font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .35em; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6em; }
a { color: var(--brand); }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 90%, transparent); position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 6px; display: block; }
#nav { display: flex; gap: 14px; align-items: center; }
.navlink { color: var(--muted); text-decoration: none; font-size: .95rem; }
.navlink:hover { color: var(--ink); }

.page { max-width: 880px; margin: 0 auto; padding: 20px 16px 80px; }
.page-record { max-width: 520px; padding-top: 10px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 8px 0 20px; flex-wrap: wrap; }
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.error { color: var(--bad); min-height: 0; }
.error:empty { display: none; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap { gap: 10px; } .gap-s { gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.center-row { justify-content: center; margin: 24px 0; }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; box-shadow: var(--shadow); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 44px;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:hover { border-color: #d9c9c5; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #c02560; }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 26px; font-size: 1.05rem; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: .875rem; }
.btn.wide { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; }
.icon { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: .95rem; }
.icon:disabled { opacity: .3; cursor: default; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], textarea {
  font: inherit; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%;
}
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #F1ECEA; color: var(--muted); white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.busy { background: var(--busy-bg); color: var(--busy); }
.chip.tiny { font-size: .7rem; padding: 1px 7px; margin-left: 8px; vertical-align: middle; }

/* login */
.login-card { max-width: 420px; margin: 8vh auto; background: var(--surface); padding: 32px 24px; border-radius: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); text-align: center; }
.login-card form { text-align: left; margin-top: 18px; }
.login-art { width: 64px; height: 64px; border-radius: 14px; display: block; margin: 0 auto 12px; }
.share-logo { width: 48px; height: 48px; border-radius: 10px; display: block; margin: 0 auto 10px; }

/* home */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 18px 0 28px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.step-n { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; display: grid; place-items: center; margin-bottom: 10px; }
.video-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.video-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.video-item:hover { border-color: #e2c9c3; }
.video-item .title { font-weight: 700; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }

/* editor */
.q-list, .answers { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.q-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #FFFCFB; }
.q-num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .85rem; display: grid; place-items: center; flex: none; }
.q-text { font-weight: 600; }
.q-actions { display: flex; gap: 4px; flex: none; }
.bank { display: grid; gap: 6px; margin: 8px 0 14px; }
.bank-item { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px dashed #DCCBC6; background: transparent; font: inherit; color: var(--ink); cursor: pointer; }
.bank-item:hover { border-color: var(--brand); background: #FFF6F4; }
.bank-item:disabled { opacity: .4; cursor: default; }
.bank-item .plus { color: var(--brand); font-weight: 700; }
.card-preview { display: block; max-width: 300px; width: 100%; margin-top: 12px; }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); justify-content: flex-end; }

/* video page */
.answer { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #FFFCFB; }
.answer-main { display: flex; gap: 12px; align-items: center; }
.answer-main .q-text { margin-bottom: 6px; }
.answer-actions { display: flex; gap: 6px; flex: none; }
.clip-box video { width: 100%; max-width: 240px; border-radius: 10px; margin-top: 10px; display: block; aspect-ratio: 9/16; background: #000; }
.result { margin: 8px 0 16px; }
.result-grid { display: grid; grid-template-columns: minmax(0, 280px) 1fr; gap: 24px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.player { width: 100%; aspect-ratio: 9/16; background: #000; border-radius: 12px; display: block; }
.notice { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 500; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.progress { height: 10px; background: #EFE6E3; border-radius: 99px; overflow: hidden; margin: 12px 0; }
.progress.wide { width: 100%; max-width: 320px; }
.progress-bar { height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s; }
.result > h2 { margin-top: 8px; }
.danger-zone { text-align: center; margin-top: 40px; }

/* recorder */
.rec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.stage {
  position: relative; width: min(100%, calc((100svh - 230px) * 9 / 16)); min-width: 220px; aspect-ratio: 9 / 16;
  margin: 0 auto; background: #111; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage .live { transform: scaleX(-1); }
.stage .review { background: #000; }
/* match the rendered layout: bars at 22/1280, card at 64/1280, 75% wide */
.stage-bars { position: absolute; left: 2.2%; right: 2.2%; top: 1.7%; display: flex; gap: .8%; z-index: 2; pointer-events: none; }
.stage-bars span { flex: 1; height: 4px; background: rgba(255,255,255,.4); border-radius: 2px; overflow: hidden; }
.stage-bars span.done i { display: block; height: 100%; width: 100%; background: #fff; }
.stage[data-state="recording"] .stage-bars span.current i { display: block; height: 100%; background: #fff; animation: fill var(--max, 60s) linear forwards; }
@keyframes fill { from { width: 0 } to { width: 100% } }
.stage-card { position: absolute; left: 12.5%; width: 75%; top: 5%; z-index: 2; pointer-events: none; }
.stage[data-state="review"] .stage-card, .stage[data-state="uploading"] .stage-card,
.stage[data-state="review"] .stage-bars, .stage[data-state="uploading"] .stage-bars { display: none; }
.stage-big { position: absolute; inset: 0; display: grid; place-items: center; font-size: 6rem; font-weight: 700; color: #fff; text-shadow: 0 2px 20px rgba(0,0,0,.5); z-index: 3; }
.stage-timer { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.55); color: #fff; padding: 4px 12px; border-radius: 99px; font-variant-numeric: tabular-nums; font-size: .9rem; z-index: 3; }
.stage-timer::first-letter { color: #ff4d4d; }
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: #fff; background: #2a2427; z-index: 4; }
.rec-controls { display: flex; justify-content: center; align-items: center; gap: 12px; min-height: 84px; margin-top: 14px; }
.rec-btn { width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--ink); background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; }
.rec-btn span { width: 52px; height: 52px; border-radius: 50%; background: #E5383B; transition: all .2s; }
.rec-btn.recording span { width: 26px; height: 26px; border-radius: 6px; }
.rec-btn:disabled { opacity: .6; }
.tips { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.tips summary { cursor: pointer; font-weight: 600; }
.tips ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: .9rem; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat-n { font-size: 1.8rem; font-weight: 700; }
.stat-l { color: var(--muted); font-size: .85rem; }
.stat.bad .stat-n { color: var(--bad); } .stat.warn .stat-n { color: var(--warn); } .stat.good .stat-n { color: var(--good); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.tab { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 6px 12px; font: inherit; font-size: .875rem; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.roster summary { cursor: pointer; list-style: none; }
.roster summary::-webkit-details-marker { display: none; }
.roster summary h2::after { content: ' ▾'; color: var(--muted); }
.roster textarea { margin: 8px 0 12px; }
.inline { display: inline; }

/* share page */
.share-main { max-width: 440px; margin: 0 auto; padding: 32px 16px 60px; text-align: center; }
.eyebrow { color: var(--brand); font-weight: 700; letter-spacing: .25em; font-size: .8rem; }
.share-player video { width: 100%; aspect-ratio: 9/16; background: #000; border-radius: 18px; margin: 12px 0 18px; box-shadow: var(--shadow); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; z-index: 100; transition: all .25s; font-weight: 500; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

.empty { text-align: center; padding: 40px 0; }

@media (max-width: 640px) {
  .result-grid { grid-template-columns: 1fr; }
  .player { max-width: 300px; margin: 0 auto; }
  .page-head { align-items: flex-start; }
  .answer-main { flex-wrap: wrap; }
  .answer-actions { width: 100%; justify-content: flex-end; }
  th:nth-child(4), td:nth-child(4) { display: none; }
}
