:root {
  --bg: #f5f4f1;
  --sidebar: #eceae6;
  --panel: #fffcf9;
  --ink: #1d1c1a;
  --muted: #6b675f;
  --line: #ddd9d2;
  --user: #e7e2da;
  --accent: #2f5d4e;
  --accent-ink: #f4faf7;
  --danger: #8d2f2f;
  --shadow: 0 16px 40px rgba(40, 36, 28, 0.12);
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
:root[data-theme="dark"] {
  --bg: #1c1e22;
  --sidebar: #15171a;
  --panel: #24272c;
  --ink: #f2f1ee;
  --muted: #b1ada4;
  --line: #34383f;
  --user: #2e333a;
  --accent: #8fbfb0;
  --accent-ink: #14221c;
  --danger: #ffb4a8;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { min-height: 100vh; display: flex; flex-direction: column; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.ai-notice { margin: 0; text-align: center; padding: 0.4rem 0.8rem; background: var(--sidebar); border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 0.5rem; top: 0.5rem; background: var(--panel); padding: 0.3rem 0.5rem; }
#app { flex: 1; min-height: 0; display: flex; }
.shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 0.75rem; gap: 0.6rem; }
.brand { display: flex; align-items: center; gap: 0.4rem; text-decoration: none; color: var(--ink); font-weight: 650; }
.mark { width: 0.8rem; height: 0.8rem; border: 2px solid var(--accent); border-bottom: 0; border-radius: 0.55rem 0.55rem 0 0; position: relative; }
.mark::after { content: ""; position: absolute; left: 0.16rem; bottom: -0.08rem; width: 0.24rem; height: 0.34rem; background: var(--accent); border-radius: 40%; }
.side-nav, .history { display: flex; flex-direction: column; gap: 0.35rem; min-height: 0; }
.history { overflow: auto; }
.search, .field, textarea, select {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem; padding: 0.55rem 0.7rem;
}
.chat-btn, .icon-btn, .send, .quiet {
  border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); padding: 0.55rem 0.8rem; cursor: pointer;
}
.quiet, .icon-btn { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.group-label { margin: 0.7rem 0 0.2rem; color: var(--muted); font-size: 0.78rem; }
.chat-row { display: flex; gap: 0.25rem; align-items: center; }
.chat-row button.history-item { flex: 1; text-align: left; background: transparent; border: 0; border-radius: 0.7rem; padding: 0.4rem 0.5rem; cursor: pointer; }
.chat-row.active button.history-item, .history-item:hover { background: var(--panel); }
.column { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.topbar { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; padding: 0.7rem 1rem; }
.model-line { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.badge { font-size: 0.75rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.45rem; color: var(--muted); }
.thread { flex: 1; overflow: auto; padding: 1rem 0 0.5rem; }
.thread-inner { width: min(740px, calc(100% - 2rem)); margin: 0 auto; display: flex; flex-direction: column; gap: 0.9rem; }
.empty { margin: auto; text-align: center; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.chips button { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 0.45rem 0.7rem; cursor: pointer; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: min(68ch, 100%); padding: 0.75rem 0.9rem; border-radius: 1.1rem; background: var(--panel); overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user); }
.bubble p { margin: 0.35rem 0; }
.bubble pre { background: var(--sidebar); padding: 0.7rem; border-radius: 0.8rem; overflow: auto; }
.msg-actions { display: flex; gap: 0.35rem; margin-top: 0.35rem; }
.composer-wrap { width: min(740px, calc(100% - 2rem)); margin: 0 auto 0.8rem; }
.composer { display: flex; gap: 0.4rem; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: 1.4rem; padding: 0.45rem; box-shadow: var(--shadow); }
.composer textarea { border: 0; background: transparent; resize: none; min-height: 2.6rem; max-height: 9rem; }
.lock, .capacity { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.85rem; text-align: center; }
.limit-state { background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem; padding: 0.8rem 0.9rem; }
.colophon { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; padding: 0.4rem 1rem 0.8rem; }
.colophon .licences { margin: 0.2rem 0 0.6rem; padding-left: 1.1rem; }
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; z-index: 3; }
.panel header, .code-tools { display: flex; gap: 0.4rem; align-items: center; padding: 0.5rem; }
.panel iframe, .panel pre { flex: 1; border: 0; width: 100%; margin: 0; }
.panel pre { overflow: auto; padding: 0.8rem; }
.kw { color: var(--accent); }
.alert { background: var(--panel); color: var(--danger); border: 1px solid var(--line); border-radius: 0.8rem; padding: 0.6rem 0.7rem; }
.stack { display: grid; gap: 0.7rem; }
.view { width: min(720px, calc(100% - 2rem)); margin: 1.5rem auto; }
.menu { display: none; }
#menu-toggle, #scrim { display: none; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw, 320px); z-index: 5; transform: translateX(-105%); }
  .sidebar.open { transform: translateX(0); }
  #menu-toggle { display: inline-flex; }
  #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 4; }
  #scrim[hidden] { display: none; }
}
