:root {
  color-scheme: dark;
  font: 16px/1.5 system-ui, sans-serif;
  --bg: #101719;
  --panel: #1b2728;
  --stroke: #35494a;
  --text: #f1f8f6;
  --muted: #bbcfc8;
  --accent: #b6f3cc;
  --on-accent: #142a21;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; background: radial-gradient(55rem 31rem at 79% 4%, #22403c, transparent 77%), var(--bg); color: var(--text); }
a { color: var(--accent); }
a, button, input, textarea, select { font: inherit; }
:focus-visible { outline: 2px solid #d5f8bf; outline-offset: 3px; }
h1, h2, p { margin: 0; }
p { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.top { display: flex; align-items: center; justify-content: space-between; gap: .55rem; padding: .8rem max(1rem, (100% - 1136px) / 2); border-bottom: 1px solid #ffffff12; background: #10191be8; backdrop-filter: blur(18px); }
.wordmark { color: var(--text); text-decoration: none; font-weight: 850; letter-spacing: -.05em; white-space: nowrap; }
.wordmark span { color: var(--accent); }
.top-actions, .conversation-actions { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .5rem .85rem; border: 1px solid var(--stroke); border-radius: 12px; color: var(--text); background: #263637; text-decoration: none; font-weight: 700; font-size: .89rem; cursor: pointer; transition: background-color .18s, translate .18s; }
.button:hover { background: #364d4a; }
.button:active { translate: 0 2px; }
.button:disabled { opacity: .46; cursor: default; }
.drawer-button { display: none; }
.layout { display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr); align-items: start; gap: 1rem; width: min(1136px, calc(100% - 32px)); margin: 1.15rem auto 1.5rem; flex: 1; }
.threads, .conversation, dialog { border: 1px solid var(--stroke); border-radius: 24px; background: linear-gradient(160deg,#203131,var(--panel) 68%); box-shadow: 0 18px 48px #070d1057; }
.threads { display: grid; gap: .8rem; padding: .9rem; }
.new-thread { justify-content: flex-start; background: #314841; }
.new-thread span { font-size: 1.14rem; }
.thread-list, .messages { padding: 0; margin: 0; list-style: none; }
.thread-list { display: grid; gap: .25rem; max-height: 57dvh; overflow: auto; }
.thread-list button { width: 100%; padding: .55rem .65rem; min-height: 42px; border: 1px solid transparent; border-radius: 10px; text-align: left; color: var(--muted); background: transparent; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.thread-list button:hover { color: var(--text); background: #263737; }
.thread-list button[aria-current="true"] { border-color: #587d71; background: #304942; color: #e4ffef; }
.storage-label { color: var(--muted); font-size: .81rem; }
.conversation { display: grid; grid-template-rows: auto auto minmax(150px,1fr) auto; gap: 1rem; min-height: min(720px,calc(100dvh - 152px)); padding: clamp(1rem, 3vw, 1.65rem); animation: appear .36s ease-out both; }
.conversation-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: .6rem; }
.conversation-head h1 { font-size: clamp(2rem,4.5vw,3rem); line-height: 1; letter-spacing: -.065em; }
.api-state { margin-top: .45rem; font-size: .88rem; }
.api-state::before { content: ""; display: inline-block; vertical-align: .12em; width: .43rem; aspect-ratio: 1; margin-right: .42rem; border-radius: 50%; background: #e6bc7e; }
.api-state[data-ready="true"] { color: var(--accent); }
.api-state[data-ready="true"]::before { background: var(--accent); box-shadow: 0 0 10px #b6f3cc78; }
.preferences { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; padding: .7rem; border: 1px solid var(--stroke); border-radius: 17px; background: #121d1ed6; }
.preference { display: grid; min-width: 0; gap: .26rem; font-size: .77rem; font-weight: 660; color: var(--muted); }
.preference label { padding-inline: .2rem; }
.preference select { min-width: 0; min-height: 45px; border: 1px solid #47625d; border-radius: 10px; padding: .45rem .55rem; color: var(--text); background: #243834; font-size: .91rem; }
.preference select:disabled { border-color: var(--stroke); color: var(--muted); background: #182625; }
.delete-thread { color: #ffd1d5; }
.empty { grid-area: 3 / 1; margin: auto; text-align: center; }
.empty h2 { font-size: 1.5rem; letter-spacing: -.045em; }
.empty-mark { display: grid; place-items: center; width: 54px; aspect-ratio: 1; margin: 0 auto .8rem; background: linear-gradient(135deg,#d5f8e6,var(--accent)); color: var(--on-accent); border-radius: 18px; font-size: 1.7rem; box-shadow: 0 12px 38px #72ce9c45; }
.messages { display: grid; align-content: start; gap: .8rem; grid-area: 3 / 1; max-height: 50dvh; overflow: auto; overscroll-behavior: contain; }
.message { padding: .7rem .9rem; border: 1px solid var(--stroke); border-radius: 14px; background: #142021; }
.message[data-role="user"] { background: #2b423a; }
.message b { display: block; margin-bottom: .27rem; color: var(--accent); font-size: .82rem; }
.message p { color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { grid-area: 4 / 1; display: grid; gap: .65rem; padding: .8rem; border-radius: 16px; border: 1px solid #47685d; background: #152222; }
textarea, input { width: 100%; margin: 0; color: var(--text); background: #111b1d; border: 1px solid #3a504e; border-radius: 11px; padding: .66rem; }
textarea { min-height: 70px; resize: vertical; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: .55rem; }
.composer-actions p { font-size: .88rem; }
.composer[data-pending] #message-status::before { content: ""; display: inline-block; width: .48rem; aspect-ratio: 1; margin-right: .4rem; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite alternate; }
.send { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.send:hover:not(:disabled) { background: #e2ffd3; }
footer { margin-top: auto; font-size: .86rem; text-align: center; padding: 1rem; color: var(--muted); }
dialog { width: min(410px,calc(100% - 24px)); padding: 1.2rem; color: var(--text); }
dialog::backdrop { background: #090f0bbf; backdrop-filter: blur(4px); }
dialog form { display: grid; gap: .65rem; margin-top: .7rem; }
dialog .top-actions { justify-content: flex-end; }
@keyframes appear { from { opacity: .9; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { from { opacity: .42; } to { opacity: 1; } }
@media (max-width: 700px) {
  .layout { grid-template-columns: minmax(0,1fr); width: calc(100% - 20px); margin-block: .65rem; gap: .65rem; }
  .drawer-button { display: inline-flex; }
  .top { padding: .62rem; }
  .top-actions .button { padding-inline: .62rem; font-size: .8rem; }
  .layout:not([data-open]) .threads { display: none; }
  .conversation { min-height: calc(100dvh - 124px); gap: .8rem; border-radius: 19px; }
  .preferences { padding: .55rem; gap: .5rem; }
  .threads { border-radius: 19px; }
  .messages { max-height: 51dvh; }
}
@media (max-width: 350px) { .top { flex-wrap: wrap; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
