:root,
:root.dark {
  color-scheme: dark;
  --bg: #0b1012;
  --paper: #131718;
  --ink: #f3f0e7;
  --page-muted: #b4c6c3;
  --line: #496460;
  --line-strong: #5f7f7a;
  --page-accent: #bce9dd;
  --on-accent: #142523;
  --focus: #ffe0a5;
  --caution: #efc181;
  --failure: #e99595;
  --code-bg: #0e1517;
  --raised-muted: #baccc9;
  --raised-accent: #c4f1e5;
  --raised-caution: #f7c989;
  --raised-failure: #f39f9f;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "DejaVu Sans Mono", SFMono-Regular, Menlo, monospace;
  --font-sans: var(--sans);
  --font-mono: var(--mono);
  --nacre: linear-gradient(100deg, #4d686b, #8fbed0, #c8b9d9, #a0dac9, #edf0ce, #647b82);
  --page-card: var(--paper);
  --chip: var(--code-bg);
  --foreground: var(--ink);
  --background: var(--paper);
  --card: var(--paper);
  --card-foreground: var(--ink);
  --popover: var(--paper);
  --popover-foreground: var(--ink);
  --muted: var(--chip);
  --muted-foreground: var(--page-muted);
  --accent: var(--chip);
  --accent-foreground: var(--ink);
  --secondary: var(--paper);
  --secondary-foreground: var(--ink);
  --primary: var(--page-accent);
  --primary-foreground: var(--on-accent);
  --destructive: var(--failure);
  --destructive-foreground: var(--bg);
  --border: var(--line-strong);
  --input: var(--line-strong);
  --ring: var(--focus);
  --syntax-keyword: #ff9fae;
  --syntax-entity: #d5b6ff;
  --syntax-constant: #9bd6ff;
  --syntax-string: #abe0b4;
  --syntax-variable: #f5ca94;
  --syntax-comment: #b4c6c3;
  --syntax-tag: #abe0b4;
  --syntax-heading: #9bd6ff;
  --syntax-list: #f5ca94;
  --syntax-addition-bg: #253e2c;
  --syntax-addition-fg: #abe0b4;
  --syntax-deletion-bg: #482b31;
  --syntax-deletion-fg: #ff9fae;
  font: 16px/1.65 var(--sans);
  color: var(--ink);
  background: var(--bg);
}
:root.light {
  color-scheme: light;
  --bg: #fbfaf7;
  --paper: #f0ede6;
  --ink: #1d1c1a;
  --page-muted: #6b675f;
  --line: #d9d4c9;
  --line-strong: #857f73;
  --page-accent: #2f5d50;
  --on-accent: #fbfaf7;
  --focus: #2f5d50;
  --caution: #655735;
  --failure: #a63224;
  --code-bg: #fbfaf7;
  --raised-muted: #625e56;
  --raised-accent: #285347;
  --raised-caution: #5b4d2b;
  --raised-failure: #98281b;
  --syntax-keyword: #9c2342;
  --syntax-entity: #65348a;
  --syntax-constant: #135f86;
  --syntax-string: #24653c;
  --syntax-variable: #834417;
  --syntax-comment: #625e56;
  --syntax-tag: #24653c;
  --syntax-heading: #135f86;
  --syntax-list: #655735;
  --syntax-addition-bg: #e3f0e5;
  --syntax-addition-fg: #24653c;
  --syntax-deletion-bg: #f7e5e5;
  --syntax-deletion-fg: #9c2342;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: inherit; background: var(--bg); color: var(--ink); }
a { color: var(--page-accent); text-underline-offset: 4px; }
header {
  padding: 6px max(16px, calc((100vw - 1280px)/2));
  border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 19px; }
.brand img { display: block; width: 28px; height: 28px; }
.brand .muted { font: 14px var(--mono); letter-spacing: .03em; }
.network, .pill { font: 13px var(--mono); white-space: nowrap; border: 1px solid var(--line-strong); border-radius: 4px; padding: 2px 8px; }
.network i { display: inline-block; width: 6px; height: 6px; background: var(--page-accent); border-radius: 50%; margin-right: 8px; }
main { max-width: 1280px; margin: auto; padding: 8px 16px; }
.workspace { min-width: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -.03em; line-height: 1.15; }
h2 { font-size: 28px; margin: 0 0 14px; }
h3 { font-size: 23px; margin: 18px 0 10px; }
p { margin: 10px 0; line-height: 1.65; }
.muted, .small.muted { color: var(--page-muted); }
.small, small, .service, .badge, footer { font-size: 14px; }
.mono, pre, code, label, summary, .service, [role="status"], .send-status, .network, .sandbox-label { font-family: var(--mono); }
.mono, pre, code { font-size: 14px; overflow-wrap: anywhere; }
.mono, pre { white-space: pre-wrap; }
label { display: block; font-size: 14px; letter-spacing: .03em; margin: 16px 0 7px; }
button, select, input, textarea { font: inherit; border-radius: 4px; }
input:not([class]), select:not([class]), textarea:not([class]) {
  width: 100%; border: 1px solid var(--line-strong); padding: 10px 12px;
  color: var(--ink); background: var(--code-bg);
}
button:not([class]), button.secondary, button.link, #send-recovery-email {
  border: 1px solid var(--page-accent); background: var(--page-accent);
  color: var(--on-accent); cursor: pointer; padding: 10px 14px; font-size: 14px; font-weight: 600;
}
button.secondary { background: transparent; color: var(--page-accent); border-color: var(--line-strong); }
button.link { border: 0; background: none; color: var(--page-accent); padding: 8px 0; text-align: left; }
button:hover, #send-recovery-email:hover { filter: brightness(.95); }
button:disabled { opacity: .45; cursor: not-allowed; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 4px;
}
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.panel, #provider-dialog {
  --page-muted: var(--raised-muted); --muted-foreground: var(--raised-muted);
  --page-accent: var(--raised-accent); --primary: var(--raised-accent);
  --caution: var(--raised-caution); --failure: var(--raised-failure); --destructive: var(--raised-failure);
}
.panel { background: var(--paper); border: 1px solid var(--line-strong); border-radius: 5px; margin: 18px 0; padding: 24px; }
.panel-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; padding-bottom: 6px; position: relative; }
.chat.panel { padding: 8px 12px; margin: 8px 0; }
#session-title { flex: 1 1 8rem; min-width: 0; margin: 0; font: 600 15px/1.4 var(--sans); letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Nacre is decorative: a retained edge and the verified model's rim. */
.chat > .panel-head::after { content: ""; position: absolute; height: 2px; left: 0; right: 0; bottom: 0; background: var(--nacre); }
.panel-head p { margin: 0; font-size: 13px; line-height: 1.4; }
.model-credit { display: flex; gap: 2px 12px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.credit-actions { display: inline-flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.credit-actions button.link, .send-status button.link { padding: 0; font-size: inherit; }
#chat-credit { white-space: nowrap; font: 13px var(--mono); color: var(--ink); }
#chat-credit-status:empty, #session-title:empty { display: none; }
#verified { flex: none; white-space: nowrap; font: 13px var(--mono); padding: 2px 8px; border: 1px solid transparent; border-radius: 4px; background: linear-gradient(var(--paper), var(--paper)) padding-box, var(--nacre) border-box; outline: 1px solid var(--line-strong); color: var(--ink); }
#verified:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.chat-toolbar { display: flex; align-items: center; gap: 6px; }
.chat-toolbar button { padding: 3px 10px; font-size: 13px; }
/* The encryption note is the model line's tooltip; screen readers still read it. */
.panel-head .privacy { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chat-body { height: calc(100dvh - 130px); min-height: 360px; }
#chat-host .max-w-3xl { max-width: none; }
#chat-host .max-w-3xl.p-4 { padding: 8px 4px 0; }
#chat-host message-editor textarea { padding: 8px 12px; }
#chat-host message-editor .pb-2 { padding-bottom: 4px; }
#chat-host message-editor button { min-height: 28px; min-width: 28px; }
.dsmack-sandbox.space-y-3 > :not(:first-child) { margin-top: 6px; }
.setup-feed > summary { display: flex; align-items: center; gap: 12px; list-style: none; padding: 0; color: inherit; font-size: inherit; }
.setup-feed > summary::-webkit-details-marker { display: none; }
.setup-feed > summary > :first-child { flex: 1; }
.setup-toggle { font: 12px var(--mono); color: var(--page-accent); white-space: nowrap; }
.setup-toggle::after { content: " ▸"; }
.setup-feed[open] .setup-toggle::after { content: " ▾"; }
.setup-feed ol { list-style: none; margin: 6px 0 0; padding: 6px 8px; font: 12px/1.5 var(--mono); border: 1px solid var(--line); border-radius: 4px; overflow-wrap: anywhere; }
.setup-feed li span { display: inline-block; min-width: 5ch; text-align: right; color: var(--page-muted); }
#empty-chat { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 12px 32px; text-align: center; }
#empty-chat img { display: block; width: 220px; max-width: 60vw; height: auto; }
.chat:has(#empty-chat:not([hidden])) #model-privacy { display: none; }
#empty-chat p { margin: 12px 0 0; color: var(--page-muted); max-width: 100%; font: 16px/1.65 var(--sans); }
#chat-host .user-message-container { background: var(--code-bg); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 5px; backdrop-filter: none; }
#chat-host .markdown-content { font-size: 16px; line-height: 1.65; }
#chat-host .markdown-content code:not(.hljs) { color: var(--ink); background: var(--code-bg); }
#chat-host .text-xs { font-size: 14px; }
#chat-host .shadow-sm, #chat-host .shadow-xs { box-shadow: none; }
#chat-host message-editor > div { border-color: var(--line-strong); border-radius: 5px; box-shadow: none; }
#chat-host message-editor textarea { font: 16px/1.65 var(--sans); color: var(--ink); }
#chat-host message-editor textarea::placeholder { color: var(--page-muted); opacity: 1; }
#chat-host message-editor button { border-radius: 4px; }
#chat-host code-block, #chat-host console-block { font-size: 14px; }
.send-status { margin: 6px 16px 14px; color: var(--page-muted); font-size: 14px; }
.send-status:empty, #capacity-status:empty { display: none; }
#capacity-status { font-size: 14px; background: var(--chip); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 4px; }
#alert { --failure: var(--raised-failure); border: 1px solid var(--failure); background: var(--paper); color: var(--failure); padding: 14px 18px; border-radius: 4px; overflow-wrap: anywhere; }
.reply-recovery { padding: 12px 16px; margin: 12px 0; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--code-bg); color: var(--ink); }
.reply-recovery p { margin: 0 0 8px; }
.code-attachment { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 8px 0; }
.code-attachment label { position: relative; overflow: hidden; cursor: pointer; margin: 0; color: var(--page-accent); border: 1px solid var(--line-strong); padding: 1px 8px; border-radius: 4px; font-size: 12px; }
.code-attachment input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.code-attachment label:focus-within { outline: 3px solid var(--focus); outline-offset: 4px; }
.code-attachment span { flex: 1; min-width: 140px; }
#advanced > summary { padding: 0; }
#advanced[open] > summary { margin-bottom: 20px; }
summary { cursor: pointer; color: var(--page-accent); font-size: 14px; padding: 10px 0; }
.account-details { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.account-details section, .account-details .trust { min-width: 0; }
.trust { grid-column: 1/-1; }
pre { background: var(--code-bg); border: 1px solid var(--line-strong); padding: 14px 16px; border-radius: 4px; line-height: 1.6; }
details pre { max-height: 240px; overflow: auto; }
#wallet { padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--line-strong); border-radius: 4px; overflow-wrap: anywhere; }
#continuity-panel { margin: 24px 0; }
#link-qr, #link-camera { display: block; max-width: 100%; margin: 16px 0; }
#send-recovery-email { display: inline-block; border-radius: 4px; text-decoration: none; margin: 10px 0; }
.recovery-notice { border: 2px solid var(--raised-caution); background: var(--paper); color: var(--ink); padding: 18px; border-radius: 4px; margin-bottom: 20px; }
.recovery-notice strong { font-size: 18px; }
#artifacts-host { display: flex; flex-direction: column; height: 650px; min-height: 360px; padding: 0; overflow: hidden; }
#artifacts-host artifacts-panel { flex: 1; min-height: 0; min-width: 0; }
#artifacts-host button { font: inherit; }
#artifacts-host iframe { background: white; }
.artifact-budget, .artifact-share { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; flex: none; }
.artifact-budget strong { overflow-wrap: anywhere; }
.artifact-budget span { flex: 1; min-width: 180px; }
.artifact-budget input { width: 90px; margin: 0; }
.artifact-budget button, .artifact-share button { margin: 0; }
.artifact-share span { flex: 1; min-width: 160px; }
.artifact-share input { width: 100%; font-size: 14px; }
.chat-exports { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 0; font-size: 14px; }
.chat-exports span { font-weight: 600; }
.message-feedback { margin: 0 16px; font-size: 14px; }
.message-feedback > button.link { font-size: 14px; padding: 4px 0; }
.message-feedback form { display: flex; gap: 8px; margin: 4px 0 8px; }
.message-feedback input { min-width: 0; flex: 1; padding: 6px; }
.message-feedback button.secondary { padding: 6px 10px; }
.feedback-note { color: var(--page-muted); white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0; }
#provider-dialog { width: min(540px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--paper); color: var(--ink); }
#provider-dialog::backdrop { background: #0009; }
footer { color: var(--page-muted); text-align: center; padding: 24px 0; }

/* Dsmack belongs to execution surfaces; their porcelain stays light in both themes. */
.dsmack-sandbox, #sandbox-evidence, #chat-host tool-message {
  --paper: #f6f3ee; --ink: #292b2a; --page-muted: #625e56; --page-accent: #a63224;
  --code-bg: #f6f3ee; --chip: #f6f3ee; --page-card: #f6f3ee;
  --line: #d9d4c9; --line-strong: #857f73; --focus: #a63224;
  --foreground: #292b2a; --background: #f6f3ee;
  --card: #f6f3ee; --card-foreground: #292b2a;
  --muted: #f6f3ee; --muted-foreground: #625e56;
  --accent: #f6f3ee; --accent-foreground: #292b2a;
  --primary: #a63224; --primary-foreground: #f6f3ee;
  --destructive: #a63224; --border: #857f73; --input: #857f73;
  --failure: #a63224; --on-accent: #f6f3ee;
  --syntax-keyword: #a63224; --syntax-entity: #65348a; --syntax-constant: #135f86;
  --syntax-string: #24653c; --syntax-variable: #834417; --syntax-comment: #625e56;
  --syntax-tag: #24653c; --syntax-heading: #135f86; --syntax-list: #655735;
  color: var(--ink); background: var(--paper); color-scheme: light;
}
.account-details > .dsmack-sandbox, #sandbox-evidence, #artifact-guest-card {
  padding: 18px; border: 1px solid #857f73; border-left: 3px solid #a63224; border-radius: 4px;
}
.dsmack-sandbox > h2, #sandbox-evidence > h3 { color: #a63224; }
.sandbox-label, #chat-host tool-message:not(:has(.sandbox-label)) > div::before {
  display: block; margin: 0 0 4px; font: 13px/1.5 var(--mono); color: #a63224;
}
#chat-host tool-message:not(:has(.sandbox-label)) > div::before { content: "Dsmack sandbox"; }
#chat-host tool-message > div { border-color: #857f73; border-left: 3px solid #a63224; background: #f6f3ee; color: #292b2a; border-radius: 4px; box-shadow: none; }
#chat-host tool-message [class*="text-green-"] { color: #292b2a; }
#chat-host tool-message console-block pre { background: #f6f3ee !important; }
#artifact-guest-card { margin: 12px 0; }
#artifact-guest-card pre { max-height: 240px; overflow: auto; }
#artifact-guest-card button { margin: 4px 8px 4px 0; }
#artifact-guest-card [data-guest-wallet] { overflow-wrap: anywhere; }

@media (max-width: 720px) {
  header { padding: 6px 16px; gap: 12px; }
  main { padding: 8px 16px; }
  .panel { padding: 18px; }
  .chat.panel { padding: 8px; }
  .account-details { display: block; }
  .account-details > section, .trust { margin: 24px 0; }
  .chat-body { height: calc(100dvh - 190px); min-height: 360px; }
  #empty-chat { padding: 20px 0; }
  #empty-chat img { width: 180px; }
  .code-attachment { padding: 4px 0 0; }
  .message-feedback form { flex-wrap: wrap; }
  .message-feedback input { flex-basis: 180px; }
  #artifacts-host { height: 70vh; }
}
