:root {
  color-scheme: dark light;
  --bg: #070a10;
  --bg-soft: #0d121c;
  --bg-card: #111827;
  --bg-elev: #172033;
  --border: #253044;
  --border-strong: #38455c;
  --text: #e8edf7;
  --text-muted: #8e99ad;
  --accent: #4f7cff;
  --accent-strong: #3d67e6;
  --accent-soft: rgba(79, 124, 255, 0.16);
  --success: #4ad295;
  --danger: #ff6b7a;
  --warn: #f0b341;
  --thinking: #b591ff;
  --tool: #5fbcff;
  --code-bg: #0b0f17;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.3);
  --skeleton-base: rgba(255, 255, 255, 0.06);
  --skeleton-shine: rgba(255, 255, 255, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
}

/* W1: explicit dark token block so a JS toggle can flip between
   `data-theme="dark"` and `data-theme="light"` without relying on
   the implicit `:root` defaults. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070a10;
  --bg-soft: #0d121c;
  --bg-card: #111827;
  --bg-elev: #172033;
  --border: #253044;
  --border-strong: #38455c;
  --text: #e8edf7;
  --text-muted: #8e99ad;
  --accent: #4f7cff;
  --accent-strong: #3d67e6;
  --accent-soft: rgba(79, 124, 255, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.3);
  --skeleton-base: rgba(255, 255, 255, 0.06);
  --skeleton-shine: rgba(255, 255, 255, 0.14);
}

/* W1: light theme. Tracks the same semantic tokens so any component
   styled with `var(--*)` automatically picks up the right palette. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --bg-card: #ffffff;
  --bg-elev: #f1f4fb;
  --border: #d8dee9;
  --border-strong: #b6bfd0;
  --text: #15213b;
  --text-muted: #5b6a85;
  --accent: #3760e6;
  --accent-strong: #2848c7;
  --accent-soft: rgba(55, 96, 230, 0.12);
  --success: #1f9c63;
  --danger: #d6334d;
  --warn: #d68a14;
  --thinking: #6b3ce0;
  --tool: #1f78d6;
  --code-bg: #eef1f7;
  --shadow: 0 1px 2px rgba(15, 32, 64, 0.06), 0 6px 18px rgba(15, 32, 64, 0.08);
  --skeleton-base: rgba(21, 33, 59, 0.08);
  --skeleton-shine: rgba(21, 33, 59, 0.16);
}

* {
  box-sizing: border-box;
}

/* Ensure the standard HTML `hidden` attribute always wins over layout rules
   like `display: flex|grid` defined on the element's class. */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 120ms ease, border-color 120ms ease;
}
button:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--border-strong);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: white;
}
button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}
button.danger {
  border-color: rgba(255, 107, 122, 0.4);
  color: var(--danger);
}
button.ghost {
  background: transparent;
}

input, textarea, select {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { resize: vertical; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }

.language-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.language-switcher--dropdown .language-switcher-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(36, 36, 33, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(18, 19, 20, 0.04);
  outline: none;
}

.language-switcher--dropdown .language-switcher-trigger:hover {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(36, 36, 33, 0.16);
  color: var(--text);
}

.language-switcher--dropdown .language-switcher-trigger:focus-visible {
  border-color: rgba(36, 36, 33, 0.28);
  box-shadow:
    0 0 0 3px rgba(36, 36, 33, 0.08),
    0 1px 2px rgba(18, 19, 20, 0.04);
}

.language-switcher-icon {
  display: block;
}

.language-switcher-caret {
  font-size: 10px;
  line-height: 1;
  opacity: 0.75;
}

.language-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  max-height: min(360px, 60vh);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.language-switcher-option {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  padding: 8px 10px;
  text-align: start;
  cursor: pointer;
}

.language-switcher-option.is-selected,
.language-switcher-option[aria-selected="true"] {
  background: var(--bg-elev);
}

.language-switcher-option:hover {
  background: var(--bg-soft);
}

/* Legacy pill switcher (unused; kept for older cached markup) */
.language-option {
  border: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
}
.language-option[aria-pressed="true"] {
  background: var(--bg-elev);
  color: var(--text);
}
.language-option:hover:not(:disabled) {
  border-color: transparent;
  background: var(--bg-card);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge.success { color: var(--success); border-color: rgba(74, 210, 149, 0.4); }
.badge.danger { color: var(--danger); border-color: rgba(255, 107, 122, 0.4); }
.badge.warn { color: var(--warn); border-color: rgba(240, 179, 65, 0.4); }
.badge.accent { color: var(--accent); border-color: rgba(108, 140, 255, 0.4); }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}
.dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(74, 210, 149, 0.18); }
.dot.offline { background: var(--text-muted); }
.dot.warn { background: var(--warn); }

.managed-model-card .row {
  margin-bottom: 6px;
}
.managed-model-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.managed-model-pill {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}
.managed-model-label {
  color: var(--text-muted);
  font-size: 12px;
}
.managed-model-pill code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.workspace-card input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.workspace-card #workspace-status {
  overflow-wrap: anywhere;
}

.workspace-actions {
  flex-wrap: wrap;
}

/* ---------- top nav ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

.topbar .me {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-decoration: none;
}

.topbar .brand:hover { text-decoration: none; }

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.10);
}

.topbar .nav-links {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.topbar .nav-links a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-muted);
}
.topbar .nav-links a.active {
  color: var(--text);
  background: var(--bg-elev);
}
.topbar .nav-links a:hover { text-decoration: none; color: var(--text); background: var(--bg-elev); }

.topbar .me {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted);
}

/* ---------- centered auth pages ---------- */

.auth-body {
  background:
    radial-gradient(ellipse at 18% -10%, rgba(108, 140, 255, 0.18), transparent 55%),
    radial-gradient(ellipse at 90% 10%, rgba(181, 145, 255, 0.16), transparent 55%),
    var(--bg);
  min-height: 100vh;
}
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-screen.split {
  align-items: stretch;
  padding: 0;
}
.auth-brand-panel {
  flex: 1.05;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px 48px;
  background:
    linear-gradient(160deg, rgba(108, 140, 255, 0.18), rgba(181, 145, 255, 0.10) 70%, transparent),
    var(--bg);
  border-right: 1px solid var(--border);
}
.auth-brand-copy {
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-brand-copy h2 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.3px;
}
.auth-brand-copy p {
  color: var(--text-muted);
  margin: 0;
  font-size: 15px;
}
.auth-brand-bullets {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
}
.auth-brand-bullets li {
  position: relative;
  padding-left: 20px;
}
.auth-brand-bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18);
}
.auth-main {
  flex: 0.95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
}
.auth-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p.lead { color: var(--text-muted); margin: 0 0 16px; }
.captcha-panel {
  display: flex;
  justify-content: flex-start;
  min-height: 44px;
}
.captcha-panel cap-widget {
  width: 100%;
  max-width: 280px;
}
.auth-mode-toggle { margin-bottom: 14px; }
.auth-footnote { margin: 16px 0 0; }
.oauth-panel {
  margin: 12px 0 14px;
}
.oauth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.oauth-divider::before,
.oauth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.oauth-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.oauth-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 600;
}
.oauth-button:hover {
  text-decoration: none;
  border-color: var(--border-strong);
  background: var(--bg-elev);
}

@media (max-width: 880px) {
  .auth-screen.split { flex-direction: column; }
  .auth-brand-panel { border-right: none; border-bottom: 1px solid var(--border); padding: 28px 24px; }
  .auth-brand-copy h2 { font-size: 22px; }
  .auth-main { padding: 24px 18px; }
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
}
.segmented button.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-muted); }

.error-banner {
  border: 1px solid rgba(255, 107, 122, 0.5);
  background: rgba(255, 107, 122, 0.1);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.notice-banner {
  border: 1px solid rgba(108, 140, 255, 0.5);
  background: rgba(108, 140, 255, 0.1);
  color: var(--accent);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.success-banner {
  border: 1px solid rgba(74, 210, 149, 0.45);
  background: rgba(74, 210, 149, 0.1);
  color: var(--success);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

/* ---------- Codex-style light auth pages ---------- */

.auth-body {
  --bg: #ffffff;
  --bg-soft: #f7f7f4;
  --bg-card: #ffffff;
  --bg-elev: #f1f1ee;
  --border: #e8e8e3;
  --border-strong: #d7d7cf;
  --text: #1f1f1d;
  --text-muted: #85847c;
  --accent: #222220;
  --accent-strong: #111110;
  --accent-soft: #f0f0eb;
  --success: #1d8f5d;
  --danger: #c33b4a;
  --code-bg: #f6f6f2;
  --shadow: 0 18px 48px rgba(30, 30, 20, 0.10), 0 2px 8px rgba(30, 30, 20, 0.06);
  background:
    radial-gradient(circle at 50% -20%, rgba(32, 32, 28, 0.05), transparent 34%),
    #fff;
  color: var(--text);
}

.auth-body .auth-screen.split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(360px, 0.95fr);
}

.auth-body .auth-brand-panel {
  padding: 28px clamp(26px, 5vw, 58px);
  background: #fff;
  border-right: 1px solid var(--border);
}

.auth-body .landing-brand {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.auth-body .brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #242421;
  color: #fff;
  box-shadow: none;
}

.auth-body .auth-brand-copy {
  max-width: 560px;
  margin-bottom: 6vh;
}

.auth-body .auth-brand-copy h2 {
  max-width: 640px;
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: -1.9px;
  font-weight: 650;
}

.auth-body .auth-brand-copy p {
  max-width: 520px;
  color: #68675f;
  font-size: 16px;
  line-height: 1.7;
}

.auth-body .auth-brand-bullets {
  color: #77766f;
  gap: 8px;
}

.auth-body .auth-brand-bullets li::before {
  background: #242421;
  box-shadow: 0 0 0 4px rgba(36, 36, 33, 0.08);
}

.auth-body .auth-main {
  padding: 48px clamp(24px, 5vw, 80px);
  background:
    radial-gradient(circle at 55% 24%, rgba(36, 36, 33, 0.05), transparent 30%),
    #fbfbf8;
}

.auth-body .auth-card {
  max-width: 410px;
  border-color: #e9e9e3;
  border-radius: 22px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.auth-body .auth-card h1 {
  color: var(--text);
  font-size: 22px;
  letter-spacing: -0.3px;
}

.auth-body .auth-card p.lead {
  color: var(--text-muted);
}

.auth-body .language-switcher {
  position: relative;
  z-index: 50;
}

.auth-body .language-switcher--dropdown .language-switcher-trigger {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(36, 36, 33, 0.12);
}

.auth-body .language-option[aria-pressed="true"] {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.auth-body .segmented {
  border-color: #e7e7df;
  border-radius: 14px;
  background: #f6f6f2;
}

.auth-body .segmented button {
  color: #77766f;
  border-radius: 11px;
}

.auth-body .segmented button.active {
  background: #fff;
  color: #242421;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}

.auth-body .oauth-divider::before,
.auth-body .oauth-divider::after {
  background: #e7e7df;
}

.auth-body .oauth-button {
  background: #fff;
  border-color: #e7e7df;
  color: #242421;
}

.auth-body .oauth-button:hover {
  background: #f6f6f2;
}

.auth-body input,
.auth-body textarea,
.auth-body select {
  border-color: #e6e6df;
  background: #fbfbf8;
  color: var(--text);
  border-radius: 12px;
}

.auth-body input:focus,
.auth-body textarea:focus,
.auth-body select:focus {
  border-color: #c9c9bf;
  box-shadow: 0 0 0 3px rgba(36, 36, 33, 0.08);
}

.auth-body button.primary {
  background: #242421;
  border-color: #242421;
  color: #fff;
  border-radius: 13px;
}

.auth-body button.primary:hover:not(:disabled) {
  background: #111110;
}

.auth-body .auth-footnote {
  color: #85847c;
  line-height: 1.55;
}

.auth-body .notice-banner {
  border-color: #e1e1da;
  background: #fbfbf8;
  color: #5d5c55;
}

.auth-body .error-banner {
  background: rgba(195, 59, 74, 0.08);
  border-color: rgba(195, 59, 74, 0.26);
}

.auth-body .password-field {
  position: relative;
}

.auth-body .password-field input {
  width: 100%;
  padding-right: 44px;
}

.auth-body .password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #8a929f;
  cursor: pointer;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.auth-body .password-toggle:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #2f3542;
}

.auth-body .password-toggle:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(84, 118, 255, 0.22);
}

.auth-body .password-toggle[aria-pressed="true"] {
  color: #59616f;
}

.auth-body .password-toggle-icon {
  display: block;
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.auth-body .password-hints {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
}

.auth-body .password-hints li[data-ok="true"] {
  color: #2f7a4d;
}

.auth-body .password-hints li[data-ok="false"] {
  color: #85847c;
}

.auth-body .password-hints li[data-ok="false"][data-touched="true"] {
  color: #b4233a;
}

.auth-body .field-hint {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.auth-body .field-hint.field-hint-ok {
  color: #2f7a4d;
}

.auth-body .field-hint.field-hint-bad {
  color: #b4233a;
}

.auth-body .reset-account-banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(76, 111, 255, 0.18);
  background: rgba(76, 111, 255, 0.08);
  color: #344054;
  font-size: 14px;
  line-height: 1.5;
}

@media (max-width: 880px) {
  .auth-body .auth-screen.split {
    display: flex;
    flex-direction: column;
  }
  .auth-body .auth-brand-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 24px;
  }
  .auth-body .auth-brand-copy {
    margin-top: 44px;
    margin-bottom: 12px;
  }
  .auth-body .auth-brand-copy h2 {
    font-size: 32px;
    letter-spacing: -1px;
  }
  .auth-body .auth-main {
    padding: 28px 18px;
  }
}

/* ---------- Modern auth refresh ---------- */

.auth-body {
  --auth-ink: #121314;
  --auth-muted: #667085;
  --auth-line: rgba(18, 19, 20, 0.09);
  --auth-panel: rgba(255, 255, 255, 0.72);
  --auth-glow-blue: rgba(76, 111, 255, 0.18);
  --auth-glow-violet: rgba(155, 91, 255, 0.16);
  background:
    radial-gradient(circle at 18% 14%, rgba(93, 131, 255, 0.18), transparent 30%),
    radial-gradient(circle at 86% 18%, rgba(179, 113, 255, 0.16), transparent 28%),
    linear-gradient(135deg, #fbfbff 0%, #f7f2ea 48%, #eef5ff 100%);
}

.auth-body .auth-modern {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.auth-body .auth-modern::before,
.auth-body .auth-modern::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: -1;
  border-radius: 999px;
  filter: blur(18px);
}

.auth-body .auth-modern::before {
  width: 360px;
  height: 360px;
  left: -120px;
  top: 12%;
  background: var(--auth-glow-blue);
}

.auth-body .auth-modern::after {
  width: 420px;
  height: 420px;
  right: -140px;
  bottom: -80px;
  background: var(--auth-glow-violet);
}

.auth-body .auth-modern .auth-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  min-height: 100vh;
  border-right: 0;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.14)),
    transparent;
}

.auth-body .auth-modern .auth-brand-copy {
  margin: 0;
  max-width: 620px;
}

.auth-body .auth-modern .auth-brand-copy h2 {
  background: linear-gradient(120deg, #15171a, #31437c 54%, #7a4cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-body .auth-modern .auth-brand-copy p {
  font-size: 17px;
  color: var(--auth-muted);
}

.auth-body .auth-modern .auth-brand-bullets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

.auth-body .auth-modern .auth-brand-bullets li {
  width: fit-content;
  padding: 9px 13px 9px 34px;
  border: 1px solid var(--auth-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: #4d5665;
  backdrop-filter: blur(18px);
}

.auth-body .auth-modern .auth-brand-bullets li::before {
  left: 14px;
  top: 15px;
  width: 7px;
  height: 7px;
  background: #5c7cff;
  box-shadow: 0 0 0 4px rgba(92, 124, 255, 0.14);
}

.auth-visual-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 520px;
}

.auth-device-card,
.auth-mini-card {
  border: 1px solid var(--auth-line);
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 20px 60px rgba(57, 72, 103, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(24px);
}

.auth-device-card {
  border-radius: 28px;
  padding: 18px;
}

.auth-device-title {
  margin-top: 22px;
  font-size: 25px;
  font-weight: 720;
  letter-spacing: -0.7px;
  color: var(--auth-ink);
}

.auth-device-subtitle {
  margin-top: 5px;
  color: var(--auth-muted);
  line-height: 1.55;
}

.auth-device-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.auth-mini-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: 22px;
  padding: 15px;
}

.auth-mini-card strong {
  color: var(--auth-ink);
}

.auth-mini-card span:last-child {
  color: var(--auth-muted);
  font-size: 12px;
}

.auth-mini-icon {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(92, 124, 255, 0.1);
  color: #4259d4;
  font-size: 11px;
  font-weight: 700;
}

.auth-body .auth-modern .auth-main {
  background: transparent;
}

.auth-body .auth-modern .auth-card {
  max-width: 460px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78)),
    rgba(255, 255, 255, 0.78);
  box-shadow: 0 28px 80px rgba(42, 50, 77, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(28px);
}

.auth-body .auth-modern .auth-card h1 {
  font-size: 29px;
  letter-spacing: -0.9px;
}

.auth-body .auth-modern .auth-card p.lead {
  margin-bottom: 18px;
  color: var(--auth-muted);
}

.auth-body .auth-modern .oauth-panel {
  margin: 16px 0;
}

.auth-body .auth-modern .oauth-title {
  margin-bottom: 8px;
  color: #5c6b84;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.auth-body .auth-modern .oauth-buttons {
  grid-template-columns: 1fr;
}

.auth-body .auth-modern .oauth-button {
  min-height: 50px;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 14px;
  border-radius: 16px;
  border-color: rgba(18, 19, 20, 0.1);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.auth-body .auth-modern .oauth-button:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 12px 30px rgba(43, 54, 88, 0.11);
}

.oauth-provider-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid rgba(18, 19, 20, 0.1);
  border-radius: 999px;
  background: #fff;
  color: #1f2937;
  font-size: 12px;
  font-weight: 800;
}

.auth-body .auth-modern .oauth-divider {
  margin: 14px 0 12px;
}

.auth-body .auth-modern .segmented {
  margin-bottom: 16px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(18, 19, 20, 0.045);
}

.auth-body .auth-modern .segmented button {
  min-height: 36px;
  border-radius: 999px;
  font-weight: 650;
}

.auth-body .auth-modern .field {
  gap: 7px;
}

.auth-body .auth-modern .field label {
  color: #566074;
  font-weight: 650;
}

.auth-body .auth-modern input {
  min-height: 48px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.82);
}

.auth-body .auth-modern button.primary {
  min-height: 50px;
  margin-top: 2px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #2f5cff, #7d4dff);
  box-shadow: 0 14px 34px rgba(85, 91, 255, 0.25);
  font-weight: 720;
}

.auth-body .auth-modern button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #244df0, #6b3df1);
  transform: translateY(-1px);
}

.auth-body .auth-modern .auth-footnote {
  text-align: center;
  color: #7a8495;
}

@media (max-width: 880px) {
  .auth-body .auth-modern .auth-brand-panel {
    min-height: auto;
    padding: 22px;
  }
  .auth-body .auth-modern .auth-brand-copy {
    margin-top: 30px;
  }
  .auth-visual-stack {
    display: none;
  }
  .auth-body .auth-modern .auth-main {
    padding: 16px;
  }
  .auth-body .auth-modern .auth-card {
    max-width: none;
    padding: 22px;
    border-radius: 24px;
  }
}

/* ---------- oauth complete ---------- */

.oauth-complete-body {
  background: #f7f8f6;
}

.oauth-complete-body .oauth-complete-screen {
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(232, 244, 235, 0.9) 0 34%, transparent 34% 100%),
    linear-gradient(152deg, transparent 0 64%, rgba(255, 230, 218, 0.86) 64% 100%),
    #f7f8f6;
}

.oauth-complete-body .oauth-complete-screen::before,
.oauth-complete-body .oauth-complete-screen::after {
  content: none;
}

.oauth-complete-body .oauth-complete-main {
  width: min(100%, 1020px);
  margin: 0 auto;
  padding: 28px;
}

.oauth-complete-station {
  position: relative;
  display: grid;
  grid-template-columns: minmax(340px, 0.94fr) minmax(390px, 0.86fr);
  gap: 48px;
  align-items: center;
  min-height: min(720px, calc(100vh - 56px));
}

.oauth-complete-topbar {
  position: absolute;
  top: 28px;
  left: 28px;
  right: 28px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.oauth-complete-body .oauth-complete-card {
  position: relative;
  align-self: center;
  padding: 38px;
  text-align: left;
  border: 1px solid rgba(31, 38, 35, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 22px 70px rgba(35, 45, 40, 0.12);
}

.oauth-complete-visual {
  position: relative;
  min-height: 480px;
  overflow: hidden;
}

.oauth-complete-body.oauth-complete-native .landing-brand {
  cursor: pointer;
}

.oauth-complete-body.oauth-complete-native .landing-brand::after {
  content: none;
}

.oauth-soft-ribbon {
  position: absolute;
  left: 36px;
  top: 116px;
  width: 330px;
  height: 180px;
  border-radius: 999px 999px 999px 120px;
  background: rgba(255, 223, 207, 0.72);
  transform: rotate(-12deg);
}

.oauth-paper {
  position: absolute;
  border: 1px solid rgba(31, 38, 35, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 50px rgba(35, 45, 40, 0.12);
}

.oauth-paper-back {
  left: 72px;
  top: 78px;
  width: 250px;
  height: 176px;
  background: #eef6ef;
  transform: rotate(-8deg);
}

.oauth-paper-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 26px;
}

.oauth-paper-grid span {
  height: 48px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.oauth-paper-main {
  left: 118px;
  top: 118px;
  z-index: 2;
  width: 232px;
  min-height: 190px;
  padding: 30px 28px;
}

.oauth-paper-main img {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(94, 73, 166, 0.16);
}

.oauth-paper-main strong {
  display: block;
  margin-top: 18px;
  color: #1e2421;
  font-size: 25px;
  line-height: 1;
}

.oauth-paper-main > span {
  display: block;
  width: 126px;
  height: 9px;
  margin-top: 18px;
  border-radius: 999px;
  background: #dce9df;
}

.oauth-paper-note {
  right: 36px;
  bottom: 92px;
  z-index: 3;
  width: 218px;
  min-height: 142px;
  padding: 22px;
  background: #fff8ef;
  transform: rotate(5deg);
}

.oauth-paper-note i {
  display: block;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  border-radius: 999px;
  background:
    linear-gradient(135deg, transparent 42%, #3f8c62 0 58%, transparent 0),
    linear-gradient(45deg, transparent 46%, #3f8c62 0 58%, transparent 0),
    #e5f4ea;
}

.oauth-paper-note span {
  display: block;
  height: 9px;
  margin-top: 10px;
  border-radius: 999px;
  background: #eadfd2;
}

.oauth-paper-note span:nth-of-type(1) {
  width: 132px;
}

.oauth-paper-note span:nth-of-type(2) {
  width: 156px;
}

.oauth-paper-note span:nth-of-type(3) {
  width: 96px;
}

.oauth-check-badge {
  position: absolute;
  right: 94px;
  top: 76px;
  z-index: 4;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #24372d;
  box-shadow: 0 20px 50px rgba(36, 55, 45, 0.18);
}

.oauth-check-badge svg {
  width: 48px;
  height: 48px;
}

.oauth-check-badge path {
  stroke: #f7f8f6;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.oauth-soft-spark {
  position: absolute;
  width: 34px;
  height: 34px;
}

.oauth-soft-spark::before,
.oauth-soft-spark::after {
  content: "";
  position: absolute;
  inset: 15px 0;
  border-radius: 999px;
  background: #d46e55;
}

.oauth-soft-spark::after {
  transform: rotate(90deg);
}

.oauth-soft-spark-a {
  left: 78px;
  bottom: 96px;
}

.oauth-soft-spark-b {
  right: 76px;
  top: 210px;
  transform: scale(0.72);
}

.oauth-soft-dot {
  position: absolute;
  left: 30px;
  top: 316px;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: #f2c75c;
}

.oauth-complete-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  color: #3f8c62;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
}

.oauth-complete-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e5f4ea;
  border: 1px solid rgba(63, 140, 98, 0.26);
}

.oauth-complete-icon svg {
  width: 17px;
  height: 17px;
}

.oauth-complete-icon path {
  stroke: #3f8c62;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.oauth-complete-body .oauth-complete-card h1 {
  margin: 0 0 12px;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: 0;
  color: #1e2421;
}

.oauth-complete-body .oauth-complete-card .lead {
  margin: 0 0 30px;
  max-width: 42ch;
  color: #66716a;
  font-size: 16px;
  line-height: 1.65;
}

.oauth-complete-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 30px 0 24px;
}

.oauth-complete-divider span {
  height: 1px;
  flex: 1;
  background: rgba(31, 38, 35, 0.1);
}

.oauth-complete-divider i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #d46e55;
}

.oauth-complete-actions {
  display: flex;
  flex-direction: row;
  gap: 16px;
  align-items: center;
  margin-top: 4px;
}

.oauth-complete-body .oauth-complete-open {
  width: auto;
  min-width: 194px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  background: #1e2421;
  box-shadow: 0 14px 28px rgba(30, 36, 33, 0.18);
  white-space: nowrap;
}

.oauth-complete-body .oauth-complete-open:hover {
  transform: translateY(-1px);
  box-shadow: 0 17px 34px rgba(30, 36, 33, 0.2);
}

.oauth-complete-open-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.oauth-complete-body .oauth-complete-close {
  flex: 0 0 auto;
  min-height: auto;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: #66716a;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.oauth-complete-body .oauth-complete-close:hover {
  color: #1e2421;
  background: transparent;
}

.oauth-complete-secure {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 22px;
  padding: 9px 12px;
  border-radius: 999px;
  background: #edf7f0;
  color: #3f8c62;
}

.oauth-complete-secure span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.oauth-complete-secure strong {
  font-size: 12px;
  font-weight: 750;
}

.oauth-complete-hint {
  margin: 18px 0 0;
  max-width: 46ch;
  line-height: 1.55;
  color: #7b857f;
}

@media (max-width: 880px) {
  .oauth-complete-body .oauth-complete-screen {
    align-items: stretch;
  }

  .oauth-complete-body .oauth-complete-main {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
  }

  .oauth-complete-station {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(84px, calc(env(safe-area-inset-top) + 68px)) 20px max(20px, env(safe-area-inset-bottom));
  }

  .oauth-complete-topbar {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    left: 20px;
    right: 20px;
  }

  .oauth-complete-visual {
    display: none;
  }

  .oauth-complete-body .oauth-complete-card {
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    border-radius: 22px;
    padding: 28px 22px max(24px, env(safe-area-inset-bottom));
  }

  .oauth-complete-body .oauth-complete-card h1 {
    font-size: 34px;
  }

  .oauth-complete-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .oauth-complete-body .oauth-complete-open {
    width: 100%;
    min-height: 52px;
  }

  .oauth-complete-body .oauth-complete-close {
    align-self: center;
  }
}

@media (max-width: 420px) {
  .oauth-complete-station {
    padding-right: 16px;
    padding-left: 16px;
  }

  .oauth-complete-topbar {
    left: 16px;
    right: 16px;
  }

  .oauth-complete-body .oauth-complete-card {
    padding-right: 20px;
    padding-left: 20px;
    border-radius: 18px;
  }

  .oauth-complete-body .oauth-complete-card h1 {
    font-size: clamp(30px, 9vw, 34px);
  }
}

/* ---------- chat layout ---------- */

.chat-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

.sidebar {
  border-right: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(79, 124, 255, 0.06), transparent 180px),
    var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* W2: sidebar IA — account row + ws chip + nav block + sessions list +
   footer. Mirrors the mockup `p1-3-workspace-switcher-mockup.html`. */
.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}
.account-row__avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.account-row__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.account-row__name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-row__email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-chip-wrap {
  position: relative;
  padding: 4px 12px 10px;
  flex-shrink: 0;
}
.ws-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.ws-chip:hover { border-color: var(--border-strong); background: var(--bg-card); }
.ws-chip[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ws-chip__emoji { font-size: 16px; }
.ws-chip__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-chip__role {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
}
.ws-chip__caret { color: var(--text-muted); font-size: 11px; }
.ws-chip-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(100% - 4px);
  z-index: 30;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.ws-chip-menu__list { display: flex; flex-direction: column; gap: 2px; }
.ws-chip-menu__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  width: 100%;
}
.ws-chip-menu__row:hover { background: var(--bg-elev); }
.ws-chip-menu__row.is-active { background: var(--accent-soft); color: var(--accent); }
.ws-chip-menu__row .meta {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}
.ws-chip-menu__divider {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}
.ws-chip-menu__action {
  width: 100%;
  display: block;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.ws-chip-menu__action:hover { background: var(--bg-elev); }

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-elev); }
.nav-item--primary {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item--primary:hover { background: var(--accent-soft); filter: brightness(1.05); }
.nav-item__icon { width: 18px; text-align: center; opacity: 0.85; }
.nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item__hint { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; }
.nav-item__badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

.sessions-section {
  flex: 1;
  min-height: 0;
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.sessions-section__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sessions-section__actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sessions-section__head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sessions-section__head h3 {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.sessions-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  padding: 0;
}
.sessions-refresh-btn .ui-icon-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  line-height: 0;
}
.sessions-refresh-btn .ui-icon {
  display: block;
  width: 16px;
  height: 16px;
  transition: opacity 120ms ease;
}
.sessions-refresh-btn.is-loading .ui-icon {
  opacity: 0;
}
.sessions-refresh-btn.is-loading .ui-icon-slot::before,
.sessions-refresh-btn.is-loading .ui-icon-slot::after {
  content: "";
  position: absolute;
  inset: 1px;
  box-sizing: border-box;
  border-radius: 50%;
}
.sessions-refresh-btn.is-loading .ui-icon-slot::before {
  border: 1.5px solid currentColor;
  opacity: 0.16;
}
.sessions-refresh-btn.is-loading .ui-icon-slot::after {
  background: conic-gradient(from 0deg, transparent 0deg, currentColor 300deg, currentColor 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 0);
  transform-origin: 50% 50%;
  animation: sessions-refresh-spin 0.78s linear infinite;
}
@keyframes sessions-refresh-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .sessions-refresh-btn.is-loading .ui-icon-slot::after {
    animation: none;
  }
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  flex-shrink: 0;
  margin-top: auto;
}
.sidebar-footer__settings {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.sidebar-footer__settings:hover { color: var(--text); border-color: var(--border-strong); }
.sidebar-footer__pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.sidebar-footer__pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
}
.sidebar-footer__pill[data-status="connecting"] { color: var(--warn); border-color: rgba(240, 179, 65, 0.4); }
.sidebar-footer__pill[data-status="connecting"] .dot { background: var(--warn); }
.sidebar-footer__pill[data-status="ready"] { color: var(--success); border-color: rgba(74, 210, 149, 0.45); }
.sidebar-footer__pill[data-status="ready"] .dot { background: var(--success); }
.sidebar-footer__pill[data-status="busy"] { color: var(--accent); border-color: rgba(79, 124, 255, 0.45); }
.sidebar-footer__pill[data-status="busy"] .dot { background: var(--accent); }
.sidebar-footer__pill[data-status="disconnected"] { color: var(--danger); border-color: rgba(255, 107, 122, 0.45); }
.sidebar-footer__pill[data-status="disconnected"] .dot { background: var(--danger); }

/* W3: two-row chat header */
.chat-header {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.chat-header__row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-header__title-block { display: flex; flex-direction: column; min-width: 0; }
.chat-header__title-block .title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header__title-block .status-text { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-info-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
}
.chat-header__row--secondary { display: none; }
.chat-header__ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.chat-header__workdir-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  max-width: 60ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-header__workdir-chip:hover { border-color: var(--border-strong); }

.chat-recording-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  margin-bottom: 8px;
  color: var(--text);
}
.chat-recording-bar__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(214, 51, 77, 0.5);
  animation: recPulse 1.2s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 51, 77, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(214, 51, 77, 0); }
}
.chat-recording-bar__timer {
  font-family: var(--mono-stack, "Menlo", "Consolas", monospace);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
}
.chat-recording-bar__partial {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* W4: settings SPA (Mac modal style) */
.settings-spa {
  width: min(480px, calc(100vw - 32px));
  max-height: min(85vh, 720px);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.settings-spa__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-spa__title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
.settings-spa__done {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
}
.settings-spa__done:hover { opacity: 0.72; }
.settings-spa__tabs {
  display: flex;
  gap: 8px;
  padding: 10px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-tab {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 6px 14px;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.settings-tab.is-active {
  color: var(--text);
  border-color: #0b6bcb;
  background: var(--bg-card);
}
.settings-tab:hover:not(.is-active) { color: var(--text); }
.settings-spa__body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.settings-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-card__title {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}
.settings-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.settings-card__action {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  padding: 0;
  cursor: pointer;
}
.settings-card__action:hover { color: var(--text); }
.settings-card__desc {
  margin: -2px 0 2px;
  line-height: 1.45;
}
.settings-card__footer {
  padding-top: 4px;
}
.settings-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
}
.settings-field__label {
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
}
.settings-field__value {
  font-size: 13px;
  text-align: right;
}
.settings-select,
.settings-field__control.settings-select {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8982' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 6px 28px 6px 10px;
  min-width: 148px;
  max-width: 220px;
  cursor: pointer;
}
.settings-spa .language-switcher--dropdown .language-switcher-trigger {
  border-radius: 8px;
  border-color: var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  min-width: 148px;
  justify-content: space-between;
}
.settings-signout-btn {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  padding: 8px 0 2px;
  cursor: pointer;
}
.settings-signout-btn:hover { color: var(--danger); }
/* Legacy row helpers (non-settings contexts) */
.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.settings-row > label { color: var(--text-muted); font-size: 13px; }
.settings-row select,
.settings-row input {
  max-width: 220px;
}
.sidebar-section h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.tunnel-list, .session-list {
  display: flex; flex-direction: column; gap: 6px; min-height: 0;
}
.tunnel-list { overflow-y: auto; max-height: 40vh; }
.session-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.tunnel-item, .session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}
.tunnel-item:hover, .session-item:hover {
  background: var(--bg-elev);
}
.tunnel-item.active, .session-item.active {
  background: linear-gradient(90deg, var(--accent-soft), rgba(79, 124, 255, 0.07));
  border-color: rgba(108, 140, 255, 0.5);
}
.tunnel-item .meta, .session-item .meta {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}
.tunnel-item .name, .session-item .name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-actions {
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.session-action-btn {
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
}
.session-action-btn svg {
  width: 15px;
  height: 15px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.session-item:hover .session-actions,
.session-item.active .session-actions,
.session-actions:focus-within {
  opacity: 1;
}
.session-action-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.tunnel-item .sub { font-size: 11px; color: var(--text-muted); }

.chat-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(79, 124, 255, 0.10), transparent 42%),
    var(--bg);
}

.chat-banner {
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-soft);
}
.chat-banner .title { font-weight: 600; }
.chat-banner .status-text { color: var(--text-muted); font-size: 12px; }

.spawned-session-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 16px 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 200, 80, 0.12);
  border: 1px solid rgba(255, 170, 60, 0.45);
  color: var(--text);
}
.spawned-session-banner[hidden] { display: none; }
.spawned-session-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: rgba(180, 95, 0, 1);
  background: rgba(255, 200, 80, 0.18);
  border: 1px solid rgba(255, 170, 60, 0.55);
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
}
.spawned-session-back:hover { background: rgba(255, 200, 80, 0.3); }
.spawned-session-back:active { background: rgba(255, 200, 80, 0.4); }
.spawned-session-back-arrow { font-size: 14px; line-height: 1; }
.spawned-session-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 170, 60, 0.4);
}
.spawned-session-icon { font-size: 16px; line-height: 1; }
.spawned-session-title { font-weight: 600; font-size: 13px; }
.spawned-session-meta {
  font-family: var(--font-mono, ui-monospace, "SFMono-Regular", Menlo, monospace);
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mirror-session-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(120, 140, 180, 0.12);
  border: 1px solid rgba(120, 140, 180, 0.22);
  color: var(--text-secondary);
}
.mirror-session-banner[hidden] { display: none; }
.mirror-session-icon { font-size: 16px; line-height: 1; opacity: 0.8; }
.mirror-session-title { font-weight: 600; font-size: 13px; }

.session-item--mirror .session-main,
.session-item--default .session-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.session-default-badge {
  text-transform: none;
  letter-spacing: 0;
}
.session-route-badge {
  flex-shrink: 0;
  margin-left: auto;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-active, rgba(0, 0, 0, 0.06));
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.session-route-icon {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  place-items: center;
  color: var(--text-muted);
}
.session-route-icon .ui-icon {
  width: 18px;
  height: 18px;
}

.search-conversations-dialog {
  width: min(640px, 92vw);
  max-height: 80vh;
}
.session-info-dialog {
  width: min(520px, 92vw);
}
.session-info-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.session-info-title-wrap {
  min-width: 0;
}
.session-info-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}
.session-info-count {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 13px;
}
.session-info-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-info-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.session-info-workdir {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-soft);
}
.session-info-workdir__icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--text-muted);
}
.session-info-workdir__icon .ui-icon {
  width: 16px;
  height: 16px;
}
.session-info-workdir code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-info-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-info-meta-row {
  display: grid;
  grid-template-columns: 20px minmax(110px, auto) 1fr;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.session-info-meta-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
}
.session-info-meta-icon .ui-icon {
  width: 15px;
  height: 15px;
}
.session-info-meta-icon,
.session-info-meta-label {
  color: var(--text-muted);
}
.session-info-meta-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.session-info-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.session-info-actions--inline {
  margin-top: 2px;
}
.session-info-actions button {
  justify-content: flex-start;
}
.session-info-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 9px;
  text-align: left;
}
.session-info-action__icon,
.session-info-action__chevron {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--text-muted);
}
.session-info-action__icon .ui-icon,
.session-info-action__chevron .ui-icon {
  width: 15px;
  height: 15px;
}
.session-info-action__label {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-info-action__chevron {
  opacity: 0.55;
}
.session-info-action:disabled .session-info-action__chevron {
  display: none;
}
.session-info-artifacts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.session-info-artifact {
  width: 100%;
  justify-content: flex-start;
}
.session-info-artifact__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.danger-text {
  color: var(--danger);
}
.search-conversations-field {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}
.search-conversations-field input[type="search"] {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
}
.search-conversations-field input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}
.search-conversations-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  margin-top: 8px;
}
.search-conversation-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background 120ms ease, border-color 120ms ease;
}
.search-conversation-row:hover {
  background: var(--bg-hover, rgba(120, 120, 120, 0.08));
  border-color: var(--accent);
}
.search-conversation-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-conversation-title {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-conversation-chevron {
  font-size: 16px;
  color: var(--text-muted);
}
.search-conversation-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-conversation-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.child-sessions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}
.child-session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}
.child-session-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}
.child-session-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.child-session-title {
  font-weight: 500;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.child-session-meta { font-size: 11px; color: var(--text-muted); }
.child-session-key {
  font-family: var(--font-mono, ui-monospace, "SFMono-Regular", Menlo, monospace);
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px clamp(20px, 5vw, 64px) 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.history-pager {
  width: min(100%, 820px);
  margin: 0 auto;
  display: flex;
  justify-content: center;
}
.history-pager__button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-card);
}
.message {
  width: min(100%, 820px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  column-gap: 12px;
  align-items: start;
}
.message.continuation {
  margin-top: -10px;
}
.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-top: 2px;
  background: rgba(95, 188, 255, 0.14);
  border: 1px solid rgba(95, 188, 255, 0.25);
  color: var(--tool);
  font-size: 11px;
  font-weight: 700;
}
.message.user .message-avatar {
  background: rgba(79, 124, 255, 0.16);
  border-color: rgba(79, 124, 255, 0.32);
  color: #9fb5ff;
}
.message.continuation .message-avatar {
  visibility: hidden;
}
.message-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message .role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.message.continuation .role {
  display: flex;
}
.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.message-process-toggle {
  cursor: pointer;
  user-select: none;
}
.message-process-toggle:hover {
  color: var(--text);
}
.message-process-count {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  opacity: 0.86;
}
.message-process-layer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: -2px 0 4px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}
.message-process-omitted {
  margin: -2px 0 4px 14px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}
.message-time {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  opacity: 0.82;
}
.message-time::before {
  content: "·";
  margin-right: 8px;
}

/* Generic part container — every message part renders as its own block. */
.part {
  min-width: 0;
  word-break: break-word;
  line-height: 1.6;
}

/* Plain prose answers: ChatGPT-style flat text, no bubble. */
.message.assistant .part-text {
  font-size: 14.5px;
  color: var(--text);
}
.message.user {
  justify-items: end;
}
.message.user .message-body {
  align-items: flex-end;
}
.message.user .part-text {
  background: var(--accent-soft);
  border: 1px solid rgba(108, 140, 255, 0.45);
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  max-width: min(640px, 100%);
  white-space: pre-wrap;
}

.message-turn-actions {
  display: flex;
  margin-top: 6px;
}
.message-turn-actions--user {
  justify-content: flex-end;
}
.message-turn-actions--assistant {
  justify-content: flex-start;
}
.turn-action-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.turn-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary, #888);
  cursor: pointer;
}
.turn-action-btn .ui-icon {
  width: 14px;
  height: 14px;
}
.turn-action-btn:hover {
  background: var(--row-hover, rgba(255, 255, 255, 0.08));
  color: var(--text, #eee);
}
.turn-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.turn-action-notice {
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface, #1a1a1a);
  color: var(--text-secondary, #aaa);
  font-size: 12px;
  pointer-events: none;
  z-index: 3;
}

.composer-edit-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent, #4f8cff) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #4f8cff) 24%, transparent);
  color: var(--text, #eee);
  font-size: 13px;
}
.composer-edit-banner__icon {
  flex-shrink: 0;
  opacity: 0.85;
}
.composer-edit-banner__text {
  flex: 1;
  min-width: 0;
}
.composer-edit-banner__cancel {
  flex-shrink: 0;
}

.fork-turn-dialog {
  border: 1px solid var(--border, #333);
  border-radius: 14px;
  padding: 0;
  max-width: min(480px, calc(100vw - 32px));
  background: var(--surface, #161616);
  color: var(--text, #eee);
}
.fork-turn-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.fork-turn-dialog__form {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.fork-turn-dialog__header {
  padding: 16px 18px 8px;
}
.fork-turn-dialog__header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.fork-turn-dialog__body {
  padding: 0 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fork-turn-dialog__hint,
.fork-turn-dialog__body-text {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary, #aaa);
  line-height: 1.45;
}
.fork-turn-dialog__hint {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-muted, rgba(255, 255, 255, 0.05));
}
.fork-turn-dialog__progress {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-muted, rgba(255, 255, 255, 0.05));
}
.fork-turn-dialog__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--text-secondary, #bbb);
  border-radius: 50%;
  animation: fork-turn-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes fork-turn-spin {
  to { transform: rotate(360deg); }
}
.fork-turn-dialog__progress-title {
  font-size: 13px;
  font-weight: 600;
}
.fork-turn-dialog__progress-detail {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary, #aaa);
}
.fork-turn-dialog__modes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fork-turn-dialog__modes--disabled {
  opacity: 0.55;
  pointer-events: none;
}
.fork-turn-dialog__mode {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border, #333);
  cursor: pointer;
}
.fork-turn-dialog__mode-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
}
.fork-turn-dialog__mode-hint {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary, #aaa);
}
.fork-turn-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
}

.generated-image-block {
  display: inline-block;
  width: fit-content;
  margin-top: 10px;
  max-width: min(720px, 100%);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: transparent;
  line-height: 0;
  vertical-align: top;
}

.generated-image-block__loading {
  min-height: 148px;
  min-width: min(320px, 72vw);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
  padding: 16px;
}

.generated-image-block__img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(70vh, 680px);
  object-fit: contain;
  cursor: zoom-in;
}

.chat-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 10000;
}

.chat-image-viewer[hidden] {
  display: none !important;
}

.chat-image-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
}

.chat-image-viewer__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  color: #fff;
}

.chat-image-viewer__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
}

.chat-image-viewer__title {
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  opacity: 0.85;
}

.chat-image-viewer__spacer {
  flex: 1;
}

.chat-image-viewer__toolbar button {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
}

.chat-image-viewer__toolbar button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.chat-image-viewer__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 12px;
}

.chat-image-viewer__img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
}

.chat-image-viewer__notice {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 13px;
}

/* Inline rich-text rendering helpers. */
.text-line { white-space: pre-wrap; }
.part-text strong { color: var(--text); }
.part-text em { color: var(--text); font-style: italic; }
.part-text code,
.thinking-detail code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12.8px;
}
.part-text .code-block,
.thinking-detail .code-block,
.tool-block-content {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 12.8px;
  line-height: 1.5;
  overflow-x: auto;
  margin: 8px 0 0;
  border: 1px solid var(--border);
  white-space: pre;
}
.part-text .code-block:first-child,
.thinking-detail .code-block:first-child {
  margin-top: 0;
}

/* ---------- Thinking card (collapsed by default) ---------- */
.thinking-card {
  border: 1px dashed rgba(181, 145, 255, 0.32);
  background: rgba(181, 145, 255, 0.06);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
}
.thinking-card[open] {
  background: rgba(181, 145, 255, 0.08);
}
.thinking-toggle {
  list-style: none;
  cursor: pointer;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d7c8ff;
  font-size: 12.5px;
  user-select: none;
}
.thinking-toggle::-webkit-details-marker { display: none; }
.thinking-card .part-icon { color: #d7c8ff; }
.thinking-card .part-chevron {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.15s ease;
  color: var(--text-muted);
}
.thinking-card[open] .part-chevron { transform: rotate(180deg); }
.thinking-detail {
  padding: 0 14px 12px;
  font-size: 13.5px;
  color: #cdbcff;
  line-height: 1.6;
  white-space: normal;
}

/* ---------- Inline artifact card (assistant-produced file) ---------- */
.artifact-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(95, 188, 255, 0.35);
  border-radius: 12px;
  background: var(--bg-card);
}
.artifact-card.status-failed { border-color: rgba(255, 122, 122, 0.55); }
.artifact-card.status-pending { border-color: rgba(255, 196, 110, 0.45); }
.artifact-card-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(95, 188, 255, 0.12);
  font-size: 14px;
  color: var(--tool);
  flex-shrink: 0;
}
.artifact-card.status-failed .artifact-card-icon { color: #ff7a7a; }
.artifact-card.status-pending .artifact-card-icon { color: #ffc46e; }
.artifact-card-body { min-width: 0; flex: 1; }
.artifact-card-title {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artifact-card-subtitle {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Tool invocation card (merged tool_use + tool_result) ---------- */
.tool-card {
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
}
.tool-card.status-pending { border-color: rgba(95, 188, 255, 0.35); }
.tool-card.status-error { border-color: rgba(255, 122, 122, 0.45); }
.tool-card-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}
.tool-card-toggle:hover { background: rgba(255, 255, 255, 0.03); }
.tool-card .part-status {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-size: 11px;
  border-radius: 999px;
  flex-shrink: 0;
}
.tool-card.status-ok .part-status { color: var(--ok, #4ad295); }
.tool-card.status-error .part-status { color: #ff7a7a; }
.tool-card.status-pending .part-status { color: var(--tool); }
.tool-card .part-icon {
  font-size: 12px;
  color: var(--tool);
}
.tool-card .part-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  flex-shrink: 0;
}
.tool-card .part-summary {
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.tool-card .part-chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.tool-card.expanded .part-chevron { transform: rotate(180deg); }
.tool-card-detail {
  border-top: 1px solid var(--border);
  padding: 10px 12px 12px;
  background: rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tool-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tool-block-label {
  font-size: 10.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.tool-block-content {
  margin: 0;
  max-height: 320px;
}
.tool-block-pending {
  color: var(--text-muted);
  font-size: 12.5px;
  font-style: italic;
}
.tool-block.muted { color: var(--text-muted); font-size: 12px; }

/* Spinner shared by tool-card pending state and the standalone placeholder. */
.part-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0.85;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Raw fallback card. */
.part-raw {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
  padding: 0 12px 10px;
}
.part-raw summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
}
.part-raw summary::-webkit-details-marker { display: none; }
.part-raw .part-chevron { margin-left: auto; }

.stream-cursor {
  display: inline-block;
  width: 7px;
  height: 1.15em;
  margin-left: 2px;
  vertical-align: -0.15em;
  border-radius: 999px;
  background: var(--accent);
  animation: stream-cursor-blink 1s steps(2, start) infinite;
}
.stream-cursor {
  display: inline-block;
  width: 7px;
  height: 1.15em;
  margin-left: 2px;
  vertical-align: -0.15em;
  border-radius: 999px;
  background: var(--accent);
  animation: stream-cursor-blink 1s steps(2, start) infinite;
}
@keyframes stream-cursor-blink {
  50% { opacity: 0; }
}

.composer {
  border-top: 1px solid var(--border);
  padding: 12px clamp(22px, 6vw, 96px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(13, 18, 28, 0.96);
}
.composer.drag-over {
  box-shadow: inset 0 0 0 2px rgba(79, 124, 255, 0.45);
}
.composer-row {
  display: flex;
  gap: 10px;
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 200px;
  resize: none;
  background: var(--bg-card);
  border-radius: 16px;
}
.composer button {
  align-self: stretch;
}
.composer .attach-btn {
  width: 44px;
  border-radius: 14px;
  font-size: 20px;
  line-height: 1;
}
.composer button.danger {
  background: rgba(255, 107, 122, 0.12);
}
.composer button.danger:hover:not(:disabled) {
  background: rgba(255, 107, 122, 0.2);
}
.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.artifact-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 0 2px;
}
.artifact-strip__label,
.artifact-strip__more {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.artifact-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
}
.artifact-chip__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip-wrap {
  position: relative;
  max-width: min(420px, 100%);
}
.attachment-chip-wrap:hover .attachment-chip-popover,
.attachment-chip-wrap:focus-within .attachment-chip-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.attachment-chip {
  display: grid;
  grid-template-columns: 36px minmax(80px, 1fr) auto 20px auto;
  align-items: center;
  gap: 8px;
  max-width: min(420px, 100%);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
}
.attachment-chip.status-uploaded {
  border-color: rgba(34, 150, 110, 0.35);
}
.attachment-chip.status-uploading {
  border-color: rgba(95, 188, 255, 0.4);
}
.attachment-chip.status-error {
  border-color: rgba(255, 107, 122, 0.5);
}
.attachment-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}
.attachment-chip.status-uploaded .attachment-status-icon {
  color: #1f9d74;
}
.attachment-chip.status-error .attachment-status-icon {
  color: #ff6b7a;
}
.attachment-status-icon--spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(127, 140, 160, 0.35);
  border-top-color: var(--accent, #5fbcff);
  border-radius: 999px;
  animation: attachment-spin 0.8s linear infinite;
}
@keyframes attachment-spin {
  to { transform: rotate(360deg); }
}
.attachment-chip-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 40;
  width: min(260px, 72vw);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.attachment-chip-popover__preview {
  display: block;
  width: 100%;
  max-height: 160px;
  margin-bottom: 8px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--bg-soft);
}
.attachment-chip-popover__title {
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
}
.attachment-chip-popover__meta {
  display: grid;
  gap: 4px;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.attachment-chip-popover__meta > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.attachment-chip-popover__meta dd {
  margin: 0;
  text-align: right;
  color: var(--text);
}
.attachment-chip-popover__error {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: #ff6b7a;
  font-size: 12px;
  word-break: break-word;
}
.chip-popover--below {
  bottom: auto;
  top: calc(100% + 6px);
}
.message-attachment-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
}
.message-attachment-chip-wrap {
  position: relative;
}
.message-attachment-chip-wrap:hover .message-attachment-chip-popover,
.message-attachment-chip-wrap:focus-within .message-attachment-chip-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.message-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(360px, 100%);
  padding: 4px 8px 4px 5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-soft);
  font-size: 13px;
}
.message-attachment-chip__badge {
  display: inline-flex;
  min-width: 22px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(95, 188, 255, 0.14);
  font-size: 10px;
  font-weight: 700;
}
.message-attachment-chip__title {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-attachment-chip__status {
  display: inline-flex;
  color: #1f9d74;
}
.message-attachment-chip-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 30;
  width: min(260px, 72vw);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.message-attachment-chip-popover__preview {
  display: block;
  width: 100%;
  max-height: 160px;
  margin-bottom: 8px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--bg-soft);
}
.message-attachment-chip-popover__title {
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
}
.message-attachment-chip-popover__meta {
  display: grid;
  gap: 4px;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.message-attachment-chip-popover__meta > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.message-attachment-chip-popover__meta dd {
  margin: 0;
  text-align: right;
}
.attachment-progress {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.attachment-progress__bar {
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #5fbcff);
  transition: width 150ms ease;
}
.attachment-chip img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-soft);
}
.attachment-chip__file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-muted);
}
.attachment-chip__file-icon svg {
  width: 18px;
  height: 18px;
}
.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.attachment-status {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.attachment-remove {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
}
.drop-hint {
  color: var(--text-muted);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  text-align: center;
}
.composer.drag-over .drop-hint {
  color: var(--accent);
  border-color: rgba(79, 124, 255, 0.6);
  background: var(--accent-soft);
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}
.empty-state .inner {
  max-width: 420px;
}
.empty-state h2 { color: var(--text); margin: 0 0 8px; }

/* ---------- console ---------- */

.console-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 18px 24px 24px;
  gap: 16px;
  overflow-y: auto;
}

.console-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.deploy-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.change-password-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  margin-top: 14px;
}
.change-password-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.metric-card strong {
  font-size: 18px;
  word-break: break-word;
}
.metric-card code {
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.analytics-detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ---------- admin section loading (per-component skeletons) ---------- */

.ui-skeleton {
  display: block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--skeleton-base, rgba(127, 136, 155, 0.12)) 0%,
    var(--skeleton-shine, rgba(127, 136, 155, 0.22)) 50%,
    var(--skeleton-base, rgba(127, 136, 155, 0.12)) 100%
  );
  background-size: 200% 100%;
  animation: uiSkeletonShimmer 1.2s ease-in-out infinite;
}
@keyframes uiSkeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.ui-skeleton-line {
  height: 12px;
  width: 100%;
}
.ui-skeleton-line-xs { height: 10px; width: 28px; }
.ui-skeleton-line-sm { height: 10px; width: 42%; }
.ui-skeleton-line-md { height: 14px; width: 58%; }
.ui-skeleton-line-lg { height: 22px; width: 48%; }
.ui-skeleton-badge {
  display: inline-block;
  height: 20px;
  width: 56px;
  border-radius: 999px;
}
.ui-skeleton-row td {
  padding-top: 11px;
  padding-bottom: 11px;
}
.ui-skeleton-metric {
  gap: 10px;
  min-height: 88px;
}
.ui-skeleton-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 168px;
}
.ui-skeleton-chart-day {
  justify-content: flex-end;
}
.ui-skeleton-bar {
  width: 24px;
  height: 120px;
  border-radius: 4px 4px 2px 2px;
  transform-origin: bottom;
  transform: scaleY(calc(var(--sk-h, 50%) / 100));
}
.ui-fade-in {
  animation: uiContentFadeIn 0.22s ease-out;
}
@keyframes uiContentFadeIn {
  from { opacity: 0.35; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}
button.is-refreshing {
  opacity: 0.72;
  pointer-events: none;
}
button.is-refreshing::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -1px;
}

.analytics-chart {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 160px;
  overflow-x: auto;
  padding-top: 12px;
}

.analytics-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 34px;
}

.analytics-bars {
  display: flex;
  align-items: end;
  gap: 3px;
  width: 24px;
  height: 120px;
}

.analytics-bar {
  display: block;
  width: 6px;
  min-height: 4px;
  border-radius: 999px 999px 0 0;
  transform-origin: bottom center;
}

.analytics-bar.pv { background: var(--accent); }
.analytics-bar.uv { background: var(--success); }
.analytics-bar.downloads { background: var(--warn); }

.analytics-day-label {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.analytics-panel.is-loading,
.admin-panel.is-loading {
  position: relative;
}
.analytics-panel.is-loading::before,
.admin-panel.is-loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 2;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent) 45%,
    var(--accent-strong) 55%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: analyticsLoadingBar 1.1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes analyticsLoadingBar {
  0% { background-position: 200% 0; opacity: 0.55; }
  100% { background-position: -200% 0; opacity: 1; }
}
.ui-fade-in .analytics-bar {
  animation: analyticsBarGrow 0.35s ease-out backwards;
}
.ui-fade-in .analytics-bar.uv { animation-delay: 0.04s; }
.ui-fade-in .analytics-bar.downloads { animation-delay: 0.08s; }
@keyframes analyticsBarGrow {
  from { transform: scaleY(0.15); opacity: 0.45; }
  to { transform: scaleY(1); opacity: 1; }
}

.log-viewer {
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 420px;
}

.tunnel-card, .user-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tunnel-card .row.title {
  align-items: center;
}
.tunnel-card .name { font-weight: 600; font-size: 16px; }
.tunnel-card .info { font-size: 12px; color: var(--text-muted); }

table.simple {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.simple th, table.simple td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
table.simple th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
table.simple tr:last-child td { border-bottom: none; }
table.simple tr.selected td {
  background: var(--accent-soft);
}
table.simple tbody tr[data-username] {
  cursor: pointer;
}
table.simple tbody tr[data-username]:hover td {
  background: rgba(255, 255, 255, 0.04);
}
table.simple tbody tr.selected:hover td {
  background: var(--accent-soft);
}

html[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}
html[data-theme="light"] .language-switcher {
  background: #eef2f8;
}
html[data-theme="light"] .managed-model-pill,
html[data-theme="light"] table.simple tbody tr[data-username]:hover td {
  background: #f6f8fc;
}
html[data-theme="light"] .log-viewer {
  background: #f8fafc;
  color: #15213b;
}

.notification-test-form {
  margin-top: 12px;
}
.notification-devices-card {
  overflow: auto;
  min-height: 96px;
}
.notification-result-card {
  margin-top: 4px;
}
.notification-result-card .log-viewer {
  min-height: 220px;
  max-height: min(52vh, 560px);
  white-space: pre;
}

dialog {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
dialog .dialog-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
dialog .dialog-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
dialog .dialog-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.account-detail-dialog {
  max-width: min(960px, 94vw);
  max-height: min(92vh, 920px);
}
.account-detail-dialog .dialog-head {
  gap: 10px;
}
.account-detail-head-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.account-detail-head-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-detail-body {
  overflow-y: auto;
  max-height: calc(92vh - 72px);
  gap: 18px;
}
.account-detail-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.table-pager-wrap {
  margin-top: 10px;
}
.table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.table-pager__summary {
  min-width: 120px;
  text-align: center;
}
.approval-dialog {
  max-width: 520px;
}
.approval-dialog .approval-body {
  gap: 14px;
}
.approval-dialog .approval-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.approval-dialog .approval-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.approval-dialog .approval-tool {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--bg-soft, rgba(127, 127, 127, 0.08));
  padding: 4px 8px;
  border-radius: 6px;
  align-self: flex-start;
}
.approval-dialog .approval-reason {
  font-size: 13px;
  color: var(--text);
}
.approval-dialog .approval-args {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-soft, rgba(127, 127, 127, 0.08));
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.approval-dialog .approval-foot {
  gap: 10px;
}

.codex-user-input-host {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  pointer-events: none;
}
.codex-user-input-host:empty { display: none; }
/* Composer hidden (files / sites / notes): dock to the viewport instead of
   stranding the card inside an invisible pane. */
.codex-user-input-host--floating {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  z-index: 60;
}
.codex-user-input-card,
.codex-user-input-banner {
  pointer-events: auto;
  border: 1px solid var(--border, #253044);
  border-radius: 14px;
  background: var(--bg-elev, #172033);
  color: var(--text, #e8edf7);
  box-shadow: var(--shadow, 0 6px 18px rgba(0, 0, 0, 0.3));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.codex-user-input-card--weak { border-color: rgba(245, 158, 11, 0.4); }
.codex-user-input-card--hint { border-color: var(--accent, #4f7cff); }
.codex-user-input-card p { margin: 0; }

.codex-user-input-card__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #253044);
}
.codex-user-input-banner .codex-user-input-card__head { border-bottom: none; }
.codex-user-input-card__icon {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  background: var(--accent-soft, rgba(79, 124, 255, 0.16));
  color: var(--accent, #4f7cff);
}
.codex-user-input-card--weak .codex-user-input-card__icon {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}
.codex-user-input-card__head-text {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.codex-user-input-card__title { font-size: 13px; font-weight: 600; }
.codex-user-input-card__subtitle {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted, #8e99ad);
}
.codex-user-input-card__badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-soft, rgba(79, 124, 255, 0.16));
  color: var(--accent, #4f7cff);
}
.codex-user-input-card__ghost {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-muted, #8e99ad);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.codex-user-input-card__ghost:hover { background: rgba(127, 127, 127, 0.12); }

.codex-user-input-card__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 14px;
  max-height: min(46vh, 420px);
  overflow-y: auto;
}
.codex-user-input-question { display: flex; flex-direction: column; gap: 6px; }
.codex-user-input-question__prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.codex-user-input-question__title { font-size: 13px; font-weight: 600; }
.codex-user-input-question__hint {
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  background: rgba(127, 127, 127, 0.14);
  color: var(--text-muted, #8e99ad);
}
.codex-user-input-question__desc {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted, #8e99ad);
}

.codex-user-input-card__choices { display: flex; flex-direction: column; gap: 6px; }
.codex-user-input-card__choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border, #253044);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  padding: 9px 11px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.codex-user-input-card__choice:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text, #1f1f1d) 8%, transparent);
  color: inherit;
}
.codex-user-input-card__choice:disabled { cursor: default; opacity: 0.6; }
.codex-user-input-card__choice.is-selected {
  border-color: var(--accent, #4f7cff);
  background: var(--accent-soft, rgba(79, 124, 255, 0.12));
}
.codex-user-input-card__mark {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong, #38455c);
  position: relative;
}
.codex-user-input-card__mark--box { border-radius: 4px; }
.is-selected .codex-user-input-card__mark { border-color: var(--accent, #4f7cff); }
.is-selected .codex-user-input-card__mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  background: var(--accent, #4f7cff);
}
/* Keep the badge next to its label instead of drifting to the row edge. */
.codex-user-input-card__choice-label { flex: 0 1 auto; min-width: 0; }
.codex-user-input-card__choice-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  background: var(--accent-soft, rgba(79, 124, 255, 0.16));
  color: var(--accent, #4f7cff);
}

.codex-user-input-card__custom { display: flex; flex-direction: column; gap: 4px; }
.codex-user-input-card__custom-label {
  font-size: 11.5px;
  color: var(--text-muted, #8e99ad);
}
.codex-user-input-card__input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border, #253044);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  padding: 9px 11px;
  font-size: 13px;
}
.codex-user-input-card__input:focus {
  outline: none;
  border-color: var(--accent, #4f7cff);
}

.codex-user-input-card__error {
  padding: 0 14px 8px;
  font-size: 12px;
  color: var(--danger, #ff6b7a);
}
.codex-user-input-card__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border, #253044);
}
.codex-user-input-banner .codex-user-input-card__actions {
  border-top: none;
  padding-top: 0;
}
.codex-user-input-card__btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 13px;
  background: transparent;
  color: var(--text-muted, #8e99ad);
  cursor: pointer;
}
.codex-user-input-card__btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text, #1f1f1d) 8%, transparent);
  color: var(--text, #1f1f1d);
}
.codex-user-input-card__btn--primary {
  background: var(--qw-btn-primary-bg, var(--accent, #4f7cff));
  color: var(--qw-btn-primary-fg, #fff);
  font-weight: 500;
}
.codex-user-input-card__btn--primary:hover:not(:disabled) {
  background: var(--qw-btn-primary-rgb, var(--accent-strong, #3d67e6));
  color: var(--qw-btn-primary-fg, #fff);
}
.codex-user-input-card__btn:disabled { opacity: 0.45; cursor: default; }
.approval-weak-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 16px;
  background: rgba(245, 158, 11, 0.14);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 13px;
}
.approval-weak-banner__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.approval-weak-banner__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.approval-weak-banner__cmd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.approval-weak-banner__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.codex-approval-host {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  pointer-events: none;
}
.codex-approval-host:empty,
.codex-approval-host[hidden] { display: none; }
.codex-approval-host--floating {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  z-index: 60;
}
.codex-approval-card {
  pointer-events: auto;
  border: 1px solid var(--border, #e8e8e3);
  border-radius: 16px;
  background: var(--bg-elev, #f7f7f4);
  color: var(--text, #1f1f1d);
  box-shadow: var(--shadow, 0 8px 24px rgba(20, 20, 18, 0.08));
  overflow: hidden;
}
.codex-approval-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 0;
  font-size: 14px;
}
.codex-approval-card__hint {
  margin: 8px 14px 0;
  font-size: 12px;
  color: var(--text-muted, #8a8982);
}
.codex-approval-card__body {
  padding: 10px 14px 12px;
  display: grid;
  gap: 8px;
}
.codex-approval-card__primary {
  font-size: 13px;
  font-weight: 600;
}
.codex-approval-card__command {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--border, #e8e8e3);
  background: var(--bg-soft, #f1f1ee);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.codex-approval-card__prompt {
  user-select: none;
  color: var(--text-muted, #8a8982);
}
.codex-approval-card__reason {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted, #8a8982);
  line-height: 1.45;
}
.codex-approval-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border, #e8e8e3);
}
.codex-approval-card__foot-start,
.codex-approval-card__foot-end {
  display: flex;
  align-items: center;
  gap: 8px;
}
.device-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}
.device-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}
.device-main {
  flex: 1;
  min-width: 0;
}
.device-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-badge {
  border: 1px solid rgba(108, 140, 255, 0.45);
  background: rgba(108, 140, 255, 0.14);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 11px;
}
.device-empty {
  padding: 12px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
}
.danger-text {
  color: var(--danger);
}

/* ---------- Codex-style chat surface ---------- */

body[data-title-key="chat.title"] {
  --bg: #ffffff;
  --bg-soft: #f7f7f4;
  --bg-card: #ffffff;
  --bg-elev: #f1f1ee;
  --border: #e8e8e3;
  --border-strong: #d7d7cf;
  --text: #1f1f1d;
  --text-muted: #8a8982;
  --accent: #222220;
  --accent-strong: #111110;
  --accent-soft: #f0f0eb;
  --success: #1d8f5d;
  --danger: #c33b4a;
  --warn: #b87512;
  --thinking: #7c6f5e;
  --tool: #6f716a;
  --code-bg: #f6f6f2;
  --shadow: 0 18px 48px rgba(30, 30, 20, 0.10), 0 2px 8px rgba(30, 30, 20, 0.06);
  --composer-shadow: 0 12px 32px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.08);
  --sidebar-text: #4f4e47;
  --sidebar-muted: #8a8981;
  background: var(--bg);
  font-size: 14px;
  letter-spacing: 0;
}

html[data-theme="dark"] body[data-title-key="chat.title"] {
  --bg: #181818;
  --bg-soft: #1c1c1c;
  --bg-card: #212121;
  --bg-elev: #282828;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f3f1;
  --text-muted: rgba(243, 243, 241, 0.46);
  --accent-soft: rgba(255, 255, 255, 0.08);
  --code-bg: #0d0d0d;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);
  --composer-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.4);
  --sidebar-text: rgba(243, 243, 241, 0.68);
  --sidebar-muted: rgba(243, 243, 241, 0.46);
}

body[data-title-key="chat.title"] .app-shell {
  background: var(--bg);
}

body[data-title-key="chat.title"] .topbar {
  height: 38px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

body[data-title-key="chat.title"] .topbar .brand {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0;
  flex-shrink: 0;
}

.codex-titlebar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 2px;
  flex-shrink: 0;
}

.codex-titlebar-nav a {
  color: var(--text-muted);
  padding: 5px 9px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1;
}

.codex-titlebar-nav a:hover {
  color: var(--text);
  background: var(--bg-elev);
  text-decoration: none;
}

.codex-titlebar-nav a[aria-current="page"] {
  color: var(--text);
}

body[data-title-key="chat.title"] .topbar .nav-links {
  display: none;
}

body[data-title-key="chat.title"].is-admin .topbar .nav-links {
  display: flex;
}

body[data-title-key="chat.title"] .topbar .me {
  gap: 8px;
}

body[data-title-key="chat.title"] #me-username {
  color: #77766f;
}

body[data-title-key="chat.title"] button {
  border-color: transparent;
  background: transparent;
  color: var(--qw-text, var(--text));
}

/* Keep this at zero extra specificity. A solid --bg-elev hover was winning
   over filled buttons and painting light-on-light / dark-on-dark. */
:where(body[data-title-key="chat.title"] button:hover:not(:disabled)) {
  background: var(--qw-hover, rgba(31, 35, 40, 0.055));
  border-color: transparent;
}

body[data-title-key="chat.title"] button.primary {
  background: var(--qw-btn-primary-bg, #0d0d0d);
  border-color: var(--qw-btn-primary-bg, #0d0d0d);
  color: var(--qw-btn-primary-fg, #fff);
}

body[data-title-key="chat.title"] button.primary:hover:not(:disabled) {
  background: var(--qw-btn-primary-rgb, #34363a);
  border-color: var(--qw-btn-primary-rgb, #34363a);
  color: var(--qw-btn-primary-fg, #fff);
}

.codex-nav-toggle {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  font-size: 15px;
  line-height: 1;
}

body[data-title-key="chat.title"] .language-switcher--dropdown .language-switcher-trigger {
  background: var(--bg-soft);
  border-color: var(--border);
}

body[data-title-key="chat.title"] .language-switcher-option.is-selected,
body[data-title-key="chat.title"] .language-switcher-option[aria-selected="true"] {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

body[data-title-key="chat.title"] .host-chip-wrap {
  margin-right: 0;
}

body[data-title-key="chat.title"] .host-chip {
  max-width: 260px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 999px;
  box-shadow: none;
}

body[data-title-key="chat.title"] .host-chip[data-state="online"] {
  border-color: rgba(29, 143, 93, 0.25);
}

body[data-title-key="chat.title"] .thin-titlebar .host-chip[data-state="offline"],
body[data-title-key="chat.title"] .thin-titlebar .host-chip[data-state="connecting"] {
  color: var(--qw-text-secondary);
}

body[data-title-key="chat.title"] .chat-layout {
  --chat-sidebar-width: 300px;
  --chat-sidebar-resizer-width: 6px;
  position: relative;
  display: grid;
  grid-template-columns: var(--chat-sidebar-width) var(--chat-sidebar-resizer-width) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
  transition: grid-template-columns 180ms ease;
}

body[data-title-key="chat.title"] .chat-layout.sidebar-collapsed {
  --chat-sidebar-width: 0px;
  --chat-sidebar-resizer-width: 0px;
}

body[data-title-key="chat.title"] .sidebar {
  position: relative;
  z-index: 20;
  width: var(--chat-sidebar-width);
  min-width: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  transform: none;
  transition: width 180ms ease, opacity 120ms ease;
  background: #f7f7f3;
  /* Divider lives on `.sidebar-resizer` so the drag handle matches the visible line. */
  border-right: 0;
  box-shadow: none;
  color: var(--sidebar-text);
}

body[data-title-key="chat.title"] .chat-layout.sidebar-collapsed .sidebar {
  opacity: 0;
  pointer-events: none;
  border-right-color: transparent;
}

body[data-title-key="chat.title"] .sidebar-resizer {
  position: relative;
  z-index: 21;
  cursor: col-resize;
  background: transparent;
}

body[data-title-key="chat.title"] .sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: var(--border);
  opacity: 0.72;
}

body[data-title-key="chat.title"] .sidebar-resizer:hover::after,
body[data-title-key="chat.title"].sidebar-resizing .sidebar-resizer::after {
  background: var(--accent);
  opacity: 1;
}

body[data-title-key="chat.title"].sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}
body[data-title-key="chat.title"].sidebar-resizing .chat-layout,
body[data-title-key="chat.title"].sidebar-resizing .sidebar {
  transition: none !important;
}

body[data-title-key="chat.title"] .sidebar-resizer {
  touch-action: none;
}

body[data-title-key="chat.title"] .sidebar-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  right: -4px;
}

body[data-title-key="chat.title"].sidebar-resizing .chat-layout {
  transition: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 38px 0 0;
  z-index: 45;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.16);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}

body[data-title-key="chat.title"] .sidebar-head {
  display: none;
}

.sidebar-head strong {
  flex: 1;
  font-size: 14px;
}

#session-drawer-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 9px;
  font-size: 18px;
}

body[data-title-key="chat.title"] .sidebar-section {
  border-bottom: 0;
  padding: 8px 8px 10px;
}

body[data-title-key="chat.title"] .account-row {
  padding: 18px 14px 12px;
}

body[data-title-key="chat.title"] .account-row__name,
body[data-title-key="chat.title"] .ws-chip,
body[data-title-key="chat.title"] .nav-item,
body[data-title-key="chat.title"] .session-item .name,
body[data-title-key="chat.title"] .sidebar-footer__settings {
  color: var(--sidebar-text);
}

body[data-title-key="chat.title"] .account-row__email,
body[data-title-key="chat.title"] .ws-chip__role,
body[data-title-key="chat.title"] .ws-chip__caret,
body[data-title-key="chat.title"] .nav-item__hint,
body[data-title-key="chat.title"] .session-item .sub {
  color: var(--sidebar-muted);
}

body[data-title-key="chat.title"] .ws-chip {
  background: transparent;
  border-color: transparent;
  font-weight: 500;
}

body[data-title-key="chat.title"] .ws-chip:hover {
  background: rgba(0, 0, 0, 0.035);
  border-color: transparent;
}

body[data-title-key="chat.title"] .ws-chip__role {
  background: rgba(0, 0, 0, 0.03);
}

body[data-title-key="chat.title"] .nav-section {
  border-bottom: 0;
}

body[data-title-key="chat.title"] .nav-item {
  font-weight: 400;
}

body[data-title-key="chat.title"] .nav-item--primary {
  background: transparent;
  font-weight: 500;
}

body[data-title-key="chat.title"] .nav-item--primary:hover,
body[data-title-key="chat.title"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.035);
  filter: none;
}

body[data-title-key="chat.title"] .nav-item__icon {
  color: currentColor;
  opacity: 0.72;
}

body[data-title-key="chat.title"] .sidebar-section h3 {
  display: none;
}

body[data-title-key="chat.title"] .session-list {
  gap: 2px;
  max-height: none;
  padding: 2px 0;
  flex: 0 0 auto;
  overflow-y: visible;
}

body[data-title-key="chat.title"] .session-list-empty {
  margin: 0;
  padding: 10px 8px 4px;
  color: var(--sidebar-muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 400;
}

body[data-title-key="chat.title"] .session-time-group__label {
  padding: 10px 8px 4px;
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 500;
}

body[data-title-key="chat.title"] .session-item {
  position: relative;
  min-height: 32px;
  border-radius: 8px;
  padding: 6px 8px;
  border: 1px solid transparent;
  color: var(--sidebar-text);
  overflow: hidden;
}

body[data-title-key="chat.title"] .session-item:hover {
  background: rgba(0, 0, 0, 0.035);
}

body[data-title-key="chat.title"] .session-item.active {
  background: #e7e7e2;
  border-color: transparent;
  box-shadow: none;
}

body[data-title-key="chat.title"] .session-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  flex-wrap: nowrap;
}

body[data-title-key="chat.title"] .session-item .name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 400;
}

body[data-title-key="chat.title"] .session-meta {
  margin-left: auto;
  display: inline-flex;
  min-width: 2rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

body[data-title-key="chat.title"] .session-age {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  color: var(--sidebar-muted);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: opacity 120ms ease;
}

body[data-title-key="chat.title"] .session-route-icon {
  order: 3;
  display: none;
  align-items: center;
  color: var(--sidebar-muted);
}

body[data-title-key="chat.title"] .session-item:hover .session-route-icon,
body[data-title-key="chat.title"] .session-item:focus-within .session-route-icon {
  display: inline-flex;
}

body[data-title-key="chat.title"] .session-route-icon .ui-icon {
  width: 18px;
  height: 18px;
}

body[data-title-key="chat.title"] .session-main > .session-route-badge:not(.session-default-badge) {
  position: relative;
  order: 2;
  display: inline-grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  place-items: center;
  margin-left: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 0;
  letter-spacing: 0;
}

body[data-title-key="chat.title"] .session-main > .session-route-badge:not(.session-default-badge)::before {
  content: "";
  width: 16px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 1.5px;
  box-sizing: border-box;
}

body[data-title-key="chat.title"] .session-main > .session-route-badge:not(.session-default-badge)::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 1.5px;
  margin-top: 16px;
  background: currentColor;
  box-shadow: 0 -3px 0 -0.5px currentColor;
}

body[data-title-key="chat.title"] .session-main > .session-age {
  order: 2;
  margin-left: 2px;
}

body[data-title-key="chat.title"] .session-actions {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  gap: 2px;
  padding-left: 18px;
  background: linear-gradient(90deg, rgba(247, 247, 243, 0), #f7f7f3 38%);
}

body[data-title-key="chat.title"] .session-item .session-actions {
  opacity: 0;
}

body[data-title-key="chat.title"] .session-item:not(.session-item--mirror):hover .session-age,
body[data-title-key="chat.title"] .session-item:not(.session-item--mirror):focus-within .session-age {
  display: none;
}

body[data-title-key="chat.title"] .session-item:not(.session-item--mirror):hover .session-actions,
body[data-title-key="chat.title"] .session-item:not(.session-item--mirror):focus-within .session-actions {
  right: 27px;
}

body[data-title-key="chat.title"] .session-item:hover .session-actions,
body[data-title-key="chat.title"] .session-item:focus-within .session-actions,
body[data-title-key="chat.title"] .session-actions:focus-within {
  opacity: 1;
}

body[data-title-key="chat.title"] .session-item.active:hover .session-actions,
body[data-title-key="chat.title"] .session-item.active:focus-within .session-actions {
  background: linear-gradient(90deg, rgba(231, 231, 226, 0), #e7e7e2 38%);
}

body[data-title-key="chat.title"] #mirror-sessions-section {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 0;
  border-radius: 0;
  background: transparent;
}

body[data-title-key="chat.title"] #mirror-sessions-label {
  display: block;
  padding: 0 8px 4px;
  color: #8d8c85;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: 0;
}

body[data-title-key="chat.title"] #mirror-sessions-hint {
  margin: 0;
  padding: 0 8px 8px;
  color: #9a9992;
  font-size: 12px;
  line-height: 1.5;
}

body[data-title-key="chat.title"] .session-list--mirror {
  margin-top: 0;
  opacity: 1;
}

body[data-title-key="chat.title"] .session-list--mirror .session-time-group__label {
  display: none;
}

body[data-title-key="chat.title"] .session-item--mirror {
  color: #77766f;
  background: transparent;
}

body[data-title-key="chat.title"] .session-item--mirror:hover {
  background: rgba(0, 0, 0, 0.025);
}

body[data-title-key="chat.title"] .session-item--mirror.active {
  background: #eeeeea;
  color: #5f5e58;
}

body[data-title-key="chat.title"] .session-item--mirror .name {
  color: inherit;
}

body[data-title-key="chat.title"] .session-item--mirror .session-main {
  display: flex;
}

body[data-title-key="chat.title"] .session-item--mirror .session-age {
  margin-top: 0;
  font-size: 13px;
  color: #92918a;
}

body[data-title-key="chat.title"] .session-item--mirror .session-route-badge {
  background: transparent;
  color: #8c8b84;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.08em;
}

body[data-title-key="chat.title"] .session-item--mirror .session-route-icon {
  color: #9a9992;
}

body[data-title-key="chat.title"] .session-item--mirror .session-main > .session-route-badge:not(.session-default-badge) {
  position: relative;
  order: 2;
  display: inline-grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  place-items: center;
  margin-left: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #9a9992;
  font-size: 0;
  letter-spacing: 0;
}

body[data-title-key="chat.title"] .session-action-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 7px;
  color: var(--sidebar-muted);
}

body[data-title-key="chat.title"] .session-action-btn:hover {
  color: var(--sidebar-text);
  background: rgba(0, 0, 0, 0.045);
}

body[data-title-key="chat.title"] .session-archive-btn {
  width: 24px;
  padding: 0;
}

body[data-title-key="chat.title"] .chat-pane {
  height: 100%;
  min-height: 0;
  background: #fff;
}

body[data-title-key="chat.title"] .chat-header {
  min-height: 44px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #ecece6;
  flex-shrink: 0;
}

body[data-title-key="chat.title"] .chat-header__title-block {
  gap: 2px;
}

body[data-title-key="chat.title"] .chat-header__title-block .title {
  color: #222220;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

body[data-title-key="chat.title"] .chat-header__title-block .status-text {
  color: #8a8981;
  font-size: 11px;
  letter-spacing: 0;
}

body[data-title-key="chat.title"] .chat-banner {
  display: none;
}

body[data-title-key="chat.title"] .chat-banner .title {
  font-size: 14px;
  font-weight: 650;
}

body[data-title-key="chat.title"] .chat-banner .status-text {
  max-width: 58vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.codex-more-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
}

body[data-title-key="chat.title"] #forget-btn {
  display: none !important;
}

body[data-title-key="chat.title"] .messages {
  flex: 1;
  gap: 28px;
  padding: 32px clamp(22px, 9vw, 132px) 190px;
  background: #fff;
  scroll-padding-bottom: 204px;
}

body[data-title-key="chat.title"] .message {
  width: min(100%, 760px);
  grid-template-columns: minmax(0, 1fr);
  column-gap: 0;
}

body[data-title-key="chat.title"] .history-pager {
  width: min(100%, 760px);
}

body[data-title-key="chat.title"] .history-pager__button {
  background: #f5f5f0;
  border-color: #ededE7;
  color: #77766f;
}

body[data-title-key="chat.title"] .message-avatar {
  display: none;
}

body[data-title-key="chat.title"] .message.user {
  justify-items: stretch;
}

body[data-title-key="chat.title"] .message.user .message-body {
  align-items: flex-end;
}

body[data-title-key="chat.title"] .message.user .message-meta {
  justify-content: flex-end;
  padding: 0 6px 2px 0;
  color: #8a8981;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

body[data-title-key="chat.title"] .message.user .part-text {
  max-width: min(560px, 86%);
  padding: 14px 16px;
  color: #222220;
  background: #f4f4f1;
  border: 0;
  border-radius: 18px;
  box-shadow: none;
  font-size: 15px;
  line-height: 1.58;
}

body[data-title-key="chat.title"] .message.assistant {
  justify-items: stretch;
}

body[data-title-key="chat.title"] .message.assistant .message-body {
  max-width: min(760px, 100%);
  align-items: stretch;
  gap: 15px;
}

body[data-title-key="chat.title"] .message.assistant .message-meta {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
}

body[data-title-key="chat.title"] .message.assistant .message-role-label {
  display: none;
}

body[data-title-key="chat.title"] .message.assistant .message-time::before {
  content: "·";
  margin-right: 8px;
}

body[data-title-key="chat.title"] .message-time {
  white-space: nowrap;
}

.task-progress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.task-progress::after {
  content: none;
}

.message-process-toggle .task-progress::after {
  content: "›";
  display: inline-block;
  color: #bbb9b0;
  font-size: 17px;
  line-height: 1;
  transform-origin: center;
  transition: color 0.15s ease, transform 0.15s ease;
}

.message-process-toggle:hover .task-progress::after,
.message-process-toggle:focus-visible .task-progress::after {
  color: var(--text);
}

.message-process-toggle.expanded .task-progress::after {
  transform: rotate(90deg);
}

body[data-title-key="chat.title"] .message.assistant .part-text {
  font-size: 15px;
  line-height: 1.78;
  color: #242421;
}

body[data-title-key="chat.title"] .thinking-card,
body[data-title-key="chat.title"] .tool-card,
body[data-title-key="chat.title"] .part-raw {
  border-color: transparent;
  background: transparent;
  border-radius: 8px;
  box-shadow: none;
}

body[data-title-key="chat.title"] .thinking-card {
  border-style: solid;
}

body[data-title-key="chat.title"] .thinking-toggle,
body[data-title-key="chat.title"] .thinking-detail {
  color: #77766f;
}

body[data-title-key="chat.title"] .thinking-toggle,
body[data-title-key="chat.title"] .tool-card-toggle {
  min-height: 30px;
  padding: 4px 6px;
  border-radius: 8px;
  color: #353530;
}

body[data-title-key="chat.title"] .thinking-toggle:hover,
body[data-title-key="chat.title"] .tool-card-toggle:hover {
  background: rgba(0, 0, 0, 0.035);
}

body[data-title-key="chat.title"] .tool-card .part-title {
  color: #3a3a35;
  font-family: inherit;
  font-weight: 500;
}

body[data-title-key="chat.title"] .tool-card-detail {
  margin: 2px 0 6px 20px;
  padding: 8px 0 2px 10px;
  border-top: 0;
  border-left: 1px solid #e4e4dd;
  background: transparent;
}

body[data-title-key="chat.title"] .thinking-detail {
  margin: 2px 0 6px 20px;
  padding: 6px 0 2px 10px;
  border-left: 1px solid #e4e4dd;
  color: #5f5e57;
}

body[data-title-key="chat.title"] .message-process-layer {
  border-left-color: #e4e4dd;
}

body[data-title-key="chat.title"] .message-process-count {
  color: #8a8981;
}

body[data-title-key="chat.title"] .tool-block-content,
body[data-title-key="chat.title"] .part-text .code-block,
body[data-title-key="chat.title"] .thinking-detail .code-block {
  background: #f6f6f2;
  border-color: #e8e8e3;
  color: #2d2d29;
}

body[data-title-key="chat.title"] .stream-cursor {
  background: #2c2c29;
}

body[data-title-key="chat.title"] .composer {
  position: fixed;
  left: calc(var(--chat-sidebar-width) + ((100vw - var(--chat-sidebar-width)) / 2));
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 35;
  width: min(700px, calc(100vw - var(--chat-sidebar-width) - 48px));
  transform: translateX(-50%);
  min-height: 86px;
  padding: 12px 14px 10px;
  gap: 6px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #e6e6e1;
  border-radius: 20px;
  box-shadow: var(--composer-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

body[data-title-key="chat.title"] .composer-row {
  align-items: center;
  gap: 14px;
}

body[data-title-key="chat.title"] .composer textarea {
  min-height: 34px;
  max-height: 160px;
  padding: 3px 4px 3px 2px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #222220;
  font-size: 15px;
  resize: none;
  overflow-y: auto;
  overflow-x: hidden;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: rgba(31, 35, 40, 0.16) transparent;
}

body[data-title-key="chat.title"] .composer textarea::-webkit-scrollbar {
  width: 5px;
}

body[data-title-key="chat.title"] .composer textarea::-webkit-scrollbar-thumb {
  background: rgba(31, 35, 40, 0.14);
  border-radius: 999px;
}

body[data-title-key="chat.title"] .composer-input-row {
  display: block;
  min-width: 0;
}

body[data-title-key="chat.title"] .composer-input-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  flex-shrink: 0;
  width: fit-content;
  margin-top: 2px;
  max-width: min(320px, 100%);
  padding: 4px 5px 4px 4px;
  border: 1px solid color-mix(in srgb, var(--qw-accent, #0d0d0d) 18%, var(--qw-border, #e6e6e1));
  border-radius: 10px;
  background: color-mix(in srgb, var(--qw-accent, #0d0d0d) 4%, var(--qw-surface, #fff));
  color: var(--qw-text-secondary, #55544f);
  font-size: 12px;
  line-height: 1.2;
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb[hidden] {
  display: none;
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  background: var(--qw-accent-soft, rgba(13, 13, 13, 0.06));
  color: var(--qw-accent, #0d0d0d);
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb__prefix {
  flex-shrink: 0;
  color: var(--qw-text-muted, #8a8983);
  font-size: 11px;
  font-weight: 500;
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb__divider {
  width: 1px;
  height: 14px;
  flex: 0 0 1px;
  background: var(--qw-border-strong, #deded9);
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--qw-text, #222220);
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--qw-text-muted, #8a8983);
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb__clear:hover {
  background: var(--qw-accent-soft-rgb, rgba(13, 13, 13, 0.1));
  color: var(--qw-text, #222220);
}

body[data-title-key="chat.title"] .composer-skill-breadcrumb__clear:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--qw-accent, #0d0d0d) 30%, transparent);
  outline-offset: 1px;
}

body[data-title-key="chat.title"] .composer-input-row textarea {
  display: block;
  width: 100%;
  min-width: 0;
}

body[data-title-key="chat.title"] .composer textarea:focus {
  border: 0;
  box-shadow: none;
}

body[data-title-key="chat.title"] .composer .attach-btn {
  width: auto;
  height: 28px;
  align-self: center;
  border-radius: 9px;
  padding: 0 2px;
  font-size: 18px;
  color: #77766f;
}

body[data-title-key="chat.title"] .composer-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  color: #77766f;
  font-size: 14px;
  white-space: nowrap;
}

body[data-title-key="chat.title"] .composer-chip::after {
  content: "⌄";
  margin-left: 4px;
  font-size: 11px;
  color: #aaa9a1;
}

body[data-title-key="chat.title"] .composer-chip--model {
  margin-left: auto;
  color: #222220;
  font-weight: 500;
}

body[data-title-key="chat.title"] #send-btn,
body[data-title-key="chat.title"] #stop-btn {
  min-width: 38px;
  width: 38px;
  height: 38px;
  min-height: 38px;
  align-self: center;
  border-radius: 999px;
  padding: 0;
}

body[data-title-key="chat.title"] #send-btn.composer-send-btn,
body[data-title-key="chat.title"] #stop-btn.composer-stop-btn {
  display: inline-grid;
  place-items: center;
  flex: 0 0 38px;
  inline-size: 38px;
  block-size: 38px;
  min-inline-size: 38px;
  max-inline-size: 38px;
  min-block-size: 38px;
  max-block-size: 38px;
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  overflow: visible;
  border: 0;
  border-radius: 50%;
  background: var(--qw-btn-primary-bg, #0d0d0d);
  color: var(--qw-btn-primary-fg, #fff);
  box-shadow: none;
  white-space: nowrap;
}

body[data-title-key="chat.title"] #send-btn.composer-send-btn:not(:disabled),
body[data-title-key="chat.title"] #stop-btn.composer-stop-btn:not(:disabled) {
  background: var(--qw-btn-primary-bg, #0d0d0d);
  color: var(--qw-btn-primary-fg, #fff);
}

body[data-title-key="chat.title"] #send-btn.composer-send-btn:not(:disabled):hover,
body[data-title-key="chat.title"] #send-btn.composer-send-btn:not(:disabled):focus-visible,
body[data-title-key="chat.title"] #stop-btn.composer-stop-btn:not(:disabled):hover,
body[data-title-key="chat.title"] #stop-btn.composer-stop-btn:not(:disabled):focus-visible {
  background: var(--qw-btn-primary-rgb, #5c5c56);
  border-color: var(--qw-btn-primary-rgb, #5c5c56);
  color: var(--qw-btn-primary-fg, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--qw-btn-primary-bg, #0d0d0d) 22%, transparent);
}

body[data-title-key="chat.title"] #send-btn.composer-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

body[data-title-key="chat.title"] #send-btn.composer-send-btn .ui-icon-slot,
body[data-title-key="chat.title"] #send-btn.composer-send-btn .ui-icon {
  display: block;
  width: 18px;
  height: 18px;
  color: var(--qw-btn-primary-fg, #fff);
}

body[data-title-key="chat.title"] #send-btn.composer-send-btn .ui-icon {
  stroke: currentColor;
  stroke-width: 2;
}

body[data-title-key="chat.title"] #send-btn.composer-send-btn--queue {
  inline-size: auto;
  width: auto;
  max-inline-size: none;
  min-inline-size: 38px;
  flex-basis: auto;
  aspect-ratio: auto;
  border: 1px solid #deded8;
  border-radius: 10px;
  padding: 0 11px;
  background: #f6f6f2;
  color: #4f4f4a;
  font-size: 13px;
  line-height: 1;
}

body[data-title-key="chat.title"] #send-btn.composer-send-btn--queue:hover:not(:disabled) {
  background: #ecece7;
  border-color: #d4d4ce;
  color: #222220;
  box-shadow: none;
}

body[data-title-key="chat.title"] #stop-btn.composer-stop-btn {
  position: relative;
  width: 38px;
  min-width: 38px;
  padding: 0;
  border: 0;
}

body[data-title-key="chat.title"] #stop-btn.composer-stop-btn::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--qw-btn-primary-fg, #fff) 28%, transparent);
  border-top-color: var(--qw-btn-primary-fg, #fff);
  animation: composer-stop-spin 0.8s linear infinite;
}

@keyframes composer-stop-spin {
  to { transform: rotate(360deg); }
}

body[data-title-key="chat.title"] .composer-stop-square {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--qw-btn-primary-fg, #fff);
  position: relative;
  z-index: 1;
}

body[data-title-key="chat.title"] .composer-queue-dock {
  position: relative;
  z-index: 1;
  margin: 0 14px -1px;
  overflow: hidden;
  border: 1px solid #e4e4de;
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: rgba(248, 248, 244, 0.96);
  color: #55554f;
}

body[data-title-key="chat.title"] .composer-queue-dock__list {
  max-height: min(28vh, 190px);
  overflow: auto;
  padding: 7px 10px 6px;
}

body[data-title-key="chat.title"] .composer-queue-dock__header {
  padding: 0 7px 4px;
  color: #92928b;
  font-size: 11px;
  font-weight: 600;
}

body[data-title-key="chat.title"] .composer-queue-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 5px;
  min-height: 30px;
}

body[data-title-key="chat.title"] .composer-queue-row__marker {
  color: #aaa9a2;
  text-align: center;
}

body[data-title-key="chat.title"] .composer-queue-row__text,
body[data-title-key="chat.title"] .composer-queue-row__remove {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

body[data-title-key="chat.title"] .composer-queue-row__text {
  min-width: 0;
  overflow: hidden;
  padding: 4px 2px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-title-key="chat.title"] .composer-queue-row__text:hover {
  color: #1f1f1d;
}

body[data-title-key="chat.title"] .composer-queue-row__remove {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  color: #999992;
  font-size: 18px;
}

body[data-title-key="chat.title"] .composer-queue-row__remove:hover {
  background: #ecece7;
  color: #c33b4a;
}

body[data-title-key="chat.title"] .attachment-strip {
  padding: 0 2px;
}

body[data-title-key="chat.title"] .artifact-chip {
  background: #f8f8f4;
  border-color: #e9e9e2;
}

body[data-title-key="chat.title"] .attachment-chip {
  background: #f8f8f4;
  border-color: #e9e9e2;
}

body[data-title-key="chat.title"] .drop-hint {
  display: none;
  border-color: #e8e8e3;
  background: #fafaf7;
}

body[data-title-key="chat.title"] .composer.drag-over .drop-hint {
  display: block;
}

body[data-title-key="chat.title"] .empty-state {
  align-items: flex-start;
  padding-top: 18vh;
}

body[data-title-key="chat.title"] .empty-state h2 {
  color: #222220;
  font-weight: 560;
}

body[data-title-key="chat.title"] .offline-host-state {
  display: flex;
  justify-content: center;
  padding: 9vh 24px 28px;
}

body[data-title-key="chat.title"] .offline-host-card {
  width: min(680px, 100%);
  border: 1px solid #e8e8e1;
  background: linear-gradient(180deg, #ffffff 0%, #fbfbf7 100%);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(36, 36, 33, 0.08);
  padding: 28px;
}

body[data-title-key="chat.title"] .offline-host-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #8a6a16;
  background: #fff8e7;
  border: 1px solid #f1deb0;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  margin-bottom: 16px;
}

body[data-title-key="chat.title"] .offline-host-card h2 {
  margin: 0 0 10px;
  color: #222220;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 620;
  letter-spacing: -0.03em;
}

body[data-title-key="chat.title"] .offline-host-card p {
  margin: 0;
  color: #65645d;
  font-size: 15px;
  line-height: 1.65;
}

body[data-title-key="chat.title"] .offline-host-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

body[data-title-key="chat.title"] .offline-host-meta span {
  border: 1px solid #ecece6;
  background: #ffffff;
  color: #65645d;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

body[data-title-key="chat.title"] .offline-host-steps {
  display: grid;
  gap: 8px;
  margin: 20px 0 0;
  padding-left: 20px;
  color: #3f3e38;
  line-height: 1.55;
}

body[data-title-key="chat.title"] .offline-host-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

@media (max-width: 800px) {
  .chat-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.mobile-open { display: flex; position: fixed; inset: 0; z-index: 10; }
}

@media (max-width: 800px) {
  body[data-title-key="chat.title"] .chat-layout {
    --chat-sidebar-width: 0px;
    display: block;
  }
  body[data-title-key="chat.title"] .sidebar {
    display: flex;
    position: fixed;
    top: 38px;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: min(320px, calc(100vw - 28px));
    transform: translateX(-102%);
    transition: transform 180ms ease;
    background: rgba(250, 250, 247, 0.98);
    border-right: 1px solid var(--border);
    box-shadow: 16px 0 42px rgba(33, 33, 25, 0.10);
    opacity: 1;
    pointer-events: auto;
  }
  body[data-title-key="chat.title"] .sidebar-head {
    display: flex;
  }
  body[data-title-key="chat.title"] .chat-layout.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body[data-title-key="chat.title"] .topbar {
    padding: 0 10px;
    gap: 8px;
  }
  body[data-title-key="chat.title"] .host-chip-label {
    max-width: 132px;
  }
  body[data-title-key="chat.title"] .host-menu {
    position: fixed;
    top: 46px;
    left: auto;
    right: 10px;
    width: min(320px, calc(100vw - 20px));
    min-width: 0;
    max-height: min(70vh, 460px);
  }
  body[data-title-key="chat.title"] .chat-banner {
    padding: 0 14px;
  }
  body[data-title-key="chat.title"] .messages {
    padding: 24px 16px 164px;
    scroll-padding-bottom: 164px;
  }
  body[data-title-key="chat.title"] .message.user .part-text {
    max-width: 92%;
  }
  body[data-title-key="chat.title"] .message.assistant .message-body,
  body[data-title-key="chat.title"] .message.assistant .part-text {
    max-width: 100%;
  }
  body[data-title-key="chat.title"] .composer {
    left: 50%;
    width: calc(100vw - 18px);
    bottom: max(8px, env(safe-area-inset-bottom));
    border-radius: 20px;
  }
  body[data-title-key="chat.title"] .composer-chip {
    display: none;
  }
  body[data-title-key="chat.title"] .topbar .me .small {
    display: none;
  }
}

@media (max-width: 520px) {
  html,
  body {
    min-width: 0;
    overflow-x: hidden;
  }

  body[data-title-key="chat.title"] .app-shell {
    height: 100dvh;
  }

  body[data-title-key="chat.title"] .topbar {
    height: 44px;
    padding: 0 8px;
  }

  body[data-title-key="chat.title"] .brand-logo {
    width: 24px;
    height: 24px;
    border-radius: 7px;
  }

  body[data-title-key="chat.title"] .topbar .brand span,
  body[data-title-key="chat.title"] #me-username {
    display: none;
  }

  body[data-title-key="chat.title"] .codex-titlebar-nav {
    display: none;
  }

  body[data-title-key="chat.title"] .codex-titlebar-nav a {
    padding: 5px 6px;
    font-size: 12px;
  }

  body[data-title-key="chat.title"] .host-chip {
    max-width: 148px;
    height: 32px;
    padding: 0 8px;
  }

  body[data-title-key="chat.title"] .host-chip-label {
    max-width: 86px;
  }

  body[data-title-key="chat.title"] .sidebar {
    top: 44px;
    width: min(300px, calc(100vw - 20px));
  }

  .sidebar-backdrop {
    inset: 44px 0 0;
  }

  body[data-title-key="chat.title"] .chat-header {
    min-height: 42px;
    padding: 8px 12px;
  }

  body[data-title-key="chat.title"] .chat-header__title-block .title {
    font-size: 13px;
  }

  body[data-title-key="chat.title"] .chat-header__title-block .status-text,
  body[data-title-key="chat.title"] #search-conversations-btn span:last-child,
  body[data-title-key="chat.title"] #child-sessions-btn {
    display: none;
  }

  body[data-title-key="chat.title"] .messages {
    padding: 18px 12px 154px;
    gap: 18px;
    scroll-padding-bottom: 154px;
  }

  body[data-title-key="chat.title"] .message.user .part-text {
    max-width: 94%;
    padding: 10px 12px;
  }

  body[data-title-key="chat.title"] .message.assistant .message-meta {
    font-size: 12px;
  }

  body[data-title-key="chat.title"] .message.assistant .part-text {
    font-size: 13px;
    line-height: 1.68;
  }

  body[data-title-key="chat.title"] .composer {
    width: calc(100vw - 14px);
    min-height: 76px;
    padding: 10px;
    border-radius: 18px;
  }

  body[data-title-key="chat.title"] .composer textarea {
    min-height: 32px;
    max-height: 128px;
    font-size: 16px;
  }

  body[data-title-key="chat.title"] .composer-row {
    gap: 8px;
  }

  body[data-title-key="chat.title"] .composer .attach-btn,
  body[data-title-key="chat.title"] #send-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    max-width: 32px;
    flex-basis: 32px;
  }

  body[data-title-key="chat.title"] #send-btn.composer-send-btn--queue {
    width: auto;
    max-width: none;
    min-width: 32px;
    flex-basis: auto;
    padding-inline: 10px;
  }

  body[data-title-key="chat.title"] #stop-btn {
    min-width: 32px;
    width: 32px;
    height: 32px;
    padding: 0;
  }

  body[data-title-key="chat.title"] .attachment-chip {
    grid-template-columns: 32px minmax(0, 1fr) auto;
  }

  body[data-title-key="chat.title"] .offline-host-state {
    padding: 32px 12px 24px;
  }

  body[data-title-key="chat.title"] .offline-host-card {
    border-radius: 18px;
    padding: 20px;
  }

  body[data-title-key="chat.title"] .offline-host-actions .btn,
  body[data-title-key="chat.title"] .onboarding-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .onboarding-view {
    padding: 24px 12px 40px;
  }

  .onboarding-card {
    border-radius: 18px;
    padding: 20px;
  }

  .onboarding-step-row {
    grid-template-columns: 28px 1fr;
    gap: 12px;
  }

  .onboarding-step-num {
    width: 28px;
    height: 28px;
  }
}

/* ---------- onboarding view (chat.html) ---------- */

.onboarding-view {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px 64px;
  overflow-y: auto;
}
.onboarding-card {
  width: 100%;
  max-width: 640px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.onboarding-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding-bottom: 4px;
}
.onboarding-hero-logo {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.onboarding-hero-logo img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.onboarding-hero h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}
.onboarding-hero p {
  margin: 0;
  max-width: 36em;
}
.onboarding-panel {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.onboarding-panel-title {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 14px;
}
.onboarding-own-device {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 16px 12px;
  background: var(--bg-soft);
}
.onboarding-own-device > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 14px 0 10px;
  list-style: none;
}
.onboarding-own-device > summary::-webkit-details-marker {
  display: none;
}
.onboarding-own-device-hint {
  margin: 0 0 12px;
  font-size: 13px;
}
.onboarding-own-device .onboarding-step-row {
  margin-top: 8px;
}
.provisioning-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
body.provisioning-open {
  overflow: hidden;
}
.provisioning-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.provisioning-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  text-align: center;
}
.provisioning-hero-logo {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.provisioning-hero-logo.is-running {
  animation: provisioning-pulse 1.6s ease-in-out infinite;
}
.provisioning-hero-logo.is-ready {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}
.provisioning-hero-logo img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.provisioning-hero h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}
.provisioning-hero p {
  margin: 0;
  font-size: 14px;
}
.provisioning-progress-wrap {
  margin-bottom: 20px;
}
.provisioning-progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-soft);
}
.provisioning-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.5s ease;
}
.provisioning-progress-count {
  margin-top: 6px;
  text-align: right;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.provisioning-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.provisioning-step {
  display: grid;
  grid-template-columns: 20px 28px 1fr;
  align-items: flex-start;
  gap: 10px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
}
.provisioning-step.is-active {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.provisioning-step-indicator {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex-shrink: 0;
}
.provisioning-step-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.provisioning-step-check-svg {
  display: block;
}
.provisioning-step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: -2px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  background: var(--bg-soft);
  color: color-mix(in srgb, var(--text) 72%, var(--text-muted));
}
.provisioning-step.is-active .provisioning-step-icon {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-soft));
  color: var(--accent);
}
.provisioning-step-icon-svg {
  display: block;
}
.provisioning-step-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
.provisioning-step-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text-muted) 45%, transparent);
}
.provisioning-step-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.provisioning-step-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}
.provisioning-step-title.is-muted {
  color: var(--text-muted);
  font-weight: 500;
}
.provisioning-step-sub {
  font-size: 12px;
  line-height: 1.45;
}
.provisioning-cold-hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
}
.provisioning-degraded {
  margin-top: 8px;
}
.provisioning-degraded-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.provisioning-degraded-body {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.5;
}
.provisioning-degraded-actions {
  display: flex;
  gap: 8px;
}
.provisioning-degraded-actions .btn {
  flex: 1;
}
.provisioning-ready {
  margin-top: 8px;
}
.provisioning-enter-btn {
  width: 100%;
}
@keyframes provisioning-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}
.onboarding-step-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 16px;
  align-items: flex-start;
}
.onboarding-step-row h3 {
  margin: 0 0 6px;
  font-size: 17px;
}
.onboarding-step-row p {
  margin: 0 0 10px;
}
.onboarding-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.onboarding-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.onboarding-status {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.onboarding-status.online {
  background: rgba(74, 210, 149, 0.08);
  border-color: rgba(74, 210, 149, 0.4);
  color: var(--success);
}
.onboarding-status .ghost {
  margin-left: auto;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
}

/* ---------- top-bar host chip + dropdown menu ---------- */

.host-chip-wrap {
  position: relative;
  margin-right: 8px;
}
.host-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.host-chip:hover { background: var(--bg-card); }
.host-chip.host-chip--locked {
  cursor: pointer;
}
.host-chip.host-chip--locked .host-chip-caret { opacity: 0.35; }
.host-chip[data-state="online"] { border-color: rgba(74, 210, 149, 0.45); }
.host-chip[data-state="offline"] { border-color: rgba(240, 179, 65, 0.45); color: var(--warn); }
.host-chip[data-state="error"] { border-color: rgba(255, 107, 122, 0.45); color: var(--danger); }
.host-chip > .dot,
.host-menu-item > .dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  min-width: 8px;
  min-height: 8px;
  align-self: center;
}
.host-chip-label {
  flex: 1;
  min-width: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host-chip-caret {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1;
}
.host-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  max-width: calc(100vw - 16px);
  max-height: min(70vh, calc(100dvh - 16px));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  box-sizing: border-box;
}
.host-menu-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}
.host-menu-section + .host-menu-section {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.host-menu-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 4px 8px;
}
.host-menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
}
.host-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
}
.host-menu-item:hover { background: var(--bg-elev); }
.host-menu-item.active {
  background: var(--accent-soft);
  border-color: rgba(108, 140, 255, 0.5);
}
.host-menu-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host-menu-item .meta {
  font-size: 11px;
  color: var(--text-muted);
}
.host-menu-action {
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
}
.host-menu-action:hover { background: var(--bg-elev); color: var(--text); }
.host-menu-empty {
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- marketing landing page ---------- */

.landing-body {
  background:
    radial-gradient(ellipse at 12% -10%, rgba(108, 140, 255, 0.18), transparent 55%),
    radial-gradient(ellipse at 90% 5%, rgba(181, 145, 255, 0.16), transparent 55%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 32px;
  background: rgba(15, 17, 23, 0.78);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid rgba(43, 51, 68, 0.7);
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
}
.landing-brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #b591ff);
  color: white;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.landing-nav-links {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}
.landing-nav-links a {
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.landing-nav-links a:hover {
  color: var(--text);
  background: var(--bg-elev);
  text-decoration: none;
}

.landing-nav-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.btn:hover { text-decoration: none; background: var(--bg-card); border-color: var(--border-strong); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  color: white;
  box-shadow: 0 8px 24px rgba(108, 140, 255, 0.28);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-strong), #4060e0); transform: translateY(-1px); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-elev); }
.btn-lg { padding: 12px 20px; font-size: 15px; border-radius: 12px; }

.landing-main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 32px 80px;
  display: flex;
  flex-direction: column;
  gap: 80px;
}

.landing-hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 56px;
  align-items: center;
  padding-top: 28px;
}
.hero-text { display: flex; flex-direction: column; gap: 18px; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(74, 210, 149, 0.35);
  background: rgba(74, 210, 149, 0.08);
  color: var(--success);
  font-size: 12px;
}
.hero-text h1 {
  font-size: 44px;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.5px;
  font-weight: 700;
}
.hero-sub {
  font-size: 17px;
  color: var(--text-muted);
  margin: 0;
  max-width: 540px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.hero-bullets {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
}
.hero-bullets li {
  position: relative;
  padding-left: 22px;
}
.hero-bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(108, 140, 255, 0.18);
}

.hero-visual {
  position: relative;
  height: 380px;
}
.hv-card {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hv-mac {
  top: 30px;
  left: 0;
  width: 320px;
}
.hv-phone {
  bottom: 0;
  right: 0;
  width: 260px;
  background: var(--bg-elev);
}
.hv-title {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}
.hv-row.hv-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(108, 140, 255, 0.35), rgba(181, 145, 255, 0.25));
}
.hv-row.hv-bar.short { width: 70%; }
.hv-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--success);
}
.hv-bubble {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  max-width: 90%;
}
.hv-bubble-user {
  align-self: flex-end;
  background: var(--accent-soft);
  border: 1px solid rgba(108, 140, 255, 0.45);
  color: var(--text);
}
.hv-bubble-ai {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.landing-section {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.landing-section h2 {
  font-size: 28px;
  margin: 0;
  letter-spacing: -0.3px;
  font-weight: 700;
}
.landing-section-tinted {
  background: rgba(28, 34, 48, 0.55);
  border: 1px solid rgba(43, 51, 68, 0.7);
  border-radius: 20px;
  padding: 36px;
}

.why-grid, .privacy-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.why-card, .privacy-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.why-card h3, .privacy-card h3 { margin: 0; font-size: 17px; }
.why-card p, .privacy-card p { color: var(--text-muted); margin: 0; font-size: 14px; }
.why-tag {
  align-self: flex-start;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 999px;
}

.steps-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.step h3 { margin: 0; font-size: 17px; }
.step p { color: var(--text-muted); margin: 0; font-size: 14px; }
.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.download-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.download-card h3 { margin: 0; font-size: 18px; }
.download-card p { margin: 0; }
.download-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.download-primary {
  background: linear-gradient(135deg, rgba(108, 140, 255, 0.15), rgba(181, 145, 255, 0.08));
  border-color: rgba(108, 140, 255, 0.4);
}

.landing-footer {
  border-top: 1px solid var(--border);
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 13px;
}
.footer-row { display: flex; align-items: center; gap: 10px; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--text); }

@media (max-width: 920px) {
  .landing-hero { grid-template-columns: 1fr; gap: 36px; }
  .hero-visual { height: 320px; }
  .hv-mac { width: 78%; }
  .hv-phone { width: 64%; }
  .hero-text h1 { font-size: 34px; }
  .why-grid, .privacy-grid, .steps-grid, .download-grid { grid-template-columns: 1fr; }
  .landing-section-tinted { padding: 24px; }
}

@media (max-width: 640px) {
  .landing-nav { padding: 12px 18px; gap: 10px; }
  .landing-nav-links { display: none; }
  .landing-nav-actions { gap: 6px; }
  .landing-nav-actions .btn-ghost { display: none; }
  .landing-main { padding: 24px 18px 60px; gap: 56px; }
  .hero-text h1 { font-size: 28px; }
}

/* ---------- Codex-style light landing page ---------- */

.landing-body {
  --bg: #ffffff;
  --bg-soft: #f7f7f4;
  --bg-card: #ffffff;
  --bg-elev: #f1f1ee;
  --border: #e8e8e3;
  --border-strong: #d7d7cf;
  --text: #1f1f1d;
  --text-muted: #85847c;
  --accent: #222220;
  --accent-strong: #111110;
  --accent-soft: #f0f0eb;
  --success: #1d8f5d;
  --code-bg: #f6f6f2;
  --shadow: 0 18px 48px rgba(30, 30, 20, 0.10), 0 2px 8px rgba(30, 30, 20, 0.06);
  background:
    radial-gradient(circle at 50% -20%, rgba(32, 32, 28, 0.05), transparent 35%),
    #fff;
}

.landing-body .landing-nav {
  height: 52px;
  padding: 0 clamp(18px, 4vw, 42px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.landing-body .landing-brand {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.landing-body .brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #242421;
  color: #fff;
  box-shadow: none;
}

.landing-body .brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  box-shadow: none;
}

.landing-body .landing-nav-links a {
  color: var(--text-muted);
  border-radius: 9px;
}

.landing-body .landing-nav-links a:hover {
  color: var(--text);
  background: var(--bg-elev);
}

.landing-body .btn {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  box-shadow: none;
}

.landing-body .btn:hover {
  background: var(--bg-elev);
  border-color: var(--border-strong);
  transform: none;
}

.landing-body .btn-primary {
  background: #242421;
  border-color: #242421;
  color: #fff;
  box-shadow: none;
}

.landing-body .btn-primary:hover {
  background: #111110;
}

.landing-body .btn-download {
  background: #fff;
  border-color: #242421;
  color: #242421;
  box-shadow: 0 10px 28px rgba(30, 30, 20, 0.10);
  font-weight: 650;
}

.landing-body .btn-download::before {
  content: "↓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #242421;
  color: #fff;
  font-size: 13px;
  line-height: 1;
}

.landing-body .btn-download:hover {
  background: #f6f6f2;
  border-color: #111110;
}

.landing-body .landing-main {
  max-width: 1080px;
  padding-top: 68px;
  gap: 96px;
  color: var(--text);
}

.landing-body .landing-hero {
  grid-template-columns: minmax(0, 1.06fr) minmax(320px, 0.94fr);
  gap: 60px;
  align-items: center;
  padding-top: 10px;
}

.landing-body .hero-badge {
  border-color: #e2e2dc;
  background: #fbfbf8;
  color: #5d5c55;
}

.landing-body .hero-text {
  gap: 20px;
}

.landing-body .hero-text h1 {
  max-width: 760px;
  font-size: clamp(42px, 6vw, 68px);
  line-height: 1.04;
  letter-spacing: -2.4px;
  font-weight: 650;
}

.landing-body .hero-sub {
  max-width: 620px;
  font-size: 18px;
  line-height: 1.75;
  color: #68675f;
}

.landing-body .hero-actions {
  margin-top: 8px;
}

.landing-body .hero-download-hint {
  margin: -8px 0 0;
  color: #6c6b63;
  font-size: 13px;
}

.landing-body .hero-bullets {
  color: #77766f;
}

.landing-body .hero-bullets li::before {
  background: #242421;
  box-shadow: 0 0 0 4px rgba(36, 36, 33, 0.08);
}

.landing-body .hero-visual {
  height: 410px;
}

.landing-body .hv-card {
  border-color: #e9e9e3;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.landing-body .hv-mac {
  width: min(360px, 82%);
}

.landing-body .hv-phone {
  width: min(292px, 70%);
  background: #fbfbf8;
}

.landing-body .hv-row.hv-bar {
  background: linear-gradient(90deg, #ecece6, #f7f7f2);
}

.landing-body .hv-bubble-user {
  background: #f5f5f0;
  border-color: #eeeeE8;
}

.landing-body .landing-section {
  gap: 24px;
  color: var(--text);
}

.landing-body .landing-section h2 {
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -1.1px;
  font-weight: 620;
  color: #20201d;
}

.landing-body .landing-section-tinted {
  background: #fafaf7;
  border: 1px solid #ecece6;
  border-radius: 28px;
  color: var(--text);
}

.landing-body .why-card,
.landing-body .privacy-card,
.landing-body .step,
.landing-body .download-card {
  border-color: #e9e9e3;
  border-radius: 20px;
  background: #fff;
  box-shadow: none;
  color: var(--text);
}

.landing-body .why-card h3,
.landing-body .privacy-card h3,
.landing-body .step h3,
.landing-body .download-card h3 {
  color: #242421;
  font-weight: 610;
  letter-spacing: -0.2px;
}

.landing-body .why-card p,
.landing-body .privacy-card p,
.landing-body .step p,
.landing-body .download-card p,
.landing-body .download-card .muted {
  color: #65645d;
  line-height: 1.65;
}

.landing-body .why-tag,
.landing-body .step-num {
  background: #f3f3ee;
  color: #343431;
  border: 1px solid #e6e6df;
}

.landing-body .download-primary {
  background: #fafaf7;
  border-color: #e4e4dc;
}

.landing-body .landing-footer {
  background: #fff;
  border-top-color: var(--border);
  color: #74736c;
}

.landing-body .footer-links a {
  color: #6f6e66;
}

.landing-body .footer-links a:hover {
  color: #242421;
}

.landing-body .muted {
  color: #6f6e66;
}

.landing-body .small {
  color: #78776f;
}

@media (max-width: 920px) {
  .landing-body .landing-hero {
    grid-template-columns: 1fr;
  }
  .landing-body .hero-visual {
    max-width: 560px;
  }
}

@media (max-width: 640px) {
  .landing-body .landing-nav {
    padding: 0 14px;
  }
  .landing-body .landing-main {
    padding-top: 40px;
  }
  .landing-body .hero-text h1 {
    letter-spacing: -1.2px;
  }
}

/* Final landing override: keep marketing pages fully light even when older
   dark-theme rules share the same class names. */
html:has(body.landing-body),
body.landing-body {
  background: #ffffff !important;
  color: #1f1f1d !important;
}

body.landing-body .landing-main,
body.landing-body .landing-section {
  background: transparent !important;
  color: #1f1f1d !important;
}

body.landing-body .landing-section-tinted {
  background: #fafaf7 !important;
  border-color: #ecece6 !important;
  color: #1f1f1d !important;
}

body.landing-body .why-card,
body.landing-body .privacy-card,
body.landing-body .step,
body.landing-body .download-card,
body.landing-body .hv-card {
  background: #ffffff !important;
  border-color: #e9e9e3 !important;
  color: #1f1f1d !important;
}

body.landing-body .download-primary,
body.landing-body .hv-phone {
  background: #fafaf7 !important;
}

body.landing-body h1,
body.landing-body h2,
body.landing-body h3 {
  color: #20201d !important;
}

body.landing-body p,
body.landing-body .muted,
body.landing-body .hero-sub,
body.landing-body .hero-bullets,
body.landing-body .why-card p,
body.landing-body .privacy-card p,
body.landing-body .step p,
body.landing-body .download-card p {
  color: #65645d !important;
}

@media (max-width: 520px) {
  .auth-body .auth-screen.split,
  .auth-body .auth-modern {
    min-height: 100dvh;
  }

  .auth-body .auth-modern::before,
  .auth-body .auth-modern::after {
    opacity: 0.65;
  }

  .auth-body .auth-modern .auth-brand-panel {
    padding: 18px 16px 8px;
  }

  .auth-body .auth-modern .auth-brand-copy {
    margin-top: 22px;
  }

  .auth-body .auth-modern .auth-brand-copy h2 {
    font-size: 28px;
    line-height: 1.08;
  }

  .auth-body .auth-modern .auth-brand-copy p,
  .auth-body .auth-modern .auth-brand-bullets {
    display: none;
  }

  .auth-body .auth-modern .auth-main {
    align-items: flex-start;
    padding: 10px 12px 24px;
  }

  .auth-body .auth-modern .auth-card {
    padding: 18px;
    border-radius: 20px;
    box-shadow: 0 18px 48px rgba(42, 50, 77, 0.12);
  }

  .auth-body .auth-modern .auth-card h1 {
    font-size: 23px;
  }

  .auth-card-head {
    gap: 10px;
  }

  .auth-body .auth-modern .segmented {
    border-radius: 16px;
  }

  .auth-body .auth-modern .segmented button {
    min-height: 40px;
    border-radius: 12px;
    padding: 8px 10px;
  }

  .auth-body .auth-modern input,
  .auth-body .auth-modern button.primary,
  .auth-body .auth-modern .oauth-button {
    min-height: 48px;
    font-size: 16px;
  }

  .landing-body .landing-nav {
    height: auto;
    min-height: 54px;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
  }

  .landing-body .landing-brand .brand-text {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .landing-body .landing-nav-actions {
    gap: 6px;
  }

  .landing-body .landing-nav-actions .btn {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .landing-body .landing-main {
    padding: 22px 12px 54px;
    gap: 44px;
  }

  .landing-body .landing-hero {
    gap: 24px;
  }

  .landing-body .hero-badge {
    max-width: 100%;
  }

  .landing-body .hero-text h1 {
    font-size: clamp(30px, 11vw, 42px);
    line-height: 1.06;
  }

  .landing-body .hero-sub {
    font-size: 15px;
  }

  .landing-body .hero-actions,
  .landing-body .download-actions {
    width: 100%;
    flex-direction: column;
  }

  .landing-body .hero-actions .btn,
  .landing-body .download-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .landing-body .hero-visual {
    height: auto;
    min-height: 260px;
    max-width: 100%;
  }

  .landing-body .hv-mac {
    width: 92%;
  }

  .landing-body .hv-phone {
    width: 74%;
    right: 0;
  }

  .landing-body .landing-section,
  .landing-body .landing-section-tinted {
    border-radius: 20px;
    padding: 20px;
  }

  .landing-body .landing-section h2 {
    font-size: 24px;
  }

  .landing-body .why-card,
  .landing-body .privacy-card,
  .landing-body .step,
  .landing-body .download-card {
    border-radius: 16px;
    padding: 18px;
  }

  .landing-body .landing-footer {
    padding: 22px 14px;
    gap: 14px;
  }

  .landing-body .footer-row,
  .landing-body .footer-links {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ---------- legal public pages ---------- */

.legal-body {
  min-height: 100vh;
  background: #ffffff;
  color: #20201d;
}

.legal-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.88);
  border-bottom-color: #ecece6;
  color: #20201d;
}

.legal-nav .landing-nav-actions {
  position: relative;
  z-index: 50;
}

.legal-nav .language-switcher--dropdown .language-switcher-trigger {
  background: #ffffff;
  border: 1px solid #e4e4dc;
}

.legal-nav .landing-brand,
.legal-nav .landing-nav-links a {
  color: #20201d;
}

.legal-nav .landing-nav-links a:not([aria-current="page"]) {
  color: #6f6e66;
}

.legal-nav .landing-nav-links a:hover,
.legal-nav .landing-nav-links a[aria-current="page"] {
  background: #f3f3ee;
  color: #20201d;
}

.legal-nav .btn-ghost {
  border-color: #e4e4dc;
  color: #20201d;
}

.legal-main {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(32px, 7vw, 72px) 20px 80px;
}

.legal-card {
  background: #ffffff;
  border: 1px solid #e9e9e3;
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(29, 27, 20, 0.08);
  padding: clamp(24px, 5vw, 56px);
}

.legal-kicker {
  margin: 0 0 12px;
  color: #77766f;
  font-size: 13px;
}

.legal-card h1 {
  margin: 0 0 18px;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: #20201d;
}

.legal-card h2 {
  margin: 32px 0 10px;
  font-size: 18px;
  color: #20201d;
}

.legal-card p {
  margin: 0 0 14px;
  color: #5f5e57;
  font-size: 15px;
  line-height: 1.72;
}

.legal-card a {
  color: #315ee8;
}

@media (max-width: 640px) {
  .legal-nav {
    padding: 12px 16px;
  }

  .legal-nav .landing-nav-links {
    display: none;
  }
}

/* ---- Account-level cloud Notes & Calendar panels (§8.4) ---- */
.nav-item--active {
  background: var(--bg-elev);
  border-color: var(--border-strong);
}

.feature-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
}

.feature-pane__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.feature-pane__head h2 {
  margin: 0;
  font-size: 16px;
}

.feature-pane__body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.feature-split {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
}

.feature-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feature-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  width: 100%;
}

.feature-item:hover {
  background: var(--bg-elev);
}

.feature-item--active {
  background: var(--bg-card);
  border-color: var(--border-strong);
}

.feature-item__title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feature-item__preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feature-empty {
  padding: 24px 12px;
  text-align: center;
}

.feature-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  overflow-y: auto;
}

.feature-input,
.feature-textarea {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  width: 100%;
  box-sizing: border-box;
}

.feature-textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.5;
}

.feature-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.feature-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.feature-editor__row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feature-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feature-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: 12px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.feature-chip:hover {
  border-color: var(--border-strong, var(--border));
  background: var(--bg-card);
}

.feature-chip__open {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  font-size: inherit;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feature-chip__open:hover {
  color: var(--accent, #2563eb);
  text-decoration: underline;
}

.feature-chip__remove {
  border: none;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}

.feature-chip__remove:hover {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger, #dc2626);
}

@media (max-width: 720px) {
  .feature-split {
    grid-template-columns: 1fr;
  }
  .feature-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }
}

/* ===== Apple Notes / Calendar redesign (§8.4 + §8.4.1) ================= */

:root {
  --notes-accent: #e6b800;        /* Apple Notes yellow */
  --notes-accent-soft: rgba(230, 184, 0, 0.16);
  --cal-accent: #ff3b30;          /* Apple Calendar red */
}

/* shared pill-style buttons */
.apple-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-elev);
  color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.apple-btn:hover:not(.apple-btn--accent):not(.apple-btn--danger) { background: var(--bg-card); }
.apple-btn--ghost { background: transparent; border-color: var(--border); }
.apple-btn--ghost:hover { background: var(--bg-elev); }
.apple-btn--accent { background: var(--accent); color: #fff; border-color: transparent; }
.apple-btn--accent:hover {
  background: var(--accent-strong, var(--accent));
  color: #fff;
  filter: none;
}
.apple-btn--danger { background: transparent; color: var(--danger, #dc2626); border-color: transparent; }
.apple-btn--danger:hover { background: rgba(220, 38, 38, 0.1); }
.apple-btn:disabled { opacity: 0.5; cursor: default; }

.saved-pill {
  font-size: 12px;
  color: #2e9e58;
  background: rgba(46, 158, 88, 0.14);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ---- Notes (Apple Notes) ---- */
.notes-split {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.note-list-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: #f7f7f6;
}

.note-list-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 10px;
  flex-shrink: 0;
}

.note-list-search__icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.note-list-search__input {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: rgba(26, 28, 31, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
}

.note-list-search__input:focus {
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.note-list-search__input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.note-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.note-list-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 6px 12px;
  text-align: center;
  font-size: 11px;
}

.note-list-group__label {
  padding: 12px 16px 4px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.note-detail-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
}

.note-detail-empty {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.note-detail-empty[hidden],
.note-editor[hidden] {
  display: none !important;
}

.note-detail-empty__icon {
  color: var(--text-muted);
  opacity: 0.45;
}

.note-detail-empty p {
  margin: 0;
  font-size: 14px;
}

.note-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  width: calc(100% - 16px);
  margin: 0 8px;
  box-sizing: border-box;
}
.note-item:hover { background: rgba(26, 28, 31, 0.05); }
.note-item--active { background: rgba(251, 191, 36, 0.55); }
.note-item--active .note-item__title { color: var(--text); }

.note-item__title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 0;
}
.note-item__date { flex-shrink: 0; }
.note-item__preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  color: var(--text-muted);
  opacity: 0.85;
}
.note-item__clip { flex-shrink: 0; opacity: 0.7; }

.note-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  box-sizing: border-box;
}

.note-editor__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.note-editor__content {
  max-width: 48rem;
  margin: 0 auto;
  padding: 16px 40px 24px;
  box-sizing: border-box;
}

.note-editor__divider {
  height: 0;
  border-bottom: 1px solid var(--border);
  margin: 12px 0 0;
}
.note-editor__title {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: clamp(22px, 2vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  padding: 0;
  outline: none;
  border-radius: 0;
  width: 100%;
}
.note-editor__title:focus {
  border: none;
  box-shadow: none;
  outline: none;
}
.note-editor__title::placeholder {
  color: var(--text-muted);
  opacity: 0.55;
  font-weight: 600;
}
.note-editor__tags {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 0 0;
  outline: none;
  border-radius: 0;
  width: 100%;
}
.note-editor__tags:focus {
  box-shadow: none;
  outline: none;
}
.note-editor__tags::placeholder {
  color: var(--text-muted);
  opacity: 0.55;
}
.note-editor__body {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.65;
  padding: 8px 0 0;
  outline: none;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.note-body-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  gap: 0;
}

.note-block {
  width: 100%;
  box-sizing: border-box;
}

/* Override global form styles inside the WYSIWYG surface. */
.note-body-editor .note-table__cell {
  width: auto;
  min-width: 0;
  border: none;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}
.note-body-editor .note-table__cell:focus {
  border: none;
  box-shadow: none;
  outline: none;
}

/* Neutralize the global form-input look: the note body must read as a
   seamless writing surface, not a stack of input boxes. */
.note-block__textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  color: inherit;
  font: inherit;
  font-size: inherit;
  line-height: 1.65;
  padding: 4px 0;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  outline: none;
}
.note-block__textarea:focus {
  border: none;
  box-shadow: none;
  outline: none;
}
.note-block__textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.55;
}

.note-block--todo {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 2px 0;
}

.note-todo__check {
  margin-top: 8px;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #2563eb);
}

.note-todo__input {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
}

.note-todo__done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.note-block__remove {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  width: 24px;
  height: 24px;
  margin-top: 6px;
  padding: 0;
  cursor: pointer;
  opacity: 0.45;
}
.note-block__remove:hover { opacity: 1; }

.note-block--table {
  margin: 10px 0;
}

.note-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}

.note-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.note-table--edit th,
.note-table--edit td {
  border: 1px solid var(--border);
  padding: 0;
  vertical-align: top;
}

.note-table__cell {
  display: block;
  width: 100%;
  box-sizing: border-box;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 8px 10px;
  outline: none;
}

.note-table__cell--header {
  font-weight: 600;
  background: var(--bg-elev);
}

.note-table__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px 0;
}

.note-table__action {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 0;
  cursor: pointer;
}
.note-table__action:hover {
  color: var(--text);
  text-decoration: underline;
}
.note-table__action--danger:hover {
  color: var(--danger, #dc2626);
}

.note-body-editor__pad {
  flex: 1 1 auto;
  min-height: 48px;
  cursor: text;
}

.note-wikilink {
  color: var(--accent, #2563eb);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.note-url-link {
  color: var(--accent, #2563eb);
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.note-block__url-preview {
  display: block;
  margin: 0 0 4px;
  font-size: inherit;
  line-height: 1.5;
}

.note-backlinks {
  margin-top: 4px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev, rgba(0, 0, 0, 0.03));
}
.note-backlinks strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.note-backlinks ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.note-backlinks .linkish {
  border: none;
  background: transparent;
  padding: 2px 0;
  font: inherit;
  font-size: 13px;
  color: var(--accent, #2563eb);
  cursor: pointer;
}
.note-backlinks .linkish:hover {
  text-decoration: underline;
}

.note-share-panel {
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev, rgba(0, 0, 0, 0.03));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-share-panel__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.note-share-panel__row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.note-share-panel__url {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg, #fff);
}

.notes-head-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.notes-more-wrap {
  position: relative;
}

.notes-more-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
}

.notes-more-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.notes-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 148px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg, #fff);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

.notes-more-menu__item {
  display: block;
  width: 100%;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  padding: 9px 12px;
  cursor: pointer;
}

.notes-more-menu__item:hover:not(:disabled) {
  background: var(--bg-elev);
}

.notes-more-menu__item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.notes-more-menu__item--danger {
  color: var(--danger, #dc2626);
}

.note-editor .feature-attachments {
  padding: 6px 0 10px;
}

.note-editor__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.note-editor__toolbar-insert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex: 1;
  min-width: 0;
}

.note-editor__toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.note-editor__tool-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent, #2563eb);
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.note-editor__tool-btn .ui-icon-slot {
  width: 18px;
  height: 18px;
}

.note-editor__tool-btn:hover {
  background: var(--bg-elev);
}

.note-editor__toolbar .apple-btn--ghost {
  border-color: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 10px;
}
.note-editor__toolbar .apple-btn--ghost:hover {
  background: var(--bg-elev);
  color: var(--text);
}
.note-editor__toolbar .apple-btn--accent {
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 12px;
}

/* ---- Calendar (Apple Calendar) ---- */
.calendar-pane { position: relative; }
.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cal-nav {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
}
.cal-nav:hover { background: var(--bg-elev); }
.cal-month-label {
  font-size: 15px;
  font-weight: 700;
  min-width: 0;
  text-align: center;
}

.calendar-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
  align-items: stretch;
  height: 100%;
  min-height: 0;
}

.calendar-grid {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 16px;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.calendar-grid__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-bottom: 8px;
}
.calendar-grid__cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(64px, auto);
  gap: 4px;
  flex: 0 0 auto;
}
.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 4px;
  min-width: 0;
  min-height: 64px;
  text-align: center;
}
.cal-cell:hover { background: var(--bg-elev); }
.cal-cell--other { color: var(--text-muted); opacity: 0.45; }
.cal-cell__num {
  font-size: 13px;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  flex-shrink: 0;
}
.cal-cell--today .cal-cell__num { background: var(--cal-accent, #ff3b30); color: #fff; font-weight: 600; }
.cal-cell--selected {
  background: var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.cal-cell__dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  width: 100%;
  min-height: 6px;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.calendar-agenda {
  border-left: 1px solid var(--border);
  padding: 12px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}
.calendar-agenda__head {
  font-size: 14px;
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-bottom: 4px;
  z-index: 1;
}
.calendar-agenda__list { display: flex; flex-direction: column; gap: 4px; }
.calendar-agenda__empty {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 24px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.agenda-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  width: 100%;
}
.agenda-row:hover { background: var(--bg-elev); }
.agenda-row__bar { width: 3px; align-self: stretch; border-radius: 2px; min-height: 32px; }
.agenda-row__time { font-size: 12px; color: var(--text-muted); width: 58px; flex-shrink: 0; padding-top: 1px; }
.agenda-row__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.agenda-row__title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.agenda-row__loc { font-size: 12px; color: var(--text-muted); }
.agenda-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
}

/* ---- modals (event editor + subscriptions) ---- */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 24px;
}
.modal-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.28);
  padding: 22px;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 86%;
  overflow-y: auto;
}
.event-editor__row { display: flex; gap: 12px; }
.event-editor__row .feature-field { flex: 1; }
.event-readonly-hint {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-elev);
  border-radius: 8px;
  padding: 8px 10px;
}

.sources-card { max-width: 520px; }
.sources-card__head { display: flex; align-items: center; gap: 10px; }
.sources-card__head h3 { margin: 0; font-size: 16px; }
.sources-list { display: flex; flex-direction: column; gap: 6px; }
.source-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.source-row__dot { width: 12px; height: 12px; border-radius: 999px; flex-shrink: 0; }
.source-row__body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.source-row__title { font-weight: 600; font-size: 14px; }
.source-row__err { font-size: 12px; color: var(--danger, #dc2626); }
.source-action { padding: 4px 10px; font-size: 12px; }
.sources-add { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.sources-add h4 { margin: 0; font-size: 14px; }
.sources-add__row { display: flex; gap: 8px; align-items: center; }
.sources-add__row .feature-input { flex: 1; }
.source-color { width: 40px; height: 38px; border: 1px solid var(--border); border-radius: 8px; background: transparent; cursor: pointer; padding: 2px; }

@media (max-width: 860px) {
  .notes-split { grid-template-columns: 1fr; }
  .note-list-column {
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .note-editor__toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .note-editor__toolbar-insert {
    justify-content: space-around;
  }
  .note-editor__toolbar-actions {
    justify-content: flex-end;
  }
  .note-editor__content {
    padding-left: 20px;
    padding-right: 20px;
  }
  .calendar-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .calendar-grid {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .calendar-agenda { border-top: none; }
}

.market-channel-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--text) 42%, transparent);
  overflow: auto;
}
.market-channel-shell {
  width: min(100%, 720px);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}
.market-channel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e5e5ea);
  background: var(--bg-card);
}
.market-channel-header__title {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
}
.market-channel-back,
.market-channel-tab,
.market-channel-btn {
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 8px;
  background: var(--bg-card);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.market-channel-send {
  border: none;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg-card);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.market-channel-send:hover {
  opacity: 0.9;
}
.market-channel-btn--ghost {
  background: var(--bg-elev);
  border-color: var(--border-strong);
  color: var(--text);
}
.market-channel-btn--ghost:hover {
  background: color-mix(in srgb, var(--text) 5%, var(--bg-elev));
}
.market-channel-tabs {
  display: inline-flex;
  gap: 4px;
}
.market-channel-tab.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg-card);
}
.market-channel-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 16px;
  background: var(--bg);
}
.market-channel-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border, #e5e5ea);
  background: var(--bg-card);
}
.market-channel-footer input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text);
}
.market-channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 12px;
  padding: 14px;
}
.market-channel-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.market-channel-card h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.market-channel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.market-channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 10px;
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.market-channel-row__name {
  font-weight: 700;
}
.market-channel-row__meta {
  display: inline-flex;
  gap: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.market-channel-badge {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}
.market-channel-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.market-channel-note,
.market-channel-footnote {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}
.commodity-venue-group + .commodity-venue-group {
  margin-top: 14px;
}
.commodity-venue-group__title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
}
.commodity-venue-group__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.commodity-venue-tile {
  width: auto;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.commodity-venue-tile--up {
  background: rgba(31, 157, 91, 0.08);
  border-color: rgba(31, 157, 91, 0.2);
}
.commodity-venue-tile--down {
  background: rgba(199, 125, 27, 0.08);
  border-color: rgba(199, 125, 27, 0.2);
}
.commodity-venue-tile--idle {
  opacity: 0.72;
  cursor: not-allowed;
}
.commodity-venue-tile__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.commodity-venue-tile__label {
  font-size: 14px;
  font-weight: 800;
}
.commodity-venue-tile__symbol {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.commodity-venue-tile__exchange {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  font-size: 10px;
  font-weight: 800;
  color: var(--text-secondary, var(--text-muted));
}
.commodity-venue-tile__price {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.commodity-venue-tile__change {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.commodity-venue-tile__ohlc {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
}
.commodity-venue-tile__ohlc > div {
  padding: 4px 5px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.commodity-venue-tile__ohlc span {
  display: block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
}
.commodity-venue-tile__ohlc strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.commodity-venue-tile__empty {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.market-channel {
  width: 100%;
  max-width: 1360px;
  max-height: min(940px, 100%);
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}
.market-header,
.market-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border, #e5e5ea);
}
.market-header .market-segment--tabs {
  margin-left: auto;
}
.market-title-stack {
  display: grid;
  gap: 2px;
  flex: 1;
}
.market-title-stack span {
  color: var(--text-muted);
  font-size: 12px;
}
.market-select {
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 999px;
  background: var(--bg-card);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.market-body { flex: 1; min-height: 0; padding: 12px 16px 16px; overflow: auto; }
.market-panel { display: grid; gap: 12px; }
.market-panel--split {
  grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
  .market-channel-overlay {
    padding: 24px;
  }
  .market-body {
    padding: 16px 24px 20px;
  }
  .market-panel--split {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }
  .market-panel--split > .market-side {
    position: sticky;
    top: 0;
  }
}
.market-watch-table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.market-watch-table-wrap {
  max-height: min(520px, 60vh);
  overflow: auto;
}
.market-watch-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.market-watch-table th,
.market-watch-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #e5e5ea);
  text-align: left;
}
.market-watch-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(6px);
}
.market-watch-table td.market-num,
.market-watch-table th:nth-child(n + 4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.market-watch-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}
.market-watch-table tbody tr {
  cursor: pointer;
}
.market-watch-table tbody tr:hover {
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
@media (max-width: 1023px) {
  .market-watch-table-wrap {
    overflow-x: auto;
  }
  .market-watch-table {
    min-width: 640px;
  }
}
.market-card {
  background: var(--bg-card);
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.market-card--flush {
  padding: 0;
  overflow: hidden;
}
.market-card--flush .market-watch-table-wrap {
  max-height: min(520px, 60vh);
}
.market-btn {
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 8px;
  background: var(--bg-card);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.market-btn:hover {
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
.market-btn--small {
  padding: 4px 10px;
  font-size: 11px;
}
.market-btn--primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg-card);
}
.market-btn--primary:hover {
  opacity: 0.9;
}
.market-btn--block {
  display: block;
  width: 100%;
  margin-top: 10px;
}
.market-segment {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
.market-segment button {
  border: none;
  border-radius: 6px;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  opacity: 0.62;
  cursor: pointer;
}
.market-segment button:hover {
  opacity: 0.85;
  background: color-mix(in srgb, var(--text) 5%, transparent);
}
.market-segment button.active {
  opacity: 1;
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow);
}
.market-segment--tabs button.active {
  background: var(--text);
  color: var(--bg-card);
  box-shadow: none;
}
.market-segment--bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border, #e5e5ea);
}
.market-segment--inline {
  flex-wrap: wrap;
}
.market-filter-row,
.market-watch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.market-filter-row {
  margin-top: 12px;
}
.market-filter-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.market-watch-toolbar h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.market-watch-toolbar__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.market-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--text) 40%, transparent);
  overflow: auto;
}
.market-detail-panel {
  width: 100%;
  max-width: 1280px;
  max-height: min(920px, 100%);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}
.market-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border, #e5e5ea);
}
.market-detail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.market-detail-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 20px;
}
.market-detail-grid {
  display: grid;
  gap: 16px;
}
@media (min-width: 1024px) {
  .market-detail-grid {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }
  .market-detail-aside {
    position: sticky;
    top: 0;
  }
}
.market-detail-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.market-detail-quote-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}
.market-detail-price {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.market-detail-change {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.market-quote-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 8px;
  min-width: 240px;
}
.market-quote-metric {
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
  padding: 8px 10px;
}
.market-quote-metric small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}
.market-quote-metric strong {
  display: block;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.market-detail-chart-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.market-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.market-range-track {
  position: relative;
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
}
.market-range-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid var(--bg-card);
  background: #10b981;
  box-shadow: var(--shadow);
  transform: translateY(-50%);
}
.market-ai-stack {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.market-ai-prompt {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-elev);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  cursor: pointer;
  color: var(--text);
}
.market-ai-prompt:hover {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.market-detail-aside {
  display: grid;
  gap: 16px;
}
.market-card h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.market-card p {
  color: var(--text);
  line-height: 1.5;
  margin: 0;
}
.market-card-heading,
.market-hero-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.market-card-heading span,
.market-muted,
.market-footnote {
  color: var(--text-muted);
  font-size: 12px;
}
.market-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.market-side-list {
  display: grid;
  gap: 0;
  margin-top: 8px;
}
.market-side-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 0;
  border: none;
  background: transparent;
  border-bottom: 1px solid var(--border, #e5e5ea);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}
.market-side-row:last-child {
  border-bottom: none;
}
.market-side-row small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}
.market-secondary {
  margin-top: 10px;
  width: 100%;
  border: 1px solid var(--border, #e5e5ea);
  background: var(--bg-card);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.market-index-grid,
.market-fx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.market-index-tile,
.market-fx-tile {
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 14px;
  padding: 12px;
}
.market-index-tile small,
.market-fx-tile small,
.market-eyebrow {
  color: var(--text-muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
}
.market-index-tile div,
.market-fx-rate,
.market-hero-value {
  align-items: baseline;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}
.market-index-tile strong,
.market-fx-rate,
.market-hero-title,
.market-hero-value strong {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.market-hero-card {
  border-radius: 24px;
}
.market-hero-title {
  font-size: 24px;
}
.market-hero-value {
  align-items: flex-end;
  flex-direction: column;
}
.market-hero-value strong {
  font-size: 32px;
  letter-spacing: -0.04em;
}
.market-fx-rate {
  flex-direction: column;
  gap: 2px;
  text-align: right;
}
.market-change--up,
.today-pin-change--up {
  color: var(--success);
}
.market-change--down,
.today-pin-change--down {
  color: var(--warn);
}
.market-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.market-chip {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elev);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.market-chip:hover {
  border-color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, var(--bg-elev));
}
.market-chip.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg-card);
}
.market-chip.active:hover {
  opacity: 0.92;
}
.market-detail-chart {
  position: relative;
  height: 300px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 2%, transparent);
  cursor: crosshair;
}
.market-detail-chart__retry {
  display: inline-block;
  margin-top: 10px;
}
.market-empty {
  text-align: center;
}
.market-empty .market-primary {
  width: auto;
  min-width: 140px;
}
.market-primary {
  margin-top: 12px;
  width: 100%;
  border: none;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg-card);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
.market-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border, #e5e5ea);
}
.market-row--button {
  width: 100%;
  align-items: center;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.market-row--button:hover {
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
.market-row:last-child { border-bottom: none; }
.market-detail-chart__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 13px;
}
.market-detail-ohlc {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--bg-card) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.market-detail-ohlc strong {
  color: var(--text);
}
.market-detail-svg {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 56px;
  width: calc(100% - 24px);
  height: 200px;
}
.market-detail-chart__hint {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  color: var(--text-muted);
  font-size: 12px;
}
.market-composer input {
  flex: 1;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  color: var(--text);
}
.market-composer button {
  border: none;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg-card);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
.market-composer button:hover {
  opacity: 0.9;
}

.billing-plan-grid {
  display: grid;
  gap: 12px;
}

.billing-plan-card {
  border: 1px solid var(--border, rgba(127, 127, 127, 0.25));
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--bg-card, #fff);
}

.billing-plan-card.is-current {
  border-color: var(--accent, #2563eb);
}

.billing-plan-card.is-highlight {
  border-color: color-mix(in srgb, var(--accent, #2563eb) 55%, var(--border, #d4d4d4));
}

.billing-usage-track {
  margin: 12px 0 4px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted, #64748b) 16%, transparent);
}

.billing-usage-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #2563eb);
}

.billing-dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.billing-plan-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.billing-plan-card__head h3 {
  margin: 0;
  font-size: 1rem;
}

.billing-plan-card__badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
}

.billing-plan-card__price {
  margin: 8px 0 4px;
  font-size: 1.35rem;
  font-weight: 700;
}

.billing-plan-card__meta {
  margin: 0;
  color: var(--text-muted, #64748b);
  font-size: 0.85rem;
}

.billing-plan-card__subscribe {
  margin-top: 12px;
  width: 100%;
  justify-content: center;
}

.billing-checkout-error {
  margin: 10px 0 0;
  color: var(--danger, #ff6b6b);
  font-size: 0.85rem;
}

/* Recoverable billing notice (mirrors Mac BillingNoticeCard): amber, not red. */
.billing-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--amber, #ffb224) 32%, transparent);
  background: color-mix(in srgb, var(--amber, #ffb224) 7%, transparent);
}
.billing-notice__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--amber, #ffb224) 16%, transparent);
  color: var(--amber, #ffb224);
  font-size: 15px;
}
.billing-notice__body {
  flex: 1;
  min-width: 0;
}
.billing-notice__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.billing-notice__text {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}
.billing-notice__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.billing-notice__cta {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #2563eb);
  cursor: pointer;
}
.billing-notice__cta:hover {
  filter: brightness(1.08);
}
.billing-notice__ghost {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}
.billing-notice__ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.billing-notice__dismiss {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.billing-notice__dismiss:hover {
  color: var(--text);
}

.billing-upgrade-card {
  margin: 0 12px 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  background: rgba(37, 99, 235, 0.06);
}

.billing-upgrade-card__title {
  margin: 0;
  font-weight: 600;
}

.billing-upgrade-card__body {
  margin: 6px 0 0;
  color: var(--text-muted, #64748b);
  font-size: 0.875rem;
  line-height: 1.45;
}

.billing-upgrade-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Sidebar credit meter (mirrors Mac SidebarCreditMeter): quiet footer pill. */
.sidebar-credit-meter {
  flex-shrink: 0;
  padding: 2px 12px 0;
}
.credit-meter {
  width: 100%;
  display: block;
  text-align: left;
  background: color-mix(in srgb, var(--bg-elev) 55%, transparent);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 9px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.credit-meter:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev);
}
.credit-meter__row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.credit-meter__summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.credit-meter__summary.is-low {
  color: var(--text);
}
.credit-meter__action {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.credit-meter:hover .credit-meter__action {
  color: var(--accent);
}
.credit-meter__track,
.account-menu__billing-track {
  display: block;
  margin-top: 6px;
  height: 2px;
  width: 100%;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 22%, transparent);
}
.credit-meter__fill,
.account-menu__billing-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--amber, #ffb224);
  transition: width 0.2s ease;
}

/* Account-menu billing block (mirrors Mac IdentityChip billing section). */
.account-menu__billing {
  margin: 6px 8px 4px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev) 45%, transparent);
}
.account-menu__billing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.account-menu__billing-plan {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.account-menu__billing-cta {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #2563eb);
  cursor: pointer;
}
.account-menu__billing-cta:hover {
  filter: brightness(1.08);
}
.account-menu__billing-credits {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Segmented range toggle (billing admin token usage) */
.seg {
  display: inline-flex;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
}
.seg .seg-btn {
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 4px 12px;
  background: transparent;
  color: var(--text-muted, #64748b);
}
.seg .seg-btn.active {
  background: var(--accent, #2563eb);
  color: #fff;
}

/* Token usage breakdown table (billing admin) */
.token-usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}
.token-usage-grid .metric-card {
  box-shadow: none;
}
.token-usage-breakdown {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.token-usage-breakdown h5 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted, #64748b);
}
.token-usage-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 2px 0;
}
.token-usage-row span:last-child {
  color: var(--text-muted, #64748b);
  white-space: nowrap;
}

/* ===== Sites view ===== */
.sites-split {
  display: grid;
  grid-template-columns: var(--sites-rail-width, 320px) 7px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  width: 100%;
  background: var(--bg);
}
.sites-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  gap: 6px;
  padding: 10px;
  overflow-y: auto;
  background: var(--bg-soft);
}
.sites-splitter {
  position: relative;
  z-index: 2;
  width: 7px;
  min-height: 0;
  cursor: col-resize;
  touch-action: none;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  border-right: 1px solid transparent;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.sites-splitter::after {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-radius: 999px;
  background: transparent;
  transition: background 120ms ease;
}
.sites-splitter:hover,
.sites-splitter:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 34%, var(--bg-soft));
}
.sites-splitter:hover::after,
.sites-splitter:focus-visible::after,
body.is-resizing-sites .sites-splitter::after {
  background: color-mix(in srgb, var(--accent) 58%, transparent);
}
body.is-resizing-sites,
body.is-resizing-sites * {
  cursor: col-resize !important;
  user-select: none !important;
}
body.is-resizing-sites .sites-preview-frame { pointer-events: none; }
.sites-content {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
}

/* Rail action items (New page / Builds) */
.sites-rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.sites-rail-item:hover { background: var(--bg-elev); }
.sites-rail-item--active { background: var(--bg-elev); }
.sites-rail-item__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 15px;
}
.sites-rail-item__icon--accent { background: var(--accent-soft); color: var(--accent); }
.sites-rail-item__body { min-width: 0; flex: 1; }
.sites-rail-item__title { display: block; font-size: 13px; font-weight: 600; }
.sites-rail-item__hint { display: block; font-size: 11px; color: var(--text-muted); }
.sites-rail-item__badge {
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

/* Rail tabs */
.sites-rail-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  margin-top: 4px;
  border-radius: 9px;
  background: var(--bg-elev);
}
.sites-rail-tab {
  border: 0;
  border-radius: 6px;
  padding: 6px 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.sites-rail-tab--active { background: var(--bg-card); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.sites-rail-tab__count { margin-left: 4px; opacity: 0.7; font-size: 10px; }

.sites-rail-list { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.sites-rail-empty { padding: 16px 8px; }
.sites-rail-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.sites-rail-card:hover { background: var(--bg-elev); }
.sites-rail-card--active { background: var(--bg-elev); }
.sites-rail-card__thumb {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 15px;
}
.sites-rail-card__body { min-width: 0; flex: 1; }
.sites-rail-card__title { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-rail-card__meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 11px; color: var(--text-muted); }
.sites-rail-card__tag {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
}
.sites-rail-card__tag--warn { background: rgba(217, 119, 6, 0.16); color: #d97706; }

.site-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}
.site-status-badge--published { background: rgba(22, 163, 74, 0.16); color: #16a34a; }
.site-status-badge--paused { background: rgba(217, 119, 6, 0.16); color: #d97706; }
.site-status-badge--removed,
.site-status-badge--deleted { background: rgba(220, 38, 38, 0.14); color: #dc2626; }
.site-status-badge--saved { background: var(--accent-soft); color: var(--accent); }
.site-status-badge--draft { background: var(--bg-elev); color: var(--text-muted); }

/* Content layouts */
.sites-scroll { width: 100%; max-width: 1320px; margin: 0 auto; padding: clamp(22px, 3vw, 40px); display: flex; flex-direction: column; gap: 18px; box-sizing: border-box; }
.sites-scroll--narrow { max-width: 720px; }
.sites-center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: clamp(28px, 5vw, 72px); box-sizing: border-box; }
.sites-eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); }
.sites-title { margin: 6px 0 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.sites-title--lg { font-size: 30px; }

.sites-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  padding: 16px;
}
.sites-card__title { margin: 0 0 8px; font-size: 14px; font-weight: 650; }
.sites-empty-card {
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  background: var(--bg-soft);
  padding: 40px 28px;
  text-align: center;
}

/* Create view */
.sites-create { width: min(100%, 920px); }
.sites-create__hero { text-align: center; margin-bottom: 22px; }
.sites-create__hero-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 22px;
  color: var(--text-muted);
}
.sites-create__box {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-soft);
  padding: clamp(14px, 2vw, 20px);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.sites-textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  line-height: 1.55;
  outline: none;
}
.sites-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sites-textarea--lg { min-height: clamp(132px, 18vh, 190px); font-size: 15px; }
.sites-create__footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-top: 12px; }
.sites-create__templates { min-width: 0; flex: 1; }
.sites-create__templates-label { margin-bottom: 6px; }
.sites-template-scroll { max-height: 168px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.sites-template-row { display: flex; align-items: flex-start; gap: 8px; }
.sites-template-row__label { width: 60px; flex: 0 0 auto; padding-top: 5px; font-size: 11px; font-weight: 600; color: var(--text-muted); }
.sites-template-row__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sites-template-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.sites-template-chip:hover { border-color: var(--accent); color: var(--accent); }
.sites-template-chip.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}
.sites-create__submit { flex: 0 0 auto; }

.sites-inspiration { margin-top: 28px; text-align: left; }
.sites-inspiration__head { margin-bottom: 12px; }
.sites-inspiration__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.sites-inspiration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.sites-inspiration-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sites-inspiration-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgb(0 0 0 / 6%);
}
.sites-inspiration-card__title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.sites-inspiration-card__cta {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.sites-edit-panel .studio-handoff { margin-top: 16px; }

/* Build jobs */
.sites-job-list { display: flex; flex-direction: column; gap: 10px; }
.sites-job {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 12px 14px;
}
/* The frame stays neutral for every outcome; the status badge and stage line
   carry success / failure colour so the list keeps the calm Codex look. */
.sites-job__head { display: flex; align-items: center; gap: 8px; }
.sites-job__title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-job--collapsed {
  padding-block: 10px;
  background: var(--bg-card);
  opacity: 0.82;
}
.sites-job--collapsed:hover { opacity: 1; }
.sites-job--collapsed .sites-job__title { font-weight: 500; }
.sites-job__open { flex: 0 0 auto; }
.sites-job__toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  padding: 4px 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.sites-job__toggle:hover { background: var(--bg-elev); color: var(--text); }
.sites-job__toggle span { font-size: 14px; line-height: 1; }
.sites-job__badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}
.sites-job--success .sites-job__badge { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.sites-job--failed .sites-job__badge { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.sites-job--billing .sites-job__badge { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.sites-job--active .sites-job__badge { background: var(--accent-soft); color: var(--accent); }
.sites-job__stage { margin-top: 4px; color: var(--text-muted); }
.sites-job--success .sites-job__stage { color: var(--success); }
.sites-job__truth-hint {
  margin-top: 10px;
  border: 1px dashed var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  color: var(--text-muted);
  font-size: 11px;
}
.sites-job__warning {
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, var(--warn) 38%, var(--border));
  border-radius: 9px;
  padding: 9px 11px;
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.5;
}
.sites-job__plan { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.sites-job__plan-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--text-muted); }
.sites-job__plan-head strong { color: var(--text); font-size: 12px; }
.sites-job__progress { height: 3px; margin-top: 7px; overflow: hidden; border-radius: 99px; background: var(--bg-elev); }
.sites-job__progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.sites-job__plan ol { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.sites-job__plan-step { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 7px; color: var(--text-muted); font-size: 12px; }
.sites-job__plan-step > span { display: grid; width: 18px; height: 18px; place-items: center; border: 1px solid var(--border); border-radius: 50%; font-size: 9px; }
.sites-job__plan-step b { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.sites-job__plan-step em { color: var(--accent); font-size: 10px; font-style: normal; }
.sites-job__plan-step.is-done { color: var(--text-muted); }
.sites-job__plan-step.is-done > span { border-color: var(--accent); background: var(--accent); color: white; }
.sites-job__plan-step.is-active { color: var(--text); }
.sites-job__plan-step.is-active > span { border-color: var(--accent); color: var(--accent); animation: sites-plan-pulse 1.2s ease-in-out infinite; }
.sites-job__plan-step.is-failed { color: var(--danger); }
.sites-job__plan-step.is-failed > span { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
@keyframes sites-plan-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); } }
@media (prefers-reduced-motion: reduce) { .sites-job__progress i { transition: none; } .sites-job__plan-step.is-active > span { animation: none; } }
/* Deleting a task is a secondary, reversible-by-regenerating action: it stays
   neutral until hover so a finished build reads as the success it is. */
.sites-job__delete { color: var(--text-muted); }
.sites-job__delete:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.sites-job-history__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}
.sites-job-history__filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-elev);
}
.sites-job-history__filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  padding: 5px 10px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.sites-job-history__filter:hover { color: var(--text); }
.sites-job-history__filter.is-active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.sites-job-history__filter span {
  border-radius: 999px;
  min-width: 20px;
  padding: 1px 6px;
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  font-size: 10px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sites-job-history__filter--attention i { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.sites-job-history__filter--attention.is-active { color: var(--danger); }
.sites-job-history__attention { margin: 0; color: var(--text-muted); font-size: 12px; }
.sites-job__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sites-job__actions .apple-btn { display: inline-flex; align-items: center; gap: 6px; }
.sites-job__summary-progress { position: relative; height: 18px; margin-top: 7px; overflow: hidden; border-radius: 6px; background: var(--bg-elev); }
.sites-job__summary-progress > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: color-mix(in srgb, var(--accent) 16%, transparent); transition: width 240ms ease; }
.sites-job__summary-progress > span { position: relative; z-index: 1; display: block; padding: 1px 7px; color: var(--text-muted); font-size: 9px; line-height: 16px; text-align: right; }
.sites-job__retry { display: inline-flex; align-items: center; gap: 6px; }
.sites-job__retry:disabled { opacity: 0.68; cursor: wait; }
.sites-job-notice {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.sites-job-notice--success { border-color: color-mix(in srgb, var(--success) 32%, var(--border)); color: var(--success); }
.sites-job-notice--error { border-color: color-mix(in srgb, var(--danger) 32%, var(--border)); color: var(--danger); }
.sites-job__spinner {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sites-spin 0.8s linear infinite;
}
.sites-job__spinner--button { width: 12px; height: 12px; border-width: 1.5px; }
@keyframes sites-spin { to { transform: rotate(360deg); } }

/* Detail view: site identity and navigation reuse the pane title bar. */
.sites-pane-head__back { display: inline-flex; min-height: 32px; flex: 0 0 auto; align-items: center; gap: 6px; border: 0; border-radius: 8px; padding: 5px 7px; background: transparent; color: var(--text-muted); font: inherit; font-size: 12px; cursor: pointer; }
.sites-pane-head__back:hover { background: var(--bg-elev); color: var(--text); }
.sites-pane-head__divider { width: 1px; height: 20px; flex: 0 0 auto; background: var(--border); }
.sites-pane-head__title { min-width: 0; max-width: min(38vw, 520px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-pane-head__meta { min-width: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-pane-head__action { flex: 0 0 auto; white-space: nowrap; }
.sites-detail-header__id { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .sites-pane-head__back span:last-child,
  .sites-pane-head__meta { display: none; }
  .sites-pane-head__title { max-width: 38vw; }
  .sites-pane-head__action { padding-inline: 9px; }
}
/* Workbench modes (preview / edit / data / publish), mirroring the desktop
   client. `auto-fit` keeps every column above its own minimum, so a narrow
   content pane stacks instead of squeezing the preview down to nothing. */
.sites-mode-tabs { display: flex; gap: 3px; padding: 3px; border-radius: 10px; background: var(--bg-elev); align-self: flex-start; }
.sites-mode-tab { border: 0; border-radius: 7px; padding: 6px 14px; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.sites-mode-tab:hover { color: var(--text); }
.sites-mode-tab--active { background: var(--bg-card); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.sites-mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.sites-mode-grid__main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sites-detail-aside { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.sites-preview { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--bg-card); min-width: 0; }
.sites-preview__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.sites-preview__head-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.sites-preview__head-actions .ui-icon { width: 15px; height: 15px; display: block; }
.sites-preview__icon-btn { display: inline-grid; width: 34px; height: 34px; place-items: center; padding: 0; border-radius: 8px; }
.sites-preview__open-btn { display: inline-flex; align-items: center; gap: 7px; }
.sites-preview__frame-wrap { aspect-ratio: 16 / 10; background: var(--bg-elev); display: flex; justify-content: center; }
.sites-preview__frame-wrap--tall { aspect-ratio: auto; height: min(70vh, 640px); }
.sites-preview__stage { max-width: 100%; height: 100%; background: #fff; }
.sites-preview__stage--framed { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.sites-preview-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.sites-preview-empty { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; }
.sites-preview__stage { position: relative; }
.sites-preview__stage > .work-resource-state { position: absolute; inset: 0; z-index: 2; background: var(--surface, #fff); }

.sites-device-switch { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--bg-elev); }
.sites-device-switch__btn { display: inline-grid; width: 36px; height: 32px; place-items: center; border: 0; border-radius: 7px; padding: 0; background: transparent; color: var(--text-muted); cursor: pointer; opacity: 0.72; }
.sites-device-switch__btn .ui-icon { width: 16px; height: 16px; }
.sites-device-switch__btn--active { background: var(--bg-card); opacity: 1; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }

.sites-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sites-stat { border-radius: 9px; background: var(--bg-elev); padding: 8px 10px; }
.sites-stat__num { font-size: 18px; font-weight: 650; margin-top: 2px; }

.sites-access-req { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); padding: 10px; margin-top: 10px; }
.sites-access-req__name { font-size: 13px; font-weight: 600; }
.sites-access-req__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.sites-share__label { margin: 12px 0 6px; }
.sites-share__url {
  display: flex;
  align-items: center;
  gap: 7px;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-elev);
  color: var(--accent);
  padding: 9px 12px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sites-share__hint { margin: 8px 0; padding: 8px 12px; border-radius: 8px; background: var(--bg-elev); line-height: 1.5; }
.sites-share__actions { display: flex; gap: 8px; margin: 8px 0 4px; }
.sites-access-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border-radius: 9px; background: var(--bg-elev); }
.sites-access-mode { border: 0; border-radius: 6px; padding: 6px 4px; background: transparent; color: var(--text-muted); font-size: 11px; font-weight: 600; cursor: pointer; }
.sites-access-mode--active { background: var(--bg-card); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.sites-access-mode:disabled { opacity: 0.5; cursor: default; }

.sites-status-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.sites-status-line__val { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-full-btn { width: 100%; justify-content: center; margin-top: 10px; }
.sites-publish-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.sites-danger-btn { color: #dc2626; }

.sites-list-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.sites-list-row:first-of-type { border-top: 0; }
.sites-list-row__title { font-size: 13px; font-weight: 600; word-break: break-all; }
.sites-list-row__actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* Audience picker: locked options stay visible so the reason is explained
   rather than the option silently missing (parity with desktop). */
.sites-audience { display: grid; gap: 8px; margin-top: 10px; }
.sites-audience__opt { display: block; width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); padding: 10px 12px; cursor: pointer; }
.sites-audience__opt--active { border-color: var(--accent); background: var(--accent-soft); }
.sites-audience__opt--locked { opacity: 0.6; cursor: default; }
.sites-audience__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sites-audience__label { font-size: 13px; font-weight: 650; }
.sites-audience__lock { flex: 0 0 auto; padding: 1px 8px; border-radius: 999px; background: var(--bg-elev); color: var(--text-muted); font-size: 11px; }
.sites-audience__desc { display: block; margin-top: 4px; line-height: 1.5; }

.sites-readiness { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 7px; }
.sites-readiness__item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.sites-readiness__item--ok { color: var(--text); }
.sites-publish-note { margin-top: 8px; text-align: center; line-height: 1.5; }

/* Hoisted to document.body so workbench overflow/filter/grid cannot trap
   `position: fixed` or squeeze the compliance copy into a 1-character column. */
.sites-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.42);
  box-sizing: border-box;
}
.sites-modal__card {
  display: flex;
  flex-direction: column;
  width: min(460px, calc(100vw - 48px));
  max-width: 460px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  box-sizing: border-box;
}
.sites-modal__title { font-size: 16px; font-weight: 650; margin: 0 0 8px; }
.sites-modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.sites-compliance {
  display: grid;
  grid-template-columns: auto minmax(12em, 1fr);
  align-items: start;
  gap: 9px;
  width: 100%;
  margin: 14px 0 8px;
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
}
.sites-compliance input { margin-top: 2px; }
.sites-compliance__text { min-width: 0; overflow-wrap: break-word; word-break: normal; }
.sites-tag-accent { flex: 0 0 auto; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.sites-link-btn { border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 600; padding: 0; cursor: pointer; }
.sites-link-btn:hover { text-decoration: underline; }

/* Edit workbench */
.sites-edit-panel { min-width: 0; }
.sites-edit-submit { display: inline-flex; align-items: center; gap: 8px; }
.sites-edit-submit:disabled { opacity: 0.78; cursor: wait; }
.sites-edit-submit__spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sites-spin 0.8s linear infinite;
}
.sites-edit-submit__hint { margin: 8px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.5; text-align: center; }
.sites-edit-targets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 12px 0; }
.sites-edit-target { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: var(--bg-card); color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.sites-edit-target--active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.sites-edit-target:disabled,
.sites-template-chip:disabled,
.sites-textarea:disabled { opacity: 0.62; cursor: not-allowed; }
.sites-edit-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }

/* Unified Sites workbench: structure + persistent preview. The existing global
   Workbench side chat occupies the right app column, so this surface does not
   create a second composer or a second Agent workflow. */
.sites-workbench {
  min-height: min(72vh, 720px);
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
}
.sites-workbench-status { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border)); border-radius: 10px; padding: 8px 11px; background: var(--accent-soft); }
.sites-workbench-status > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sites-workbench-status strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sites-workbench-status small { overflow: hidden; color: var(--text-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.sites-workbench__structure { min-width: 0; border-right: 1px solid var(--border); background: var(--bg-soft); padding: 13px 10px; }
.sites-workbench__aside-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 2px 5px 12px; }
.sites-workbench__aside-head > span:first-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sites-workbench__aside-head strong { font-size: 12px; }
.sites-workbench__aside-head small { color: var(--text-muted); font-size: 10px; line-height: 1.45; }
.sites-workbench__tree { display: grid; gap: 8px; }
.sites-workbench__page { border: 1px solid var(--border); border-radius: 9px; background: var(--bg-card); padding: 5px; }
.sites-workbench__page-title { display: flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 6px; color: var(--accent); font-size: 11px; }
.sites-workbench__page-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-workbench__block { width: 100%; min-height: 28px; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 6px; padding: 4px 7px; background: transparent; color: var(--text-muted); font: inherit; font-size: 11px; text-align: left; cursor: pointer; }
.sites-workbench__block:hover { background: var(--bg-elev); color: var(--text); }
.sites-workbench__block i { width: 5px; height: 5px; flex: 0 0 auto; border-radius: 50%; background: var(--border-strong); }
.sites-workbench__block span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-workbench__tree-empty { border: 1px dashed var(--border); border-radius: 9px; padding: 18px 10px; color: var(--text-muted); font-size: 10px; line-height: 1.6; text-align: center; }
.sites-workbench__preview { display: flex; min-height: 0; flex-direction: column; border: 0; border-radius: 0; }
.sites-workbench__preview-stage { position: relative; min-height: 0; flex: 1; }
.sites-workbench__preview-stage > .sites-preview__frame-wrap { height: 100%; min-height: 520px; }
.sites-workbench__designer-button { display: inline-flex; align-items: center; gap: 6px; }
.sites-workbench__picker-button { display: inline-flex; align-items: center; gap: 6px; }
.sites-workbench__picker-button.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.sites-workbench__build-overlay { position: absolute; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; background: color-mix(in srgb, var(--bg-card) 4%, transparent); }
.sites-workbench__scan { position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), #55c5c1, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 72%, transparent); animation: sites-workbench-scan 3.4s linear infinite; animation-delay: var(--sites-scan-delay, 0ms); }
.sites-workbench__build-chip { position: absolute; left: 50%; bottom: 17px; transform: translateX(-50%); width: min(430px, calc(100% - 28px)); display: flex; align-items: center; gap: 10px; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border)); border-radius: 10px; padding: 10px 12px; background: color-mix(in srgb, var(--bg-card) 94%, transparent); box-shadow: 0 14px 35px rgba(0,0,0,.13); backdrop-filter: blur(14px); }
.sites-workbench__build-chip > span:last-child { min-width: 0; display: grid; gap: 2px; }
.sites-workbench__build-chip strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sites-workbench__build-chip small { color: var(--text-muted); font-size: 10px; }
.sites-workbench__promptbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 48px; border-top: 1px solid var(--border); padding: 7px 10px; background: var(--bg-card); }
.sites-workbench__promptbar > #sites-selected-elements-slot { display: contents; }
.sites-workbench__selected { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 2px; }
.sites-workbench__selected-chip { display: inline-flex; max-width: 220px; align-items: center; gap: 5px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: 999px; padding: 3px 7px; background: var(--accent-soft); color: var(--text); font-size: 10px; }
.sites-workbench__selected-chip > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-workbench__selected-chip button, .sites-workbench__selected-clear { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; }
.sites-workbench__selected-clear { font-size: 10px; }
.sites-workbench__picker-error { width: 100%; margin: 0; color: var(--danger); font-size: 10px; }
.sites-workbench__promptbar-label { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; color: var(--text); font-size: 11px; font-weight: 600; }
.sites-workbench__promptbar-label .sites-edit-submit__spinner { border-color: color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); }
.sites-workbench__quick-actions { min-width: 0; display: flex; flex: 1; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.sites-workbench__quick-actions button { flex: 0 0 auto; min-height: 29px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 9px; background: var(--bg-soft); color: var(--text-muted); font: inherit; font-size: 10px; cursor: pointer; }
.sites-workbench__quick-actions button:hover { border-color: var(--border-strong); color: var(--text); }
.sites-workbench__send { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 8px; background: var(--accent); color: white; cursor: pointer; }
.sites-workbench__legacy-note { border-top: 1px solid var(--border); padding: 7px 12px; background: color-mix(in srgb, var(--warn) 7%, var(--bg-card)); color: var(--text-muted); font-size: 10px; }
.sites-workbench__fallback-edit { display: flex; align-items: flex-end; gap: 8px; border-top: 1px solid var(--border); padding: 10px; }
.sites-workbench__fallback-edit.is-hidden { display: none; }
.sites-workbench__fallback-edit textarea { min-height: 66px; resize: none; }
.sites-workbench__fallback-edit button { flex: 0 0 auto; }
.sites-workbench__desktop-tools { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); }
.sites-workbench__desktop-tools > summary { padding: 9px 12px; color: var(--text-muted); font-size: 11px; cursor: pointer; }
.sites-workbench__desktop-tools .studio-handoff { margin: 0 10px 10px; }

/* Quick builds keep their background semantics, but open into the same spatial
   model as editing instead of forcing users to stare at a task ledger. */
.sites-live-build { min-height: 100%; display: grid; grid-template-rows: 52px minmax(0, 1fr); background: var(--bg-soft); }
.sites-live-build__head { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); padding: 0 14px; background: var(--bg-card); }
.sites-live-build__identity { min-width: 0; display: flex; align-items: center; gap: 8px; }
.sites-live-build__identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sites-live-build__count { margin-left: auto; color: var(--text-muted); font-size: 11px; }
.sites-live-build__body { min-height: 0; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sites-live-build__body--canvas { grid-template-columns: minmax(0, 1fr); }
.sites-live-build__rail { min-height: 0; overflow: auto; border-right: 1px solid var(--border); padding: 17px 14px; background: var(--bg-card); }
.sites-live-build__rail-title { margin-bottom: 10px; font-size: 12px; font-weight: 650; }
.sites-live-build__rail ol { display: grid; gap: 5px; margin: 14px 0; padding: 0; list-style: none; }
.sites-live-build__step { min-height: 36px; display: grid; grid-template-columns: 20px minmax(0,1fr); align-items: center; gap: 8px; border-radius: 8px; padding: 5px 6px; color: var(--text-muted); font-size: 11px; }
.sites-live-build__step > span { width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 50%; font-size: 9px; }
.sites-live-build__step b { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.sites-live-build__step.is-done > span { border-color: var(--success); background: var(--success); color: white; }
.sites-live-build__step.is-active { background: var(--accent-soft); color: var(--text); }
.sites-live-build__step.is-active > span { border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: sites-spin .8s linear infinite; }
.sites-live-build__step.is-failed { color: var(--danger); }
.sites-live-build__waiting { display: flex; gap: 8px; margin: 15px 0; color: var(--text-muted); font-size: 11px; line-height: 1.55; }
.sites-live-build__all { width: 100%; justify-content: center; }
.sites-live-build__canvas { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0,1fr) auto; gap: 10px; padding: 14px; }
.sites-live-build__saved-preview { min-height: 510px; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--bg-card); box-shadow: 0 16px 44px rgba(20,25,38,.09); }
.sites-live-build__saved-preview .sites-preview__frame-wrap--tall { height: 100%; min-height: 510px; }
.sites-live-build__browser { min-height: 510px; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 12px; background: white; box-shadow: 0 16px 44px rgba(20,25,38,.09); }
.sites-live-build__chrome { height: 30px; display: flex; align-items: center; gap: 5px; border-bottom: 1px solid #e5e7eb; padding: 0 10px; background: #f7f7f8; }
.sites-live-build__chrome i { width: 7px; height: 7px; border-radius: 50%; background: #d2d4da; }
.sites-live-build__chrome span { width: 42%; height: 15px; margin: auto; border-radius: 5px; background: #e9eaed; }
.sites-live-build__blueprint { position: relative; min-height: 480px; overflow: hidden; padding: clamp(24px, 4vw, 55px); background: #f8faff; }
.sites-live-build__wire { position: relative; overflow: hidden; border-radius: 7px; background: #dfe5f2; }
.sites-live-build__wire::after, .sites-live-build__cards i::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); animation: sites-wire-shimmer 1.7s infinite; }
.sites-live-build__wire--nav { height: 34px; }
.sites-live-build__hero-wire { display: grid; grid-template-columns: 1.08fr .92fr; gap: clamp(22px, 4vw, 54px); margin-top: 38px; }
.sites-live-build__wire--eyebrow { width: 38%; height: 10px; margin-top: 18px; }
.sites-live-build__wire--title { width: 88%; height: 38px; margin-top: 16px; }
.sites-live-build__wire--title.short { width: 62%; margin-top: 8px; }
.sites-live-build__wire--copy { width: 70%; height: 12px; margin-top: 22px; }
.sites-live-build__wire--button { width: 112px; height: 30px; margin-top: 20px; border-radius: 999px; }
.sites-live-build__wire--art { min-height: 245px; border-radius: 46% 46% 16% 16%; }
.sites-live-build__cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 32px; }
.sites-live-build__cards i { position: relative; overflow: hidden; height: 74px; border-radius: 8px; background: #e3e7ef; }
.sites-live-build__scan { position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), #58c8c0, transparent); box-shadow: 0 0 20px var(--accent); animation: sites-workbench-scan 3.4s linear infinite; animation-delay: var(--sites-scan-delay, 0ms); }
.sites-live-build__blueprint.is-terminal { opacity: .65; }
.sites-live-build__activity { min-height: 48px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; background: var(--bg-card); color: var(--text-muted); font-size: 11px; }
.sites-live-build__activity strong { min-width: 0; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.sites-live-build__activity > span:not(.sites-job__spinner) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes sites-workbench-scan {
  0% { top: 2%; opacity: 0; }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% { top: 98%; opacity: 0; }
}
@keyframes sites-wire-shimmer { to { transform: translateX(100%); } }

@media (max-width: 900px) {
  .sites-split { grid-template-columns: 1fr; }
  .sites-rail { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .sites-splitter { display: none; }
  .sites-mode-grid { grid-template-columns: 1fr; }
  .sites-mode-tabs { overflow-x: auto; align-self: stretch; }
  .sites-scroll { padding: 18px; }
  .sites-center { align-items: flex-start; padding: 28px 18px; }
  .sites-create__footer { align-items: stretch; flex-direction: column; }
  .sites-create__submit { align-self: flex-end; }
  .sites-job-history__toolbar { align-items: flex-start; flex-direction: column; }
  .sites-job-history__filters { max-width: 100%; }
  .sites-job__head { align-items: flex-start; flex-wrap: wrap; }
  .sites-job__time { width: 100%; }
  .sites-workbench { grid-template-columns: 1fr; }
  .sites-workbench__structure { display: none; }
  .sites-workbench__promptbar-label { display: none; }
  .sites-live-build__body { grid-template-columns: 1fr; }
  .sites-live-build__rail { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  .sites-workbench__scan, .sites-live-build__scan, .sites-live-build__wire::after, .sites-live-build__cards i::after { animation: none; }
}

@media (max-height: 760px) and (min-width: 901px) {
  .sites-center { align-items: flex-start; padding-top: 34px; padding-bottom: 34px; }
  .sites-create__hero { margin-bottom: 16px; }
  .sites-create__hero-icon { width: 42px; height: 42px; margin-bottom: 10px; }
}

/* ── My AI experts (Expert Profile, §8.14) ───────────────────────────────── */
.experts-pane__body { padding: 18px; overflow-y: auto; }
.experts-hint { margin: 0 0 14px; }
.experts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.expert-card { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--bg-card); }
.expert-card__head { display: flex; gap: 12px; align-items: flex-start; }
.expert-card__icon { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--text); }
.expert-card__icon .ui-icon { width: 18px; height: 18px; }
.expert-card__titles { min-width: 0; }
.expert-card__name { margin: 0 0 4px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.expert-card__desc { margin: 0 0 4px; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.expert-card__badge { flex: 0 0 auto; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; }
.expert-card__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.experts-form { display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.experts-form__head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.experts-form__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-left: 2px;
}
.experts-form__back-icon,
.experts-form__back-icon .ui-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
}
.experts-form__titles {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.experts-form__head h3 { margin: 0; font-size: 15px; }
.experts-form__section { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.experts-form__section legend { padding: 0 6px; font-size: 13px; font-weight: 600; }
.experts-form__row { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.experts-form__row > span:first-child { font-weight: 600; color: var(--text-muted); }
.experts-form__row input,
.experts-form__row textarea,
.experts-form__row select { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font: inherit; width: 100%; box-sizing: border-box; }
.experts-form__row textarea { resize: vertical; line-height: 1.5; }
.experts-form__row--emoji input { width: 72px; text-align: center; }
.experts-form__row--icon .experts-form__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text);
}
.experts-form__row--icon .experts-form__icon .ui-icon { width: 20px; height: 20px; }
.experts-form__locked { color: var(--text-muted); }
.experts-kinds { display: flex; flex-wrap: wrap; gap: 10px; }
.experts-kind { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.experts-form__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Remote app-toggles: hide the pinned default assistant without a client release. */
body.hide-default-assistant .default-assistant-wrap { display: none; }
.creative-reference-chip{display:inline-flex;max-width:100%;align-items:center;gap:8px;margin:10px 0 0;padding:5px 8px;border:1px solid #ddd0fa;border-radius:999px;background:#f7f2ff;color:#301b57;font-size:12px}.creative-reference-chip img,.creative-reference-chip__icon{width:24px;height:24px;border-radius:999px;object-fit:cover}.creative-reference-chip__icon{display:grid;place-items:center;background:#e9ddff}.creative-reference-chip strong{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.creative-reference-chip span{color:#7951b8}.creative-reference-chip button{border:0;background:transparent;color:inherit;cursor:pointer;font-size:18px;line-height:1}
