:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e6ef;
  --text: #1c2333;
  --muted: #6b7691;
  --primary: #4d6cf0;
  --primary-dark: #3852c9;
  --accent: #f0884d;
  --ok: #2ea36b;
  --warn: #c78600;
  --error: #d24a4a;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.05);
  --moderator: #6b51c5;
  --pro: #2e8b57;
  --con: #c1493b;
  --neutral: #8a7e2f;
  --perspective: #a06028;
  --user: #4d6cf0;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.small { font-size: 0.85rem; }
.error { color: var(--error); margin-top: 8px; min-height: 1.2em; }
.req { color: var(--error); }

/* Header */
#app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-btn {
  background: none;
  border: none;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--primary);
  cursor: pointer;
}
.header-nav { display: flex; align-items: center; gap: 8px; }
.nav-tab { font-size: 0.9rem; padding: 6px 12px; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.benchmark-problems { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.benchmark-problem {
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}
.benchmark-problem .p-motion { font-weight: 600; }
.benchmark-problem .p-meta { color: var(--muted); font-size: 0.85rem; }
.benchmark-problem .remove { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; cursor: pointer; color: var(--muted); }
.benchmark-problem .remove:hover { color: var(--error); border-color: var(--error); }

.run-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.run-card:hover { border-color: var(--primary); }
.run-card .v-tag { font-weight: 700; color: var(--primary-dark); }
.run-summary {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.run-summary .metric { text-align: center; }
.run-summary .metric .num { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }
.run-summary .metric .lbl { color: var(--muted); font-size: 0.85rem; }
.run-summary .bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 6px; background: #f0f1f8; }
.run-summary .bar .y { background: var(--pro); }
.run-summary .bar .n { background: var(--con); }
.run-summary .bar .h { background: var(--neutral); }
.run-summary .bar .nc { background: var(--muted); }
#welcome { color: var(--muted); font-size: 0.95rem; }

/* Container */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px;
}
.container-wide {
  max-width: 1240px;
}
.view { padding-bottom: 40px; }

/* Hero */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.hero h2 { margin: 0; }

/* Auth overlay */
.overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #5870e8, #6b51c5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
}
.brand { margin: 0 0 4px; font-size: 2rem; color: var(--primary); text-align: center; }
.brand-sub { margin: 0 0 24px; color: var(--muted); font-size: 0.9rem; text-align: center; }
.tab-row {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.95rem;
}
.tab.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.auth-form input { font: inherit; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }

/* Buttons */
.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  transition: background .15s ease;
}
.btn:hover { background: #f1f3fa; }
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-danger { background: var(--error); color: white; border-color: var(--error); }

/* Forms */
.form-grid { display: flex; flex-direction: column; gap: 16px; }
fieldset, .adv-fieldset {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.adv-fieldset { padding: 0; }
.adv-fieldset > summary {
  cursor: pointer;
  padding: 12px 20px;
  color: var(--primary-dark);
  font-weight: 600;
  user-select: none;
}
.adv-inner { padding: 0 20px 12px; }
legend { font-weight: 600; padding: 0 6px; color: var(--primary-dark); }
.form-grid label {
  display: flex; flex-direction: column;
  gap: 4px; margin-bottom: 12px;
  font-size: 0.9rem; color: var(--muted);
}
.form-grid input, .form-grid textarea, .form-grid select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
}
.form-grid textarea { resize: vertical; font-family: inherit; }
.form-grid small { color: var(--muted); font-size: 0.8rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row label { flex: 1; min-width: 120px; }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; }
.checkbox-row input { width: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
}
.chip input { margin: 0; }
.chip:has(input:checked) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.form-actions { display: flex; justify-content: flex-end; gap: 12px; }

/* Debaters editor */
.debaters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.debater-row {
  display: grid;
  grid-template-columns: auto 1fr 2fr auto auto;
  gap: 8px;
  align-items: start;
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.debater-row .d-model { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: white; font: inherit; }
.debater-row .role-tag {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
  color: white;
  align-self: start;
}
.debater-row.role-pro .role-tag { background: var(--pro); }
.debater-row.role-con .role-tag { background: var(--con); }
.debater-row.role-neutral .role-tag { background: var(--neutral); }
.debater-row.role-frame_critic .role-tag { background: var(--moderator); }
.utterance.role-frame_critic .avatar { background: var(--moderator); }
.debater-row.role-judge .role-tag { background: #5870e8; }
.utterance.role-judge { border-color: #5870e8; background: linear-gradient(135deg, #f3f6ff, #fff); }
.utterance.role-judge .avatar { background: #5870e8; }
.utterance.role-judge .label::before { content: "🧑‍⚖️ "; }
.debater-row input,
.debater-row textarea { width: 100%; padding: 6px 8px; font: inherit; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
.debater-row textarea { resize: vertical; }
.debater-row .remove {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
}
.debater-row .remove:hover { color: var(--error); border-color: var(--error); }

/* Card list */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.debate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.debate-card:hover { border-color: var(--primary); }
.debate-card .card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.debate-card .title { font-weight: 600; color: var(--text); flex: 1; }
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
}
.btn-icon:hover { color: var(--error); border-color: var(--error); background: rgba(210,74,74,.05); }
.debate-card .meta { color: var(--muted); font-size: 0.85rem; display: flex; gap: 10px; flex-wrap: wrap; }
.debate-card .snippet { color: var(--muted); font-size: 0.9rem; }

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.status-pending { background: #fff0d6; color: var(--warn); }
.status-running { background: #d8e1ff; color: var(--primary-dark); }
.status-awaiting_input { background: #ffe9c2; color: var(--accent); }
.status-completed { background: #d9f3e3; color: var(--ok); }
.status-failed { background: #fde2e0; color: var(--error); }
.status-aborted { background: #ede9ff; color: var(--moderator); }

/* Debate live view layout */
.debate-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.header-left { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.header-controls {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.btn-warn {
  background: var(--accent); color: white; border-color: var(--accent);
}
.btn-warn:hover { background: #d9743f; }
.status-paused { background: #fde3c2; color: var(--accent); }
.context-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-bottom: 16px;
}
.context-box summary { cursor: pointer; color: var(--muted); }
.context-box pre {
  white-space: pre-wrap;
  font-family: inherit;
  color: var(--text);
  margin-top: 10px;
  font-size: 0.9rem;
}

.debate-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .debate-layout { grid-template-columns: 1fr; }
  .debate-side { order: -1; position: static !important; max-height: none !important; }
}

.debate-side {
  display: flex; flex-direction: column; gap: 12px;
  position: sticky; top: 70px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding-right: 4px;
  /* スリムなスクロールバー */
  scrollbar-width: thin;
}
.debate-side::-webkit-scrollbar { width: 6px; }
.debate-side::-webkit-scrollbar-thumb { background: #c8cee0; border-radius: 3px; }
.debate-main { min-width: 0; }
.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.side-card h3 { margin: 0 0 10px; font-size: 1rem; color: var(--primary-dark); }
.side-card textarea {
  width: 100%;
  font: inherit;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}
.side-card hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Dominance */
.dominance { display: flex; flex-direction: column; gap: 8px; }
.dom-row {
  display: grid;
  grid-template-columns: 50px 1fr 48px;
  gap: 8px;
  align-items: center;
}
.dom-label { font-weight: 600; font-size: 0.85rem; }
.dom-label.dom-pro { color: var(--pro); }
.dom-label.dom-con { color: var(--con); }
.dom-bar {
  height: 14px;
  background: #f0f1f8;
  border-radius: 8px;
  overflow: hidden;
}
.dom-fill {
  height: 100%;
  width: 0%;
  transition: width .6s ease;
}
.dom-pro-fill { background: linear-gradient(90deg, #5ec692, var(--pro)); }
.dom-con-fill { background: linear-gradient(90deg, #d97b6d, var(--con)); }
.dom-pct { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.9rem; }

/* Key points list */
.key-points { display: flex; flex-direction: column; gap: 8px; }
.kp-item {
  border-left: 3px solid var(--border);
  padding: 6px 10px;
  background: #f8faff;
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
}
.kp-item.side-pro { border-left-color: var(--pro); background: rgba(46,139,87,.07); }
.kp-item.side-con { border-left-color: var(--con); background: rgba(193,73,59,.07); }
.kp-item.side-neutral { border-left-color: var(--neutral); background: rgba(138,126,47,.08); }
.kp-item.side-shared { border-left-color: var(--moderator); background: rgba(107,81,197,.07); }
.kp-item .side-tag {
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 6px;
}
.kp-item.side-pro .side-tag { color: var(--pro); }
.kp-item.side-con .side-tag { color: var(--con); }
.kp-item.side-neutral .side-tag { color: var(--neutral); }
.kp-item.side-shared .side-tag { color: var(--moderator); }
.kp-item .kp-head { font-weight: 600; color: var(--text); display: block; margin: 2px 0 4px; }
.kp-item .kp-detail { color: var(--text); font-size: 0.85rem; line-height: 1.5; }
.kp-item .kp-meta { color: var(--muted); font-size: 0.75rem; margin-top: 4px; }

/* ============================================================
   Vote tally & related
   ============================================================ */
.tally { display: flex; flex-direction: column; gap: 8px; }
.tally-bar {
  height: 14px;
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f1f8;
}
.tally-bar .seg-yes { background: linear-gradient(90deg, #5ec692, var(--pro)); }
.tally-bar .seg-no { background: linear-gradient(90deg, #d97b6d, var(--con)); }
.tally-bar .seg-hold { background: linear-gradient(90deg, #d0c876, var(--neutral)); }
.tally-counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  font-size: 0.85rem;
}
.tally-counts > div {
  border-radius: 6px;
  padding: 4px 6px;
  text-align: center;
}
.tally-counts .c-yes { background: rgba(46,139,87,.12); color: var(--pro); }
.tally-counts .c-no { background: rgba(193,73,59,.12); color: var(--con); }
.tally-counts .c-hold { background: rgba(138,126,47,.15); color: var(--neutral); }
.tally-counts .num { font-weight: 700; font-size: 1.05rem; }
.tally-voters { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; max-height: 220px; overflow-y: auto; padding-right: 4px; }
.tally-voter {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  align-items: center;
}
.tally-voter.v-yes { background: rgba(46,139,87,.08); }
.tally-voter.v-no { background: rgba(193,73,59,.08); }
.tally-voter.v-hold { background: rgba(138,126,47,.10); }
.tally-voter .v-tag { font-weight: 600; }
.tally-voter .v-conf { color: var(--muted); }

#echo-warning-card {
  background: #fff8e6;
  border-color: #f0c060;
}
#echo-warning-card h3 { color: #a06c00; }

#hold-lock-card {
  background: #fff5f3;
  border: 2px solid var(--con);
}
#hold-lock-card h3 { color: var(--con); }
.hold-item {
  background: white;
  border: 1px solid #e2c4c0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
}
.hold-item.resolved { background: #f0f9f0; border-color: #b8d8b8; opacity: 0.7; }
.hold-item .h-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; color: var(--text);
  margin-bottom: 6px;
}
.hold-item .h-reasons {
  font-size: 0.85rem; color: var(--text);
  margin: 6px 0; padding-left: 18px;
}
.hold-item .h-reasons li { margin-bottom: 2px; }
.hold-item .h-actions {
  display: flex; gap: 6px; margin-top: 8px;
  flex-wrap: wrap;
}
.hold-item textarea {
  width: 100%; padding: 6px; font: inherit; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: 6px;
  resize: vertical; min-height: 50px;
  margin-top: 6px;
}
.hold-item .btn-resolve { background: var(--ok); color: white; border-color: var(--ok); font-size: 0.85rem; padding: 6px 12px; }
.hold-item .btn-override { background: var(--warn); color: white; border-color: var(--warn); font-size: 0.85rem; padding: 6px 12px; }
.hold-item .resolution-badge {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  font-size: 0.75rem; font-weight: 600;
}
.hold-item .resolution-badge.resolved { background: rgba(46,163,107,.15); color: var(--ok); }
.hold-item .resolution-badge.override { background: rgba(199,134,0,.15); color: var(--warn); }

.diversity-hint {
  background: #eef5ff;
  border: 1px solid #b9d2f5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 0.9rem;
  color: #2a4a82;
}

.weight-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.preset-btn {
  background: white;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
  color: var(--text);
  font: inherit;
  transition: all .15s ease;
}
.preset-btn:hover { border-color: var(--primary); }
.preset-btn.active {
  border-color: var(--primary);
  background: rgba(77,108,240,.06);
}
.preset-btn small { color: var(--muted); font-size: 0.75rem; line-height: 1.4; display: block; margin-top: 4px; }
@media (max-width: 600px) {
  .weight-presets { grid-template-columns: 1fr; }
}

/* Per-utterance vote chip */
.vote-chip {
  display: inline-flex;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: auto;
}
.vote-chip.v-yes { background: rgba(46,139,87,.15); color: var(--pro); }
.vote-chip.v-no { background: rgba(193,73,59,.15); color: var(--con); }
.vote-chip.v-hold { background: rgba(138,126,47,.18); color: var(--neutral); }

/* Conclusion - tally section */
.conclusion .tally-section {
  background: rgba(77,108,240,.05);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.conclusion .tally-section h4 { margin: 0 0 8px; color: var(--primary-dark); }

/* ============================================================
   モバイル (≤ 600px) 最適化
   ============================================================ */
@media (max-width: 600px) {
  /* コンテナ余白を詰める */
  .container, .container-wide { padding: 14px 12px; }
  .header-inner { padding: 10px 12px; }
  .brand-btn { font-size: 1.1rem; }
  #welcome { display: none; } /* スペース確保のため非表示 */
  .header-actions { gap: 8px; }

  /* タッチターゲット確保 */
  .btn { min-height: 40px; padding: 10px 14px; }
  .btn-icon { min-height: 36px; min-width: 36px; }

  /* 議論ヘッダーは縦並び */
  .debate-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .header-left { justify-content: space-between; }
  .header-controls { width: 100%; }
  .header-controls .btn { flex: 1 1 calc(50% - 4px); font-size: 0.82rem; padding: 9px 8px; min-width: 0; }

  /* お題タイトル */
  #debate-motion { font-size: 1.2rem; margin: 6px 0; line-height: 1.4; }
  h2 { font-size: 1.3rem; }

  /* フォーム余白 */
  fieldset, .adv-fieldset { padding: 12px 14px; }
  .adv-fieldset > summary { padding: 12px 14px; }
  .adv-inner { padding: 0 14px 10px; }
  legend { font-size: 0.95rem; }
  .form-grid .row { flex-direction: column; gap: 8px; }
  .form-grid .row label { min-width: 0; }
  .form-actions { flex-direction: column-reverse; gap: 8px; }
  .form-actions .btn { width: 100%; }

  /* 議論者の行: モバイルでは縦に並ぶ */
  .debater-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "tag remove"
      "name name"
      "personality personality"
      "model model";
    gap: 6px;
    padding: 10px;
  }
  .debater-row .role-tag { grid-area: tag; justify-self: start; }
  .debater-row .d-name { grid-area: name; }
  .debater-row .d-personality { grid-area: personality; }
  .debater-row .d-model { grid-area: model; padding: 8px; }
  .debater-row .remove { grid-area: remove; justify-self: end; min-height: 36px; min-width: 36px; }

  /* チップ */
  .chip { padding: 6px 12px; font-size: 0.9rem; }

  /* 発言カード */
  .utterance { padding: 12px 14px; }
  .utterance .speaker { gap: 8px; }
  .utterance .container-tag { font-size: 0.7rem; }
  .markdown { font-size: 0.95rem; }
  .markdown h2 { font-size: 1.05rem; }
  .markdown h3 { font-size: 1rem; }

  /* 結論カード */
  .conclusion { padding: 18px 14px; }
  .conclusion .title-headline { font-size: 1.15rem; }
  .conclusion h3 { font-size: 1.05rem; }
  .conclusion .pros-cons { grid-template-columns: 1fr; gap: 12px; }
  .conclusion .pros, .conclusion .cons, .conclusion .final { padding: 12px; }
  .conclusion ul { padding-left: 18px; }

  /* サイドバー (モバイルでは上に来る + 高さ制限解除) */
  .debate-side { gap: 10px; padding-right: 0; }
  .side-card { padding: 12px 14px; }
  .side-card h3 { font-size: 0.95rem; }
  .dom-row { grid-template-columns: 40px 1fr 40px; }
  .dom-label { font-size: 0.8rem; }
  .dom-pct { font-size: 0.85rem; }

  /* インターラウンドカード(モバイル時の操作を明確に) */
  #interlude-card .row { flex-direction: column; gap: 6px; }
  #interlude-card .row .btn { width: 100%; }
  #inject-textarea { min-height: 80px; }

  /* 認証カード */
  .auth-card { padding: 24px 20px; }
  .brand { font-size: 1.7rem; }

  /* 履歴カード */
  .debate-card { padding: 14px 16px; }
  .debate-card .title { font-size: 1rem; }
  .debate-card .meta { font-size: 0.8rem; gap: 8px; }

  /* ラウンド区切り */
  .round-divider::before, .round-divider::after { width: 22%; }

  /* コンテキスト(お題詳細) */
  .context-box { padding: 8px 12px; font-size: 0.9rem; }
  .context-box pre { font-size: 0.85rem; }
}

/* さらに狭い (≤ 360px) */
@media (max-width: 360px) {
  .header-inner { padding: 8px 10px; }
  .container, .container-wide { padding: 12px 10px; }
  .btn { font-size: 0.85rem; padding: 8px 10px; }
  fieldset, .adv-fieldset { padding: 10px 12px; }
  #debate-motion { font-size: 1.1rem; }
}

/* Stream */
.stream { display: flex; flex-direction: column; gap: 16px; }
.round-divider {
  text-align: center;
  margin: 16px 0 8px;
  font-weight: 600;
  color: var(--muted);
  position: relative;
}
.round-divider::before, .round-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 32%;
  height: 1px;
  background: var(--border);
}
.round-divider::before { left: 0; }
.round-divider::after { right: 0; }

.utterance {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.utterance .speaker {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.utterance .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
}
.utterance .label { font-weight: 600; }
.utterance .container-tag {
  font-size: 0.75rem;
  color: var(--muted);
  background: #f1f3fa;
  padding: 2px 8px;
  border-radius: 8px;
}
.utterance.role-moderator .avatar { background: var(--moderator); }
.utterance.role-pro .avatar { background: var(--pro); }
.utterance.role-con .avatar { background: var(--con); }
.utterance.role-neutral .avatar { background: var(--neutral); }
.utterance.role-perspective .avatar { background: var(--perspective); }
.utterance.role-user_inject { background: #f5f8ff; border-color: var(--user); }
.utterance.role-user_inject .avatar { background: var(--user); }
.utterance .content {
  line-height: 1.65;
  color: var(--text);
}
/* Markdown rendered content */
.markdown { line-height: 1.7; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 0.8em 0 0.4em; color: var(--text); }
.markdown h1 { font-size: 1.4rem; }
.markdown h2 { font-size: 1.2rem; }
.markdown h3 { font-size: 1.05rem; color: var(--primary-dark); }
.markdown ul, .markdown ol { padding-left: 1.4em; margin: 0.4em 0; }
.markdown li { margin: 0.15em 0; }
.markdown p { margin: 0.5em 0; }
.markdown code {
  background: #f1f3fa;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
}
.markdown pre {
  background: #1c2333;
  color: #f0f3fb;
  padding: 10px 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
}
.markdown pre code { background: transparent; color: inherit; padding: 0; }
.markdown blockquote {
  border-left: 3px solid var(--primary);
  margin: 0.5em 0;
  padding: 0.1em 12px;
  color: var(--muted);
  background: rgba(77,108,240,.04);
}
.markdown table { border-collapse: collapse; margin: 0.5em 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 4px 8px; }
.markdown a { color: var(--primary); }

.thinking {
  background: linear-gradient(90deg, #f1f3fa, #e2e7f5, #f1f3fa);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--muted);
  font-style: italic;
}
@keyframes shimmer {
  0% { background-position: 0% 0%; }
  100% { background-position: -200% 0%; }
}

/* Conclusion */
.conclusion {
  background: linear-gradient(135deg, #f5f9ff, #fff);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(77,108,240,.15);
}
.conclusion .title-headline {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 6px;
}
.stream-wrap { background: transparent; }
.stream-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin: 8px 0 10px;
}
.stream-title { margin: 0; color: var(--muted); font-size: 1rem; font-weight: 600; }
.stream-wrap.collapsed .stream { display: none; }
.conclusion h3 { margin: 0 0 12px; color: var(--primary-dark); }
.conclusion .summary { font-size: 1.05rem; margin-bottom: 16px; }
.conclusion .pros-cons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 640px) {
  .conclusion .pros-cons { grid-template-columns: 1fr; }
}
.conclusion .pros, .conclusion .cons { border-radius: 8px; padding: 14px; }
.conclusion .pros { background: rgba(46,139,87,.08); border: 1px solid var(--pro); }
.conclusion .cons { background: rgba(193,73,59,.08); border: 1px solid var(--con); }
.conclusion .pros h4 { color: var(--pro); margin: 0 0 8px; }
.conclusion .cons h4 { color: var(--con); margin: 0 0 8px; }
.conclusion ul { margin: 0; padding-left: 20px; }
.conclusion li { margin-bottom: 6px; }
.conclusion .final {
  background: rgba(77,108,240,.06);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.conclusion .final h4 { margin: 0 0 6px; color: var(--primary-dark); }
.conclusion .open-questions { color: var(--muted); font-size: 0.9rem; }

#questions-for-user {
  margin: 8px 0;
  font-size: 0.9rem;
}
#questions-for-user .q-item {
  padding: 6px 8px;
  background: #fffdf3;
  border: 1px solid #f2e2a8;
  border-radius: 6px;
  margin-bottom: 4px;
}
.injected-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.injected-list .injected-item {
  background: #eaf2ff;
  border-left: 3px solid var(--user);
  padding: 6px 10px;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  color: var(--text);
  white-space: pre-wrap;
}
.injected-list .injected-item::before {
  content: "✓ 投入済み: ";
  color: var(--user);
  font-weight: 600;
  font-size: 0.75rem;
}
