/* ═══════════════════════════════════════════════════════
   Dhamma Agent — Jarvis-style dark UI
   ═══════════════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #05080e;
  --surface:      #0b1220;
  --border:       #1a2a3a;
  --text:         #c8dff0;
  --text-dim:     #4a6a80;
  --text-muted:   #2a4a60;
  --accent:       #00b8d4;

  /* orb colors — overridden by JS per state */
  --orb-core:     #003a55;
  --orb-glow:     #00aaffcc;
  --ring-color:   rgba(0,170,255,0.35);
  --ring-color2:  rgba(0,170,255,0.18);
  --ring-color3:  rgba(0,170,255,0.08);

  --user-bg:      #0e2038;
  --user-border:  #1a4060;
  --agent-bg:     #080f1a;
  --agent-border: #0a2030;

  --input-bg:     #0a1520;
  --input-border: #1a2a3a;

  --radius-bubble: 18px;
  --radius-sm:     8px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Light theme overrides (class on body, set by JS) ────── */
body.light-theme {
  --bg:           #f8f4ec;
  --surface:      #f0ead8;
  --border:       #d4c9b0;
  --text:         #2a2015;
  --text-dim:     #7a6a50;
  --text-muted:   #b5a888;
  --accent:       #b06000;

  --orb-core:     #4d1f00;
  --orb-glow:     rgba(200,120,0,0.55);
  --ring-color:   rgba(180,100,0,0.4);
  --ring-color2:  rgba(180,100,0,0.2);
  --ring-color3:  rgba(180,100,0,0.08);

  --user-bg:      #e4eef8;
  --user-border:  #9ec0d8;
  --agent-bg:     #faf8f2;
  --agent-border: #ddd5be;

  --input-bg:     #f0ece2;
  --input-border: #c8bfa8;
}

body.light-theme .bubble-user          { color: #1a3050; }
body.light-theme .bubble-content strong { color: #7a3800; }
body.light-theme .bubble-content em     { color: #5a4000; }
body.light-theme .bubble-content h1,
body.light-theme .bubble-content h2     { color: #8a4400; border-color: rgba(180,100,0,0.2); }
body.light-theme .bubble-content h3     { color: #6a3800; }
body.light-theme .bubble-content h4     { color: #5a3000; }
body.light-theme .bubble-content code   { background: rgba(180,100,0,0.1); color: #7a4400; }
body.light-theme .bubble-content blockquote { border-color: var(--accent); }
body.light-theme .bubble-content a      { color: var(--accent); }
body.light-theme .citation              {
  background: rgba(180,100,0,0.12);
  border-color: rgba(180,100,0,0.35);
  color: #8a5000;
}
body.light-theme #chat-area { background: linear-gradient(to bottom, var(--bg) 0%, transparent 5%), var(--bg); }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 960px;
  margin: 0 auto;
}

/* ── Main split (orb sidebar + chat panel) ────────────── */
#main-split {
  flex: 1 1 auto;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

#right-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────── */
#header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  z-index: 10;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon {
  font-size: 1.4rem;
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent));
  line-height: 1;
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text);
  text-transform: uppercase;
}

/* ── Language buttons ─────────────────────────────────── */
.lang-group {
  display: flex;
  gap: 4px;
}

.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.lang-btn:hover { border-color: var(--accent); color: var(--accent); }

.lang-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,184,212,0.12);
}

body.light-theme .lang-btn.active {
  background: rgba(176,96,0,0.12);
}

/* Mode toggle buttons (theme, debate) — match lang-btn style */
.mode-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  line-height: 1;
}
.mode-btn:hover { border-color: var(--accent); color: var(--accent); }
.mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,184,212,0.12);
}
body.light-theme .mode-btn.active { background: rgba(176,96,0,0.12); }

/* ── Orb sidebar ──────────────────────────────────────── */
#orb-section {
  flex: 0 0 120px;
  width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 6px;
  gap: 12px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: relative;
}

#orb-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Rings */
.ring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

#ring1 { width: 56px;  height: 56px;  border: 1.5px solid var(--ring-color); }
#ring2 { width: 76px;  height: 76px;  border: 1px   solid var(--ring-color2); }
#ring3 { width: 96px;  height: 96px;  border: 1px   solid var(--ring-color3); }

/* Core orb */
#orb-core {
  position: relative;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, #0066aa, var(--orb-core) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: rgba(0,180,230,0.9);
  box-shadow:
    0 0 12px var(--orb-glow),
    0 0 24px rgba(0,100,200,0.2),
    inset 0 0 8px rgba(0,0,0,0.6);
  cursor: default;
  transition:
    background     0.5s ease,
    box-shadow     0.5s ease;
  user-select: none;
}

#status-text {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-transform: uppercase;
  text-align: center;
  min-height: 1.2em;
  transition: color 0.4s;
  line-height: 1.3;
  word-break: break-word;
}

/* ── State-specific orb & ring styles ─────────────────── */

/* idle — very slow breathe, dim */
.state-idle #ring1  { animation: breathe 5s ease-in-out infinite; }
.state-idle #ring2  { animation: breathe 5s ease-in-out infinite 1s; }
.state-idle #ring3  { animation: breathe 5s ease-in-out infinite 2s; }
.state-idle #orb-core {
  --orb-core: #001e33;
  --orb-glow: rgba(0,100,180,0.4);
  color: rgba(0,140,200,0.6);
}
.state-idle #status-text { color: var(--text-muted); }

/* listening — steady gentle pulse, cyan */
.state-listening #ring1  { animation: pulse 2.5s ease-in-out infinite; }
.state-listening #ring2  { animation: pulse 2.5s ease-in-out infinite 0.5s; }
.state-listening #ring3  { animation: pulse 2.5s ease-in-out infinite 1s; }
.state-listening #orb-core {
  background: radial-gradient(circle at 38% 38%, #0099cc, #003355 70%);
  box-shadow: 0 0 22px rgba(0,160,220,0.7), 0 0 50px rgba(0,120,180,0.2),
              inset 0 0 12px rgba(0,0,0,0.6);
  color: rgba(0,220,255,0.9);
}

/* recording — fast red pulse, user speaking */
.state-recording #ring1  { animation: pulse-fast 0.7s ease-in-out infinite; }
.state-recording #ring2  { animation: pulse-fast 0.7s ease-in-out infinite 0.15s; }
.state-recording #ring3  { animation: pulse-fast 0.7s ease-in-out infinite 0.3s; }
.state-recording #orb-core {
  background: radial-gradient(circle at 38% 38%, #cc2244, #440011 70%);
  box-shadow: 0 0 26px rgba(220,40,80,0.8), 0 0 55px rgba(180,0,40,0.25),
              inset 0 0 12px rgba(0,0,0,0.6);
  color: rgba(255,100,130,0.95);
}
.state-recording #status-text { color: #ff4466; }

/* transcribing — counter-rotating dashed rings, purple */
.state-transcribing #ring1 {
  border: 2px dashed rgba(160,80,255,0.7);
  animation: spin-cw 1.2s linear infinite;
}
.state-transcribing #ring2 {
  border: 1px dashed rgba(130,60,220,0.4);
  animation: spin-ccw 2s linear infinite;
}
.state-transcribing #ring3 {
  border: 1px dashed rgba(100,40,180,0.2);
  animation: spin-cw 3s linear infinite;
}
.state-transcribing #orb-core {
  background: radial-gradient(circle at 38% 38%, #7733cc, #220044 70%);
  box-shadow: 0 0 24px rgba(160,80,255,0.7), 0 0 50px rgba(120,40,200,0.2),
              inset 0 0 12px rgba(0,0,0,0.6);
  color: rgba(200,140,255,0.95);
}
.state-transcribing #status-text { color: #b060ff; }

/* thinking — fast counter-rotating, amber */
.state-thinking #ring1 {
  border: 2px dashed rgba(240,160,0,0.8);
  animation: spin-cw 0.8s linear infinite;
}
.state-thinking #ring2 {
  border: 1px dashed rgba(200,120,0,0.5);
  animation: spin-ccw 1.4s linear infinite;
}
.state-thinking #ring3 {
  border: 1px dashed rgba(160,80,0,0.25);
  animation: spin-cw 2s linear infinite;
}
.state-thinking #orb-core {
  background: radial-gradient(circle at 38% 38%, #cc8800, #331a00 70%);
  box-shadow: 0 0 26px rgba(240,160,0,0.75), 0 0 55px rgba(180,100,0,0.25),
              inset 0 0 12px rgba(0,0,0,0.6);
  color: rgba(255,200,80,0.95);
}
.state-thinking #status-text { color: #ffaa22; }

/* speaking — flowing wave rings, teal */
.state-speaking #ring1  { animation: wave 0.55s ease-in-out infinite; }
.state-speaking #ring2  { animation: wave 0.55s ease-in-out infinite 0.18s; }
.state-speaking #ring3  { animation: wave 0.55s ease-in-out infinite 0.36s; }
.state-speaking #orb-core {
  background: radial-gradient(circle at 38% 38%, #009977, #001a11 70%);
  box-shadow: 0 0 26px rgba(0,220,160,0.75), 0 0 55px rgba(0,160,110,0.25),
              inset 0 0 12px rgba(0,0,0,0.6);
  color: rgba(0,255,190,0.95);
}
.state-speaking #status-text { color: #00eebb; }

/* tts — gentle pulse, green-teal */
.state-tts #ring1  { animation: pulse 1.5s ease-in-out infinite; }
.state-tts #ring2  { animation: pulse 1.5s ease-in-out infinite 0.4s; }
.state-tts #ring3  { animation: pulse 1.5s ease-in-out infinite 0.8s; }
.state-tts #orb-core {
  background: radial-gradient(circle at 38% 38%, #006644, #001108 70%);
  box-shadow: 0 0 22px rgba(0,200,120,0.65), 0 0 50px rgba(0,140,80,0.2),
              inset 0 0 12px rgba(0,0,0,0.6);
  color: rgba(80,255,170,0.9);
}

/* playing — audio playing, ripple out */
.state-playing #ring1  { animation: ripple 1.2s ease-out infinite; }
.state-playing #ring2  { animation: ripple 1.2s ease-out infinite 0.4s; }
.state-playing #ring3  { animation: ripple 1.2s ease-out infinite 0.8s; }
.state-playing #orb-core {
  background: radial-gradient(circle at 38% 38%, #008855, #000f06 70%);
  box-shadow: 0 0 28px rgba(0,230,140,0.8), 0 0 60px rgba(0,180,100,0.25),
              inset 0 0 12px rgba(0,0,0,0.6);
  color: rgba(60,255,160,0.95);
}
.state-playing #status-text { color: #33ffaa; }

/* ── Keyframes ────────────────────────────────────────── */
@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: 0.25; }
  50%       { transform: scale(1.05); opacity: 0.55; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1);    opacity: 0.55; }
  50%       { transform: scale(1.08); opacity: 0.9; }
}
@keyframes pulse-fast {
  0%, 100% { transform: scale(1);    opacity: 0.7; }
  50%       { transform: scale(1.14); opacity: 1; }
}
@keyframes wave {
  0%   { transform: scale(1);    opacity: 0.8; }
  25%  { transform: scale(1.10); opacity: 1;   }
  75%  { transform: scale(0.95); opacity: 0.5; }
  100% { transform: scale(1);    opacity: 0.8; }
}
@keyframes ripple {
  0%   { transform: scale(1);    opacity: 0.8; }
  100% { transform: scale(1.18); opacity: 0;   }
}
@keyframes spin-cw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes spin-ccw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

/* ── Chat area ────────────────────────────────────────── */
#chat-area {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 16px;
  scroll-behavior: smooth;
  background:
    linear-gradient(to bottom, var(--bg) 0%, transparent 5%),
    var(--bg);
}

#chat-area::-webkit-scrollbar { width: 4px; }
#chat-area::-webkit-scrollbar-track { background: transparent; }
#chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Bubbles */
.bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: var(--radius-bubble);
  font-size: 0.93rem;
  line-height: 1.65;
  word-break: break-word;
  animation: fadeSlideIn 0.2s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble-user {
  align-self: flex-end;
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-bottom-right-radius: 4px;
  color: #b8d8f0;
}

.bubble-agent {
  align-self: flex-start;
  background: var(--agent-bg);
  border: 1px solid var(--agent-border);
  border-bottom-left-radius: 4px;
  color: var(--text);
  position: relative;
}

.bubble-agent::before {
  content: "☸";
  position: absolute;
  top: -8px;
  left: -4px;
  font-size: 0.75rem;
  color: var(--accent);
  filter: drop-shadow(0 0 4px var(--accent));
}

/* Markdown content inside agent bubble */
.bubble-content strong { color: #80ccee; }
.bubble-content em     { color: #90b8d0; }
.bubble-content h1 {
  color: #60d0f0;
  font-size: 1.25em;
  font-weight: 700;
  margin: 0.7em 0 0.35em;
  border-bottom: 1px solid rgba(0,180,220,0.2);
  padding-bottom: 0.2em;
}
.bubble-content h2 {
  color: #60d0f0;
  font-size: 1.15em;
  font-weight: 700;
  margin: 0.65em 0 0.3em;
}
.bubble-content h3 {
  color: #70c8e8;
  font-size: 1.05em;
  font-weight: 600;
  margin: 0.6em 0 0.3em;
}
.bubble-content h4 {
  color: #80c0d8;
  font-size: 0.98em;
  font-weight: 600;
  margin: 0.5em 0 0.25em;
}
.bubble-content p      { margin: 0.4em 0; }
.bubble-content ol,
.bubble-content ul     { padding-left: 1.2em; margin: 0.4em 0; }
.bubble-content li     { margin: 0.2em 0; }
.bubble-content code   {
  background: rgba(0,120,180,0.2);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.88em;
  font-family: monospace;
  color: #80ddee;
}
.bubble-content blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  color: var(--text-dim);
  margin: 0.5em 0;
}
.bubble-content a { color: var(--accent); text-decoration: none; }
.bubble-content a:hover { text-decoration: underline; }

/* Citation markers */
.citation {
  display: inline-block;
  font-size: 0.72em;
  vertical-align: super;
  background: rgba(0,100,180,0.3);
  border: 1px solid rgba(0,140,220,0.3);
  border-radius: 3px;
  padding: 0 3px;
  color: #60aaee;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 1px;
  cursor: default;
}

/* Sources */
.sources-area { margin-top: 8px; }

.sources-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sources-details summary {
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-dim);
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sources-details summary:hover { color: var(--accent); }
.sources-details[open] summary { border-bottom: 1px solid var(--border); }

.source-link {
  display: block;
  padding: 6px 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}

.source-link:hover { background: rgba(0,120,200,0.1); color: var(--accent); }
.source-link:last-of-type { border-bottom: none; }

.source-label {
  font-weight: 700;
  color: var(--accent);
  margin-right: 4px;
}

.source-snippet {
  padding: 4px 10px 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}

.source-snippet:last-child { border-bottom: none; }

/* System messages */
.system-msg {
  align-self: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 12px;
}

/* Streaming cursor */
.streaming-cursor::after {
  content: "▍";
  animation: blink 0.8s step-start infinite;
  color: var(--accent);
  font-size: 0.9em;
}
@keyframes blink {
  50% { opacity: 0; }
}

/* ── Input area ───────────────────────────────────────── */
#input-area {
  flex: 0 0 auto;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#footer-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 32px;
}

/* Stop answer button — shown only when agent is active */
#stop-btn {
  display: none;
  align-items: center;
  gap: 5px;
  background: rgba(255,50,70,0.1);
  border: 1px solid rgba(255,60,80,0.45);
  color: #ff4466;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
#stop-btn:hover { background: rgba(255,50,70,0.2); border-color: #ff4466; }

/* Mic mute toggle */
#mic-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,184,212,0.1);
  border: 1px solid rgba(0,184,212,0.4);
  color: var(--accent);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
#mic-btn:hover { background: rgba(0,184,212,0.2); }
#mic-btn.muted {
  color: #ff4466;
  border-color: rgba(255,60,80,0.45);
  background: rgba(255,50,70,0.1);
}
#mic-btn.muted:hover { background: rgba(255,50,70,0.2); border-color: #ff4466; }

/* Clear button */
#clear-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  padding: 5px;
}
#clear-btn svg { width: 14px; height: 14px; }
#clear-btn:hover { border-color: #ff4466; color: #ff4466; }

/* Debate setup panel */
#debate-panel { padding: 4px 0; }

#debate-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

#debate-controls select,
#debate-controls input[type="text"] {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
#debate-controls select:focus,
#debate-controls input[type="text"]:focus { border-color: rgba(0,184,212,0.5); }
#debate-topic-input { flex: 1 1 220px; min-width: 180px; }
#debate-opponent-sel { flex: 0 1 160px; }
#debate-rounds-sel   { flex: 0 1 100px; }

#debate-start-btn {
  background: rgba(0,184,212,0.15);
  border: 1px solid rgba(0,184,212,0.4);
  color: var(--accent);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
#debate-start-btn:hover { background: rgba(0,184,212,0.28); border-color: var(--accent); }
#debate-start-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Debate transcript bubbles */
.debate-source {
  font-style: italic;
  opacity: 0.65;
  font-size: 0.68rem;
  text-transform: none;
  letter-spacing: 0;
}

.debate-round-header {
  align-self: center;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 10px;
  margin: 6px 0 2px;
}

.bubble-opponent {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
  position: relative;
  max-width: 84%;
  padding: 10px 14px;
  border-radius: var(--radius-bubble);
  font-size: 0.93rem;
  line-height: 1.65;
  word-break: break-word;
  animation: fadeSlideIn 0.2s ease;
}
.bubble-opponent::before {
  content: attr(data-flag);
  position: absolute;
  top: -8px;
  left: -4px;
  font-size: 0.85rem;
  line-height: 1;
}

/* Text row */
#text-row {
  display: flex;
  gap: 8px;
}

#text-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 22px;
  color: var(--text);
  padding: 9px 16px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#text-input::placeholder { color: var(--text-muted); }
#text-input:focus { border-color: rgba(0,184,212,0.5); }

#send-btn {
  background: rgba(0,184,212,0.15);
  border: 1px solid rgba(0,184,212,0.3);
  color: var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex: 0 0 auto;
  padding: 10px;
}

#send-btn svg { width: 16px; height: 16px; }
#send-btn:hover { background: rgba(0,184,212,0.28); border-color: var(--accent); }

/* ── Senior tester review panel ──────────────────────── */
.review-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.review-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.review-title {
  flex: 1 1 auto;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.review-close-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}
.review-close-btn:hover { background: rgba(255,255,255,0.06); }

.review-action-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}
.review-action-btn:hover { background: rgba(0,184,212,0.1); }

.review-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.review-empty {
  color: var(--text-dim);
  font-size: 0.88rem;
  text-align: center;
  padding: 40px 0;
}

.review-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.review-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.review-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity 0.3s, flex 0.2s;
}
.review-card.review-card-done { opacity: 0.5; }

/* Expanded: card fills the remaining panel height */
.review-card.review-card-expanded {
  flex: 1 1 auto;
}
.review-card.review-card-expanded .review-answer-edit,
.review-card.review-card-expanded .review-answer-text {
  flex: 1 1 auto;
  min-height: 300px;
  resize: vertical;
}
.review-card.review-card-expanded .review-card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* Section containing expanded card fills available space */
.review-section:has(.review-card-expanded) {
  flex: 1 1 auto;
}
.review-body:has(.review-card-expanded) {
  flex-direction: column;
}

/* Collapsed: only the header row is visible */
.review-card.review-card-collapsed {
  gap: 0;
}

.review-card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.review-card-meta {
  font-size: 0.74rem;
  color: var(--text-dim);
  flex: 0 0 auto;
}

.review-card-question-preview {
  font-size: 0.82rem;
  color: var(--text);
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Expand/collapse toggle button */
.review-expand-btn {
  flex: 0 0 auto;
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.4;
}
.review-expand-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }

.review-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-field-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-top: 4px;
}

.review-question {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
}

.review-answer-edit {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.6;
}
.review-answer-edit:focus { border-color: var(--accent); }

.review-answer-text {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.review-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.review-btn {
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s;
}
.review-btn-accept {
  background: rgba(0,200,100,0.12);
  border-color: rgba(0,200,100,0.4);
  color: #00c864;
}
.review-btn-accept:hover { background: rgba(0,200,100,0.22); }

.review-btn-reject {
  background: rgba(255,60,80,0.1);
  border-color: rgba(255,60,80,0.4);
  color: #ff4455;
}
.review-btn-reject:hover { background: rgba(255,60,80,0.2); }

.review-btn-deploy {
  background: rgba(0,184,212,0.12);
  border-color: rgba(0,184,212,0.4);
  color: var(--accent);
}
.review-btn-deploy:hover { background: rgba(0,184,212,0.22); }

.review-card-status {
  font-size: 0.78rem;
  color: var(--text-dim);
  min-height: 16px;
}

/* ── Tester badge ─────────────────────────────────────── */
.tester-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #ffd060;
  background: rgba(255,200,50,0.1);
  border: 1px solid rgba(255,200,50,0.3);
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  white-space: nowrap;
}

/* ── UAT token modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  width: min(380px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.modal-input:focus { border-color: var(--accent); }

.modal-error {
  font-size: 0.78rem;
  color: #ff5566;
  margin: -6px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 18px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.modal-btn-secondary {
  background: transparent;
  color: var(--text-dim);
}
.modal-btn-secondary:hover { background: rgba(255,255,255,0.05); }

.modal-btn-primary {
  background: rgba(0,184,212,0.15);
  border-color: rgba(0,184,212,0.45);
  color: var(--accent);
}
.modal-btn-primary:hover { background: rgba(0,184,212,0.28); border-color: var(--accent); }

/* ── Feedback buttons (thumbs up/down) ────────────────── */
.feedback-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.feedback-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-dim);
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}
.feedback-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.07);
  border-color: var(--text-dim);
}
.feedback-btn:disabled { cursor: default; opacity: 0.5; }
.feedback-btn.feedback-chosen {
  background: rgba(0,184,212,0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.feedback-edit {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.feedback-textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}
.feedback-textarea:focus { border-color: var(--accent); }

.feedback-submit-btn {
  align-self: flex-end;
  background: rgba(0,184,212,0.15);
  border: 1px solid rgba(0,184,212,0.45);
  color: var(--accent);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.feedback-submit-btn:hover { background: rgba(0,184,212,0.28); }
.feedback-submit-btn:disabled { opacity: 0.6; cursor: default; }

/* Light theme overrides for modal / feedback */
body.light-theme .modal-box { background: var(--surface); border-color: var(--border); }
body.light-theme .feedback-btn { color: var(--text-dim); border-color: var(--border); }
body.light-theme .feedback-textarea { background: var(--input-bg); border-color: var(--input-border); color: var(--text); }

/* ── Responsive — small screens ───────────────────────── */
@media (max-width: 480px) {
  #orb-section { flex: 0 0 72px; width: 72px; padding: 10px 4px; }
  #orb-wrap { width: 60px; height: 60px; }
  #orb-core { width: 26px; height: 26px; font-size: 0.75rem; }
  #ring1 { width: 34px; height: 34px; }
  #ring2 { width: 46px; height: 46px; }
  #ring3 { width: 58px; height: 58px; }
  #status-text { font-size: 0.58rem; }
  .bubble { max-width: 92%; }
}
