:root {
  --bg: #ffffff;
  --side: #f4f4f2;
  --raised: #f7f7f5;
  --hover: #ececea;
  --line: #e6e6e2;
  --text: #1b1b1a;
  --muted: #6c6c67;
  --faint: #9a9a94;
  --accent: #b4f00d;
  --accent-ink: #3f7d0a;
  --send: #1b1b1a;
  --send-ink: #ffffff;
  --warn: #9a6500;
  --bad: #b3261e;
  --ok: #2f6f0c;
  --focus: #4ab00b;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --read: 720px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161715; --side: #1d1e1c; --raised: #222321; --hover: #2a2b29; --line: #2f302d;
    --text: #ecebe6; --muted: #a3a39d; --faint: #75756f; --accent-ink: #b4f00d; --send: #ecebe6; --send-ink: #161715;
    --warn: #e5c34a; --bad: #ff8a80; --ok: #b4f00d; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161715; --side: #1d1e1c; --raised: #222321; --hover: #2a2b29; --line: #2f302d;
  --text: #ecebe6; --muted: #a3a39d; --faint: #75756f; --accent-ink: #b4f00d; --send: #ecebe6; --send-ink: #161715;
  --warn: #e5c34a; --bad: #ff8a80; --ok: #b4f00d; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.ico svg, .icon-btn svg, .send svg { width: 18px; height: 18px; display: block; }
.ico { display: inline-flex; }

.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 272px; flex-shrink: 0; background: var(--side); display: flex; flex-direction: column; padding: 20px 14px 16px; transition: margin-left .2s ease; }
.shell.collapsed .sidebar { margin-left: -272px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 18px; }
.brand { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; display: flex; align-items: center; }
.brand .bar { display: inline-block; width: 3px; height: 24px; background: var(--accent-ink); margin: 0 3px; border-radius: 1px; }
:root[data-theme="dark"] .brand .bar { background: var(--accent); }
.side-action { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 10px; text-align: left; font-size: 15px; }
.side-action:hover { background: var(--hover); }
.side-action.settings { margin-top: auto; color: var(--muted); }
.search { display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin: 6px 0 4px; border-radius: 10px; color: var(--muted); }
.search:focus-within { background: var(--bg); }
.search input { border: 0; background: transparent; outline: none; width: 100%; font-size: 14px; }
.side-label { color: var(--faint); font-size: 13px; padding: 16px 10px 6px; }
.recent { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.recent button { text-align: left; padding: 7px 10px; border-radius: 10px; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent button:hover { background: var(--hover); }
.recent button.active { background: var(--hover); font-weight: 550; }
.recent .empty { color: var(--faint); font-size: 13.5px; padding: 4px 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; min-height: 58px; }
.top-title { flex: 1; min-width: 0; font-size: 14.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
#show-sidebar { display: none; }
.shell.collapsed #show-sidebar { display: grid; }
.versions { display: flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--muted); }
.versions select { background: transparent; border: 1px solid var(--line); border-radius: 9px; padding: 4px 8px; }

.conversation { flex: 1; overflow-y: auto; padding: 8px 24px 24px; scroll-behavior: smooth; }
.thread { max-width: var(--read); margin: 0 auto; display: flex; flex-direction: column; gap: 22px; padding-top: 12px; }
.hero { max-width: var(--read); margin: 0 auto; text-align: center; padding-top: 18vh; }
.hero h1 { font-size: clamp(34px, 4.6vw, 52px); line-height: 1.1; letter-spacing: -0.025em; margin: 0 0 16px; font-weight: 700; }
.hero p { color: var(--muted); font-size: 17px; margin: 0; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 28px; }
.suggestions button { border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 14px; color: var(--muted); }
.suggestions button:hover { color: var(--text); background: var(--raised); }
.main.empty .conversation { flex: 0 1 auto; }
.main.empty .composer-area { margin-top: 32px; }
.main.empty { justify-content: flex-start; }

.msg-user { align-self: flex-end; max-width: 82%; background: var(--raised); border-radius: 18px; padding: 10px 16px; white-space: pre-wrap; word-wrap: break-word; }
.attachments { align-self: flex-end; display: flex; gap: 6px; flex-wrap: wrap; }
.doc-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13.5px; }
.doc-chip small { color: var(--faint); }
.msg-ai { white-space: pre-wrap; word-wrap: break-word; }
.msg-ai p { margin: 0 0 10px; }
.turn { position: relative; }
.turn { display: flex; gap: 8px; align-items: flex-start; }
.turn-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.turn-more { position: relative; opacity: 0; transition: opacity .15s; }
.turn:hover .turn-more, .turn:focus-within .turn-more, .turn-more:has(.turn-menu:not([hidden])) { opacity: 1; }
.more-btn { width: 30px; height: 30px; border-radius: 8px; color: var(--muted); font-size: 18px; line-height: 1; }
.more-btn:hover { background: var(--hover); color: var(--text); }
.turn-menu { bottom: auto; top: 34px; left: auto; right: 0; }
ul.plain { margin: 0; padding-left: 20px; }
ul.plain li { margin-bottom: 4px; }
.quiet { color: var(--muted); font-size: 13.5px; }
.quiet:hover { color: var(--text); }
.note { color: var(--muted); font-size: 14px; }
.note.center { text-align: center; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.item-detail { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.btn { border-radius: 10px; padding: 7px 14px; font-size: 14px; border: 1px solid var(--line); }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--send); color: var(--send-ink); border-color: var(--send); }
.btn.primary:hover { opacity: .9; background: var(--send); }
.done-line { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.done-line::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.doc { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; background: var(--raised); }
.doc-head strong { font-weight: 600; }
.doc-state { font-size: 13px; color: var(--muted); }
.doc-state.ok { color: var(--ok); }
.doc-state.bad { color: var(--bad); }
.doc-body { padding: 16px 18px; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.doc-foot { padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.checks { list-style: none; padding: 0; margin: 0 0 6px; font-size: 14px; }
.checks li { display: flex; gap: 8px; }
.checks .yes { color: var(--ok); }
.checks .no { color: var(--bad); }

.thinking { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.thinking .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .thinking .pulse { animation: none; } * { transition: none !important; } }

.composer-area { padding: 0 24px 16px; }
.composer { max-width: var(--read); margin: 0 auto; border: 1px solid var(--line); border-radius: 26px; padding: 14px 14px 10px 20px; background: var(--bg); box-shadow: 0 1px 2px rgba(0,0,0,.03); transition: border-color .15s; }
.composer:focus-within { border-color: var(--faint); }
.composer textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; font-size: 16px; line-height: 1.5; max-height: 240px; padding: 4px 0; }
.composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.plus { color: var(--text); }
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--send); color: var(--send-ink); display: grid; place-items: center; }
.send:disabled { opacity: .25; }
.pending { display: flex; gap: 6px; flex-wrap: wrap; }
.pending:not(:empty) { margin-bottom: 8px; }
.pending .doc-chip select { border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.pending .doc-chip button { color: var(--faint); }
.attach-wrap { position: relative; }
.menu { position: absolute; bottom: 44px; left: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 190px; box-shadow: 0 8px 24px rgba(0,0,0,.08); z-index: 5; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.menu button:hover { background: var(--hover); }
.footnote { max-width: var(--read); margin: 10px auto 0; text-align: center; color: var(--muted); font-size: 13px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-quiet { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.link-quiet .ico { color: var(--accent-ink); }
.link-quiet .ico svg { width: 15px; height: 15px; }
[hidden] { display: none !important; }
.notice { max-width: var(--read); margin: 4px auto 0; text-align: center; color: var(--faint); font-size: 12.5px; }

.workspace { width: 360px; flex-shrink: 0; border-left: 1px solid var(--line); overflow-y: auto; padding: 20px 22px 40px; }
.workspace h2 { font-size: 16px; margin: 0 0 4px; }
.workspace h4 { font-size: 13.5px; color: var(--muted); font-weight: 500; margin: 22px 0 8px; }
.workspace ul { margin: 0; padding-left: 18px; }
.workspace li { margin-bottom: 6px; }
.ws-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(620px, 92vw); max-height: 84vh; background: var(--bg); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,20,18,.35); }
.dlg { padding: 22px 24px 20px; }
.dlg h2 { margin: 0 0 6px; font-size: 19px; }
.dlg-body { max-height: 60vh; overflow-y: auto; margin: 12px 0 16px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; }
.history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.history .item-detail { white-space: pre-wrap; }
.source-text { white-space: pre-wrap; font-size: 14px; background: var(--raised); border-radius: 12px; padding: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 6px 12px; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--hover); font-weight: 550; }
.field-label { font-size: 14px; color: var(--muted); margin: 16px 0 6px; display: block; }
.textarea { width: 100%; min-height: 160px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); resize: vertical; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--send); color: var(--send-ink); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: min(560px, 90vw); box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 20; }

@media (max-width: 900px) {
  .workspace { position: fixed; right: 0; top: 0; bottom: 0; background: var(--bg); z-index: 10; box-shadow: -10px 0 30px rgba(0,0,0,.1); }
  .sidebar { position: fixed; z-index: 11; height: 100vh; }
  .shell:not(.collapsed) .main::before { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.2); z-index: 10; }
}
.block { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 10px; }
.inline-input { flex: 1; min-width: 180px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; background: var(--bg); }
