/* Jsu v8 design system: themes, accents, chat, composer, action cards, settings sheet */

:root {
  --accent: #6366f1;
  --accent-2: #818cf8;
  --radius: 18px;
  --font-size: 16px;
  --gap: 10px;
  --pad-y: 11px;
}
[data-accent="teal"]  { --accent: #14b8a6; --accent-2: #2dd4bf; }
[data-accent="rose"]  { --accent: #f43f5e; --accent-2: #fb7185; }
[data-accent="amber"] { --accent: #f59e0b; --accent-2: #fbbf24; }
[data-font="s"] { --font-size: 14px; }
[data-font="l"] { --font-size: 18px; }
[data-density="compact"] { --gap: 6px; --pad-y: 8px; --radius: 14px; }

[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0b1020; --bg-glow: rgba(99,102,241,.14);
  --surface: #151b2e; --surface-2: #1c2440; --border: #232c4a;
  --text: #e7eaf6; --muted: #8b93b8;
}
[data-theme="oled"] {
  color-scheme: dark;
  --bg: #000000; --bg-glow: rgba(99,102,241,.10);
  --surface: #101014; --surface-2: #17171d; --border: #26262e;
  --text: #f0f0f5; --muted: #8a8a99;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5fb; --bg-glow: rgba(99,102,241,.08);
  --surface: #ffffff; --surface-2: #eef0fa; --border: #dde1f0;
  --text: #171a2c; --muted: #5d6480;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--font-size);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  color: var(--text);
}

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

/* ---------- header ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
}
.id-block { display: flex; align-items: center; gap: 12px; }
#avatar, #heroChar, .setup-logo {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 45%, transparent);
}
#title { font-size: 18px; margin: 0; letter-spacing: .2px; }
#status { font-size: 12px; color: var(--muted); }
#status.busy { color: var(--accent-2); }

.icon-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); padding: 8px; display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- setup ---------- */
#setup { flex: 1; display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.setup-card {
  width: 100%; max-width: 380px; display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.setup-logo { width: 56px; height: 56px; font-size: 24px; margin: 0 auto; }
#avatar { font-size: 17px; flex: none; }
#heroChar { width: 96px; height: 96px; border-radius: 28px; font-size: 42px; margin: 0 auto; }
.setup-card h2 { margin: 0; text-align: center; font-size: 20px; }
.setup-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.fine { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }

input, select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); padding: 11px 12px; font-size: var(--font-size); width: 100%;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
input[type="checkbox"] { width: auto; padding: 0; accent-color: var(--accent); transform: scale(1.3); }
input[type="range"] { padding: 0; accent-color: var(--accent); }

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; border-radius: 14px; color: #fff; padding: 13px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
}
.ghost-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); padding: 10px; font-size: 14px; cursor: pointer;
}
.ghost-btn:hover { background: var(--surface-2); }

/* ---------- chat ---------- */
#chat { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
#log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: var(--gap);
}
.msg {
  padding: var(--pad-y) 14px; border-radius: var(--radius);
  max-width: 82%; white-space: pre-wrap; word-break: break-word;
  line-height: 1.45; animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.you {
  align-self: flex-end; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-bottom-right-radius: 6px;
}
.bot {
  align-self: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.meta { display: block; font-size: 11px; opacity: .65; margin-top: 4px; }

/* typing indicator */
.typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* action cards */
.card {
  align-self: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; max-width: 85%;
  display: grid; gap: 10px; font-size: calc(var(--font-size) - 1px);
  animation: pop .18s ease-out;
}
.card .chiprow { display: flex; align-items: center; gap: 8px; }
.chipstat {
  font-size: 11px; font-weight: 700; letter-spacing: .6px; padding: 3px 9px;
  border-radius: 999px; text-transform: uppercase;
}
.chipstat.ready { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-2); }
.chipstat.pending { background: rgba(245, 158, 11, .16); color: #fbbf24; }
.chipstat.blocked { background: rgba(244, 63, 94, .16); color: #fb7185; }
.chipstat.unsupported { background: var(--surface-2); color: var(--muted); }
.card .devpick { margin-top: 8px; width: 100%; }
.caprow { display: flex; gap: 16px; margin: 8px 0; }
.caprow label { display: flex; align-items: center; gap: 6px; }
.devrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--surface-2); }
#devTokenOut { word-break: break-all; user-select: all; }
.card .cta {
  justify-self: start; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; border-radius: 10px; color: #fff; padding: 9px 16px; font-size: 14px;
  font-weight: 600; cursor: pointer;
}
.note { align-self: center; font-size: 12px; color: var(--muted); text-align: center; max-width: 90%; }

/* empty hero */
#hero {
  position: absolute; inset: 0 0 76px; display: grid; place-content: center;
  justify-items: center; gap: 10px; text-align: center; padding: 24px;
}
.hero-avatar { width: 72px; height: 72px; font-size: 30px; }
#hero h2 { margin: 4px 0 0; font-size: 24px; }
#hero p { margin: 0; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; max-width: 420px; }
.chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); padding: 9px 14px; font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent-2); }

/* ---------- composer ---------- */
#composer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
}
#composer input { flex: 1; min-width: 0; border-radius: 999px; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.round-btn.send {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
#micBtn.rec { background: #dc2626; border-color: #dc2626; color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .5); }
  70% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
#recTime { color: #dc2626; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }

/* ---------- settings sheet ---------- */
#sheetWrap { position: fixed; inset: 0; z-index: 20; }
#sheetBack { position: absolute; inset: 0; background: rgba(4,6,14,.62); }
#sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(400px, 92vw);
  background: var(--surface); border-left: 1px solid var(--border);
  padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px;
  animation: slidein .22s ease-out;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.set-group { display: grid; gap: 10px; }
.set-group h3 {
  margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
}
.set-group label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.set-group label.row { display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: 14px; }
.row-label { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.swatches { display: flex; gap: 10px; }
.sw {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent;
  background: var(--c); cursor: pointer;
}
.sw.sel { border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 40%, transparent); }

[hidden] { display: none !important; }

/* ---------- technology-feel layer: motion tied to REAL state/signal ---------- */
#vizbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px 0;
}
#viz {
  flex: 1; height: 28px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
}
#vizLabel { font-size: 11px; letter-spacing: 1px; color: #dc2626; font-weight: 700; flex-shrink: 0; }

/* hero orb: idle breathing (state = idle, not fake signal) */
.orb { position: relative; }
.orb::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(.92); opacity: .35; }
  50% { transform: scale(1.06); opacity: .9; }
}

/* speaking ring on the header avatar: tied to real utterance start/end events */
#avatar.speaking::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--accent-2);
  animation: breathe 1.4s ease-in-out infinite;
}
#avatar { position: relative; }

/* status dot */
#status::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e; margin-right: 6px; vertical-align: 1px;
}
#status.busy::before { background: var(--accent-2); animation: blinkdot 1.1s infinite; }
@keyframes blinkdot { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .orb::after, #avatar.speaking::after, #status.busy::before, #micBtn.rec,
  .msg, .card, .typing i { animation: none !important; }
}

