:root {
  color-scheme: dark;
  --bg: #08080b;
  --side: #0d0d12;
  --surface: #131319;
  --surface-2: #1a1a22;
  --surface-3: #22222c;
  --line: #24242e;
  --line-2: #2f2f3b;
  --text: #ececf2;
  --text-2: #b7b7c4;
  --muted: #7d7d8c;
  --accent: #9467f5;
  --accent-2: #b39cff;
  --accent-ink: #f6f2ff;
  --accent-soft: rgba(148, 103, 245, 0.14);
  --user: #2a2142;
  --user-line: #3a2d5e;
  --ok: #3ddc97;
  --warn: #f5b84a;
  --bad: #f2667a;
  --radius: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: 272px 1fr; height: 100dvh; }
.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  min-height: 0;
}
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-mark { display: inline-flex; gap: 4px; padding: 6px 7px; background: #000; border-radius: 9px; border: 1px solid var(--line-2); }
.brand-mark i { width: 7px; height: 12px; border-radius: 3px; background: linear-gradient(90deg, #9467f5, #50d5f0); background-size: 200% 100%; }
.brand-mark i:first-child { background-position: 0 0; }
.brand-mark i:last-child { background-position: 100% 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  border-radius: 11px; padding: 9px 14px; font-weight: 550; font-size: 14px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #a57bff; border-color: #a57bff; }
.btn.primary.muted-primary { background: var(--accent-soft); border-color: #4a3878; color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.ghost.on { background: var(--surface-2); color: var(--text); border-color: var(--line-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.danger { color: #f59aa7; }
.btn.danger:hover:not(:disabled) { background: rgba(242, 102, 122, 0.1); color: var(--bad); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { background: none; border: 0; padding: 0; color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }

.new-chat { width: 100%; justify-content: flex-start; padding: 10px 12px; background: var(--surface); }
.side-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 20px 10px 8px; }
.conversations { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; }
.conversations li { position: relative; }
.conv {
  width: 100%; text-align: left; background: transparent; border: 0; border-radius: 10px;
  padding: 9px 36px 9px 10px; display: flex; flex-direction: column; gap: 1px; color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.conv:hover { background: var(--surface); color: var(--text); }
.conv.active { background: var(--surface-2); color: var(--text); }
.conv-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: var(--muted); }
.conv-del {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); opacity: 0; transition: opacity 0.15s;
}
.conversations li:hover .conv-del, .conv-del:focus-visible { opacity: 1; }
.conv-del:hover { color: var(--bad); background: rgba(242, 102, 122, 0.1); }
.conv-empty { color: var(--muted); font-size: 13px; padding: 6px 10px; }
@media (hover: none) { .conv-del { opacity: 0.7; } }

.side-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.device-card {
  display: flex; align-items: center; gap: 11px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px;
  transition: border-color 0.15s;
}
.device-card:hover { border-color: var(--line-2); }
.device-icon { position: relative; width: 36px; height: 28px; border-radius: 7px; background: #000; border: 1px solid var(--line-2); display: grid; place-items: center; flex: none; }
.device-icon .status-dot { position: absolute; right: -3px; bottom: -3px; border: 2px solid var(--surface); }
.device-body { display: flex; flex-direction: column; min-width: 0; }
.device-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-btn { justify-content: flex-start; width: 100%; }

.mini-eyes { display: inline-flex; gap: 3px; vertical-align: middle; }
.mini-eyes::before, .mini-eyes::after { content: ""; width: 6px; height: 10px; border-radius: 2.5px; background: linear-gradient(90deg, var(--a, #9467f5), var(--b, #50d5f0)); background-size: 200% 100%; }
.mini-eyes::before { background-position: 0 0; }
.mini-eyes::after { background-position: 100% 0; }
.row-title .mini-eyes { margin-left: 8px; padding: 3px 4px; background: #000; border-radius: 4px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
[data-kind="ok"] > .status-dot, [data-kind="ok"] .device-icon .status-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.16); }
[data-kind="warn"] > .status-dot { background: var(--warn); }
[data-kind="bad"] > .status-dot, [data-kind="bad"] .device-icon .status-dot { background: var(--bad); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--muted); }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  border-bottom: 1px solid transparent; min-height: 60px;
}
.menu-btn { display: none; }
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-title span { color: var(--muted); font-weight: 400; }
.pills { margin-left: auto; display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; color: var(--text-2); transition: border-color 0.15s;
}
.pill:hover { border-color: var(--line-2); color: var(--text); }

/* ------------------------------------------------------------------ chat */
.scroller { flex: 1; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.chat { max-width: 780px; margin: 0 auto; padding: 18px 24px 36px; display: flex; flex-direction: column; gap: 22px; }

.msg { display: flex; gap: 12px; animation: rise 0.32s var(--ease) both; }
.msg-body { min-width: 0; display: flex; flex-direction: column; gap: 10px; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.msg.user .msg-body { align-items: flex-end; max-width: min(78%, 600px); }
.msg.assistant .msg-body { flex: 1; }
.bubble { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble {
  background: var(--user); border: 1px solid var(--user-line);
  padding: 10px 15px; border-radius: 18px 18px 6px 18px; color: #f1ecff;
}
.msg.assistant .bubble { padding-top: 5px; color: var(--text); }
.msg.warn .bubble { color: #f3d9a4; }
.msg.error .bubble { color: #f7b0ba; }
.note { font-size: 13px; color: var(--muted); }
.retry { font-size: 13px; align-self: flex-start; }

.avatar {
  flex: none; width: 34px; height: 34px; border-radius: 10px; background: #000;
  border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; gap: 4px;
}
.avatar i { width: 6px; height: 13px; border-radius: 3px; background: var(--accent-2); }
.avatar i:last-child { background: #7cdcf3; }
.avatar.thinking i { animation: blink 1.6s infinite; }

.thinking-bubble { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); animation: dot 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
.loading-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; justify-content: center; padding: 40px 0; }
.notice { padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.notice.error { border-color: #5a2a33; color: #f7b0ba; }

/* hero */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 7vh 0 10px; animation: rise 0.5s var(--ease) both; }
.hero-screen {
  width: 240px; aspect-ratio: 4 / 3; border-radius: 18px; background: #000; padding: 0;
  border: 1px solid var(--line-2); box-shadow: 0 30px 80px -30px rgba(148, 103, 245, 0.35), inset 0 0 0 6px #050507;
  overflow: hidden; margin-bottom: 26px;
}
.hero-canvas { width: 100%; height: 100%; display: block; }
.hero h1 { font-size: 28px; letter-spacing: -0.03em; margin: 0 0 6px; font-weight: 700; }
.hero p { color: var(--muted); margin: 0 0 28px; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 620px; }
.suggestion {
  text-align: left; padding: 13px 15px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); color: var(--text-2); font-size: 14px; line-height: 1.4;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s;
}
.suggestion:hover { border-color: #4a3878; background: var(--surface-2); color: var(--text); transform: translateY(-1px); }

/* ------------------------------------------------------------------ eye preview card */
.look {
  width: min(100%, 480px); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 12px;
  animation: rise 0.4s var(--ease) both;
}
.look-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 0 2px; }
.look-kicker { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.look-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.tag { flex: none; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); border: 1px solid #3c2d66; }

.screen {
  position: relative; border-radius: 13px; background: #000; overflow: hidden;
  aspect-ratio: 4 / 3; box-shadow: inset 0 0 0 1px #1e1e26, 0 0 0 5px #0a0a0e, 0 0 0 6px #1d1d25;
  margin: 5px;
}
.screen-canvas { width: 100%; height: 100%; display: block; }
.screen-glare { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(160deg, rgba(255,255,255,0.045), transparent 38%); }


.look-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0 4px; font-size: 13px; color: var(--text-2); }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta-item .dot { width: 11px; height: 11px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); }
.look-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.look-actions .spacer { flex: 1; }
.look[data-state="mixing"] .look-actions, .look[data-state="mixing"] .look-meta { opacity: 0.4; pointer-events: none; }
.look-actions, .look-meta { transition: opacity 0.3s; }

.look-panel { border-top: 1px solid var(--line); padding: 14px 2px 2px; display: flex; flex-direction: column; gap: 14px; animation: rise 0.25s var(--ease) both; }
.look-panel.save { flex-direction: row; gap: 8px; }
.look-panel.save .text-input { flex: 1; }
.look-status { font-size: 13px; color: var(--text-2); padding: 0 4px; min-height: 0; }
.look-status:empty { display: none; }
.look-status[data-kind="ok"] { color: var(--ok); }
.look-status[data-kind="warn"] { color: var(--warn); }
.look-status[data-kind="error"] { color: var(--bad); }
.look-status[data-kind="busy"]::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent-2); animation: spin 0.8s linear infinite; vertical-align: -1px; }
.ok-line { display: inline-flex; align-items: center; gap: 6px; }
.pick { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field.disabled, .color-field.disabled { opacity: 0.4; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.field-error { font-size: 12px; color: var(--bad); min-height: 0; }
.field-error:empty { display: none; }
.color-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.color-pair .icon-btn { margin-top: 18px; }
.color-row { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 5px 8px 5px 5px; }
.color-row:focus-within { border-color: var(--accent); }
.swatch-input { width: 30px; height: 30px; border: 0; padding: 0; border-radius: 8px; background: none; cursor: pointer; flex: none; }
.swatch-input::-webkit-color-swatch-wrapper { padding: 0; }
.swatch-input::-webkit-color-swatch { border: 1px solid rgba(255,255,255,0.15); border-radius: 7px; }
.swatch-input::-moz-color-swatch { border: 1px solid rgba(255,255,255,0.15); border-radius: 7px; }
.hex-input { width: 100%; min-width: 0; border: 0; background: transparent; font-family: var(--mono); font-size: 14px; outline: none; text-transform: uppercase; }
.hex-input.bad { color: var(--bad); }

.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 11px; align-self: flex-start; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--text-2); font-weight: 550; }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset; }

.angle-row { display: flex; align-items: center; gap: 6px; }
.dir { width: 32px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); font-size: 14px; }
.dir.on { border-color: var(--accent); color: var(--accent-2); background: var(--accent-soft); }
.range { flex: 1; min-width: 60px; accent-color: var(--accent); }
.range-out { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); min-width: 44px; text-align: right; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text-2); font-size: 13px;
}
.chip-btn:hover { color: var(--text); }
.chip-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }

.text-input, .select {
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 12px; outline: none; min-width: 0; width: 100%;
}
.text-input:focus, .select:focus { border-color: var(--accent); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

/* ------------------------------------------------------------------ composer */
.composer-wrap { padding: 0 24px max(14px, env(safe-area-inset-bottom)); }
.composer {
  max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 20px; padding: 8px 8px 8px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within { border-color: #4a3878; box-shadow: 0 0 0 4px rgba(148, 103, 245, 0.08); }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; background: transparent;
  padding: 8px 0; max-height: 200px; line-height: 1.5; font-size: 15px;
}
.composer textarea::placeholder { color: var(--muted); }
.send {
  flex: none; width: 38px; height: 38px; border-radius: 12px; border: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  transition: background 0.15s, opacity 0.15s, transform 0.15s;
}
.send:hover:not(:disabled) { background: #a57bff; }
.send:active:not(:disabled) { transform: scale(0.94); }
.send:disabled { background: var(--surface-3); color: var(--muted); }
.composer-foot { text-align: center; color: var(--muted); font-size: 12px; padding-top: 8px; }

/* ------------------------------------------------------------------ settings dialog */
.settings {
  border: 1px solid var(--line-2); border-radius: 20px; padding: 0; background: var(--side); color: var(--text);
  width: min(860px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 48px)); max-width: none; max-height: none;
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.8);
}
.settings::backdrop { background: rgba(4, 4, 8, 0.66); backdrop-filter: blur(4px); }
.settings[open] { animation: pop 0.22s var(--ease) both; }
.settings-shell { display: grid; grid-template-columns: 200px 1fr; height: 100%; }
.settings-nav { border-right: 1px solid var(--line); padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; }
.settings-heading { font-weight: 700; font-size: 16px; padding: 0 10px 14px; }
.settings-nav button { text-align: left; border: 0; background: transparent; border-radius: 9px; padding: 9px 10px; color: var(--text-2); font-size: 14px; }
.settings-nav button:hover { background: var(--surface); color: var(--text); }
.settings-nav button.on { background: var(--surface-2); color: var(--text); }
.settings-main { position: relative; overflow-y: auto; min-height: 0; }
.settings-close { position: absolute; top: 12px; right: 12px; }
.settings-body { padding: 24px 28px 30px; }
.pane { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.pane h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.pane h4 { margin: 12px 0 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.input-row { display: flex; gap: 6px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.check small { display: block; color: var(--muted); font-size: 12.5px; }
.row-end { display: flex; justify-content: flex-end; }
.form-result { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.form-result:empty { display: none; }
.form-result[data-kind="ok"], .form-result .ok { color: var(--ok); }
.form-result[data-kind="error"], .form-result .error { color: var(--bad); }
.form-result[data-kind="busy"] { color: var(--muted); }
.form-result .line { display: inline-flex; align-items: center; gap: 6px; }
.pair-form { display: grid; grid-template-columns: 150px 1fr auto; gap: 10px; align-items: end; }
.code-input { font-family: var(--mono); letter-spacing: 0.18em; text-transform: uppercase; }
.list { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.row.dim { opacity: 0.55; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; }
.row-sub { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.empty-row { color: var(--muted); font-size: 13px; padding: 10px 2px; }
.empty-row.error { color: var(--bad); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 14px; }
.kv span:nth-child(odd) { color: var(--muted); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text);
  padding: 9px 16px; border-radius: 12px; font-size: 14px; transition: opacity 0.2s, transform 0.2s var(--ease); z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast[data-kind="ok"] { border-color: #245c45; }
#toast[data-kind="error"] { border-color: #6a2c37; }

/* ------------------------------------------------------------------ motion */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 86%, 100% { transform: scaleY(1); } 92% { transform: scaleY(0.15); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------------------------ responsive */
.scrim { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30;
    transform: translateX(-102%); transition: transform 0.28s var(--ease);
  }
  body.nav-open .sidebar { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 25; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 12px; }
  .topbar-title span { display: none; }
  .chat { padding: 10px 14px 28px; }
  .composer-wrap { padding: 0 10px max(10px, env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .pill .pill-text { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #conn-pill .pill-text { display: none; }
  #conn-pill { padding: 9px; }
  .suggestions { grid-template-columns: 1fr; }
  .hero { padding-top: 4vh; }
  .hero-screen { width: 200px; }
  .msg.user .msg-body { max-width: 88%; }
  .avatar { width: 28px; height: 28px; }
  .avatar i { width: 5px; height: 10px; }
  .look { padding: 10px; border-radius: 16px; }
  .field.two { grid-template-columns: 1fr; }
  .color-pair { grid-template-columns: 1fr; }
  .color-pair .icon-btn { margin: 0; justify-self: center; transform: rotate(90deg); }
  .settings { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .settings-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 10px; }
  .settings-heading { display: none; }
  .settings-nav button { white-space: nowrap; }
  .settings-body { padding: 18px 16px 30px; }
  .pair-form { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .composer-foot { display: none; }
}
