:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e8eee9;
  background: #111614;
  --surface: #161d19;
  --raised: #1b241e;
  --line: #2a372e;
  --muted: #a5b4aa;
  --green: #adeda8;
  --dark-green: #203826;
  --warning: #f3cd92;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

.layout { height: 100dvh; min-height: 320px; display: grid; grid-template-columns: 254px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 25px 17px 17px; min-height: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 8px 30px; letter-spacing: .11em; font-weight: 750; line-height: 1.2; }
.brand-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px; background: var(--dark-green); color: var(--green); font-size: 23px; letter-spacing: normal; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; font-weight: 500; letter-spacing: normal; }
.new-chat { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid #3b5240; border-radius: 9px; background: #213027; color: #d6f4d7; font-weight: 600; font-size: .87rem; text-align: left; }
.new-chat:hover:enabled { background: #2a3d2f; }
.new-chat span { font-size: 1.2rem; line-height: 1; }
.history { min-height: 0; overflow: auto; padding: 0 2px 6px; margin-top: 24px; }
.history h2 { color: var(--muted); font-size: .73rem; font-weight: 600; margin: 0 8px 8px; }
.history-row { display: flex; align-items: stretch; border-radius: 8px; margin-bottom: 4px; }
.history-row:hover, .history-row:focus-within, .history-row.selected { background: var(--raised); }
.history-row button, .text-button { border: 0; background: transparent; color: var(--muted); border-radius: 6px; }
.history-row button:hover, .text-button:hover, .history-row.selected button { color: #e8eee9; }
.history-row .chat-title { min-width: 0; flex: 1; text-align: left; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; padding: 9px 8px; font-size: .82rem; }
.delete-chat { padding: 5px 9px; opacity: 0; }
.history-row:hover .delete-chat, .history-row:focus-within .delete-chat, .history-row.selected .delete-chat { opacity: 1; }
.sidebar-footer { margin-top: auto; padding: 15px 7px 0; color: var(--muted); display: grid; justify-items: start; gap: 8px; font-size: .75rem; }
.text-button { padding: 6px 0; font-size: .85rem; }

.workspace { display: grid; min-height: 0; min-width: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
.topbar { min-height: 63px; display: flex; align-items: center; gap: 14px; padding: 10px 24px; border-bottom: 1px solid #222c25; }
.topbar-name { font-size: .91rem; font-weight: 650; }
.menu { display: none; padding: 5px; }
.status { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); text-align: right; font-size: .76rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); flex: none; }
.status[data-state="ready"] .status-dot { background: var(--green); }

.conversation { overflow-y: auto; position: relative; }
.welcome, .gate { display: grid; align-content: center; justify-items: center; min-height: 100%; padding: 22px 20px; text-align: center; }
.welcome { background: radial-gradient(ellipse 340px 205px at 50% 47%, #21372a 0%, transparent 95%); }
.hero-icon { display: grid; place-items: center; width: 58px; height: 58px; color: var(--green); border: 1px solid #496c4e; border-radius: 17px; background: var(--dark-green); font-size: 35px; }
h1 { margin: 18px 0 10px; max-width: 100%; font-size: clamp(2rem, 5vw, 3.35rem); line-height: 1.08; letter-spacing: -.055em; }
h1 em { color: var(--green); font-style: normal; }
.welcome p { color: var(--muted); margin: 4px 0 23px; line-height: 1.5; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.suggestions button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: #dae6dd; font-size: .81rem; }
.suggestions button:hover { background: var(--raised); border-color: #456349; }
.suggestions span { color: var(--green); margin-right: 4px; }

.gate { overflow: auto; }
.login { width: min(100%, 360px); display: grid; gap: 12px; text-align: left; }
.login h1 { font-size: 2rem; margin: 5px 0 12px; }
.login input { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 11px; color: inherit; }
.login .primary { min-height: 43px; }

.messages { display: grid; gap: 25px; width: min(calc(100% - 36px), 790px); margin: 0 auto; padding: 32px 0; }
.message { min-width: 0; max-width: 100%; }
.message.user { justify-self: end; width: fit-content; max-width: 84%; padding: 13px 18px; border: 1px solid #374b3c; border-radius: 15px 15px 4px 15px; background: #24352a; }
.message > strong { display: block; margin-bottom: 6px; color: var(--green); font-size: .8rem; }
.message.user > strong { color: #bed0c1; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.message.assistant .message-body { white-space: normal; }
.message-body :where(p, ul, ol, blockquote, table) { margin: 0 0 .85em; }
.message-body :where(ul, ol) { padding-inline-start: 1.6em; }
.message-body li > p { margin: .2em 0; }
.message-body blockquote { border-left: 2px solid #496c4e; padding-inline-start: 1em; color: var(--muted); }
.message-body :where(h1, h2, h3, h4, h5, h6) { margin: .8em 0 .35em; font-size: 1.13em; line-height: 1.3; letter-spacing: normal; }
.message-body table { display: block; overflow: auto; border-collapse: collapse; }
.message-body :where(th, td) { border: 1px solid var(--line); padding: 5px 9px; }
.message-body pre { white-space: pre; overflow: auto; border: 1px solid var(--line); background: #0e1310; border-radius: 8px; padding: 12px 15px; margin: 8px 0; }
.message-body code { font-family: Consolas, monospace; font-size: .88em; }
.message-body :not(pre) > code { padding: .1em .3em; border-radius: 4px; background: var(--raised); }
.message-body > :first-child { margin-top: 0; }
.message-body > :last-child { margin-bottom: 0; }
.message-body a { color: var(--green); text-underline-offset: .16em; }
.citation { display: inline-block; margin-inline: .18em; padding: 0 .33em; border-radius: 4px; background: var(--dark-green); color: var(--green); font-size: .78em; font-weight: 700; }
.message-body .citation:hover, .message-body .citation:focus-visible { background: var(--green); color: #152719; }
.message-note { font-size: .8rem; margin-top: 7px; color: var(--warning); }

.composer-area { width: min(calc(100% - 36px), 790px); margin-inline: auto; padding-bottom: max(16px, env(safe-area-inset-bottom)); background: #111614; }
.composer { padding: 10px; border: 1px solid #3c5042; background: var(--surface); border-radius: 14px; }
.composer:focus-within { border-color: #6b9970; }
.input-row { display: flex; align-items: end; gap: 10px; }
.composer textarea { flex: 1; min-width: 0; width: 100%; min-height: 42px; max-height: 150px; field-sizing: content; resize: none; padding: 9px 7px; border: 0; background: transparent; color: inherit; line-height: 1.45; }
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:focus-visible { outline: none; }
.primary { border: 0; border-radius: 9px; background: var(--green); color: #152719; font-weight: 700; }
.primary:hover:enabled { background: #c8f5c4; }
.send { flex: none; width: 41px; height: 41px; font-size: 1.4rem; line-height: 1; }
.composer-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; padding: 7px 5px 1px; color: var(--muted); font-size: .69rem; }
.notice { color: var(--warning); font-size: .84rem; margin: 1px 6px 8px; line-height: 1.4; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 56px auto 0 0; width: min(82vw, 270px); box-shadow: 12px 0 35px #0008; }
  .sidebar:not(.open) { display: none; }
  .menu { display: inline-block; }
  .topbar { min-height: 56px; padding-inline: 14px; gap: 10px; }
  .topbar-name { font-size: .83rem; }
  .status { font-size: .69rem; }
  .welcome p { margin-bottom: 15px; }
  .hero-icon { width: 48px; height: 48px; font-size: 28px; }
  .delete-chat { opacity: 1; }
  .composer textarea { font-size: 16px; }
  .composer-footer span:first-child { display: none; }
  .message.user { max-width: 94%; }
}

@media (max-height: 570px) {
  .welcome { align-content: start; }
}

:root {
  color-scheme: light;
  --bg: #fff;
  --surface: #f9f9f9;
  --raised: #ececec;
  --composer: #f4f4f4;
  --text: #0d0d0d;
  --muted: #6b6b6b;
  --line: #e5e5e5;
  --code: #f7f7f7;
  --green: #256a50;
  --dark-green: #e6f1eb;
  --warning: #8a4d13;
  --button: #0d0d0d;
  --button-text: #fff;
  color: var(--text);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #212121;
    --surface: #171717;
    --raised: #353535;
    --composer: #303030;
    --text: #ececec;
    --muted: #a6a6a6;
    --line: #424242;
    --code: #171717;
    --green: #a9dac5;
    --dark-green: #31483e;
    --warning: #f3cd92;
    --button: #fff;
    --button-text: #0d0d0d;
  }
}

.layout { grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { padding: 0 10px 12px; border: 0; }
.brand { display: flex; align-items: center; min-height: 58px; margin: 0; padding-inline: 10px; color: var(--text); font-size: .98rem; font-weight: 750; letter-spacing: .08em; text-decoration: none; }
.new-chat, .history-search { display: flex; align-items: center; width: 100%; min-height: 38px; gap: 10px; padding: 7px 10px; color: var(--text); background: transparent; border: 0; border-radius: 8px; }
.new-chat:hover:enabled, .history-search:hover { background: var(--raised); }
.history-search input { width: 100%; border: 0; background: transparent; color: var(--text); font-size: .84rem; }
.history-search span { color: var(--muted); font-size: 1.12rem; }
.history { margin-top: 22px; }
.history-row button:hover, .text-button:hover, .history-row.selected button { color: var(--text); }
.topbar { min-height: 58px; padding-inline: 20px; border-bottom: 0; }
.topbar-name { font-size: .98rem; }
.status[data-state="ready"] .status-dot { background: #43a27a; }

.welcome { align-content: center; width: min(100%, 690px); margin-inline: auto; padding: 24px; background: transparent; }
.welcome h1, .login h1 { font-weight: 550; letter-spacing: -.035em; }
.welcome h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.25rem); }
.welcome p { font-size: .95rem; margin: 10px 0 28px; }
.welcome-mark { position: relative; width: 100px; height: 100px; margin-bottom: 24px; }
.welcome-orbit { position: absolute; inset: 0; border: 1px solid #80808055; border-radius: 50%; }
.welcome-spark { position: absolute; top: 8px; left: 12px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px #0003, 0 0 10px #8888; }
.welcome-core { display: grid; place-items: center; width: 72px; height: 72px; border: 1px solid #ffffff40; border-radius: 24px; background: linear-gradient(145deg, #474747, #303030); box-shadow: inset 0 1px 1px #fff2, 0 9px 24px #0002; transform: rotate(-8deg); }
.welcome-mark .welcome-core { position: absolute; inset: 14px; }
.welcome-core img { width: 45px; height: 45px; transform: rotate(8deg); }
.suggestions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 10px; }
.suggestions button { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); padding: 12px; background: var(--bg); color: var(--text); border-radius: 14px; text-align: left; }
.suggestions button:hover { background: var(--composer); border-color: var(--line); }
.suggestions button span { margin-right: 0; }
.starter-icon { flex: none; display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; background: var(--raised); color: var(--text); }
.starter-copy { display: grid; gap: 3px; flex-grow: 1; color: var(--text); }
.starter-copy small, .starter-arrow { color: var(--muted); }

.messages, .composer-area { width: min(calc(100% - 46px), 768px); }
.message.user { background: var(--composer); color: var(--text); border: 0; border-radius: 24px; }
.message > strong, .message.user > strong { color: var(--muted); }
.message-body pre { background: var(--code); }
.message-body blockquote { border-color: var(--line); }
.composer-area { background: var(--bg); }
.composer { background: var(--composer); border: 1px solid transparent; border-radius: 29px; }
.composer:focus-within { border-color: var(--line); }
.composer textarea { padding-inline-start: 12px; }
.primary { background: var(--button); color: var(--button-text); }
.primary:hover:enabled { background: var(--button); opacity: .82; }
.send { border-radius: 50%; }
.composer-footer { padding-inline: 12px; }
.login input { background: var(--bg); }

@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { inset-block-start: 58px; }
  .topbar { padding-inline: 14px; }
  .welcome-mark { margin-bottom: 16px; }
  .suggestions { grid-template-columns: minmax(0, 1fr); max-width: 310px; }
  .suggestions button { padding: 7px 10px; }
  .messages, .composer-area { width: calc(100% - 28px); }
}
