:root {
  --bg: #111217;
  --panel: #171922;
  --panel-2: #1f2230;
  --text: #e8eaf0;
  --muted: #8a90a2;
  --line: #2b3040;
  --accent: #8eb6ff;
  --user: #26324a;
  --danger: #ed6a6a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); font-size: 12.5px; }
.pair { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.pair-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.pair-card select, .pair-card input[type="password"] { width: 100%; box-sizing: border-box; }
.pair-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); margin: 8px 0 12px; }
.pair-help { margin: 12px 0; font-size: 12px; color: var(--muted); }
.pair-help summary { cursor: pointer; color: var(--text); }
.pair-help code { display: block; margin: 6px 0; padding: 6px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; word-break: break-all; font-size: 11px; }
.logo { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; background: #fff; color: #111; font-weight: 800; font-size: 28px; }
.logo.small { width: 42px; height: 42px; font-size: 22px; border-radius: 12px; }
.pair h1 { margin: 16px 0 4px; font-size: 32px; }
.pair p { margin: 0 0 20px; color: var(--muted); }
.pair label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pair input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.pair button { width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #0b1220; font-weight: 700; }
.pair button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.pair-divider { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 8px; }
.app { display: grid; grid-template-columns: 280px 1fr; height: 100%; }
.sidebar { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); padding: 12px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; padding: 4px 4px 14px; }
.mark { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: #fff; color: #111; }
.new { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 10px; text-align: left; }
.threads { margin-top: 10px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.thread { border: 0; background: transparent; text-align: left; padding: 10px; border-radius: 9px; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread:hover, .thread.active { background: var(--panel-2); }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.link { border: 0; background: transparent; color: var(--accent); padding: 4px; }
.chat { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; height: 100%; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.menu { display: none; border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 5px 9px; }
.messages { overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.welcome { margin: auto; text-align: center; max-width: 480px; color: var(--muted); }
.welcome h2 { color: var(--text); margin: 12px 0 4px; }
.welcome .logo { margin: 0 auto; }
.msg { max-width: min(760px, 92%); white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 14px; padding: 12px 14px; }
.msg.user { align-self: flex-end; background: var(--user); border: 1px solid #35456a; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg .thinking { margin: 0 0 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 13px; background: #121722; }
.msg .thinking summary { cursor: pointer; color: var(--accent); }
.msg .thinking div { white-space: pre-wrap; margin-top: 7px; max-height: 220px; overflow: auto; }
.composer { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 180px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 11px 13px; }
.composer button { width: 46px; border: 0; border-radius: 12px; background: var(--accent); color: #0b1220; font-size: 18px; }
.composer button.mic { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-size: 17px; }
.composer button.mic.listening { border-color: var(--accent); color: var(--accent); }
.msg .speak { margin-top: 7px; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; padding: 3px 8px; font-size: 12px; }
.msg .speak:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 5; inset: 0 auto 0 0; width: min(86vw, 320px); transform: translateX(-105%); transition: transform .2s ease; }
  .app.open .sidebar { transform: translateX(0); }
  .menu { display: block; }
  .messages { padding: 14px; }
}
