/* AI 101 apps (phone playground + presenter). Light, warm paper, one accent. No inline styles anywhere. */
@font-face { font-family: "Boska"; src: url("/fonts/boska-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Boska"; src: url("/fonts/boska-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Boska"; src: url("/fonts/boska-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --ink: #1f1b16;
  --muted: #554e45;
  --line: #cfc5b3;
  --accent: #2c5a43;
  --accent-ink: #ffffff;
  --accent-soft: #dfeadf;
  --warn: #8a2f12;
  --warn-soft: #fbe6dc;
  --ok: #1f6b3a;
  --face: "Boska", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 1.2rem; line-height: 1.5;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-x: clip; /* not hidden: on iOS that stops focused inputs scrolling above the keyboard */
}
.offscreen { position: absolute; left: -9999px; top: 0; }
h1, h2, h3 { font-family: var(--face); font-weight: 500; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
img, video { max-width: 100%; display: block; }
:focus-visible { outline: 4px solid #1b5fb0; outline-offset: 2px; }

#app { max-width: 560px; margin: 0 auto; }
.screen > * + * { margin-top: 20px; }
.lead { color: var(--muted); }
.note { color: var(--muted); font-size: 1.05rem; }

/* controls */
[hidden] { display: none !important; } /* .btn sets display:flex, which would beat the hidden attribute */
.btn {
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 100%; min-height: 60px; padding: 12px 20px;
  font: inherit; font-weight: 600; font-size: 1.2rem; line-height: 1.2;
  border-radius: var(--r); border: 2px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-quiet { background: transparent; color: var(--accent); }
.btn-warn { background: transparent; color: var(--warn); border-color: var(--warn); }
.btn-small { width: auto; min-height: 56px; padding: 8px 18px; }
.btn-row { display: grid; gap: 12px; }

label, .label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=search], textarea {
  display: block; width: 100%; min-height: 60px; padding: 12px 14px;
  font: inherit; font-size: 1.2rem; color: var(--ink);
  background: var(--surface); border: 2px solid #8b8070; border-radius: var(--r);
}
textarea { min-height: 130px; resize: vertical; }
input.big-code { font-size: 2rem; letter-spacing: .12em; text-transform: uppercase; text-align: center; font-weight: 600; }
.field + .field { margin-top: 16px; }

.status { color: var(--muted); font-weight: 500; }
.status.live::before { content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .5em; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.error { color: var(--warn); background: var(--warn-soft); border-left: 6px solid var(--warn); padding: 12px 14px; border-radius: 8px; font-weight: 500; }
.banner { background: var(--accent-soft); border-left: 6px solid var(--accent); padding: 10px 14px; border-radius: 8px; font-size: 1.05rem; }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); font-weight: 600; }

/* top of each screen */
.topbar { display: flex; flex-direction: column; gap: 12px; }
.topbar h1 { margin: 0; }
.hello { font-family: var(--face); font-size: 2.2rem; margin: 0; }

/* home tiles */
.tiles { display: grid; gap: 14px; }
.tile {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--ink);
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r);
  padding: 16px 18px; min-height: 84px; cursor: pointer; touch-action: manipulation;
}
.tile:active { background: var(--accent-soft); }
.tile .t-name { display: block; font-family: var(--face); font-weight: 500; font-size: 1.6rem; line-height: 1.15; }
.tile .t-sub { display: block; color: var(--muted); font-size: 1.05rem; margin-top: 2px; }
.tile .t-left { display: inline-block; margin-top: 6px; font-weight: 600; color: var(--accent); font-size: 1.05rem; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 56px; padding: 8px 18px; font: inherit; font-size: 1.15rem; color: var(--ink);
  background: var(--surface); border: 2px solid #8b8070; border-radius: 999px; cursor: pointer; touch-action: manipulation;
}
.chip[aria-checked=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.group + .group { margin-top: 22px; }
.group .other { margin-top: 10px; }

/* text answers */
.thread > * + * { margin-top: 14px; }
.msg { padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 2px solid var(--line); }
.msg.you { background: var(--accent-soft); border-color: transparent; }
.msg .who { font-size: 1rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.msg .body p { margin: 0 0 .8em; font-size: 1.3rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .body p:last-child { margin-bottom: 0; }
.msg.ai { border-color: var(--ink); }

/* pictures */
.pic { background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.pic img { width: 100%; height: auto; background: var(--line); }
.pic figcaption { padding: 12px 14px; font-weight: 500; }
.pic-wrap { margin: 0; }
.mine { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mine .pic figcaption { font-size: 1rem; padding: 8px 10px; }
.mine-item { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mine-item .btn { min-height: 56px; padding: 8px 10px; font-size: 1rem; }

.video-box video { width: 100%; height: auto; border-radius: var(--r); background: #000; }
.meter { height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .5s; }

/* wall */
.wall { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.w-item { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.w-item img { width: 100%; height: auto; background: var(--line); }
.w-item .w-cap { padding: 8px 10px 4px; font-size: 1rem; line-height: 1.3; flex: 1; }
.w-item .w-by { padding: 0 10px 8px; font-size: 1rem; color: var(--muted); }
.like { margin: 0 10px 10px; width: calc(100% - 20px); min-height: 56px; font-size: 1.1rem; }
.like[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); }

/* story */
.story-title { font-family: var(--face); font-size: 1.8rem; margin: 0; }
.lines > * + * { margin-top: 12px; }
.line { font-family: var(--face); font-size: 1.45rem; line-height: 1.4; margin: 0; overflow-wrap: anywhere; }
.line .by { display: block; font-family: var(--sans); font-size: 1rem; color: var(--muted); }
.line.ai .by { color: var(--accent); font-weight: 600; }
.counter { text-align: right; color: var(--muted); font-size: 1.05rem; }

/* quiz */
.bubble { background: #e8e4da; border: 2px solid var(--line); border-radius: 22px 22px 22px 6px; padding: 16px 18px; }
.bubble .from { font-size: 1.05rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.bubble .text { font-size: 1.3rem; line-height: 1.5; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice .btn { min-height: 96px; font-size: 1.8rem; font-family: var(--face); background: var(--surface); color: var(--ink); border-color: var(--ink); }
.choice .btn[aria-pressed=true] { background: var(--ink); color: #fff; }
.verdict { font-family: var(--face); font-size: 2rem; margin: 0; }
.verdict.ok { color: var(--ok); }
.verdict.no { color: var(--warn); }
.bars > * + * { margin-top: 10px; }
.bar { position: relative; background: var(--line); border-radius: 10px; height: 52px; overflow: hidden; }
.bar > span.fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }
.bar.scam > span.fill { background: var(--warn); }
.bar > span.txt { position: absolute; left: 14px; top: 0; bottom: 0; display: flex; align-items: center; font-weight: 700; color: #fff; text-shadow: 0 0 3px rgba(0,0,0,.6); }
ol.top { margin: 0; padding-left: 1.6em; }
ol.top li { padding: 4px 0; }
ol.top .sc { float: right; font-weight: 700; }

/* ---------- presenter ---------- */
body.present { max-width: none; font-size: 1.2rem; }
body.present #app, .p-wrap { max-width: 1920px; margin: 0 auto; }
.p-login { max-width: 420px; margin: 12vh auto 0; }
.p-login > * + * { margin-top: 16px; }
.p-band { display: grid; grid-template-columns: auto 1fr minmax(380px, 520px); gap: 28px; align-items: center; padding-bottom: 18px; border-bottom: 2px solid var(--ink); }
.p-qr-small { width: 190px; }
.qr { background: #fff; padding: 8px; border: 2px solid var(--ink); border-radius: 10px; line-height: 0; }
.qr svg { width: 100%; height: auto; display: block; }
.p-code-label { font-size: 1.2rem; font-weight: 600; color: var(--muted); }
.p-code { font-family: var(--face); font-weight: 500; font-size: clamp(3.5rem, 7vw, 7.5rem); line-height: 1; letter-spacing: .06em; margin: 0; overflow-wrap: anywhere; }
.p-url { font-size: 1.6rem; font-weight: 600; margin: 6px 0 0; }
.p-people { font-size: 1.4rem; color: var(--muted); margin: 4px 0 0; }
.p-ctl > * + * { margin-top: 10px; }
.p-switches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 14px; font: inherit; font-size: 1.05rem; font-weight: 600; color: var(--ink); background: var(--surface); border: 2px solid #8b8070; border-radius: 999px; cursor: pointer; }
.sw .st { font-weight: 700; color: var(--muted); }
.sw[aria-checked=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.sw[aria-checked=true] .st { color: #fff; }
.p-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.p-row .btn { width: auto; min-height: 48px; padding: 6px 16px; font-size: 1.05rem; }
.p-meta { font-size: 1.1rem; margin: 0; }
.p-meta strong { font-size: 1.5rem; }
.tabs { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.tab { flex: 1 1 140px; min-height: 64px; font: inherit; font-family: var(--face); font-size: 1.8rem; color: var(--ink); background: transparent; border: 2px solid var(--ink); border-radius: var(--r); cursor: pointer; }
.tab[aria-selected=true] { background: var(--ink); color: #fff; }
.p-panel[hidden] { display: none; }
.p-join { display: grid; grid-template-columns: auto 1fr; gap: 6vw; align-items: center; justify-content: center; min-height: 60vh; }
.p-join .qr { width: min(58vh, 44vw); }
.p-join .p-code { font-size: clamp(4rem, 12vw, 14rem); }
.p-join .p-url { font-size: clamp(1.6rem, 2.6vw, 3rem); }
.p-wall { column-width: 300px; column-gap: 16px; }
.pw-item { break-inside: avoid; margin: 0 0 16px; background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; position: relative; }
.pw-item img { width: 100%; height: auto; }
.pw-item .pw-meta { padding: 10px 14px; display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.pw-item .pw-cap { font-size: 1.3rem; font-weight: 500; }
.pw-item .pw-by { color: var(--muted); font-size: 1.1rem; }
.pw-item .pw-votes { font-family: var(--face); font-size: 1.8rem; white-space: nowrap; }
.pw-item .pw-hide { position: absolute; top: 8px; right: 8px; width: auto; min-height: 44px; padding: 4px 14px; font-size: 1rem; background: rgba(255,253,248,.92); color: var(--ink); border-color: var(--ink); }
.fresh { animation: fadein .9s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.p-story .line { font-size: clamp(1.8rem, 2.8vw, 3rem); }
.p-story .story-title { font-size: clamp(2.2rem, 3.6vw, 4rem); margin-bottom: 14px; }
.p-story .lines { max-width: 1200px; }
.p-story .tools { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.p-story .tools input { max-width: 420px; }
.p-story .tools .btn { width: auto; }
.p-quiz .bubble { max-width: 1100px; padding: 28px 32px; }
.p-quiz .bubble .text { font-size: clamp(1.8rem, 2.8vw, 3rem); }
.p-quiz .bubble .from { font-size: 1.5rem; }
.p-quiz .tools { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.p-quiz .tools .btn { width: auto; min-width: 160px; }
.p-quiz .big { font-family: var(--face); font-size: 2.2rem; margin: 16px 0 0; }
.p-quiz .bar { height: 76px; max-width: 1000px; }
.p-quiz .bar > span.txt { font-size: 1.8rem; left: 20px; }
.p-quiz .bars { margin-top: 18px; }
.p-quiz ol.top { font-size: 1.7rem; max-width: 600px; }

@media (max-width: 1100px) {
  .p-band { grid-template-columns: auto 1fr; }
  .p-ctl { grid-column: 1 / -1; }
  .p-join { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .p-join .qr { width: min(70vw, 60vh); }
}
@media (prefers-reduced-motion: reduce) {
  .fresh { animation: none; }
  .status.live::before { animation: none; }
  .meter > span { transition: none; }
}
