:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #212121;
  color: #f4f4f4;
  --muted: #b4b4b4;
  --line: #424242;
  --surface: #303030;
  --accent: #f1e5d7;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #e1b98c; outline-offset: 3px; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.app { display: flex; height: 100dvh; overflow: hidden; }
.sidebar { display: flex; flex-direction: column; width: 260px; flex: 0 0 260px; background: #171717; padding: 17px 12px 12px; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 7px; font-weight: 650; line-height: 1.15; }
.brand-detail { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 3px; }
.brand img, .welcome img, .avatar { object-fit: cover; object-position: 53% 38%; border-radius: 50%; border: 1px solid #ffffff26; }
.new-chat, .source { display: flex; align-items: center; gap: 9px; border-radius: 9px; padding: 10px; background: transparent; color: inherit; text-decoration: none; font-size: 14px; }
.new-chat { border: 1px solid var(--line); }
.new-chat:hover, .source:hover, .icon-button:hover { background: #ffffff0f; }
.sidebar nav { flex: 1; min-height: 0; overflow: auto; }
.sidebar h2 { margin: 0 8px 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
#history { display: grid; gap: 3px; }
.chat-row { display: flex; align-items: center; border-radius: 8px; min-width: 0; }
.chat-row:hover, .chat-row:has([aria-current="true"]) { background: var(--surface); }
.chat-link, .delete-chat { border: 0; background: transparent; border-radius: 8px; }
.chat-link { flex: 1; min-width: 0; padding: 9px 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; font-size: 14px; }
.delete-chat { padding: 7px; display: grid; place-items: center; color: var(--muted); }
.delete-chat:hover { color: #fff; background: #ffffff12; }
.delete-chat svg { width: 15px; height: 15px; }
.source { color: var(--muted); }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
header { min-height: 59px; display: flex; align-items: center; gap: 10px; padding: 0 17px; font-size: 17px; font-weight: 650; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.workspace { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.scroll-area { flex: 1; overflow: auto; min-height: 0; scrollbar-width: thin; }
.workspace:has(.welcome:not([hidden])) { justify-content: center; padding-bottom: min(12vh, 100px); }
.workspace:has(.welcome:not([hidden])) .scroll-area { flex: 0 1 auto; }
.welcome { padding: 24px 18px 22px; text-align: center; }
.welcome h1 { margin: 13px 0 5px; font-size: clamp(26px, 5vw, 34px); font-weight: 650; letter-spacing: -.035em; }
.welcome p { margin: 0; color: var(--muted); font-size: 15px; }
#messages, .compose-area { width: min(100% - 36px, 720px); margin-inline: auto; }
#messages { padding-block: 18px; }
.message { margin: 12px 0 26px; font-size: 15px; line-height: 1.65; }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { display: flex; justify-content: flex-end; }
.message.user p { max-width: 85%; border-radius: 22px; background: var(--surface); padding: 9px 16px; }
.message.assistant { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 11px; align-items: start; }
.message.pending { color: var(--muted); }
.avatar { margin-top: 1px; }
.compose-area { padding-top: 7px; padding-bottom: env(safe-area-inset-bottom); }
.suggestions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 15px; }
.suggestions button { padding: 8px 11px; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: #dedede; font-size: 13px; }
.suggestions button:hover { background: var(--surface); }
#composer { display: flex; align-items: flex-end; gap: 8px; padding: 9px; border: 1px solid #ffffff0d; background: var(--surface); border-radius: 27px; }
#composer:focus-within { border-color: #ffffff35; }
textarea { width: 100%; min-height: 36px; max-height: 148px; padding: 7px 5px 7px 9px; line-height: 22px; resize: none; background: none; border: 0; outline: none; }
textarea:focus-visible { outline: none; }
textarea::placeholder { color: var(--muted); }
#composer button { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: #212121; }
#composer button:hover:not(:disabled) { background: #fff3e8; }
#composer button:disabled { background: #454545; color: #aaa; }
.disclaimer { text-align: center; color: var(--muted); font-size: 12px; margin: 9px 0 11px; }
.error { color: #ffb9aa; font-size: 14px; margin: 0 4px 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); }
#backdrop { position: fixed; inset: 0; border: 0; background: #0009; z-index: 1; }

@media (max-width: 680px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 2; width: min(82vw, 280px); }
  header { padding-inline: 10px; }
  #messages, .compose-area { width: calc(100% - 24px); }
  .workspace:has(.welcome:not([hidden])) { padding-bottom: 5vh; }
}
