:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #11141b;
  --panel-2: #171b24;
  --line: #252b37;
  --text: #f3f4f6;
  --muted: #8e96a6;
  --accent: #c5ff53;
  --accent-dark: #85b22e;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, textarea, input { font: inherit; }
button { color: inherit; }

.shell { display: grid; grid-template-columns: 272px 1fr; height: 100%; }
.sidebar { display: flex; flex-direction: column; min-width: 0; padding: 22px 14px 14px; border-right: 1px solid var(--line); background: #0e1117; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark, .login-logo { display: grid; place-items: center; background: var(--accent); color: #11150b; font-weight: 900; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px 8px 8px 2px; }
.new-chat { display: flex; align-items: center; gap: 9px; width: 100%; margin-top: 28px; padding: 11px 13px; border: 1px solid #303744; border-radius: 10px; background: #171b23; cursor: pointer; text-align: left; }
.new-chat:hover { border-color: #4c5668; background: #1c212b; }
.new-chat span { color: var(--accent); font-size: 19px; }
.history-label { margin: 26px 10px 9px; color: #697182; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.history { display: flex; flex: 1; flex-direction: column; gap: 3px; overflow-y: auto; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; }
.history-item:hover, .history-item.active { background: #1a1f29; }
.history-item span { overflow: hidden; color: #cbd0da; text-overflow: ellipsis; white-space: nowrap; }
.history-item small { flex: 0 0 auto; color: #606979; }
.sidebar-footer { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 7px; padding: 14px 6px 3px; border-top: 1px solid var(--line); }
.sidebar-footer strong, .sidebar-footer span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer strong { font-size: 12px; }
.sidebar-footer span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.model-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px #c5ff5377; }
.icon-button { padding: 7px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: #202632; color: var(--text); }

.main { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0; background: radial-gradient(circle at 50% 0, #171b25 0, var(--bg) 38%); }
.mobile-header { display: none; }
.messages { overflow-y: auto; padding: 40px max(24px, calc((100% - 820px) / 2)) 24px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; padding-bottom: 7vh; text-align: center; }
.empty-orbit { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 25px; border: 1px solid #303847; border-radius: 50%; box-shadow: 0 0 55px #b6fa4030, inset 0 0 28px #b6fa4012; }
.empty-orbit span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px 13px 13px 4px; background: var(--accent); color: #11150b; font-size: 23px; font-weight: 900; }
.empty-state h1 { margin: 0; font-size: clamp(30px, 5vw, 46px); letter-spacing: -.045em; }
.empty-state > p { margin: 13px 0 30px; color: var(--muted); font-size: 16px; }
.suggestions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(700px, 100%); }
.suggestions button { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #11151caa; color: #b6bdca; cursor: pointer; }
.suggestions button:hover { border-color: #485265; background: #181d26; color: var(--text); }
.message { display: grid; grid-template-columns: 42px 1fr; gap: 15px; padding: 24px 0; border-bottom: 1px solid #202530; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #222936; color: #cbd1db; font-size: 11px; font-weight: 800; }
.message.assistant .avatar { border-radius: 10px 10px 10px 3px; background: var(--accent); color: #11150b; font-size: 15px; }
.message-body { min-width: 0; }
.message-label { margin-bottom: 8px; color: #929aaa; font-size: 12px; font-weight: 700; }
.message-text { color: #e4e7ec; line-height: 1.68; overflow-wrap: anywhere; white-space: pre-wrap; }

.composer-wrap { width: min(900px, calc(100% - 32px)); margin: 0 auto; padding: 10px 0 15px; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 17px; border: 1px solid #303746; border-radius: 17px; background: #171b23; box-shadow: 0 14px 50px #0008; }
.composer:focus-within { border-color: #596577; box-shadow: 0 14px 50px #0008, 0 0 0 3px #c5ff530d; }
.composer textarea { flex: 1; min-height: 28px; max-height: 180px; padding: 4px 0; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.5; }
.composer textarea::placeholder { color: #717a89; }
.send { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border: 0; border-radius: 11px; background: var(--accent); color: #11150b; cursor: pointer; font-size: 22px; font-weight: 800; }
.send:hover { background: #d2ff78; }
.send:disabled { cursor: wait; filter: grayscale(1); opacity: .45; }
.fine-print { margin: 8px 0 0; color: #606979; font-size: 11px; text-align: center; }

.login-overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: #090b10f5; backdrop-filter: blur(12px); }
.login-overlay[hidden] { display: none; }
.login-card { width: min(390px, 100%); padding: 34px; border: 1px solid #2b3240; border-radius: 20px; background: #12161d; box-shadow: 0 35px 100px #000c; }
.login-logo { width: 44px; height: 44px; margin-bottom: 27px; border-radius: 13px 13px 13px 4px; font-size: 23px; }
.login-card h1 { margin: 0; font-size: 27px; letter-spacing: -.035em; }
.login-card p { margin: 9px 0 25px; color: var(--muted); }
.login-card label { display: block; margin-bottom: 7px; color: #aeb5c1; font-size: 12px; font-weight: 700; }
.login-card input { width: 100%; padding: 12px 13px; border: 1px solid #343c4b; border-radius: 10px; outline: 0; background: #0d1016; color: var(--text); }
.login-card input:focus { border-color: var(--accent-dark); }
.login-card button { width: 100%; margin-top: 13px; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #11150b; cursor: pointer; font-weight: 800; }
.login-error { min-height: 18px; margin-top: 8px; color: #ff818c; font-size: 12px; }

.settings-overlay { position: fixed; z-index: 30; inset: 0; display: flex; justify-content: flex-end; background: #05070ba8; backdrop-filter: blur(5px); }
.settings-overlay[hidden] { display: none; }
.settings-panel { width: min(620px, 100%); height: 100%; overflow-y: auto; border-left: 1px solid #303746; background: #10141b; box-shadow: -30px 0 90px #000b; }
.settings-header { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 25px 28px 20px; border-bottom: 1px solid var(--line); background: #10141bf2; backdrop-filter: blur(16px); }
.settings-header span { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.settings-header h2 { margin: 3px 0 0; font-size: 25px; letter-spacing: -.035em; }
.settings-header .icon-button { font-size: 28px; line-height: 1; }
.settings-section { padding: 25px 28px; border-bottom: 1px solid var(--line); }
.settings-section h3 { margin: 0; font-size: 16px; }
.settings-section > p { margin: 6px 0 22px; color: var(--muted); font-size: 12px; }
.range-field { display: block; margin-top: 22px; }
.range-field > span { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 9px; }
.range-field strong { font-size: 13px; font-weight: 650; }
.range-field output { min-width: 58px; color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; text-transform: capitalize; }
.range-field input { width: 100%; height: 4px; margin: 5px 0 8px; accent-color: var(--accent); cursor: pointer; }
.range-field small { display: block; color: #6f7888; font-size: 11px; }
.prompt-fields label { display: block; margin-top: 18px; }
.prompt-fields label > span { display: block; margin-bottom: 7px; color: #b5bcc8; font-size: 12px; font-weight: 700; }
.prompt-fields textarea { width: 100%; padding: 12px 13px; resize: vertical; border: 1px solid #343c4b; border-radius: 10px; outline: 0; background: #0b0e13; color: #e6e9ee; line-height: 1.5; }
.prompt-fields textarea:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px #c5ff530d; }
.settings-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 16px 28px; border-top: 1px solid var(--line); background: #10141bf2; backdrop-filter: blur(16px); }
.settings-actions button { padding: 10px 15px; border-radius: 9px; cursor: pointer; font-weight: 750; }
.settings-actions .secondary { border: 1px solid #343c4b; background: #181d26; color: #bdc3ce; }
.settings-actions .primary { border: 1px solid var(--accent); background: var(--accent); color: #10140a; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: min(310px, 87vw); transform: translateX(-101%); box-shadow: 25px 0 70px #000b; transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; height: 58px; padding: 0 13px; border-bottom: 1px solid var(--line); background: #0d1016db; backdrop-filter: blur(14px); }
  .mobile-header .brand { padding: 0; font-size: 15px; }
  .mobile-header .brand-mark { width: 25px; height: 25px; }
.status-pill { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.status-pill span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.mobile-actions { display: flex; align-items: center; gap: 3px; }
  .messages { padding: 20px 17px; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestions button { padding: 12px; }
  .message { grid-template-columns: 34px 1fr; gap: 11px; padding: 19px 0; }
  .avatar { width: 29px; height: 29px; }
  .composer-wrap { width: calc(100% - 22px); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .settings-panel { width: 100%; border-left: 0; }
  .settings-header, .settings-section { padding-right: 20px; padding-left: 20px; }
  .settings-actions { padding-right: 20px; padding-left: 20px; }
}

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