/* ── EMPTY STATE ── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 32px 16px;
  text-align: center;
  overflow-y: auto;
  min-height: 0;
}

.seal-wrap {
  position: relative;
  margin-bottom: 16px;
  width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.seal-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--accent-mid);
  animation: spinSlow 12s linear infinite;
}
.seal-ring-2 {
  position: absolute; inset: 6px;
  border-radius: 50%;
  border: 1px dashed var(--accent-dim);
  animation: spinSlow 8s linear infinite reverse;
}
@keyframes spinSlow { to { transform: rotate(360deg); } }
.seal-core {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1.5px solid var(--accent-mid);
  display: flex; align-items: center; justify-content: center;
  animation: floatCore 3s ease-in-out infinite;
}
.seal-core svg { width: 22px; height: 22px; }
@keyframes floatCore {
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-3px)}
}

.empty-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.empty-title {
  font-family: var(--font-d);
  font-size: clamp(26px, 3.5vw, 38px);
  font-weight: 900;
  color: var(--ink);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.empty-title em { font-style: italic; color: var(--accent); }
.empty-sub {
  font-size: 13px;
  color: var(--ink-dim);
  max-width: 360px;
  line-height: 1.6;
  font-weight: 300;
  margin-bottom: 20px;
}

.examples-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 560px;
  width: 100%;
}

.ex-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 8px;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  animation: slideUp 0.4s cubic-bezier(.22,.68,0,1.2) both;
}
.ex-card:nth-child(1){animation-delay:0.05s}
.ex-card:nth-child(2){animation-delay:0.10s}
.ex-card:nth-child(3){animation-delay:0.15s}
.ex-card:nth-child(4){animation-delay:0.20s}
@keyframes slideUp { from{opacity:0;transform:translateY(14px)} to{opacity:1;transform:translateY(0)} }
.ex-card:hover {
  border-color: var(--accent-mid);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-dim);
}
.ex-card:active { transform: translateY(0); }

.ex-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-dim); border-radius: 4px;
  padding: 2px 7px; flex-shrink: 0; margin-top: 1px; white-space: nowrap;
}
.ex-icon {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
  user-select: none;
}
.ex-text { font-size: 13px; color: var(--ink-mid); line-height: 1.4; font-weight: 400; }

/* ── MESSAGES ── */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 40px;
  display: none;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}
.chat-scroll.on { display: flex; }
.chat-scroll::-webkit-scrollbar { width: 4px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg-wrap {
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
  padding: 18px 0;
  border-bottom: 1px solid var(--border-2);
  animation: msgIn 0.35s cubic-bezier(.22,.68,0,1.2) both;
}
@keyframes msgIn {
  from { opacity:0; transform: translateY(16px) scale(0.97); }
  to   { opacity:1; transform: none; }
}
.msg-wrap:last-child { border-bottom: none; }

/* judge message */
.judge-msg { display: flex; flex-direction: column; gap: 0; }

.msg-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 7px;
  display: flex; align-items: center; gap: 6px;
}
.judge-msg .msg-label { color: var(--accent); }
.user-msg  .msg-label { color: var(--ink-faint); text-align: right; }

.msg-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
}
.badge-offtopic {
  background: var(--rose-dim);
  color: var(--rose);
  border: 1px solid var(--rose-mid);
}
.badge-question {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid var(--amber-mid);
}

.judge-body {
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink);
  font-weight: 300;
}
.judge-body.is-offtopic { color: var(--ink-dim); font-style: italic; }

/* user message — bubble on the right */
.user-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.user-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  padding: 12px 16px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-mid);
  font-weight: 400;
}

/* markdown inside judge responses */
.judge-body p       { margin-bottom: 10px; }
.judge-body p:last-child { margin-bottom: 0; }
.judge-body strong  { font-weight: 600; color: var(--ink); }
.judge-body em      { font-style: italic; color: inherit; font-weight: 500; }
.judge-body code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12.5px;
  font-family: 'Courier New', monospace;
  color: var(--accent);
}
.judge-body h2, .judge-body h3 {
  font-family: var(--font-d);
  font-weight: 700;
  color: var(--ink);
  margin: 14px 0 6px;
  font-size: 16px;
}
.judge-body h3 { font-size: 14.5px; }
.judge-body ul, .judge-body ol {
  padding-left: 18px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.judge-body ul li, .judge-body ol li { font-size: 14px; line-height: 1.6; }
.judge-body blockquote {
  border-left: 2.5px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  font-weight: 500;
}
.judge-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}
.judge-body h1 {
  font-family: var(--font-d);
  font-weight: 700;
  color: var(--ink);
  margin: 14px 0 6px;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.judge-body pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.5;
}
.judge-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--ink);
  font-size: inherit;
}
.judge-body table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 13.5px;
}
.judge-body th, .judge-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.judge-body th {
  background: var(--surface-2);
  font-weight: 600;
}
.judge-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-mid);
  text-underline-offset: 2px;
}
.judge-body a:hover { text-decoration-color: var(--accent); }

/* ── CONFIDENCE BADGE (below judge body, above actions) ── */
.conf-badge {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.conf-badge::before {
  content: '⚠';
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}
.conf-badge.med {
  background: var(--amber-dim);
  border: 1px solid var(--amber-mid);
  color: var(--amber);
}
.conf-badge.med::before { content: 'ℹ'; }
.conf-badge.low {
  background: var(--rose-dim);
  border: 1px solid var(--rose-mid);
  color: var(--rose);
}

/* ── MESSAGE ACTIONS (copy, etc.) ── */
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.msg-act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 9px;
  font-family: var(--font-b);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.msg-act:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--ink-faint);
}
.msg-act:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.msg-act svg { flex-shrink: 0; }
.copy-btn.copied {
  background: var(--mint-dim);
  color: var(--mint);
  border-color: var(--mint-mid);
}

/* ── TOURNAMENT MODE ── */
body.mode-tournament .judge-body {
  font-size: 17px;
  line-height: 1.85;
  font-weight: 400;
}
body.mode-tournament .user-bubble {
  font-size: 16px;
}
body.mode-tournament .empty-title {
  font-size: clamp(32px, 4.5vw, 48px);
}
body.mode-tournament .empty-sub {
  font-size: 15px;
  max-width: 460px;
}
body.mode-tournament .msg-wrap { max-width: 820px; }
body.mode-tournament .input-row { max-width: 820px; }
body.mode-tournament .input-field { font-size: 16px; min-height: 56px; }
body.mode-tournament .sidebar {
  opacity: 0.5;
  transition: opacity 0.2s;
}
body.mode-tournament .sidebar:hover,
body.mode-tournament .sidebar:focus-within,
body.sidebar-open .sidebar {
  opacity: 1;
}
body.mode-tournament .tweaks-btn { opacity: 0.55; }
body.mode-tournament .tweaks-btn:hover { opacity: 1; }

/* ── REVEAL WORDS (final answer fades in word-by-word, not char-by-char) ── */
.reveal-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(3px);
  animation-name: revealWord;
  animation-duration: 320ms;
  animation-fill-mode: forwards;
  animation-timing-function: cubic-bezier(.22,.68,0,1.2);
  /* per-word animation-delay is set inline by JS */
}
@keyframes revealWord {
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal-word {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ── STAGE INDICATOR (shown while the answer is being drafted/verified) ── */
.stage-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0 4px;
  min-height: 28px;
}
.stage-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: stageSpin 0.85s linear infinite;
}
@keyframes stageSpin { to { transform: rotate(360deg); } }
.stage-label {
  font-size: 13px;
  color: var(--ink-mid);
  font-weight: 400;
  font-style: italic;
  transition: opacity 0.16s, transform 0.16s;
}
.stage-label.fading {
  opacity: 0;
  transform: translateY(-2px);
}

/* ── TYPING INDICATOR (still used by historic addMsg fallback) ── */
.typing { display: flex; gap: 5px; align-items: center; padding: 6px 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: tdot 1.4s ease-in-out infinite;
}
.typing span:nth-child(2){animation-delay:.18s}
.typing span:nth-child(3){animation-delay:.36s}
@keyframes tdot{0%,80%,100%{opacity:0.2;transform:scale(0.75)}40%{opacity:1;transform:scale(1)}}

/* ── CHAR COUNTER ── */
.char-count {
  font-size: 11px;
  color: var(--ink-faint);
  transition: color 0.2s;
}
.char-count.warn   { color: var(--amber); }
.char-count.danger { color: var(--rose); }

/* ── INPUT BAR ── */
.input-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 40px 18px;
  transition: background 0.4s;
}
.input-bar.sending { animation: inputPulse 0.4s ease; }
@keyframes inputPulse {
  0%  { transform: scale(1); }
  30% { transform: scale(0.992); }
  100%{ transform: scale(1); }
}

/* ── ANSWER MODE PILLS (above the textarea) ── */
.input-mode-row {
  max-width: 700px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-mode-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  font-family: var(--font-b);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.input-mode-pill:hover { color: var(--ink); }
.input-mode-pill.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-mid);
  font-weight: 600;
}
.input-mode-hint {
  font-size: 11px;
  color: var(--ink-faint);
  margin-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 680px) {
  .input-mode-hint { display: none; }
}

.input-row {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.input-field {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: var(--font-b);
  font-size: 14px;
  color: var(--ink);
  resize: none;
  outline: none;
  line-height: 1.55;
  min-height: 48px;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.4s;
  font-weight: 400;
}
.input-field::placeholder { color: var(--ink-faint); }
.input-field:focus {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.send-btn {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: var(--accent);
  border: none;
  color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), opacity 0.15s, filter 0.15s;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 10px var(--accent-mid));
  position: relative;
  overflow: hidden;
}
.send-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: white;
  border-radius: inherit;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s, transform 0.3s;
}
.send-btn.fired::after { animation: sendRipple 0.5s ease forwards; }
@keyframes sendRipple {
  0%   { opacity: 0.35; transform: scale(0); }
  100% { opacity: 0;    transform: scale(2.5); }
}
.send-btn:hover   { transform: scale(1.1) rotate(-5deg); }
.send-btn:active  { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.35; filter: none; transform: none; cursor: default; }

/* Stop mode: button morphs into a square stop icon while a stream is in flight. */
.send-btn.is-stop {
  background: var(--rose);
  filter: drop-shadow(0 3px 10px var(--rose-mid));
  animation: stopPulse 1.6s ease-in-out infinite;
}
.send-btn.is-stop:hover { transform: scale(1.06) rotate(0); }
@keyframes stopPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--rose-mid); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

.input-footer {
  max-width: 700px;
  margin: 7px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.input-hint {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* ── RESPONSIVE ── */
@media (max-width: 680px) {
  .chat-scroll, .empty-state { padding: 20px; }
  .input-bar { padding: 12px 16px 16px; }
}
