:root {
    color-scheme: light dark;
    --bg: #f8f7f3;
    --paper: #fffefa;
    --ink: #2b2926;
    --muted: #6a655d;
    --line: #dedbd2;
    --accent: #9d462f;
    --soft: #f5e7df;
    font: 14px/1.52 system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
@media (prefers-color-scheme: dark) {
    :root { --bg: #211f1d; --paper: #292725; --ink: #f3efe9; --muted: #c0b8ac; --line: #423d37; --accent: #f2ac8e; --soft: #423129; }
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: flex; flex-direction: column; }
button, textarea { font: inherit; color: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
button, summary { cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.workspace-bar { display: flex; align-items: center; gap: 12px; padding: 0 18px; min-height: 46px; background: #282724; color: #f7f4ed; font-size: 13px; }
.workspace-icon { width: 24px; height: 23px; display: grid; place-items: center; background: #4c4037; border: 1px solid #77614f; border-radius: 6px; font: 700 12px/1 monospace; color: #f4c2a4; }
.crumb { color: #91897e; }
.project { color: #d6d0c7; }
#restart { margin-left: auto; display: flex; align-items: center; gap: 6px; color: inherit; background: transparent; border: 1px solid #605c55; border-radius: 6px; padding: 4px 9px; font-size: 12px; }
#restart:hover { background: #45413a; }
#restart span { font-size: 16px; }
main { flex: 1; min-height: 0; display: grid; grid-template-columns: clamp(280px, 25vw, 398px) minmax(0, 1fr); }
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); border-right: 1px solid var(--line); }
.chat-head { display: flex; gap: 11px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; color: var(--accent); background: var(--soft); border-radius: 9px; font: 30px/1 system-ui; }
.chat-head h1, .message h2 { margin: 0; font-size: 14px; font-weight: 650; }
.chat-head span { font: 11px/1.4 ui-monospace, monospace; color: var(--muted); }
.conversation { flex: 1; min-height: 0; overflow: auto; padding: 20px; scrollbar-width: thin; }
.message { margin: 0 0 20px; overflow-wrap: anywhere; }
.message h2 { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.message h2::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: #807c74; }
.assistant h2::before { content: '✳'; width: auto; height: auto; color: var(--accent); background: transparent; font: 16px/1 system-ui; }
.message p { margin: 6px 0; white-space: pre-line; }
.history, .batch { background: var(--paper); border: 1px solid var(--line); border-radius: 9px; margin-top: 10px; }
summary { padding: 9px 11px; font-size: 12px; font-weight: 600; }
summary span { color: var(--muted); float: right; font-weight: 400; }
.history ol { list-style: none; padding: 0 11px 7px; margin: 0; }
.history li { border-top: 1px solid var(--line); }
.history a { padding: 7px 4px; display: block; color: inherit; text-decoration: none; font-size: 12px; }
.history a:hover b { text-decoration: underline; }
.history small { display: block; color: var(--muted); font-size: 11px; }
.action-link { display: inline-flex; align-items: center; gap: 8px; padding: 5px 9px; margin: 4px 5px 0 0; border-radius: 6px; background: var(--soft); color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 650; }
.action-link:hover { text-decoration: underline; }
.batch pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16em; overflow: auto; margin: 0; padding: 10px; border-top: 1px solid var(--line); font: 11px/1.6 ui-monospace, monospace; }
.composer { margin: 6px 14px 14px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.composer:focus-within { border-color: var(--accent); }
textarea { width: 100%; resize: none; border: 0; outline: 0; background: transparent; }
.composer footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer code { color: var(--muted); font-size: 11px; }
.composer button { width: 30px; height: 30px; border: 0; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: 19px; }
.composer button:disabled { opacity: .4; cursor: default; }
.viewer { position: relative; min-height: 0; min-width: 0; background: var(--paper); }
#status { position: absolute; inset: 0; padding: 16px; background: var(--paper); margin: 0; }
iframe { display: block; width: 100%; height: 100%; border: none; }
.sr-only { position: absolute; clip-path: inset(50%); height: 1px; width: 1px; overflow: hidden; }
.mobile-nav { display: none; }
@media (max-width: 760px) {
    main { grid-template-columns: minmax(0, 1fr); }
    .mobile-nav { display: flex; gap: 5px; padding: 5px 12px; border-bottom: 1px solid var(--line); }
    .mobile-nav button { flex: 1; border: 0; border-radius: 5px; background: transparent; padding: 6px; font-size: 13px; }
    .mobile-nav [aria-pressed="true"] { color: var(--accent); background: var(--soft); font-weight: 650; }
    [data-pane="viewer"] .chat, [data-pane="chat"] .viewer { display: none; }
    .workspace-bar { gap: 7px; padding: 0 10px; }
}
