:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #121826;
  --muted: #5d6475;
  --border: #e1e5ee;
  --cyan: #00caff;
  --blue: #1f6feb;
  --scam: #d6336c;
  --scam-soft: #ffe3ec;
  --warn: #d9480f;
  --warn-soft: #fff0e0;
  --safe: #2b8a3e;
  --safe-soft: #e3f7e8;
  --device: #1b1f2a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --surface: #161a23;
    --text: #e8ebf2;
    --muted: #98a0b3;
    --border: #283042;
    --scam: #ff6b9a;
    --scam-soft: #3a1826;
    --warn: #ffa94d;
    --warn-soft: #3a2812;
    --safe: #5fd17a;
    --safe-soft: #16301d;
    --device: #0a0c11;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted, small { color: var(--muted); }

.topbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; font-size: 1.25rem; }
.brand .for { color: var(--cyan); font-weight: 700; }
.badge { font-size: .75rem; padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }

.layout { max-width: 1100px; margin: 0 auto; padding: 24px 16px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

/* The "Echo" device */
.device { background: var(--device); border-radius: 28px; padding: 36px 20px 22px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.ring { width: 170px; height: 170px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(from 0deg, #0b3d5c, #0b3d5c); transition: background .4s; }
.ring-inner { width: 138px; height: 138px; border-radius: 50%; background: var(--device); }
.state-label { color: #c9d2e3; margin: 18px 0 0; min-height: 1.5em; font-size: .95rem; }
.device[data-state="listening"] .ring { background: conic-gradient(var(--cyan), var(--blue), var(--cyan)); animation: pulse 1.1s ease-in-out infinite; }
.device[data-state="thinking"] .ring { background: conic-gradient(var(--cyan) 0 25%, #0b3d5c 25% 100%); animation: spin 1s linear infinite; }
.device[data-state="speaking"] .ring { background: conic-gradient(var(--cyan), #6ee7ff, var(--blue), var(--cyan)); animation: glow 1.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.04); box-shadow: 0 0 40px rgba(0, 202, 255, .5); } }
@keyframes glow { 50% { box-shadow: 0 0 60px rgba(0, 202, 255, .55); } }

.controls { text-align: center; margin: 18px 0 8px; }
.mic { width: 72px; height: 72px; border-radius: 50%; border: none; font-size: 1.9rem; cursor: pointer; background: var(--blue); color: #fff; box-shadow: 0 8px 20px rgba(31, 111, 235, .35); }
.mic.on { background: var(--scam); }
.hint { color: var(--muted); font-size: .9rem; }
.link { background: none; border: none; color: var(--blue); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

.type-form { display: grid; gap: 8px; }
textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; resize: vertical; }
.btn { font: inherit; font-weight: 600; border: none; border-radius: 10px; padding: 10px 16px; background: var(--blue); color: #fff; cursor: pointer; justify-self: end; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; font-size: .85rem; color: var(--muted); }
.examples button { font: inherit; font-size: .8rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 5px 10px; cursor: pointer; }
.examples button:hover { border-color: var(--blue); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 1rem; margin: 0 0 10px; }
.panel h3 { font-size: .9rem; margin: 14px 0 6px; }

.chat { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-height: 280px; overflow-y: auto; }
.chat li { padding: 10px 12px; border-radius: 14px; max-width: 90%; word-break: break-word; }
.chat .user { background: var(--blue); color: #fff; justify-self: end; border-bottom-right-radius: 4px; }
.chat .bot { background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.verdict { font-size: 1.2rem; font-weight: 800; padding: 8px 12px; border-radius: 10px; }
.verdict.scam { background: var(--scam-soft); color: var(--scam); }
.verdict.suspicious { background: var(--warn-soft); color: var(--warn); }
.verdict.safe { background: var(--safe-soft); color: var(--safe); }
.verdict small { font-weight: 400; font-size: .8rem; margin-left: 6px; }
.flags, .todo, .report { padding-left: 18px; margin: 8px 0 0; display: grid; gap: 6px; font-size: .9rem; }
.flags q { display: block; color: var(--muted); font-size: .85rem; word-break: break-all; }
.flags small { display: block; font-size: .8rem; }
.official { font-size: .88rem; }
.official q { color: var(--muted); }
a { color: var(--blue); }

.calls { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-height: 260px; overflow-y: auto; font-size: .8rem; }
.call { border-left: 3px solid var(--border); padding: 4px 0 4px 10px; }
.call.ok { border-color: var(--safe); }
.call.running { border-color: var(--cyan); }
.call.error { border-color: var(--scam); }
.call .tool { font-weight: 700; }
.call .status { margin-left: 6px; color: var(--muted); }
.call .args { display: block; color: var(--muted); word-break: break-all; margin-top: 2px; }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 30px; max-width: 760px; margin: 0 auto; }

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