:root {
  color-scheme: light;
  --bg: #ece9e0;
  --desktop: #edeae1;
  --surface: #fbfaf6;
  --surface-2: #f0ede5;
  --metal: #d8d4ca;
  --line: #bcb7ac;
  --text: #172337;
  --muted: #505a67;
  --accent: #204da9;
  --accent-strong: #173d8c;
  --accent-ink: #ffffff;
  --accent-soft: #e9eef8;
  --copper: #a64824;
  --copper-soft: #f7eee7;
  --danger: #a73a2c;
  --danger-soft: #f7e3df;
  --focus: #337acf;
  --shadow: 0 3px 9px #0a253326;
  --radius: 2px;
  --frame: #7d8591;
  --titlebar: #192b46;
  --font: Tahoma, "Segoe UI", sans-serif;
  --mono: Consolas, ui-monospace, monospace;
  --topbar-height: 54px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--desktop);
  color: var(--text);
  font: 16px/1.5 var(--font);
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-strong); text-underline-offset: .2em; }
button, input, select, textarea { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 12px 16px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 48px 16px; text-align: center; color: var(--muted); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid #a49e92; border-radius: var(--radius);
  background: #eeeae2; box-shadow: inset 1px 1px #fff, inset -1px -1px #c0b9ad;
  cursor: pointer; font-weight: 600;
  text-decoration: none; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: inset 0 1px #ffffff45; }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.quiet { border-color: transparent; background: transparent; box-shadow: none; }
.btn.quiet:hover { background: var(--surface-2); }
.btn.small { padding: 0 12px; font-size: 14px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); }
input:is([type=text], [type=email], [type=password]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.error {
  background: var(--danger-soft); color: var(--danger); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; display: flex; gap: 8px; align-items: flex-start;
}
.stack { display: flex; flex-direction: column; gap: 14px; }

/* Top bar */
.topbar {
  height: var(--topbar-height); padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 12px;
  color: #fffaf1; background: var(--titlebar); border-bottom: 3px double #8896a8;
}
.brand { display: flex; align-items: center; gap: 9px; font: 700 22px/1 Georgia, serif; color: inherit; text-decoration: none; min-height: 44px; }
.shell-label { padding-inline-start: 11px; border-inline-start: 1px solid #8190a4; color: #e7e0d4; font-size: 13px; }
@media (max-width: 405px) { .topbar:has(.who) .shell-label { display: none; } }
.pixel-mail {
  width: 24px; height: 18px; flex: none; display: inline-block; position: relative;
  background: #e5d8bd; border-block: 2px solid #fff6e2;
  clip-path: polygon(8% 0, 92% 0, 92% 11%, 100% 11%, 100% 89%, 92% 89%, 92% 100%, 8% 100%, 8% 89%, 0 89%, 0 11%, 8% 11%);
}
.pixel-mail::before {
  content: ''; position: absolute; top: 2px; left: 3px; width: 18px; height: 8px;
  background: #455971;
  clip-path: polygon(0 0, 11% 0, 11% 22%, 33% 22%, 33% 48%, 45% 48%, 45% 70%, 55% 70%, 55% 48%, 67% 48%, 67% 22%, 89% 22%, 89% 0, 100% 0, 100% 40%, 78% 40%, 78% 64%, 63% 64%, 63% 90%, 37% 90%, 37% 64%, 22% 64%, 22% 40%, 0 40%);
}
.pixel-mail::after { content: ''; position: absolute; width: 4px; height: 3px; background: #a64824; left: 10px; top: 8px; }
.spacer { flex: 1; }
.who { color: #e0eafa; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; display: none; }
.topbar .btn.quiet { color: #fff; border-color: #a6bde8; min-height: 34px; }
.topbar .btn.quiet:hover { background: #ffffff1f; }
@media (min-width: 640px) { .who { display: block; max-width: 260px; } }

/* Landing */
.landing {
  width: min(1220px, calc(100% - 36px)); margin: clamp(22px, 6vh, 70px) auto 30px;
  background: #f6f3eb; border: 1px solid var(--line); padding: clamp(16px, 4.4vw, 52px);
}
.landing-hero { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 25px; }
.landing h1 { font: 700 clamp(39px, 5.4vw, 76px)/1.02 Georgia, serif; letter-spacing: -.052em; }
.landing-copy > p { font-size: clamp(16px, 1.5vw, 19px); margin: 16px 0 21px; max-width: 35ch; }
.landing .sign-in { min-height: 47px; gap: 14px; }
.landing-access { margin-top: 16px; max-width: 460px; }
.landing-account-options { display: flex; flex-wrap: wrap; column-gap: 14px; border-bottom: 1px solid var(--line); }
.landing-account-options a, .account-panel a:not(.btn), .account-alternate {
  display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 650;
}
.landing-account-options a { padding: 0 3px; text-decoration: none; }
.landing-account-options a[aria-current] { box-shadow: inset 0 -2px var(--accent); }
.landing-account-options a:hover { text-decoration: underline; }
.account-panel-inline { padding-top: 12px; }
.account-panel-inline .account-intro { color: var(--muted); margin: 0 0 10px; font-size: 14px; }
.account-panel-inline form { gap: 9px; }
.account-panel-inline form > .btn { align-self: flex-start; }
.account-panel-inline h2:not(.sr-only) { font-size: 18px; margin-bottom: 6px; }
.account-fields { display: grid; gap: 10px; }
@media (min-width: 500px) {
  .account-panel-inline .account-fields:has([type=password]) { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
}
.demo-window { min-width: 0; border: 1px solid var(--frame); background: var(--metal); }
.window-caption { min-height: 33px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 11px; color: #fffaf1; background: #263d5a; }
.window-caption h2 { font-size: 14px; }
.demo-mode { color: #e1ddd6; font-size: 12px; }
.demo-stage { position: relative; height: clamp(164px, 24vw, 342px); overflow: hidden; background: #18283f; }
.demo-stage > canvas, .demo-wires, .patch-wires { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.demo-stage > canvas { opacity: 0; pointer-events: none; touch-action: pan-y; }
.demo-stage[data-renderer="three"] > canvas { opacity: 1; pointer-events: auto; }
.demo-stage[data-renderer="three"] .demo-flat { opacity: 0; visibility: hidden; }
.demo-flat { position: absolute; inset: 0; display: grid; place-items: center; }
.demo-unit {
  display: grid; grid-template-rows: 1fr 1.45fr 1fr; align-items: center;
  max-width: 89%; height: 74%; aspect-ratio: 2.13; padding: 5px 4%; border: 5px ridge #a09984;
  background: #c7bca3; box-shadow: 5px 6px #101a2a, inset 0 0 0 1px #faf0d280;
  font: 700 clamp(9px, 1.05vw, 13px)/1.2 var(--font);
}
.demo-plate-head, .demo-plate-foot { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.demo-plate-head { padding: 0 6%; }
.demo-plate-head strong { letter-spacing: .07em; }
.demo-ports {
  align-self: stretch; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center; border-block: 1px solid #8c8371; gap: 0;
}
.demo-ports span { display: grid; justify-items: center; gap: 3px; cursor: pointer; }
.demo-ports span:hover .jack { border-color: #be7849; }
.demo-outlet, .demo-ack { display: flex; gap: 7px; align-items: center; text-transform: uppercase; }
.demo-outlet { padding-inline-start: 3%; }
.demo-ack { padding-inline-end: 8%; }
.demo-ack i { width: 11px; height: 6px; border: 1px solid #39463d; background: #697266; }
.demo-stage[data-delivered] .demo-ack i { background: #38885a; box-shadow: 0 0 4px #b0e9a7; }
.demo-wires, .patch-wires { pointer-events: none; }
.jack { position: relative; z-index: 1; display: block; width: 17px; height: 17px; border: 3px solid #827c70; border-radius: 50%; background: #222730; box-shadow: inset 0 1px 2px #0b0d10, 0 1px #f4efe6; flex: none; }
.jack.lit, [aria-pressed=true] > .jack { border-color: #a95f3b; }
.demo-controls { display: grid; gap: 9px; padding: 10px; }
.demo-selector { min-width: 0; padding: 0; margin: 0; border: 0; }
.demo-selector legend { margin: 0 0 5px; padding: 0; font-size: 13px; font-weight: 700; }
.demo-choices { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.btn.demo-choice { padding: 4px 6px; min-height: 37px; gap: 4px; font-size: 12px; }
.demo-mark { width: 18px; height: 18px; display: grid; place-items: center; flex: none; }
.demo-choice :is(.demo-mark, .provider-icon) { width: 14px; height: 14px; }
.demo-choice[aria-pressed=true] { color: var(--accent-strong); background: var(--accent-soft); border-color: var(--accent); }
.demo-hint { color: var(--muted); font-size: 13px; }
.demo-dispatch { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.demo-dispatch .btn { min-height: 39px; padding-inline: clamp(5px, 2vw, 12px); font-size: clamp(11px, 3.1vw, 13px); }
.demo-status { min-height: 2.8em; display: flex; align-items: center; gap: 6px; font: 650 13px/1.35 var(--font); }
.demo-status::before { content: ''; width: 7px; height: 7px; flex: none; border: 1px solid #766b56; background: #c1b191; }
.demo-status[data-state="sending"]::before { border-color: #966915; background: #e4ab40; }
.demo-status:is([data-state="delivered"], [data-state="acknowledged"]) { color: #235533; }
.demo-status:is([data-state="delivered"], [data-state="acknowledged"])::before { border-color: #286445; background: #71ab76; }
.landing-steps { margin: clamp(20px, 4vw, 36px) 0 0; padding: 8px 0 0; list-style: none; display: grid; border-top: 1px solid var(--line); }
.landing-steps li { display: grid; align-content: start; gap: 3px; padding: 9px 0; }
.landing-steps li + li { border-top: 1px solid var(--line); }
.landing-steps span { font-size: 16px; }
@media (min-width: 600px) and (max-width: 799px) {
  .demo-stage { height: 38vw; }
}
@media (min-width: 800px) {
  .landing-hero { grid-template-columns: minmax(0, .9fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 60px); }
  .landing-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
  .landing-steps li + li { border-top: 0; }
}

/* Workspace list */
.page { max-width: 794px; margin: 0 auto; padding: 34px 16px 48px; }
.workspace-sheet { padding: clamp(16px, 4vw, 30px); background: var(--surface); border: 1px solid var(--frame); }
.directory-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 25px; }
.page h1 { font-size: 24px; letter-spacing: -.02em; margin-bottom: 16px; }
.directory-head h1 { margin: 0; font: 700 clamp(30px, 4vw, 44px)/1.06 Georgia, serif; letter-spacing: -.035em; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ws-list { display: grid; gap: 14px; list-style: none; margin: 0; padding: 0; }
.ws-item {
  position: relative; display: flex; align-items: center; gap: 13px;
  min-height: 62px; padding: 10px 13px; color: inherit; text-decoration: none; background: var(--surface-2); border: 1px solid var(--line);
}
.ws-item::before { content: ''; position: absolute; inset: -6px auto auto 12px; width: 52px; height: 6px; border: 1px solid var(--line); border-bottom: 0; background: inherit; }
.ws-item:hover { background: var(--accent-soft); }
.ws-item .name { font-weight: 600; }
.ws-item .meta { display: block; color: var(--muted); font-size: 14px; }
.workspace-folder { color: var(--accent); }
.workspace-detail { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.empty { padding: 24px 16px; color: var(--muted); text-align: center; }

.account-page { max-width: 520px; }
.account-panel {
  padding: clamp(18px, 4vw, 32px); background: var(--surface);
  border: 1px solid var(--frame); border-top: 4px solid var(--titlebar);
}
.account-panel h1 { margin: 0 0 10px; font: 700 clamp(26px, 5vw, 36px)/1.1 Georgia, serif; }
.account-panel p { margin-bottom: 14px; }
.account-panel .field p, .account-panel .error { margin-bottom: 0; }
.account-panel form { margin-bottom: 8px; }
.account-panel > .btn { margin-top: 8px; }
.account-reveal { display: flex; align-items: center; gap: 6px; min-height: 30px; cursor: pointer; }
.account-reveal input { accent-color: var(--accent); }

/* Workspace view */
.ws {
  --conversation-gutter: clamp(16px, 3.2vw, 26px);
  display: flex; flex-direction: column; background: var(--surface);
  height: calc(100vh - var(--topbar-height)); height: calc(100dvh - var(--topbar-height));
}
.ws-head { display: flex; align-items: center; gap: 12px; padding: 4px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ws-head h1 { font: 700 clamp(19px, 2.6vw, 28px)/1.15 Georgia, serif; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-back { padding-inline: 5px !important; }
.live { display: inline-flex; align-items: center; flex: none; gap: 7px; font-size: 13px; color: var(--muted); min-height: 44px; }
.live.on { color: var(--text); }
.live-lamp { width: 8px; height: 8px; background: #b38238; border: 1px solid #8a642f; }
.live.on .live-lamp { background: #69c7a0; border-color: #3d8465; }
.tabs { display: flex; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.tabs button {
  flex: 1; min-height: 44px; border: 0; border-bottom: 2px solid transparent;
  background: transparent; cursor: pointer; font-weight: 600;
}
.tabs button[aria-selected=true] { border-color: var(--accent); color: var(--accent-strong); }
.panes { flex: 1; min-height: 0; display: flex; }
.pane { flex: 1; min-width: 0; min-height: 0; display: none; flex-direction: column; }
.ws[data-tab=chat] .pane-chat, .ws[data-tab=agents] .pane-agents { display: flex; }
.pane-agents { overflow-y: auto; padding: 12px; gap: 10px; background: var(--metal); }
.pane-chat { background: var(--surface); }
.pane-chat .chat-head { display: none; }

@media (min-width: 900px) {
  .ws { margin: 16px auto; width: calc(100% - 32px); max-width: 1320px;
    height: calc(100dvh - var(--topbar-height) - 32px); min-height: 480px;
    border: 1px solid var(--frame); overflow: hidden; }
  .ws-head { padding: 4px 18px; }
  .tabs { display: none; }
  .panes { display: grid; grid-template-columns: clamp(270px, 24vw, 316px) minmax(0, 1fr); }
  .pane { display: flex; }
  .pane-agents { border-inline-end: 1px solid var(--line); }
  .pane-chat .chat-head { display: flex; flex: none; justify-content: flex-start; min-height: 46px; padding: 0 var(--conversation-gutter); border-bottom: 1px solid var(--line); background: var(--surface-2); }
}
@media (max-width: 460px) { .workspace-back span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }

/* Agents */
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pane-head h2 { font-size: 15px; font-weight: 650; }
.agent-list { display: grid; gap: 6px; }
.agent { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 7px; padding: 8px; border: 1px solid var(--line); background: #eeebe3; box-shadow: inset 0 1px #fdfbf6; }
.agent.patched { border-color: #ae7556; background: var(--copper-soft); }
.agent.revoked { opacity: .75; }
.agent-detail { display: grid; gap: 3px; }
.agent-top { display: flex; align-items: center; gap: 2px 6px; flex-wrap: wrap; }
.agent-name { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.provider-icon { display: block; width: 18px; height: 18px; object-fit: contain; flex: none; }
.agent-provider { display: grid; place-items: center; width: 24px; min-height: 26px; color: var(--muted); }
.agent-desc { color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.agent-meta { display: flex; flex-wrap: wrap; gap: 1px 10px; color: var(--muted); font-size: 12px; }
.manage-agent { min-height: 32px; padding-inline: 5px !important; color: var(--accent-strong); }
.manage-agent:hover { text-decoration: underline; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px;
  font-size: 12px; font-weight: 600;
}
.status-lamp { width: 10px; height: 6px; border: 1px solid #5b6876; border-radius: 2px; background: #a5a9aa; }
.pill.listening .status-lamp { border-color: #346344; background: #6ba073; }
.pill.revoked { color: var(--danger); }
.pill.revoked .status-lamp { border-color: #974937; background: #ce7e64; }
.badge-unread { color: var(--accent-strong); font-weight: 700; }
.agent-empty { padding: 18px 8px; text-align: left; }
.client-select { position: relative; }
.client-select select { padding-inline-start: 38px; }
.client-mark { position: absolute; inset: 0 auto 0 11px; display: grid; align-items: center; pointer-events: none; color: var(--muted); }

/* Patch bay */
.patch-panel { margin-top: auto; padding: 9px; border: 1px solid #979185; background: #cbc6ba; box-shadow: inset 1px 1px #ece9df, inset -1px -1px #afa899; }
.patch-head { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.patch-head h3, .patch-route { font-size: 12px; }
.patch-route { color: #384553; overflow-wrap: anywhere; }
.patch-stage { position: relative; min-height: 105px; padding-top: 4px; }
.patch-ports, .patch-outbox { position: relative; display: flex; align-items: start; justify-content: space-between; gap: 4px; flex-wrap: wrap; }
.patch-outbox { margin-top: 15px; align-items: end; }
.patch-outbox > span, .btn.patch-socket { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 30px; font-size: 11px; font-weight: 650; }
.btn.patch-socket { min-height: 42px; max-width: 100%; padding: 4px; border: 1px solid transparent; background: transparent; box-shadow: none; overflow-wrap: anywhere; }
.btn.patch-socket:hover, .btn.patch-socket[aria-pressed=true] { background: #efe9de; border-color: #a39b8b; }
.patch-outbox > span { padding-bottom: 3px; }

/* Chat */
.feed-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.feed { flex: 1; overflow-y: auto; padding: 22px max(var(--conversation-gutter), calc((100% - 760px) / 2)) 22px max(32px, calc((100% - 760px) / 2)); display: flex; flex-direction: column; gap: 15px; overscroll-behavior: contain; }
.older { align-self: center; }
.feed-empty { margin: auto; text-align: center; color: var(--muted); max-width: 32ch; }
.feed-empty > * { display: block; }
.feed-empty > .pixel-mail { margin: 0 auto 10px; }
.feed-empty strong { color: var(--text); }
.jump { position: absolute; right: 12px; bottom: 12px; box-shadow: var(--shadow); }
.msg { --signal: var(--copper); position: relative; display: flex; flex-direction: column; gap: 4px; width: 100%; }
.msg.mine { --signal: var(--accent); }
.msg::before { content: ''; position: absolute; inset: -15px auto 0 -17px; width: 1px; background: var(--line); }
.msg::after { content: ''; position: absolute; inset: 6px auto auto -20px; width: 7px; height: 7px; border: 2px solid var(--signal); border-radius: 50%; background: var(--surface); }
.msg-head { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; font-size: 13px; color: var(--muted); }
.msg-from { font-weight: 700; color: var(--text); }
.msg.mine .msg-from { color: var(--accent-strong); }
.bubble { background: var(--copper-soft); border: 1px solid #d8bda9; border-radius: var(--radius); padding: 10px 14px; min-width: 0; }
.msg.mine .bubble { background: var(--accent-soft); border-color: #c4d3ed; }
.msg-subject { font-weight: 650; margin-bottom: 2px; overflow-wrap: anywhere; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-foot { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 13px; color: var(--muted); align-items: center; }
.thread { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.rcpt { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 6px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.rcpt .icon { width: 13px; height: 13px; }
.rcpt.acked { border-color: #bf8e74; color: #7f331b; background: var(--copper-soft); }
.ack-need { font-weight: 600; }

/* Composer */
.composer { border-top: 1px solid var(--line); background: var(--surface-2); padding: 12px max(var(--conversation-gutter), calc((100% - 760px) / 2)) calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; max-height: 65%; overflow-y: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips .label { margin-right: 2px; }
.chip {
  min-height: 40px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 550;
}
.chip[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.chip .icon { width: 15px; height: 15px; }
.message-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.composer .row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.composer .row .check { margin-inline-start: auto; font-size: 13px; }
.composer .row .quiet { min-height: 34px; padding-inline: 0; margin-inline-end: auto; color: var(--accent-strong); }
@media (max-width: 440px) {
  .composer .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; }
  .composer .row .check { grid-column: 1; margin: 0; min-height: 36px; }
  .composer .row .primary { grid-area: 1 / 2 / 3 / 3; }
}

/* Dialog */
dialog {
  border: 1px solid var(--frame); border-top: 5px solid var(--titlebar); background: var(--surface); color: var(--text);
  padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 14, 12, .55); }
.dlg { padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.dlg h2 { font-size: 18px; letter-spacing: -.01em; }
.provider-title { display: flex; align-items: center; gap: 9px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.agent-setup { width: min(650px, calc(100vw - 24px)); border-top-width: 1px; overflow: hidden; }
.agent-setup .dlg {
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0; padding: 0; max-height: calc(100dvh - 26px);
  min-height: min(390px, calc(100dvh - 26px));
}
.setup-header {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--titlebar); color: #fff;
}
.setup-header h2 { line-height: 1.2; overflow-wrap: anywhere; }
.setup-header p { font-size: 13px; margin-top: 3px; color: #d8e2f3; }
.setup-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.setup-mark > :is(.provider-icon, .icon) { width: 24px; height: 24px; }
.setup-close { width: 44px; padding: 0; color: #fff; }
.setup-header .setup-close:hover { background: #30425e; }
.setup-nav {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 16px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.setup-nav .setup-tab {
  min-width: 0; border: 0; border-bottom: 3px solid transparent; border-radius: 0; box-shadow: none;
  padding: 4px 6px; background: transparent; font-size: 14px; line-height: 1.25;
}
.setup-nav .setup-tab:hover { background: var(--surface); }
.setup-nav .setup-tab[aria-current=step] { border-bottom-color: var(--accent); color: var(--accent-strong); background: var(--surface); }
.setup-nav .setup-tab:focus-visible { outline-offset: -4px; }
.setup-panel { display: grid; align-content: start; gap: 12px; min-height: 0; overflow: auto; padding: 20px; }
.setup-panel h3 { font-size: 17px; line-height: 1.3; }
.setup-panel h3:focus { outline: none; }
.setup-lead { color: var(--muted); font-size: 14px; max-width: 61ch; }
.setup-key { display: grid; gap: 6px; }
.setup-key-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
.setup-key-value {
  display: flex; align-items: center; min-width: 0; padding: 9px 12px;
  border: 1px solid var(--line); background: var(--surface-2); overflow-wrap: anywhere;
  font: 13px/1.45 var(--mono);
}
.setup-option { border-top: 1px solid var(--line); }
.setup-option > summary { display: list-item; padding: 10px 0; min-height: 44px; font-size: 14px; font-weight: 600; cursor: pointer; }
.setup-footer {
  display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px;
  border-top: 1px solid var(--line); background: var(--surface-2);
}
.setup-footer > .primary { margin-inline-start: auto; }
.copyblock { display: flex; flex-direction: column; gap: 6px; }
.copyblock .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.copyblock pre {
  margin: 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius);
  font: 13px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.copy-feedback { color: var(--muted); font-size: 13px; }
@media (max-width: 430px) {
  .setup-header, .setup-footer { padding-inline: 12px; }
  .setup-nav { padding-inline: 4px; }
  .setup-panel { padding: 14px; }
  .setup-key-row { grid-template-columns: 1fr 1fr; }
  .setup-key-value { grid-column: 1 / -1; min-height: 44px; }
}
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 50; }

@media (prefers-reduced-motion: no-preference) {
  .demo-stage > canvas { transition: opacity .24s ease-out; }
  .demo-stage[data-renderer="three"] .demo-flat {
    transition: opacity .24s ease-out, visibility 0s .24s;
  }
  .new-mail .bubble { animation: delivery .55s steps(3, end); }
  @keyframes delivery { from { border-inline-start-color: var(--accent); transform: translateY(4px); } }
}
