[hidden] { display: none !important; }
:root {
  --ink: #1d2b36; --paper: #f4f1ea; --card: #fffdf8; --line: #ddd6c8; --muted: #6b7680;
  --accent: #c9821f; --accent-soft: #f6e4c3; --ok: #3f8f7f; --bad: #b5473a;
  --r: 12px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 var(--font); }
body { min-height: 100dvh; display: flex; flex-direction: column; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: .6em 1em; background: var(--ink); color: #fff; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.link { background: none; color: var(--accent); padding: .2em .3em; text-decoration: underline; }
button:disabled { opacity: .45; cursor: default; }
button.icon { background: none; color: #fff; font-size: 1.5rem; padding: .1em .45em; line-height: 1; }
input, textarea, select { border: 1px solid var(--line); border-radius: 10px; padding: .6em .7em; background: #fff; width: 100%; }
textarea { resize: none; }

#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .4rem;
  background: var(--ink); color: #fff; padding: calc(.55rem + env(safe-area-inset-top)) .7rem .55rem; }
#top h1 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 820px; margin: 0 auto; }
.pad { padding: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.grow { flex: 1; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .3rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem 1rem; margin: .6rem 0; }
.game { display: flex; gap: .8rem; align-items: center; cursor: pointer; }
.game .t { font-weight: 650; }
.badge { display: inline-block; font-size: .75rem; padding: .1em .55em; border-radius: 999px; background: var(--accent-soft); }
.badge.failed { background: #f3d6d1; color: var(--bad); }
.badge.ready { background: #d6ebe5; color: var(--ok); }
.spin { display: inline-block; width: .9em; height: .9em; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: s 1s linear infinite; vertical-align: -2px; }
@keyframes s { to { transform: rotate(360deg); } }

.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login input { text-align: center; letter-spacing: .12em; text-transform: uppercase; margin: 1rem 0; }

.tabs { display: flex; position: sticky; top: 3.1rem; z-index: 4; background: var(--paper); border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; color: var(--muted); border-radius: 0; border-bottom: 3px solid transparent; padding: .7em .3em; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 650; }

.chat { flex: 1; padding: .8rem 1rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.msg { max-width: 88%; padding: .6rem .85rem; border-radius: 14px; white-space: normal; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg p { margin: .25em 0; }
.msg ul { margin: .25em 0; padding-left: 1.2em; }
.msg .tools { margin-top: .35rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.chip { display: inline-block; background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: .05em .6em;
  font-size: .82rem; margin: 0 .1em; border: 0; cursor: pointer; }
.say { background: none; color: var(--muted); padding: 0 .3em; font-size: .9rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.suggest { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: .8rem; }
.suggest button { background: var(--card); color: var(--ink); border: 1px solid var(--line); font-size: .9rem; }

.composer { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--line);
  padding: .55rem .7rem calc(.55rem + env(safe-area-inset-bottom)); display: flex; gap: .4rem; align-items: flex-end; }
.composer textarea { min-height: 2.6em; max-height: 8em; }
.composer button { flex: none; height: 2.6em; min-width: 2.6em; padding: 0 .7em; }
.mic.rec { background: var(--bad); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.photo-prev { display: flex; gap: .5rem; align-items: center; padding: .4rem .7rem 0; }
.photo-prev img { height: 54px; border-radius: 8px; }

.learn ol, .learn ul { padding-left: 1.3em; }
.learn li { margin: .35em 0; }
.when { font-size: .78rem; background: #e4ecf2; padding: .05em .5em; border-radius: 999px; margin-left: .3em; }
.check li { list-style: none; margin-left: -1.3em; }
.check input { width: auto; margin-right: .5em; transform: scale(1.2); }
.check li.done span { color: var(--muted); text-decoration: line-through; }

.viewer { position: fixed; inset: 0; z-index: 20; background: #111; display: flex; flex-direction: column; }
.viewer .bar { display: flex; align-items: center; gap: .5rem; padding: calc(.5rem + env(safe-area-inset-top)) .7rem .5rem; color: #fff; }
.viewer .bar button { background: #333; }
.viewer .img { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start; touch-action: pan-x pan-y pinch-zoom; }
.viewer img { max-width: 100%; height: auto; background: #fff; }
.viewer img.zoom { max-width: none; width: 180%; }

#sheet { position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; }
#sheet .panel { background: var(--card); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom)); max-height: 90dvh; overflow: auto; }
#sheet label { display: block; margin: .8rem 0 .3rem; font-weight: 600; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border-radius: 0; background: #fff; color: var(--ink); }
.seg button.on { background: var(--ink); color: #fff; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: .3rem; }
.meter i { display: block; height: 100%; background: var(--ok); }
.meter i.hi { background: var(--bad); }

#toast { position: fixed; left: 50%; bottom: calc(5rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; max-width: 90vw; }
.note { display: flex; gap: .5rem; align-items: flex-start; }
.note .x { background: none; color: var(--muted); padding: 0 .3em; }
.fab { margin: 1rem 0; width: 100%; }
@media (min-width: 700px) { .msg { max-width: 75%; } }

.s-top { align-items: flex-start; } .s-center { align-self: center; } .s-center-t { text-align: center; } .s-bad { color: var(--bad); }
.s-wrap { flex-wrap: wrap; margin-top: .5rem; } .s-col { flex: 1; display: flex; flex-direction: column; } .s-b { font-weight: 600; }
.s-mt { margin-top: .8rem; } .s-mt0 { margin-top: 0; } .s-mt2 { margin-top: 1.2rem; } .s-full { width: 100%; } .s-auto { width: auto; }

.admin .card .row + .small { margin-top: .2rem; }
.admin label.small { display: block; margin: .6rem 0 .25rem; }
.person.is-off b { color: var(--muted); text-decoration: line-through; }
.person .acts { gap: .2rem; margin-top: .3rem; }
.codebox { border-color: var(--accent); background: var(--accent-soft); }
.codebox .code { font-size: 1.3rem; letter-spacing: .12em; font-family: ui-monospace, Menlo, monospace; }
.logrow { padding: .2rem 0; border-bottom: 1px solid var(--line); }
.logrow:last-child { border-bottom: 0; }
