:root {
  --bg: #000;
  --fg: #fff;
  --muted: #c8c8c8;
  --panel: #161616;
  --line: #fff;
  --red: #ff2d2d;
  --green: #3ddc6b;
  --blue: #4da3ff;
  --testing: #ffd23f;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; height: 100%; color: var(--fg); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 24px; }
body { display: flex; flex-direction: column; background: transparent; }
/* A very faint family photo behind everything, for warmth. Text stays on solid panels and stays easy to read. */
body::before { content: ''; position: fixed; inset: 0; background: url(bg.jpg) center / cover no-repeat; opacity: 0.13; z-index: -1; pointer-events: none; }
.hidden { display: none !important; }

button { font: inherit; color: var(--fg); background: var(--panel); border: 3px solid var(--line); border-radius: 18px; padding: 18px 24px; min-height: 72px; cursor: pointer; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; }
button.small { min-height: 56px; font-size: 20px; padding: 10px 16px; }

/* Sign in */
#signin { margin: auto; width: min(560px, 92vw); text-align: center; display: flex; flex-direction: column; gap: 22px; }
#signin h1 { font-size: 44px; margin: 0; }
#signin input { font: inherit; font-size: 30px; padding: 20px; border-radius: 14px; border: 3px solid var(--line); background: #000; color: #fff; text-align: center; }
#signin .primary { background: var(--blue); color: #000; font-weight: 700; font-size: 30px; }
#signin .linkish { background: none; border: none; color: var(--muted); font-size: 18px; min-height: 0; text-decoration: underline; }
#signinMsg { color: #ffb3b3; min-height: 1.4em; }
#signin .uses { color: var(--muted); font-size: 22px; line-height: 1.5; }
#signin form { display: flex; flex-direction: column; gap: 18px; }
#signin #username { font-size: 24px; color: var(--muted); background: #111; border-style: dashed; }

/* App frame */
#app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 3px solid var(--line); font-size: 20px; }
#spaceName { font-weight: 700; }
#spaceName.testing { color: var(--testing); }
#syncStatus { color: var(--muted); text-align: right; }
main { flex: 1; overflow-y: auto; padding: 16px; }
nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px; border-top: 3px solid var(--line); }
nav button { min-height: clamp(64px, 11vh, 92px); font-size: clamp(17px, 2.4vw, 26px); font-weight: 700; padding: 8px; }
nav button.active { background: var(--fg); color: #000; }

/* Talk */
#view-talk { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
#stateBanner { width: 100%; padding: 12px; border-radius: 20px; font-size: clamp(28px, 6vh, 42px); font-weight: 800; border: 4px solid var(--line); }
#stateBanner.off { background: #222; color: var(--fg); }
#stateBanner.on { background: var(--red); color: #fff; border-color: #fff; }
#stateBanner.paused { background: var(--testing); color: #000; }
#storyLine { font-size: clamp(18px, 3.4vh, 26px); color: var(--muted); }
#storyLine strong { color: var(--fg); }
#timer { font-size: clamp(34px, 7vh, 56px); line-height: 1; font-variant-numeric: tabular-nums; font-weight: 700; }
#recBtn { width: clamp(140px, 32vh, 340px); height: clamp(140px, 32vh, 340px); min-height: 0; padding: 0; border-radius: 50%; font-size: clamp(28px, 5vh, 40px); font-weight: 800; background: var(--green); color: #000; border-color: #fff; }
#talkMsg { min-height: 1.2em; }
#recBtn.recording { background: var(--red); color: #fff; }
.row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; width: 100%; }
.row button { flex: 1 1 220px; font-size: 28px; font-weight: 700; }

/* Lists */
h2 { font-size: 34px; margin: 4px 0 14px; }
.card { background: var(--panel); border: 3px solid #555; border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.card .title { font-size: 28px; font-weight: 700; }
.card .meta { color: var(--muted); font-size: 20px; margin: 4px 0 10px; }
.card .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.card audio { width: 100%; margin-top: 12px; height: 56px; }
.empty { color: var(--muted); font-size: 26px; padding: 30px 0; text-align: center; }
.filter { background: #222; border: 2px solid var(--blue); border-radius: 14px; padding: 12px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 22px; }
.note { color: var(--muted); font-size: 20px; margin: 10px 0; }
.tiny { color: #aaa; font-size: 15px; margin: 0 0 8px; }
#notice { width: 100%; background: var(--testing); color: #000; border-radius: 16px; padding: 14px 16px; font-size: 22px; font-weight: 700; display: flex; gap: 12px; align-items: center; justify-content: space-between; text-align: left; }
#notice button { background: #000; color: #fff; border-color: #000; min-height: 52px; font-size: 20px; padding: 8px 16px; }
.dialog textarea { font: inherit; font-size: 26px; line-height: 1.4; padding: 14px; border-radius: 14px; border: 3px solid var(--line); background: #000; color: #fff; width: 100%; resize: vertical; }
.seg.latest { cursor: default; white-space: pre-wrap; }
.hdrLeft { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#bookBtn { min-height: 36px; font-size: 14px; padding: 2px 12px; border-width: 2px; border-radius: 999px; border-color: var(--blue); }
header { flex-wrap: wrap; }
.hdrRight { display: flex; align-items: center; gap: 12px; }
#modeBtn { min-height: 36px; font-size: 14px; padding: 2px 12px; border-width: 2px; border-radius: 999px; }
#strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 3px solid var(--line); background: #0d0d0d; }
#strip .stripText { min-width: 0; }
#stripTopic { font-size: 24px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stripSaved { font-size: 18px; color: var(--green); }
#fixBtn { border-color: var(--blue); }
.liveBox { width: 100%; background: #101010; border: 2px solid #444; border-radius: 16px; padding: 12px 14px; margin: 4px 0 8px; text-align: left; }
.liveHead { font-size: 15px; color: var(--muted); margin-bottom: 4px; }
.liveText { font-size: 26px; line-height: 1.4; min-height: 2.8em; }
button.add { background: var(--green); color: #000; border-color: #fff; font-weight: 800; }
button.cancel { background: #000; color: #ff9b9b; border-color: #ff6b6b; }
.recList { max-height: 42vh; overflow-y: auto; border: 2px solid #333; border-radius: 14px; padding: 8px; margin-top: 8px; }
.recRow { padding: 12px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; }
.recRow + .recRow { border-top: 1px solid #333; }
.recRow:active { background: #1d1d1d; border-color: var(--blue); }
.recRow .recHead { font-size: 20px; color: var(--muted); }
.recRow .recSnip { font-size: 24px; line-height: 1.35; margin-top: 4px; }
#storyPage { position: fixed; inset: 0; background: #000; z-index: 5; overflow-y: auto; padding: 14px 16px 40px; }
#storyPage .pageHead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
#storyPage .pageTitle { font-size: 32px; font-weight: 800; flex: 1 1 260px; }
#storyPage .pageBtns { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
body.simple nav { display: none; }
#simpleArea { width: 100%; text-align: left; }
#simpleArea .topicHead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 12px; }
#simpleArea .topicTitle { font-size: 32px; font-weight: 800; }
#simpleArea .pick { display: block; width: 100%; margin-bottom: 12px; }
.sent { font-size: 28px; line-height: 1.45; padding: 10px 12px; margin: 4px 0; border-radius: 12px; border: 2px solid transparent; cursor: pointer; }
.sent:active { background: #1d1d1d; border-color: var(--blue); }
.mark { margin-left: 10px; font-size: 24px; background: #222; border: 2px solid #555; border-radius: 12px; padding: 2px 10px; cursor: pointer; white-space: nowrap; }
.undoBar { background: var(--testing); color: #000; border-radius: 14px; padding: 12px 16px; font-size: 22px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.undoBar button { background: #000; color: #fff; border-color: #000; min-height: 52px; }
.words { margin-top: 8px; }
.seg { font-size: 22px; line-height: 1.35; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.seg:active { background: #222; }
.seg .ts { color: #8ab4ff; font-size: 16px; }
.footer { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap; }

button.primary { background: var(--blue); color: #000; font-weight: 700; }
.badge { display: inline-block; background: var(--testing); color: #000; font-weight: 800; font-size: 18px; padding: 4px 12px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
.sub { margin: 10px 0 0 12px; padding-left: 12px; border-left: 4px solid #555; }
.sub .item { padding: 8px 0; border-bottom: 1px solid #333; }
.sub .item:last-child { border-bottom: none; }
.sub .item .actions { margin-top: 6px; }
.recentHead { font-size: 22px; color: var(--muted); margin: 14px 0 8px; text-align: left; width: 100%; }
#recent { width: 100%; text-align: left; }

/* Dialog */
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.dialog { width: min(720px, 94vw); max-height: 92vh; overflow-y: auto; background: #111; border: 4px solid var(--line); border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.dialog h2 { margin: 0; font-size: 34px; }
.dialog .row button { flex: 1 1 180px; }
.micRow { display: flex; gap: 10px; }
.micRow input { flex: 1; min-width: 0; font: inherit; font-size: 30px; padding: 16px; border-radius: 14px; border: 3px solid var(--line); background: #000; color: #fff; }
.micRow .mic { min-height: 0; width: 84px; font-size: 38px; padding: 0; border-radius: 14px; }
.micRow .mic.live { background: var(--red); border-color: #fff; }
.pick { text-align: left; font-size: 26px; }
