:root {
  color-scheme: light;
  --canvas: #eef1ef;
  --sidebar: #e9eeeb;
  --surface: #f8faf8;
  --surface-muted: #f1f4f2;
  --surface-hover: #e4eae6;
  --ink: #18221f;
  --ink-2: #56625e;
  --ink-3: #7b8581;
  --border: #d4dcd7;
  --border-strong: #bbc7c0;
  --accent: #2d715b;
  --accent-strong: #245d4b;
  --accent-soft: #deebe5;
  --running: #27845a;
  --warning: #ad6b1d;
  --danger: #b44538;
  --shadow: 0 10px 28px rgba(30, 47, 40, .08), 0 2px 6px rgba(30, 47, 40, .05);
  --sidebar-width: 264px;
  --control-height: 44px;
  --conversation-inline: clamp(18px, 5vw, 56px);
  --motion-fast: 120ms;
  --motion-base: 200ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f1513;
  --sidebar: #121a17;
  --surface: #18211e;
  --surface-muted: #1d2824;
  --surface-hover: #24312c;
  --ink: #e7eeea;
  --ink-2: #aab7b1;
  --ink-3: #7f8f88;
  --border: #2b3933;
  --border-strong: #3b4b44;
  --accent: #58a887;
  --accent-strong: #72ba9c;
  --accent-soft: #1b3329;
  --running: #63b78f;
  --warning: #d59b51;
  --danger: #df7f72;
  --shadow: 0 12px 32px rgba(0, 0, 0, .24), 0 2px 6px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
input, select, textarea { width: 100%; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
input { min-height: 44px; padding: 0 12px; }
select { min-height: 44px; padding: 0 34px 0 12px; }
textarea { padding: 12px 48px 12px 14px; line-height: 1.5; resize: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid rgba(45, 113, 91, .24); outline-offset: 2px; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; color: white; background: var(--accent-strong); border-radius: 6px; }
.offline-banner { position: fixed; z-index: 90; top: 0; left: 50%; transform: translateX(-50%); padding: 7px 14px; color: #fff; background: var(--danger); border-radius: 0 0 6px 6px; font-size: 12px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 28px 22px 22px; overflow-y: auto; background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; }
.brand span { display: grid; gap: 3px; }
.brand strong { font: 700 14px/1.2 Bahnschrift, "Microsoft YaHei UI", sans-serif; }
.brand small { color: var(--ink-3); font: 10px/1.2 "Cascadia Mono", Consolas, monospace; }
.host-summary { display: flex; align-items: center; gap: 10px; margin-top: 48px; padding: 14px 10px; border-block: 1px solid var(--border); }
.host-summary div { display: grid; gap: 3px; }
.host-summary strong { font-size: 12px; }
.host-summary small { color: var(--ink-3); font-size: 10px; }
.connection-dot { width: 8px; height: 8px; flex: none; background: var(--running); border-radius: 50%; box-shadow: 0 0 0 4px rgba(39, 132, 90, .12); }
.connection-dot.offline { background: var(--danger); box-shadow: 0 0 0 4px rgba(180, 69, 56, .12); }
.workspace-nav { display: grid; gap: 4px; margin-top: 32px; }
.nav-link { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 10px; color: var(--ink-2); border: 1px solid transparent; border-radius: 6px; font-size: 13px; font-weight: 600; text-decoration: none; }
.nav-link:hover { color: var(--ink); background: var(--surface-hover); }
.nav-link.current { color: var(--accent); background: var(--accent-soft); border-color: rgba(45, 113, 91, .14); }
.nav-icon { width: 16px; color: currentColor; text-align: center; font: 16px/1 Bahnschrift, sans-serif; }

.main { min-width: 0; min-height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr); background: var(--surface); }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 28px; border-bottom: 1px solid var(--border); }
.eyebrow { margin: 0 0 5px; color: var(--accent); font: 700 10px/1.2 "Cascadia Mono", Consolas, monospace; }
h1, h2, p { letter-spacing: 0; }
h1 { margin: 0; font: 700 24px/1.2 Bahnschrift, "Microsoft YaHei UI", sans-serif; }
h2 { margin: 0; font: 700 16px/1.25 Bahnschrift, "Microsoft YaHei UI", sans-serif; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.sync-state { color: var(--ink-3); font: 11px/1.2 "Cascadia Mono", Consolas, monospace; }
.device-identity { margin: 5px 0 0; color: var(--ink-3); font-size: 11px; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; color: var(--ink-2); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font-size: 19px; }
.icon-button:hover { color: var(--accent); border-color: var(--border-strong); }
.view-tabs { min-height: 50px; display: flex; align-items: end; gap: 22px; padding: 0 28px; border-bottom: 1px solid var(--border); }
.view-tab { min-height: 49px; padding: 0 2px; color: var(--ink-3); background: transparent; border: 0; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 600; }
.view-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.view { min-height: 0; }
.sessions-workspace { padding: 24px 28px 30px; overflow-y: auto; }
.empty-state { padding: 22px 10px; color: var(--ink-3); font-size: 12px; line-height: 1.7; }
.conversation { width: min(1120px, 100%); min-width: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; margin: 0 auto; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.conversation-head { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px var(--conversation-inline); border-bottom: 1px solid var(--border); }
.session-picker { min-width: 0; display: grid; grid-template-columns: auto minmax(220px, 520px); align-items: center; gap: 4px 12px; }
.session-picker label { color: var(--ink-2); font-size: 11px; font-weight: 700; }
.session-picker select { min-width: 0; height: var(--control-height); padding: 0 34px 0 11px; color: var(--ink); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; transition: border-color var(--motion-fast) ease-out, background-color var(--motion-fast) ease-out; }
.session-picker select[aria-busy="true"] { color: var(--ink-2); border-color: var(--border-strong); }
.conversation-head p { margin: 5px 0 0; color: var(--ink-3); font: 10px/1.3 "Cascadia Mono", Consolas, monospace; }
.session-picker p { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-actions { flex: none; display: flex; align-items: center; gap: 10px; }
.status-badge { min-height: 30px; flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; color: var(--ink-2); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 999px; font-size: 11px; font-weight: 650; white-space: nowrap; transition: color var(--motion-base) ease-out, border-color var(--motion-base) ease-out, background-color var(--motion-base) ease-out; }
.status-badge::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; }
.status-badge.running { color: var(--running); background: rgba(39, 132, 90, .08); border-color: rgba(39, 132, 90, .24); }
.status-badge.running::before { background: currentColor; box-shadow: 0 0 0 0 rgba(39, 132, 90, .24); animation: status-pulse 1.8s ease-out infinite; }
.status-badge.loading::before { background: transparent; border: 1.5px solid var(--border-strong); border-top-color: var(--accent); animation: activity-spin .8s linear infinite; }
.status-badge.stopped::before { background: transparent; border: 1.5px solid currentColor; }
.status-badge.completed { color: var(--accent-strong); border-color: rgba(45, 113, 91, .2); }
.status-badge.completed::before { background: currentColor; box-shadow: inset 0 0 0 2px var(--surface-muted); }
.status-badge.failed { color: var(--danger); background: rgba(180, 69, 56, .07); border-color: rgba(180, 69, 56, .22); }
.status-badge.failed::before { background: currentColor; border-radius: 2px; transform: rotate(45deg); }
.runtime-strip { min-height: 56px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px var(--conversation-inline); background: var(--surface-muted); border-bottom: 1px solid var(--border); transition: box-shadow var(--motion-base) ease-out; }
.runtime-strip.running { box-shadow: inset 2px 0 0 var(--running); }
.runtime-strip.failed { box-shadow: inset 2px 0 0 var(--danger); }
.runtime-strip.loading { box-shadow: inset 2px 0 0 var(--border-strong); }
.runtime-signal { position: relative; width: 22px; height: 22px; background: transparent; border: 1px solid var(--border-strong); border-radius: 50%; }
.runtime-signal::before { content: ""; position: absolute; inset: 7px; background: var(--border-strong); border-radius: 50%; }
.runtime-rotor.running { border: 2px solid rgba(39, 132, 90, .26); }
.runtime-rotor.running::before { background: var(--running); box-shadow: 0 0 0 3px rgba(39, 132, 90, .1); }
.runtime-rotor.running::after { content: ""; position: absolute; inset: -4px; border: 2px solid transparent; border-top-color: var(--running); border-right-color: var(--running); border-radius: 50%; animation: activity-spin .85s linear infinite; }
.runtime-rotor.loading { border-color: var(--border-strong); }
.runtime-rotor.loading::before { background: var(--accent); }
.runtime-rotor.loading::after { content: ""; position: absolute; inset: -2px; border: 2px solid transparent; border-top-color: var(--accent); border-radius: 50%; animation: activity-spin .9s linear infinite; }
.runtime-signal.failed { border-color: rgba(180, 69, 56, .4); }
.runtime-signal.failed::before { background: var(--danger); }
.runtime-copy { min-width: 0; display: grid; gap: 3px; }
.runtime-copy strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.runtime-copy small { overflow: hidden; color: var(--ink-3); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.runtime-metrics { color: var(--ink-3); font: 10px/1.2 "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transcript-shell { position: relative; min-height: 0; }
.transcript { height: clamp(300px, calc(100dvh - 490px), 620px); min-height: 0; padding: 26px var(--conversation-inline); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.turn { display: grid; gap: 16px; margin-bottom: 36px; }
.turn-divider { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font: 9px/1 "Cascadia Mono", Consolas, monospace; }
.turn-divider::before, .turn-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.message { max-width: min(680px, 88%); display: grid; gap: 7px; }
.message.user { justify-self: end; }
.message.agent { width: min(760px, 94%); max-width: none; justify-self: start; }
.message-label { color: var(--ink-3); font: 10px/1.2 "Cascadia Mono", Consolas, monospace; }
.message.user .message-label { text-align: right; }
.message-body { padding: 12px 14px; color: var(--ink); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 8px; font-size: 14px; line-height: 1.72; overflow-wrap: anywhere; }
.message.user .message-body { color: var(--accent-strong); background: var(--accent-soft); border-color: rgba(45, 113, 91, .18); }
.message.agent .message-body { max-width: 76ch; padding: 2px 0; background: transparent; border: 0; border-radius: 0; font-size: 15px; line-height: 1.78; }
.rich-text { display: grid; gap: 11px; white-space: normal; }
.rich-text p, .rich-text h3, .rich-text ul, .rich-text ol, .rich-text pre, .rich-text blockquote, .rich-text hr { margin: 0; }
.rich-text p { text-wrap: pretty; }
.message-heading { padding-top: 5px; color: var(--ink); font-size: 1em; font-weight: 700; line-height: 1.45; }
.message-heading:first-child { padding-top: 0; }
.message-list { display: grid; gap: 6px; padding-left: 1.45em; }
.message-list li { padding-left: .2em; }
.message-list li::marker { color: var(--accent); font-weight: 700; }
.inline-code { padding: 1px 5px; color: var(--ink); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 4px; font: .88em/1.45 "Cascadia Mono", Consolas, monospace; }
.inline-strong { font-weight: 700; }
.message-code { max-width: 100%; padding: 12px 14px; overflow-x: auto; color: var(--ink); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 6px; font: 12px/1.65 "Cascadia Mono", Consolas, monospace; tab-size: 2; }
.message-code[data-language]::before { content: attr(data-language); display: block; margin-bottom: 8px; color: var(--ink-3); font-size: 9px; }
.rich-text blockquote { padding: 3px 0 3px 12px; color: var(--ink-2); border-left: 2px solid var(--border-strong); white-space: pre-line; }
.rich-text hr { height: 1px; background: var(--border); border: 0; }
.activity-row { width: min(720px, 94%); display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 30px; padding: 3px 1px; color: var(--ink-2); font-size: 11px; }
.activity-row + .activity-row { margin-top: -10px; }
.activity-signal { width: 9px; height: 9px; display: inline-block; background: var(--border-strong); border-radius: 50%; }
.activity-signal.completed::after { content: ""; display: block; width: 3px; height: 5px; margin: -1px 0 0 2px; border: solid var(--surface); border-width: 0 1px 1px 0; transform: rotate(45deg); }
.activity-signal.running { width: 11px; height: 11px; background: transparent; border: 1.5px solid rgba(39, 132, 90, .28); border-top-color: var(--running); animation: activity-spin .8s linear infinite; }
.activity-signal.failed, .activity-signal.systemError, .activity-signal.interrupted { background: var(--danger); }
.activity-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-status { color: var(--ink-3); font: 9px/1.2 "Cascadia Mono", Consolas, monospace; }
.reasoning-trace { width: min(720px, 94%); color: var(--ink-2); border-left: 2px solid var(--border); }
.reasoning-trace summary { min-height: 36px; display: flex; align-items: center; gap: 9px; padding: 6px 11px; cursor: pointer; font-size: 12px; font-weight: 600; list-style: none; }
.reasoning-trace summary::-webkit-details-marker { display: none; }
.reasoning-trace summary::after { content: "+"; margin-left: auto; color: var(--ink-3); font: 12px/1 "Cascadia Mono", Consolas, monospace; }
.reasoning-trace[open] summary::after { content: "−"; }
.reasoning-body { padding: 5px 14px 12px 32px; color: var(--ink-2); font-size: 12.5px; line-height: 1.72; overflow-wrap: anywhere; }
.stream-caret { width: 2px; height: 1.05em; display: inline-block; margin-left: 4px; vertical-align: -.14em; background: var(--running); border-radius: 1px; animation: stream-caret 1s steps(2, jump-none) infinite; }
.stream-tail { min-height: 24px; display: flex; align-items: center; gap: 12px; color: var(--running); font-size: 11px; font-weight: 650; }
.stream-tail > span:first-child { width: 4px; height: 4px; margin-left: 1px; background: currentColor; border-radius: 50%; box-shadow: 7px 0 0 currentColor, 14px 0 0 currentColor; animation: stream-dots 1.2s ease-in-out infinite; }
.conversation-skeleton { width: min(760px, 94%); display: grid; gap: 13px; padding-top: 8px; }
.conversation-skeleton span { position: relative; width: var(--skeleton-width); height: 14px; overflow: hidden; background: var(--surface-muted); border-radius: 4px; }
.conversation-skeleton span:first-child { width: 96px; height: 10px; margin-bottom: 5px; }
.conversation-skeleton span::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 38%; background: rgba(255, 255, 255, .48); transform: translateX(-110%); animation: skeleton-sweep 1.45s var(--ease-out) infinite; }
:root[data-theme="dark"] .conversation-skeleton span::after { background: rgba(255, 255, 255, .07); }
.jump-latest { position: absolute; right: 20px; bottom: 16px; z-index: 3; min-height: 34px; padding: 0 11px; color: var(--accent-strong); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; box-shadow: var(--shadow); font-size: 10px; }
.jump-latest:hover { border-color: var(--accent); }
.conversation-empty { min-height: 100%; display: grid; place-content: center; gap: 8px; color: var(--ink-3); text-align: center; }
.conversation-empty strong { color: var(--ink-2); font-size: 13px; }
.conversation-empty span { font-size: 11px; }
.conversation-empty.error strong { color: var(--danger); }
.composer { position: relative; margin: 16px var(--conversation-inline) 20px; }
.composer textarea { min-height: 54px; max-height: 160px; background: var(--surface); box-shadow: var(--shadow); }
.send-button { position: absolute; right: 8px; bottom: 8px; width: 36px; height: 36px; display: grid; place-items: center; color: #fff; background: var(--accent); border: 0; border-radius: 6px; font-size: 18px; }
.send-button:hover { background: var(--accent-strong); }
@keyframes activity-spin { to { transform: rotate(360deg); } }
@keyframes status-pulse { 65%, 100% { box-shadow: 0 0 0 7px rgba(39, 132, 90, 0); } }
@keyframes stream-caret { 50% { opacity: .2; } }
@keyframes stream-dots { 0%, 100% { opacity: .35; transform: translateY(0); } 45% { opacity: 1; transform: translateY(-2px); } }
@keyframes skeleton-sweep { to { transform: translateX(370%); } }
@keyframes tunnel-pulse { 50% { box-shadow: 0 0 0 4px rgba(39, 132, 90, .12); } }
.connection-track { display: grid; grid-template-columns: 18px 1fr; gap: 0 10px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.track-line { grid-row: 1 / 4; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 5px 0; }
.track-line::before { content: ""; position: absolute; width: 1px; height: 92px; background: var(--border-strong); }
.track-line span { z-index: 1; width: 7px; height: 7px; background: var(--running); border: 2px solid var(--surface); border-radius: 50%; box-sizing: content-box; }
.track-copy { min-height: 48px; display: grid; align-content: start; gap: 3px; }
.track-copy strong { font-size: 11px; }
.track-copy small { color: var(--ink-3); font-size: 10px; }
.remote-access-status { padding: 20px 0 22px; border-bottom: 1px solid var(--border); }
.remote-access-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.remote-access-head h2 { margin: 0; font-size: 14px; }
.tunnel-status-dot { width: 8px; height: 8px; background: var(--border-strong); border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--border-strong); }
.tunnel-status-dot.running { background: var(--running); box-shadow: 0 0 0 1px rgba(39, 132, 90, .28); animation: tunnel-pulse 1.8s ease-in-out infinite; }
.tunnel-status-dot.failed { background: var(--danger); box-shadow: 0 0 0 1px rgba(180, 69, 56, .24); }
.tunnel-state-line { display: grid; gap: 3px; margin-top: 10px; }
.tunnel-state-line strong { font-size: 12px; }
.tunnel-state-line small { color: var(--ink-3); font-size: 10px; line-height: 1.5; }
.tunnel-facts { display: grid; gap: 7px; margin: 16px 0 0; }
.tunnel-facts div { min-width: 0; display: grid; grid-template-columns: 68px minmax(0, 1fr); align-items: baseline; gap: 12px; }
.tunnel-facts dt { color: var(--ink-3); font-size: 10px; }
.tunnel-facts dd { min-width: 0; margin: 0; overflow: hidden; color: var(--ink-2); font: 10px/1.45 "Cascadia Mono", Consolas, monospace; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.pairing-admin { padding-top: 22px; }
.pairing-admin label { display: block; margin: 16px 0 7px; color: var(--ink-2); font-size: 11px; }
.button { min-height: 42px; padding: 0 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font-weight: 600; }
.button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-strong); }
.button.compact { min-height: var(--control-height); padding-inline: 12px; font-size: 11px; }
.button.wide { width: 100%; margin-top: 10px; }
.qr-result { display: grid; justify-items: center; gap: 7px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.qr-result img { width: min(176px, 100%); aspect-ratio: 1; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.qr-result span, .qr-result small { color: var(--ink-3); font-size: 10px; }
.qr-result strong { font: 700 24px/1.2 "Cascadia Mono", Consolas, monospace; }
.devices-view { padding: 24px 28px; overflow-y: auto; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.section-heading > span { color: var(--ink-3); font-size: 11px; }
.device-list { margin-top: 20px; border-top: 1px solid var(--border); }
.device-row { min-height: 64px; display: grid; grid-template-columns: minmax(160px, 1fr) 180px 92px; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); }
.device-row strong { font-size: 13px; }
.device-row small { color: var(--ink-3); font-size: 10px; }
.devices-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(420px, 1fr); gap: clamp(28px, 5vw, 72px); }
.pairing-column { padding-right: clamp(0px, 2vw, 24px); border-right: 1px solid var(--border); }
.section-copy { max-width: 620px; margin: 12px 0 0; color: var(--ink-2); font-size: 12px; line-height: 1.65; }
.device-meta { display: grid; gap: 4px; }
.text-button { min-height: 36px; color: var(--danger); background: transparent; border: 1px solid transparent; border-radius: 6px; }
.text-button:hover { background: rgba(180, 69, 56, .08); }
.mobile-nav { display: none; }

.pair-screen { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); background: var(--canvas); }
.pair-brand { display: flex; align-items: center; gap: 9px; color: var(--ink-2); font: 700 10px/1.2 "Cascadia Mono", Consolas, monospace; }
.pair-brand img { width: 28px; height: 28px; border-radius: 6px; }
.pair-panel { width: min(420px, 100%); align-self: center; justify-self: center; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.pair-panel h1 { margin-bottom: 10px; }
.pair-copy { margin: 0 0 22px; color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.pair-panel label { display: block; margin-bottom: 7px; color: var(--ink-2); font-size: 12px; }
.pair-start, .pair-details { display: grid; }
.pair-memory { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 11px; align-items: start; margin-bottom: 18px; padding: 13px 0; border-block: 1px solid var(--border); }
.pair-memory-mark { position: relative; width: 24px; height: 24px; border: 1px solid var(--border-strong); border-radius: 50%; }
.pair-memory-mark::before { content: ""; position: absolute; width: 7px; height: 5px; top: 7px; left: 7px; border: solid var(--accent); border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.pair-memory div, .pair-ready div { min-width: 0; display: grid; gap: 3px; }
.pair-memory strong, .pair-ready strong { font-size: 12px; }
.pair-memory small, .pair-ready small, .comparison small { color: var(--ink-3); font-size: 10px; line-height: 1.55; }
.scan-button { min-height: var(--control-height); display: flex; align-items: center; justify-content: center; gap: 9px; }
.scan-icon { width: 16px; height: 16px; display: inline-block; background: linear-gradient(currentColor 0 0) 0 0 / 6px 1.5px no-repeat, linear-gradient(currentColor 0 0) 0 0 / 1.5px 6px no-repeat, linear-gradient(currentColor 0 0) 100% 0 / 6px 1.5px no-repeat, linear-gradient(currentColor 0 0) 100% 0 / 1.5px 6px no-repeat, linear-gradient(currentColor 0 0) 0 100% / 6px 1.5px no-repeat, linear-gradient(currentColor 0 0) 0 100% / 1.5px 6px no-repeat, linear-gradient(currentColor 0 0) 100% 100% / 6px 1.5px no-repeat, linear-gradient(currentColor 0 0) 100% 100% / 1.5px 6px no-repeat; }
.pair-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 13px; color: var(--ink-3); font-size: 10px; }
.pair-divider::before, .pair-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.pair-link-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 8px; }
.pair-link-row .button { min-height: 44px; }
.qr-scanner { display: grid; gap: 12px; }
.scanner-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.scanner-head strong { font-size: 13px; }
.scanner-viewport { position: relative; aspect-ratio: 1; overflow: hidden; background: #0b110f; border-radius: 6px; }
.scanner-viewport video { width: 100%; height: 100%; display: block; object-fit: cover; }
.scanner-frame { position: absolute; inset: 16%; border: 2px solid rgba(255, 255, 255, .85); border-radius: 6px; box-shadow: 0 0 0 999px rgba(4, 10, 8, .34); }
.qr-scanner > p { margin: 0; color: var(--ink-2); font-size: 11px; text-align: center; }
.pair-ready { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 11px; margin-bottom: 18px; color: var(--accent-strong); }
.pair-ready > span { width: 24px; height: 24px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 50%; font-size: 13px; }
.comparison { display: grid; justify-items: center; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.comparison span { color: var(--ink-3); font-size: 11px; }
.comparison strong { font: 700 30px/1.2 "Cascadia Mono", Consolas, monospace; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 11px; }
.toast { position: fixed; z-index: 110; right: 20px; bottom: 20px; max-width: min(360px, calc(100vw - 40px)); padding: 11px 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow); font-size: 12px; }
.sync-dialog { width: min(760px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 32px)); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); }
.sync-dialog::backdrop { background: rgba(10, 18, 15, .48); }
.dialog-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); max-height: inherit; }
.dialog-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-close { width: 36px; height: 36px; font-size: 22px; }
.dialog-body { min-height: 0; padding: 20px; overflow-y: auto; }
.sync-picker h3, .synced-catalog h3 { margin: 0; font-size: 13px; }
.sync-form-row { display: grid; grid-template-columns: minmax(200px, 1.4fr) minmax(160px, 1fr) auto; gap: 10px; margin-top: 12px; }
.form-error { min-height: 18px; margin: 8px 0 0; color: var(--danger); font-size: 11px; }
.synced-catalog { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.catalog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.catalog-heading span { color: var(--ink-3); font-size: 11px; }
.synced-session-list { margin-top: 10px; border-top: 1px solid var(--border); }
.synced-session-row { min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); }
.synced-session-meta { min-width: 0; display: grid; gap: 4px; }
.synced-session-meta strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.synced-session-meta small { overflow: hidden; color: var(--ink-3); font: 9px/1.3 "Cascadia Mono", Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1120px) {
  .devices-layout { grid-template-columns: minmax(240px, 300px) minmax(320px, 1fr); gap: 28px; }
}

@media (max-width: 760px) {
  :root { --conversation-inline: 16px; }
  html, body { height: 100%; }
  body { overflow: hidden; background: var(--surface); }
  .app-shell { height: 100dvh; min-height: 0; display: block; padding-bottom: calc(64px + env(safe-area-inset-bottom)); overflow: hidden; }
  .sidebar { display: none; }
  .main { height: calc(100dvh - 64px - env(safe-area-inset-bottom)); min-height: 0; grid-template-rows: auto auto minmax(0, 1fr); overflow: hidden; }
  body.remote-mode .app-shell { padding-bottom: 0; }
  body.remote-mode .main { height: 100dvh; }
  body.remote-mode .mobile-nav { display: none; }
  .topbar { min-height: 72px; padding: max(14px, env(safe-area-inset-top)) 16px 12px; }
  .topbar h1 { font-size: 20px; }
  .device-identity { font-size: 10px; }
  .sync-state { display: none; }
  .view-tabs { display: none; }
  .sessions-workspace { height: 100%; min-height: 0; display: block; padding: 0; overflow: hidden; }
  .conversation { width: 100%; height: 100%; min-height: 0; border: 0; border-radius: 0; }
  .conversation-head { min-height: 92px; align-items: end; padding: 10px var(--conversation-inline); }
  .session-picker { width: 100%; grid-template-columns: 1fr; gap: 4px; }
  .session-picker label { font-size: 10px; }
  .session-picker select { width: 100%; height: 42px; font-size: 13px; }
  .session-picker p { display: none; }
  .conversation-actions { align-self: end; margin-left: 8px; }
  .conversation-actions .button.compact { width: 42px; padding: 0; overflow: hidden; color: transparent; font-size: 0; }
  .conversation-actions .button.compact span { color: var(--ink); font-size: 18px; }
  .runtime-strip { min-height: 56px; padding: 8px var(--conversation-inline); }
  .runtime-metrics { display: none; }
  .transcript-shell { min-height: 0; overflow: hidden; }
  .transcript { height: 100%; min-height: 0; padding: 18px var(--conversation-inline); }
  .message { max-width: 92%; }
  .message.agent { width: 96%; }
  .message-body { font-size: 14px; }
  .message.agent .message-body { max-width: 100%; font-size: 14.5px; line-height: 1.75; }
  .activity-row, .reasoning-trace { width: 96%; }
  .jump-latest { right: 14px; bottom: 12px; }
  .composer { position: relative; bottom: auto; z-index: 10; margin: 0; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--border); }
  .composer textarea { min-height: 50px; font-size: 16px; box-shadow: none; }
  .composer .send-button { right: 20px; bottom: 17px; }
  body.remote-mode .composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  body.remote-mode .composer .send-button { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 7px); }
  .devices-view { padding: 18px 16px; }
  .devices-layout { grid-template-columns: 1fr; gap: 30px; }
  .pairing-column { padding: 0 0 28px; border-right: 0; border-bottom: 1px solid var(--border); }
  .device-row { grid-template-columns: minmax(0, 1fr) 72px; }
  .device-row > small { display: none; }
  .mobile-nav { position: fixed; z-index: 40; inset: auto 0 0; height: calc(64px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
  .mobile-nav button { min-height: 64px; display: grid; place-content: center; gap: 3px; color: var(--ink-3); background: transparent; border: 0; font-size: 10px; }
  .mobile-nav button span { font-size: 16px; }
  .mobile-nav button.active { color: var(--accent); }
  .toast { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  body[data-mobile-view="devices"] .sessions-workspace { display: none; }
  .sync-form-row { grid-template-columns: 1fr; }
  .pair-screen { grid-template-rows: auto auto; align-content: start; gap: clamp(20px, 5dvh, 40px); overflow-y: auto; }
  .pair-panel { align-self: start; }
  .pair-panel { padding: 22px 20px; }
  .pair-panel input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .runtime-rotor.running::after, .runtime-rotor.loading::after, .status-badge.loading::before, .activity-signal.running { animation-duration: 1.8s !important; }
  .status-badge.running::before, .stream-tail > span:first-child, .stream-caret, .conversation-skeleton span::after { animation: none !important; }
  .tunnel-status-dot.running { animation: none !important; }
}
