:root {
  color-scheme: light;
  --ink: #252624;
  --muted: #898b86;
  --line: #e8e8e2;
  --paper: #fbfbf8;
  --sidebar: #f3f3ef;
  --accent: #6d6758;
  --accent-dark: #4f4a40;
  --white: #fff;
  font-family: "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  height: 100vh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

button, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible { outline: 2px solid #928a77; outline-offset: 3px; }

.app-shell { display: flex; height: 100%; }
.sidebar {
  position: relative;
  z-index: 4;
  display: flex;
  flex: 0 0 264px;
  flex-direction: column;
  padding: 22px 14px 12px;
  background: var(--sidebar);
  border-right: 1px solid #ecece7;
}

.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 9px; }
.brand {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  color: #39392f;
  font: 800 21px/1 "Segoe UI", sans-serif;
  letter-spacing: -1.1px;
  text-decoration: none;
}
.brand-mark { width: 27px; height: 27px; color: #817966; }
.brand-mark svg, .welcome-orbit svg { width: 100%; height: 100%; }
.new-chat-button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  margin: 30px 0 27px;
  padding: 11px 11px;
  border: 1px solid #dfdfd8;
  border-radius: 9px;
  background: rgba(255,255,255,.57);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.new-chat-button:hover { background: white; border-color: #c9c9c0; }
.new-chat-button svg, .icon-button svg, .send-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.shortcut { margin-left: auto; color: #a1a198; font-size: 11px; }
.history-heading { padding: 0 10px 9px; color: #9c9c93; font-size: 10px; font-weight: 700; letter-spacing: 1.1px; }
.conversation-list { display: flex; flex: 1; flex-direction: column; gap: 3px; overflow: auto; }
.history-empty { padding: 11px 10px; color: #9b9b93; font-size: 12px; line-height: 1.5; }
.history-item {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #686961;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.history-item:hover, .history-item.active { background: #e9e9e3; color: #363730; }
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; }
.sidebar-footer { padding-top: 12px; }
.demo-note { display: flex; align-items: center; gap: 7px; padding: 9px 10px 13px; color: #86877f; font-size: 11px; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #8d9f7b; }
.profile-button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 8px; border: 0; border-top: 1px solid #e4e4de; background: transparent; cursor: default; text-align: left; }
.avatar { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 50%; background: #ded8c9; color: #5c5649; font-size: 12px; font-weight: 600; }
.profile-copy { display: flex; flex: 1; flex-direction: column; gap: 2px; }
.profile-copy strong { font-size: 11px; font-weight: 600; }
.profile-copy small { color: #96978e; font-size: 10px; }
.profile-menu-icon { width: 17px; height: 17px; fill: #898a82; }

.main-panel { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.topbar { display: flex; height: 62px; flex: none; align-items: center; justify-content: space-between; padding: 0 32px; border-bottom: 1px solid rgba(232,232,226,.7); }
.topbar-label { color: #686960; font-size: 12px; font-weight: 500; letter-spacing: .1px; }
.topbar-actions { display: flex; align-items: center; gap: 15px; }
.demo-pill { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid #e9e9e3; border-radius: 20px; color: #77786f; font-size: 10px; }
.icon-button { display: grid; width: 34px; height: 34px; flex: none; place-items: center; border: 0; border-radius: 7px; background: transparent; color: #77786f; cursor: pointer; }
.icon-button:hover { background: #f0f0eb; color: #34352f; }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.moon-icon { display: none; }
.model-picker select { max-width: 190px; padding: 6px 26px 6px 10px; border: 1px solid #e5e5de; border-radius: 7px; background: #fff; color: #66675f; font: inherit; font-size: 10px; outline: none; }
.model-picker select:focus-visible { outline: 2px solid #928a77; outline-offset: 2px; }
.model-picker select:disabled { color: #aaa99f; }
.status-dot.offline { background: #c17d70; }
.menu-button, .mobile-close { display: none; }

.conversation-view { position: relative; display: flex; min-height: 0; flex: 1; flex-direction: column; overflow: auto; }
.welcome { width: min(660px, calc(100% - 48px)); margin: auto; padding: 34px 0 38px; text-align: center; }
.welcome-orbit { width: 54px; height: 54px; margin: 0 auto 19px; color: #88806d; }
.eyebrow { margin: 0 0 10px; color: #969487; font-size: 9px; font-weight: 700; letter-spacing: 1.7px; }
h1 { margin: 0; color: #292a25; font: 600 clamp(30px, 4vw, 39px)/1.16 "Segoe UI", sans-serif; letter-spacing: -1.8px; }
.welcome-copy { max-width: 390px; margin: 13px auto 30px; color: #85867e; font-size: 13px; line-height: 1.7; }
.suggestion-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; text-align: left; }
.suggestion-card { display: flex; min-height: 66px; align-items: center; gap: 11px; padding: 12px; border: 1px solid #e9e9e3; border-radius: 10px; background: rgba(255,255,255,.63); cursor: pointer; text-align: left; transition: transform .15s, border-color .15s, background .15s; }
.suggestion-card:hover { transform: translateY(-1px); border-color: #d7d4ca; background: white; }
.suggestion-icon { display: grid; width: 32px; height: 32px; flex: none; place-items: center; border-radius: 9px; font-size: 17px; }
.lavender { background: #eeebf3; color: #77708c; }
.peach { background: #f6eee7; color: #a67d60; }
.mint { background: #e9f0e9; color: #71866e; }
.blue { background: #e9eff2; color: #708794; }
.suggestion-card span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; }
.suggestion-card strong { color: #494a44; font-size: 11px; font-weight: 600; }
.suggestion-card small { overflow: hidden; color: #94958c; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-card > svg { width: 14px; height: 14px; flex: none; fill: none; stroke: #aaa99f; stroke-width: 1.6; }
.mobile-break { display: none; }

.message-list { display: none; width: min(710px, calc(100% - 48px)); margin: 0 auto; padding: 32px 0 22px; }
.message-list.visible { display: flex; flex-direction: column; gap: 23px; }
.message { display: flex; align-items: flex-start; gap: 12px; animation: appear .2s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.message-avatar { display: grid; width: 29px; height: 29px; flex: none; place-items: center; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 600; }
.message.user .message-avatar { background: #c4bca9; color: #4d493f; }
.message.assistant .message-avatar { background: #7d786b; }
.message-body { min-width: 0; flex: 1; padding-top: 4px; }
.message-author { margin: 0 0 7px; color: #45463f; font-size: 11px; font-weight: 700; }
.message-text { color: #55564f; font-size: 13px; line-height: 1.75; overflow-wrap: anywhere; white-space: pre-wrap; }
.message.assistant .message-text { color: #45463f; }
.message-text p { margin: 0 0 12px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text h3, .message-text h4, .message-text h5 { margin: 14px 0 7px; color: #393a34; font-size: 13px; }
.message-text ul, .message-text ol { margin: 5px 0 12px; padding-left: 22px; }
.message-text li { padding: 2px 0; }
.message-text pre { margin: 10px 0 13px; padding: 14px; overflow-x: auto; border: 1px solid #e9e9e3; border-radius: 9px; background: #f5f5f1; color: #41423c; font: 12px/1.6 Consolas, "Courier New", monospace; white-space: pre; }
.message-text code { padding: 2px 4px; border-radius: 4px; background: #efeee9; color: #665c48; font: .92em Consolas, "Courier New", monospace; }
.message-text pre code { padding: 0; background: transparent; color: inherit; }
.typing-indicator { display: flex; width: fit-content; gap: 4px; padding: 10px 12px; border-radius: 12px; background: #f0f0eb; }
.typing-indicator i { width: 5px; height: 5px; border-radius: 50%; background: #8d8e85; animation: typing 1s infinite ease-in-out; }
.typing-indicator i:nth-child(2) { animation-delay: .15s; }
.typing-indicator i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.composer-wrap { width: min(710px, calc(100% - 48px)); flex: none; margin: 0 auto; padding: 0 0 16px; }
.composer { padding: 12px 13px 10px 16px; border: 1px solid #deded7; border-radius: 13px; background: #fff; box-shadow: 0 4px 20px rgba(43,43,35,.035); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: #bdb8ab; box-shadow: 0 4px 20px rgba(43,43,35,.06); }
.composer textarea { display: block; width: 100%; min-height: 27px; max-height: 150px; resize: none; border: 0; outline: 0; background: transparent; color: #363730; font-size: 13px; line-height: 1.55; }
.composer textarea::placeholder { color: #a3a39b; }
.composer textarea:focus-visible { outline: none; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.composer-hint { color: #aaa99f; font-size: 10px; }
.composer-controls { display: flex; align-items: center; gap: 10px; }
.key-hint { color: #b2b1a9; font-size: 9px; }
.send-button { display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 8px; background: #777263; color: white; cursor: pointer; transition: background .15s, opacity .15s; }
.send-button:hover:not(:disabled) { background: #585447; }
.send-button:disabled { cursor: default; opacity: .38; }
.send-button svg { width: 17px; height: 17px; }
.disclaimer { margin: 9px 0 0; color: #aaa99f; font-size: 9px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.toast { position: fixed; z-index: 10; bottom: 24px; left: 50%; padding: 9px 14px; transform: translate(-50%, 12px); border: 1px solid #e4e2db; border-radius: 8px; background: #fff; box-shadow: 0 5px 20px #00000012; color: #55564f; font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7e7e0;
  --muted: #a4a69e;
  --line: #383a36;
  --paper: #1d1e1b;
  --sidebar: #181916;
  --accent: #b6ae9b;
  --accent-dark: #d1c8b3;
  --white: #252622;
}
[data-theme="dark"] body,
[data-theme="dark"] .main-panel { background: var(--paper); color: var(--ink); }
[data-theme="dark"] .sidebar { border-color: #30312d; background: var(--sidebar); }
[data-theme="dark"] .sidebar-top .brand { color: #e3e1d8; }
[data-theme="dark"] .brand-mark, [data-theme="dark"] .welcome-orbit { color: #b5ad99; }
[data-theme="dark"] .new-chat-button { border-color: #3a3b36; background: #22231f; color: #deded6; }
[data-theme="dark"] .new-chat-button:hover { border-color: #55564e; background: #292a25; }
[data-theme="dark"] .history-item { color: #b1b2aa; }
[data-theme="dark"] .history-item:hover, [data-theme="dark"] .history-item.active { background: #2a2b26; color: #f0efe8; }
[data-theme="dark"] .profile-button { border-color: #33342f; }
[data-theme="dark"] .avatar { background: #454338; color: #e0d9c8; }
[data-theme="dark"] .topbar { border-color: #30312d; }
[data-theme="dark"] .topbar-label, [data-theme="dark"] .demo-pill { color: #b8b9b1; }
[data-theme="dark"] .demo-pill, [data-theme="dark"] .model-picker select { border-color: #3b3c37; background: #242521; color: #d1d1c9; }
[data-theme="dark"] .icon-button { color: #b9bab2; }
[data-theme="dark"] .icon-button:hover { background: #2c2d28; color: #f0efe8; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }
[data-theme="dark"] h1 { color: #e8e7df; }
[data-theme="dark"] .eyebrow { color: #aaa99c; }
[data-theme="dark"] .welcome-copy, [data-theme="dark"] .composer-hint { color: #a4a59d; }
[data-theme="dark"] .suggestion-card { border-color: #383a35; background: #232420; }
[data-theme="dark"] .suggestion-card:hover { border-color: #57574d; background: #292a25; }
[data-theme="dark"] .suggestion-card strong { color: #e1e0d8; }
[data-theme="dark"] .suggestion-card small, [data-theme="dark"] .suggestion-card > svg { color: #a8a99f; }
[data-theme="dark"] .lavender { background: #373440; color: #c0b5d7; }
[data-theme="dark"] .peach { background: #3a302a; color: #d2a98a; }
[data-theme="dark"] .mint { background: #2d382e; color: #a4c0a2; }
[data-theme="dark"] .blue { background: #2c3539; color: #a7c2ce; }
[data-theme="dark"] .message-author, [data-theme="dark"] .message.assistant .message-text { color: #e1e0d8; }
[data-theme="dark"] .message-text { color: #c4c5bd; }
[data-theme="dark"] .message-text h3, [data-theme="dark"] .message-text h4, [data-theme="dark"] .message-text h5 { color: #eeede6; }
[data-theme="dark"] .message.user .message-avatar { background: #514d42; color: #f1ecdf; }
[data-theme="dark"] .message.assistant .message-avatar { background: #777161; }
[data-theme="dark"] .message-text pre { border-color: #3a3b35; background: #161714; color: #e1e0d8; }
[data-theme="dark"] .message-text code { background: #33342e; color: #d2c8ae; }
[data-theme="dark"] .message-text pre code { background: transparent; color: inherit; }
[data-theme="dark"] .typing-indicator { background: #30312c; }
[data-theme="dark"] .composer { border-color: #40413a; background: #252622; box-shadow: 0 4px 20px #00000018; }
[data-theme="dark"] .composer:focus-within { border-color: #6a6659; }
[data-theme="dark"] .composer textarea { color: #e3e2da; }
[data-theme="dark"] .composer textarea::placeholder { color: #93948b; }
[data-theme="dark"] .send-button { background: #928a77; color: #171815; }
[data-theme="dark"] .send-button:hover:not(:disabled) { background: #b0a791; }
[data-theme="dark"] .disclaimer, [data-theme="dark"] .key-hint { color: #85867e; }
[data-theme="dark"] .toast { border-color: #3b3c36; background: #292a25; color: #e5e4dc; }

@media (min-width: 1100px) {
  .welcome { transform: translateY(-12px); }
}

@media (max-width: 720px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 278px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 12px 0 36px #0000000a; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 3; inset: 0; display: none; background: #21211f42; }
  .sidebar-scrim.visible { display: block; }
  .menu-button, .mobile-close { display: grid; }
  .topbar { height: 56px; padding: 0 15px; }
  .topbar-label { margin-right: auto; margin-left: 10px; }
  .topbar-actions { gap: 5px; }
  .demo-pill { padding: 5px 7px; font-size: 9px; }
  .model-picker select { max-width: 125px; }
  .welcome { width: min(460px, calc(100% - 36px)); padding: 30px 0 26px; }
  .welcome-orbit { width: 45px; height: 45px; margin-bottom: 15px; }
  .welcome-copy { max-width: 310px; margin: 11px auto 22px; font-size: 12px; }
  .suggestion-grid { gap: 8px; }
  .suggestion-card { min-height: 64px; gap: 8px; padding: 9px; }
  .suggestion-icon { width: 28px; height: 28px; }
  .suggestion-card strong { font-size: 10px; }
  .suggestion-card small { font-size: 9px; }
  .message-list, .composer-wrap { width: calc(100% - 32px); }
  .message-list { padding-top: 24px; }
  .composer-wrap { padding-bottom: 11px; }
  .disclaimer { font-size: 8px; }
}

@media (max-width: 420px) {
  .suggestion-grid { grid-template-columns: 1fr; }
  .suggestion-card { min-height: 56px; }
  .welcome { padding-top: 17px; }
  .mobile-break { display: initial; }
  .key-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
