:root {
  --paper: #f5f1e8;
  --card: #fffdf8;
  --ink: #23262b;
  --muted: #6d6a63;
  --line: #e2dbcd;
  --ai: #2d4b7a;       /* 藍 */
  --ai-soft: #e6ebf3;
  --me: #b8452f;       /* 朱 */
  --me-soft: #f6e4de;
  --ok: #4b7a4f;
  --c-sato: #2d4b7a;
  --c-tanaka: #7a6a4f;
  --c-suzuki: #4f7a73;
  --c-me: #b8452f;
  --shadow: 0 1px 2px rgba(60, 50, 30, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16181c; --card: #1f2227; --ink: #ece8df; --muted: #9c978d; --line: #2f333a;
    --ai: #8eaee0; --ai-soft: #24304a; --me: #e98a73; --me-soft: #3c2722; --ok: #8cc290;
    --c-sato: #8eaee0; --c-tanaka: #c9b58e; --c-suzuki: #8fcabf; --c-me: #e98a73;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #16181c; --card: #1f2227; --ink: #ece8df; --muted: #9c978d; --line: #2f333a;
  --ai: #8eaee0; --ai-soft: #24304a; --me: #e98a73; --me-soft: #3c2722; --ok: #8cc290;
  --c-sato: #8eaee0; --c-tanaka: #c9b58e; --c-suzuki: #8fcabf; --c-me: #e98a73;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.screen {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ブランド */
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 2px 6px; }
.seal { width: 44px; height: 44px; flex: none; }
.seal rect { fill: var(--me); stroke: none; }
.seal text { fill: #fff; stroke: none; font-size: 22px; font-weight: 700; font-family: inherit; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: .04em; }
.sub { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.card h2 { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .08em; }
.card.note { border-left: 4px solid var(--me); }
.card.note p { font-size: 15px; }

/* ボタン：高さ・角丸・太さを全部そろえる */
.btn {
  appearance: none; font: inherit; font-weight: 500;
  height: 52px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, background .2s ease;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--me); border-color: var(--me); color: #fff; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.small { height: 40px; padding: 0 14px; font-size: 14px; }
.btn.round { width: 52px; padding: 0; border-radius: 50%; }
.btn:disabled { opacity: .45; }

/* 種類の切り替え（4つ同じ大きさ） */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button {
  appearance: none; font: inherit; height: 48px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ai); border-color: var(--ai); color: var(--card); font-weight: 700; }
.topic { display: flex; flex-direction: column; gap: 10px; }
.topic p { font-size: 18px; font-weight: 500; line-height: 1.55; padding: 4px 2px; }
.topic .btn { align-self: flex-start; height: 40px; font-size: 14px; }

.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.members li { display: flex; align-items: center; gap: 12px; }
.members .who { font-weight: 700; }
.members .desc { color: var(--muted); font-size: 13px; line-height: 1.5; }
.face {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  color: var(--card); background: var(--c, var(--ai));
}
.hint { color: var(--muted); font-size: 13px; text-align: center; }

.history { list-style: none; margin: 0; padding: 0; }
.history li + li { border-top: 1px solid var(--line); }
.history button {
  appearance: none; font: inherit; color: inherit; background: none; border: 0; width: 100%;
  text-align: left; padding: 10px 2px; display: flex; gap: 10px; align-items: center; cursor: pointer;
}
.history .t { flex: 1; font-size: 14px; line-height: 1.45; }
.history .d { color: var(--muted); font-size: 12px; }
.history .s { font-variant-numeric: tabular-nums; color: var(--ai); font-weight: 700; font-size: 14px; }

/* ディスカッション中 */
#room { min-height: 100dvh; padding-bottom: 0; gap: 10px; }
.roombar { display: flex; align-items: center; gap: 12px; }
.timer { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.timer.low { color: var(--me); }
.phase { flex: 1; color: var(--muted); font-size: 13px; line-height: 1.35; }
.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.avatar { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.avatar .face { width: 44px; height: 44px; font-size: 17px; transition: box-shadow .2s ease, transform .2s ease; }
.avatar.on .face { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--c); transform: scale(1.06); }
.avatar.on { color: var(--ink); font-weight: 700; }
.roomtopic { font-size: 14px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; }

.log { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; }
.log.static { padding: 0; }
.msg { display: flex; gap: 8px; align-items: flex-start; animation: rise .25s ease both; }
.msg .face { width: 30px; height: 30px; font-size: 13px; }
.msg .body { background: var(--card); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 8px 12px; max-width: 82%; }
.msg .name { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.msg .tag { font-size: 10px; border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }
.msg.me { flex-direction: row-reverse; }
.msg.me .body { background: var(--me-soft); border-color: transparent; border-radius: 14px 4px 14px 14px; }
.msg.me .name { justify-content: flex-end; }
.msg.interim .body { opacity: .6; border-style: dashed; }
.msg.sys { justify-content: center; }
.msg.sys .body { background: none; border: 0; color: var(--muted); font-size: 13px; text-align: center; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.dock {
  position: sticky; bottom: 0; margin: 0 -16px; padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--paper) 18%);
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
.status { text-align: center; color: var(--muted); font-size: 14px; min-height: 1.6em; }
.dockrow { display: flex; justify-content: center; align-items: center; gap: 28px; }
.mic {
  appearance: none; width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--me); color: #fff; display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(184, 69, 47, .3); -webkit-tap-highlight-color: transparent;
}
.mic svg { width: 32px; height: 32px; }
.mic .i-stop { display: none; }
.mic.live .i-mic { display: none; }
.mic.live .i-stop { display: block; fill: currentColor; }
.mic.live { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 10px rgba(184, 69, 47, .15); } }
.typebox { display: flex; gap: 8px; }
.typebox input {
  flex: 1; font: inherit; font-size: 16px; height: 40px; border-radius: 12px; padding: 0 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}

/* 採点 */
.resulthead { display: flex; flex-direction: column; gap: 4px; padding: 4px 2px; }
.date { color: var(--muted); font-size: 13px; }
.rtopic { font-size: 15px; }
.share { display: flex; height: 18px; border-radius: 9px; overflow: hidden; background: var(--line); }
.share span { height: 100%; background: var(--c); transition: width .6s ease; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.judge { font-size: 14px; }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.role b { font-size: 15px; }
.role small { font-size: 12px; }
.role.on { border-color: var(--ai); background: var(--ai-soft); color: var(--ink); }
.score { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.score + .score { border-top: 1px solid var(--line); padding-top: 12px; }
.score .row { display: flex; align-items: center; justify-content: space-between; }
.score .lab { font-weight: 700; }
.dots { display: flex; gap: 5px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ai); }
.dots i.f { background: var(--ai); }
.score p { font-size: 14px; color: var(--muted); }
.good { color: var(--muted); font-size: 14px !important; }
.loading { color: var(--muted); }
details summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .08em; }

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