/* ───────────── Tokens ─────────────
   Ink & paper neutrals, screen-tone grays, three working accents:
   vermilion  --accent    primary actions, the one thing to press
   teal       --accent-2  focus, selection, links, progress
   amber      --accent-3  badges, "new"/"soon", highlights (warnings read in --warn)
   Corners are crisp (3–6px); depth comes from 1px hairlines and soft, layered shadows. */
:root {
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Inter", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font); /* one sans across studio + marketing */
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo,
    Consolas, monospace;

  --spectrum: linear-gradient(90deg, var(--accent), var(--accent-3) 50%, var(--accent-2));

  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;
  --topbar-h: 60px;
  --sidebar-w: 380px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 150ms;
  --t: 200ms;
  --t-slow: 280ms;

  /* Fixed ink and paper (same in both themes: toasts, stamps, swatches). */
  --ink: #16150f;
  --paper: #f6f2e9;

  /* Dark (default) */
  --bg: #111112;
  --bg-elev: #161617;
  --surface: #1b1b1d;
  --surface-2: #232326;
  --surface-3: #2d2d31;
  --line: #2d2d31;
  --line-strong: #46464c;
  --text: #f2eee4;
  --text-2: #bfbaae;
  --text-3: #9c978b;
  --tone-1: #262629;
  --tone-2: #3a3a3f;
  --tone-3: #6f6b63;
  --toast-error-bg: #b4233c;
  --toast-error-fg: #ffffff;
  --accent: #ff5f38;
  --accent-hover: #ff7b59;
  --on-accent: #1a0702;
  --accent-soft: rgba(255, 95, 56, 0.14);
  --accent-line: rgba(255, 95, 56, 0.5);
  --accent-2: #38c2bb;
  --accent-2-hover: #5fd3cd;
  --on-accent-2: #031c1b;
  --accent-2-soft: rgba(56, 194, 187, 0.13);
  --accent-2-line: rgba(56, 194, 187, 0.5);
  --accent-3: #f4c03c;
  --on-accent-3: #1d1500;
  --accent-3-soft: rgba(244, 192, 60, 0.14);
  --accent-3-line: rgba(244, 192, 60, 0.5);
  --focus: var(--accent-2);
  --ok: #5fd39a;
  --warn: #f2c14e;
  --danger: #ff6b81;
  --danger-soft: rgba(255, 107, 129, 0.12);
  --info: #38c2bb;
  --stage: #0c0c0d;
  --tone: rgba(255, 255, 255, 0.06);
  --hard: rgba(0, 0, 0, 0.45);
  --edge: #46464c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.24), 0 10px 28px -14px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.28), 0 28px 60px -20px rgba(0, 0, 0, 0.7);
  --scrim: rgba(8, 8, 9, 0.76);
  --backdrop: rgba(6, 6, 7, 0.62);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3efe6;
    --bg-elev: #f8f5ee;
    --surface: #fffdf8;
    --surface-2: #eeeae0;
    --surface-3: #e4dfd3;
    --line: #dad4c6;
    --line-strong: #b5ae9e;
    --text: #16150f;
    --text-2: #4d493f;
    --text-3: #655f54;
    --tone-1: #e6e1d6;
    --tone-2: #c2bcae;
    --tone-3: #8d877a;
    --toast-error-bg: #b4233c;
    --toast-error-fg: #ffffff;
    --accent: #c2340f;
    --accent-hover: #a82b0b;
    --on-accent: #ffffff;
    --accent-soft: rgba(194, 52, 15, 0.09);
    --accent-line: rgba(194, 52, 15, 0.45);
    --accent-2: #0b7479;
    --accent-2-hover: #075c60;
    --on-accent-2: #ffffff;
    --accent-2-soft: rgba(11, 116, 121, 0.1);
    --accent-2-line: rgba(11, 116, 121, 0.45);
    --accent-3: #f0b323;
    --on-accent-3: #1d1500;
    --accent-3-soft: rgba(240, 179, 35, 0.2);
    --accent-3-line: rgba(176, 124, 0, 0.55);
    --ok: #1a7548;
    --warn: #865c00;
    --danger: #b4233c;
    --danger-soft: rgba(180, 35, 60, 0.08);
    --info: #0b7479;
    --stage: #e8e3d8;
    --tone: rgba(22, 21, 15, 0.08);
    --hard: rgba(22, 21, 15, 0.16);
    --edge: #bdb6a6;
    --shadow-sm: 0 1px 2px rgba(22, 21, 15, 0.07);
    --shadow: 0 1px 2px rgba(22, 21, 15, 0.06), 0 10px 26px -14px rgba(22, 21, 15, 0.22);
    --shadow-lg: 0 2px 6px rgba(22, 21, 15, 0.06), 0 28px 56px -22px rgba(22, 21, 15, 0.32);
    --scrim: rgba(243, 239, 230, 0.82);
    --backdrop: rgba(22, 21, 15, 0.32);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3efe6;
  --bg-elev: #f8f5ee;
  --surface: #fffdf8;
  --surface-2: #eeeae0;
  --surface-3: #e4dfd3;
  --line: #dad4c6;
  --line-strong: #b5ae9e;
  --text: #16150f;
  --text-2: #4d493f;
  --text-3: #655f54;
  --tone-1: #e6e1d6;
  --tone-2: #c2bcae;
  --tone-3: #8d877a;
  --toast-error-bg: #b4233c;
  --toast-error-fg: #ffffff;
  --accent: #c2340f;
  --accent-hover: #a82b0b;
  --on-accent: #ffffff;
  --accent-soft: rgba(194, 52, 15, 0.09);
  --accent-line: rgba(194, 52, 15, 0.45);
  --accent-2: #0b7479;
  --accent-2-hover: #075c60;
  --on-accent-2: #ffffff;
  --accent-2-soft: rgba(11, 116, 121, 0.1);
  --accent-2-line: rgba(11, 116, 121, 0.45);
  --accent-3: #f0b323;
  --on-accent-3: #1d1500;
  --accent-3-soft: rgba(240, 179, 35, 0.2);
  --accent-3-line: rgba(176, 124, 0, 0.55);
  --ok: #1a7548;
  --warn: #865c00;
  --danger: #b4233c;
  --danger-soft: rgba(180, 35, 60, 0.08);
  --info: #0b7479;
  --stage: #e8e3d8;
  --tone: rgba(22, 21, 15, 0.08);
  --hard: rgba(22, 21, 15, 0.16);
  --edge: #bdb6a6;
  --shadow-sm: 0 1px 2px rgba(22, 21, 15, 0.07);
  --shadow: 0 1px 2px rgba(22, 21, 15, 0.06), 0 10px 26px -14px rgba(22, 21, 15, 0.22);
  --shadow-lg: 0 2px 6px rgba(22, 21, 15, 0.06), 0 28px 56px -22px rgba(22, 21, 15, 0.32);
  --scrim: rgba(243, 239, 230, 0.82);
  --backdrop: rgba(22, 21, 15, 0.32);
  color-scheme: light;
}

/* ───────────── Base ───────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
a {
  color: inherit;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
img {
  display: block;
}
h1,
h2,
h3 {
  margin: 0;
}
kbd {
  font: 600 10.5px/1 var(--font-mono);
  padding: 2px 5px 3px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  background: var(--surface-2);
}
[hidden] {
  display: none !important;
}
::selection {
  background: var(--accent-3);
  color: var(--on-accent-3);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm {
  width: 15px;
  height: 15px;
}
.icon-lg {
  width: 26px;
  height: 26px;
}
.icon-xl {
  width: 40px;
  height: 40px;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  top: 10px;
}
.spacer {
  flex: 1;
}
.hint {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
  margin: 0;
}
.hint.warn {
  color: var(--warn);
}
.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.tag.muted {
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--text-3);
}
.tag.cap {
  background: var(--accent-soft);
  color: var(--accent);
}
.mini-spin {
  display: inline-block;
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-2);
  font-size: 12.5px;
  font-weight: 550;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--t-fast) var(--ease), text-decoration-color var(--t-fast) var(--ease);
}
.link-btn:hover {
  color: var(--accent-2-hover);
  text-decoration-thickness: 2px;
}

/* width utility classes (CSP forbids inline style attributes) */
.w0 { width: 0%; } .w5 { width: 5%; } .w10 { width: 10%; } .w15 { width: 15%; } .w20 { width: 20%; }
.w25 { width: 25%; } .w30 { width: 30%; } .w35 { width: 35%; } .w40 { width: 40%; } .w45 { width: 45%; }
.w50 { width: 50%; } .w55 { width: 55%; } .w60 { width: 60%; } .w65 { width: 65%; } .w70 { width: 70%; }
.w75 { width: 75%; } .w80 { width: 80%; } .w85 { width: 85%; } .w90 { width: 90%; } .w95 { width: 95%; } .w100 { width: 100%; }

/* ───────────── Buttons ───────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
  user-select: none;
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  gap: 6px;
}
.btn-lg {
  height: 46px;
  padding: 0 20px;
  font-size: 14.5px;
  border-radius: var(--radius);
}
/* Primary: solid vermilion; hover brightens and lifts a pixel. */
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}
.btn-primary:disabled {
  box-shadow: none;
}
.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--text-3);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--line);
}
.btn-ghost:hover:not(:disabled),
.btn-ghost.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.btn-ghost.active {
  border-color: var(--accent-2-line);
  background: var(--accent-2-soft);
  color: var(--accent-2);
}
.btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 88%, #fff);
  transform: translateY(-1px);
}
.btn-danger:active:not(:disabled) {
  transform: translateY(0);
}
.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  flex: none;
  text-decoration: none;
  transition:
    background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.icon-btn:active:not(:disabled) {
  transform: scale(0.96);
}
.icon-btn.sm {
  width: 28px;
  height: 28px;
}
.icon-btn:hover:not(:disabled):not(.disabled) {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
.icon-btn:disabled,
.icon-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.icon-btn[aria-pressed="true"] {
  color: var(--accent-2);
  background: var(--accent-2-soft);
  border-color: var(--accent-2-line);
}
.split {
  display: flex;
}
.split > .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.split > .btn:first-child:not(:only-child) {
  border-right: 0;
}
.split-toggle {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  border-left: 1px solid color-mix(in srgb, currentColor 28%, transparent) !important;
  padding: 0 9px;
}

/* ───────────── Top bar ───────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: none;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.025em;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  font-size: 13.5px;
  color: var(--text-3);
  padding-left: 14px;
  border-left: 1px solid var(--line-strong);
}
.crumbs a {
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.crumbs a:hover {
  color: var(--text);
}
.crumbs [aria-current] {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumb-sep {
  opacity: 0.45;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  max-width: 360px;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.engine-pill > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.engine-pill:hover {
  border-color: var(--text-3);
  color: var(--text);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--text-3);
  position: relative;
}
.status-dot[data-tone="ok"] {
  background: var(--ok);
}
.status-dot[data-tone="busy"] {
  background: var(--warn);
}
.status-dot[data-tone="pending"] {
  background: var(--info);
}
.status-dot[data-tone="error"] {
  background: var(--danger);
}
.status-dot[data-tone="busy"]::after,
.status-dot[data-tone="pending"]::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--warn);
  opacity: 0;
  animation: ping 1.6s var(--ease) infinite;
}
.status-dot[data-tone="pending"]::after {
  border-color: var(--info);
}
@keyframes ping {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.view {
  flex: 1;
  min-height: 0;
  outline: none;
}

/* ───────────── Menus, popovers, dialogs ───────────── */
.popover {
  position: fixed;
  z-index: 70;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  transform-origin: top left;
  animation: pop-in var(--t) var(--ease-out);
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.menu button {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: left;
  font-size: 13px;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.menu button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform var(--t-fast) var(--ease);
}
.menu button:hover:not(:disabled)::before,
.menu button:focus-visible::before {
  transform: none;
}
.menu button .icon {
  margin-top: 1px;
  color: var(--text-3);
}
.menu button span {
  display: flex;
  flex-direction: column;
}
.menu button strong {
  font-weight: 550;
}
.menu button small {
  color: var(--text-3);
  font-size: 11.5px;
}
.menu button:hover:not(:disabled),
.menu button:focus-visible {
  background: var(--surface-2);
  outline: none;
}
.menu button:hover:not(:disabled) .icon,
.menu button:focus-visible .icon {
  color: var(--text);
}
.menu button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.menu button.danger,
.menu button.danger .icon {
  color: var(--danger);
}
.menu hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 4px 6px;
}
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 860px);
  padding: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog-wide {
  width: min(760px, calc(100vw - 32px));
}
.dialog-small {
  width: min(420px, calc(100vw - 32px));
}
.dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in var(--t-slow) var(--ease-out);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}
.dialog::backdrop {
  background: var(--backdrop);
}
.dialog[open]::backdrop {
  animation: fade-in var(--t-slow) var(--ease);
}
.dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.dialog-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  display: grid;
  gap: 16px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.confirm {
  padding: 20px;
  display: grid;
  gap: 10px;
}
.confirm h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.confirm p {
  margin: 0;
  color: var(--text-2);
  font-size: 13.5px;
}

/* ───────────── Form controls ───────────── */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 13px;
  line-height: 20px;
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  accent-color: var(--accent-2);
}
textarea {
  resize: vertical;
  line-height: 1.5;
  display: block;
}
input:hover:not(:focus),
select:hover,
textarea:hover:not(:focus) {
  border-color: var(--text-3);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2), 0 0 0 4px var(--accent-2-soft);
  outline: none;
}
::placeholder {
  color: var(--text-3);
  opacity: 1;
}
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  align-content: start;
}
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.segmented label {
  position: relative;
  display: block;
  cursor: pointer;
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented label > span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  white-space: nowrap;
  transition:
    background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}
.segmented label:hover > span {
  color: var(--text);
  background: var(--tone);
}
.segmented input:checked + span {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.segmented input:checked + span small {
  color: inherit;
  opacity: 0.75;
}
.segmented input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.seg-4 label > span {
  flex-direction: column;
  gap: 0;
  padding: 5px 2px;
}
.seg-4 strong {
  font-variant-numeric: tabular-nums;
}
.seg-4 small {
  font-size: 10.5px;
  color: var(--text-3);
  font-weight: 450;
}
.switch-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
}
.switch-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.switch-text strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.switch-text span {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
}
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 38px;
  height: 22px;
  margin: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  position: relative;
  cursor: pointer;
  transition:
    background-color var(--t) var(--ease),
    border-color var(--t) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 1px;
  background: var(--text-2);
  transition:
    transform var(--t) var(--ease-out),
    background-color var(--t) var(--ease);
}
.switch:checked {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
.switch:checked::after {
  transform: translateX(16px);
  background: var(--on-accent-2);
}
.style-grid {
  display: grid;
  gap: 6px;
}
.style-grid.compact {
  grid-template-columns: 1fr 1fr;
}
.style-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.style-card:hover {
  border-color: var(--text-3);
}
.style-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.style-card:has(input:checked) {
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
  box-shadow: inset 0 0 0 1px var(--accent-2);
}
.style-card:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  flex: none;
  border: 1px solid var(--edge);
}
.swatch-anime {
  background: linear-gradient(135deg, transparent 49%, rgba(0, 0, 0, 0.18) 50%),
    conic-gradient(from 200deg at 35% 40%, #ff5f6d, #ffc371, #47c6ff, #7a5cff, #ff5f6d);
}
.swatch-vivid {
  background: linear-gradient(135deg, #ff2e93, #ff9a2e 40%, #2ee6ff 75%, #7c4dff);
}
.swatch-watercolor {
  background: radial-gradient(circle at 30% 30%, rgba(255, 170, 190, 0.95), transparent 45%),
    radial-gradient(circle at 70% 65%, rgba(140, 200, 235, 0.95), transparent 50%),
    radial-gradient(circle at 75% 25%, rgba(250, 225, 150, 0.9), transparent 40%), #f7f1e6;
}
.swatch-natural {
  background: linear-gradient(180deg, #a9c1cf 0 38%, #d8c3a2 38% 62%, #7b8a5c 62% 100%);
}
.style-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.style-text strong {
  font-size: 12.5px;
  font-weight: 600;
}
.style-text span {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.3;
}

/* ───────────── Stage chips ───────────── */
.chips-row {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--text-3);
  white-space: nowrap;
  transition: color var(--t) var(--ease), background-color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.stage-chip .icon {
  width: 13px;
  height: 13px;
}
.stage-chip .mini-spin {
  width: 9px;
  height: 9px;
}
.stage-chip.s-done {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}
.stage-chip.s-running {
  color: var(--accent-2);
  border-color: var(--accent-2-line);
  background: var(--accent-2-soft);
}
.stage-chip.s-queued {
  color: var(--text-2);
  border-color: var(--line-strong);
  border-style: dashed;
}
.stage-chip.s-error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: var(--danger-soft);
}

/* ───────────── Library ───────────── */
.view-library {
  padding: 28px clamp(16px, 4vw, 48px) 48px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
}
.eyebrow {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.025em;
}
.hero h1 em {
  font-style: italic;
  background: var(--spectrum);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 4px;
}
.lede {
  margin: 12px 0 0;
  max-width: 54ch;
  color: var(--text-2);
  font-size: 15px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.hero-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.hero-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.hero-steps .icon {
  color: var(--accent-2);
  margin-top: 2px;
}
.hero-steps div {
  display: flex;
  flex-direction: column;
}
.hero-steps strong {
  font-size: 13.5px;
}
.hero-steps span {
  font-size: 12.5px;
  color: var(--text-3);
}
.projects {
  margin-top: 32px;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  overflow: hidden;
  transition:
    border-color var(--t) var(--ease),
    transform var(--t) var(--ease-out),
    box-shadow var(--t) var(--ease-out);
  animation: card-in var(--t-slow) var(--ease-out) both;
}
.project-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.project-card:active {
  transform: none;
  box-shadow: var(--shadow-sm);
}
@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 650;
  background: var(--ink);
  color: var(--paper);
}
.card-body {
  padding: 10px 12px 12px;
  display: grid;
  gap: 2px;
}
.card-title {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 24px;
}
.card-meta {
  font-size: 12px;
  color: var(--text-3);
}
.meter {
  height: 4px;
  border-radius: 0;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: 6px;
}
.meter-fill {
  display: block;
  height: 100%;
  background: var(--accent-2);
  transition: width var(--t-slow) var(--ease);
}
.card-more {
  position: absolute;
  right: 4px;
  bottom: 30px;
  width: 30px;
  height: 30px;
}
.new-card {
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 260px;
  border-style: dashed;
  color: var(--text-2);
  background: transparent;
  text-align: center;
  padding: 20px;
}
.new-card .icon {
  color: var(--accent);
}
.new-card:hover {
  border-style: solid;
}
.new-card span {
  font-size: 12.5px;
  color: var(--text-3);
}

/* ───────────── Project board ───────────── */
.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: calc(100dvh - var(--topbar-h));
}
.board-main {
  padding: 20px clamp(16px, 2.5vw, 32px) 40px;
  min-width: 0;
}
.board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.board-title {
  min-width: 0;
  flex: 1;
}
.title-input {
  font-family: var(--font-display) !important;
  font-size: 26px !important;
  line-height: 1.25 !important;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-color: transparent !important;
  background: transparent !important;
  padding: 2px 6px !important;
  margin-left: -7px;
  max-width: 640px;
}
.title-input:hover {
  border-color: var(--line) !important;
}
.title-input:focus {
  border-color: var(--accent-2) !important;
  background: var(--surface) !important;
}
.board-stats {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.board-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pipeline-bar {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.pb-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  font-size: 12.5px;
}
.pb-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--text-2);
}
.pb-track {
  display: flex;
  gap: 2px;
  height: 8px;
}
.pb-seg {
  flex: 1;
  border-radius: 0;
  background: var(--surface-3);
  position: relative;
  overflow: hidden;
  transition: background-color var(--t-slow) var(--ease);
}
.pb-seg.s-done {
  background: var(--ok);
}
.pb-seg.s-queued {
  background:
    repeating-linear-gradient(135deg, transparent 0 2px, var(--tone) 2px 4px),
    var(--tone-2);
}
.pb-seg.s-error {
  background: var(--danger);
}
.pb-seg.s-running {
  background: var(--accent-2-soft);
}
.pb-seg.s-running::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}
.pb-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}
.pb-count em {
  font-style: normal;
  color: var(--text-3);
}
.pb-count b {
  color: var(--danger);
  font-weight: 600;
}
.selection-bar {
  position: sticky;
  top: calc(var(--topbar-h) + 8px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 8px 10px 8px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-2);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: pop-in var(--t) var(--ease-out);
}
.selection-bar strong {
  margin: 0 6px;
}
.board-empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  margin-top: 24px;
  padding: 56px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  color: var(--text-3);
}
.board-empty h2 {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.board-empty p {
  margin: 0;
  max-width: 48ch;
}
.page-grid {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.page-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition:
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease-out),
    transform var(--t) var(--ease-out);
  animation: card-in var(--t-slow) var(--ease-out) both;
}
.page-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.page-card.selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2), var(--shadow-sm);
}
.page-card.dragging {
  opacity: 0.4;
}
.page-card.drop-before {
  box-shadow: -4px 0 0 var(--accent-2);
}
.page-card.drop-after {
  box-shadow: 4px 0 0 var(--accent-2);
}
.page-card.working .thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--accent-2) 30%, transparent) 45%, color-mix(in srgb, var(--accent-3) 30%, transparent) 60%, transparent 75%);
  mix-blend-mode: color;
  animation: sweep 2.4s linear infinite;
}
@keyframes sweep {
  from {
    transform: translateX(-60%);
  }
  to {
    transform: translateX(60%);
  }
}
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}
.thumb-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.3);
}
.thumb-progress span {
  display: block;
  height: 100%;
  background: var(--accent-2);
  transition: width 0.4s var(--ease);
}
.page-select {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: rgba(15, 15, 16, 0.65);
  opacity: 0;
  transition: opacity 0.15s;
  cursor: pointer;
}
.page-select input {
  accent-color: var(--accent-2);
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
}
.page-card:hover .page-select,
.page-card.selected .page-select,
.page-select:focus-within {
  opacity: 1;
}
@media (hover: none) {
  .page-select {
    opacity: 1;
  }
}
.page-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.page-num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 18px;
}
.page-name {
  flex: 1;
  min-width: 0;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-foot .stage-chip {
  height: 20px;
  padding: 0 5px;
}

/* Settings panel */
.settings-panel {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 4px 18px 24px;
  scrollbar-width: thin;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 6px;
}
.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.save-state {
  font-size: 12px;
  color: var(--text-3);
}
.panel-section {
  border-bottom: 1px solid var(--line);
  padding: 4px 0 16px;
}
.panel-section[open] {
  display: grid;
  gap: 16px;
}
.panel-section summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 2px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 650;
  transition: color var(--t-fast) var(--ease);
}
.panel-section summary:hover {
  color: var(--text);
}
.panel-section summary::-webkit-details-marker {
  display: none;
}
.panel-section summary::after {
  content: "";
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-right: 1.8px solid var(--text-3);
  border-bottom: 1.8px solid var(--text-3);
  transform: rotate(45deg);
  transition: transform var(--t) var(--ease-out);
}
.panel-section[open] summary::after {
  transform: rotate(225deg);
}

/* ───────────── Editor ───────────── */
.view-editor {
  flex: 0 0 calc(100dvh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}
.editor {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  flex-wrap: wrap;
}
.eb-left,
.eb-right,
.eb-mid {
  display: flex;
  align-items: center;
  gap: 6px;
}
.eb-left {
  min-width: 0;
}
.divider {
  width: 1px;
  height: 22px;
  background: var(--line-strong);
  margin: 0 4px;
}
.pager-text {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: center;
}
.view-tabs label > span {
  min-height: 28px;
  padding: 2px 12px;
}
.zoom-label {
  min-width: 58px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
}
.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
}
.canvas {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 16px;
  background-color: var(--stage);
  outline: none;
}
.canvas.zoomed {
  place-items: start;
}
.surface {
  position: relative;
  --pos: 50%;
  outline: 1px solid var(--hard);
  box-shadow: var(--shadow-lg);
  background: #fff;
  user-select: none;
}
.surface img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.surface .layer-top {
  clip-path: inset(0 0 0 var(--pos));
}
.surface[data-view="compare"] {
  cursor: ew-resize;
  touch-action: none;
}
.surface .cmp-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 44px;
  margin-left: -22px;
  display: grid;
  place-items: center;
  outline: none;
}
.cmp-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 0 12px rgba(0, 0, 0, 0.35);
}
.cmp-knob {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid rgba(22, 21, 15, 0.18);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 6px 16px -6px rgba(0, 0, 0, 0.45);
}
.cmp-handle:focus-visible .cmp-knob {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.overlay {
  position: absolute;
  inset: 0;
  touch-action: none;
}
.overlay.drawing {
  cursor: crosshair;
}
.canvas.zoomed .overlay:not(.drawing) {
  cursor: grab;
}
.tbox {
  position: absolute;
  border: 1.5px solid color-mix(in srgb, var(--accent) 85%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-radius: var(--radius-sm);
  cursor: move;
  transition: background-color var(--t-fast) var(--ease);
}
.tbox.k-sfx,
.tbox.k-sign {
  border-color: color-mix(in srgb, var(--accent-2) 90%, transparent);
  background: color-mix(in srgb, var(--accent-2) 7%, transparent);
}
.tbox.muted {
  border-style: dashed;
  background: transparent;
}
.tbox:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.tbox.selected {
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.18);
  z-index: 2;
}
.tbox.drafting {
  border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  pointer-events: none;
}
.tbox-num {
  position: absolute;
  top: -10px;
  left: -10px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.k-sfx .tbox-num,
.k-sign .tbox-num {
  background: var(--accent-2);
  color: var(--on-accent-2);
}
.srcbox {
  position: absolute;
  border: 1.5px dashed rgba(255, 255, 255, 0.9);
  outline: 1.5px dashed rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 1;
}
.rs {
  position: absolute;
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  background: var(--paper);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
}
.rs-nw { left: 0; top: 0; cursor: nwse-resize; }
.rs-ne { left: 100%; top: 0; cursor: nesw-resize; }
.rs-sw { left: 0; top: 100%; cursor: nesw-resize; }
.rs-se { left: 100%; top: 100%; cursor: nwse-resize; }
.rs-n { left: 50%; top: 0; cursor: ns-resize; }
.rs-s { left: 50%; top: 100%; cursor: ns-resize; }
.rs-e { left: 100%; top: 50%; cursor: ew-resize; }
.rs-w { left: 0; top: 50%; cursor: ew-resize; }
.draw-hint {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  border-left: 3px solid var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  z-index: 5;
  pointer-events: none;
  animation: fade-in var(--t) var(--ease);
}

/* Inspector */
.inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--bg-elev);
}
.tabs {
  display: flex;
  gap: 2px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: -1px;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.tab:hover {
  color: var(--text);
  border-bottom-color: var(--line-strong);
}
.tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab .count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
}
.tab-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 24px;
  display: grid;
  align-content: start;
  gap: 12px;
  scrollbar-width: thin;
}
.tab-head {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.empty-note {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  padding: 28px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 13px;
  list-style: none;
}
.empty-note strong {
  color: var(--text);
}
.empty-note p {
  margin: 0;
}
.block-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.block-card {
  display: grid;
  gap: 6px;
  padding: 8px 10px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.block-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line);
}
.bc-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bc-num {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
}
.mini-select {
  width: auto !important;
  padding: 3px 6px !important;
  font-size: 12px !important;
  height: 26px;
}
.toggle {
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: none;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.toggle:hover {
  color: var(--text);
}
.toggle[aria-pressed="true"] {
  border-color: var(--accent-2-line);
  background: var(--accent-2-soft);
  color: var(--accent-2);
}
.block-card .source {
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  border-color: transparent;
  min-height: 30px;
}
.block-card .translation {
  font-size: 13.5px;
  font-weight: 500;
  min-height: 52px;
}
.bc-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}
.bc-foot input[type="range"] {
  flex: 1;
  accent-color: var(--accent-2);
}
.bc-foot output {
  font-variant-numeric: tabular-nums;
  min-width: 38px;
}
.tip {
  text-align: center;
}
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius);
  border-left-width: 3px !important;
  font-size: 13px;
  animation: fade-in var(--t) var(--ease);
}
.notice > div {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}
.notice p {
  margin: 0;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.notice small {
  color: var(--text-3);
}
.notice .bar {
  height: 4px;
  border-radius: 0;
  background: var(--surface-3);
  overflow: hidden;
}
.notice .bar span {
  display: block;
  height: 100%;
  background: var(--accent-2);
  transition: width var(--t-slow) var(--ease);
}
.notice-busy {
  background: var(--accent-2-soft);
  border: 1px solid var(--accent-2-line);
  color: var(--accent-2);
}
.notice-busy strong {
  color: var(--text);
}
.notice-error {
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}
.notice-error strong {
  color: var(--text);
}
.insp-section {
  display: grid;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.insp-section:last-child {
  border-bottom: 0;
}
.insp-section h3,
h3.sub {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.seed-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}
.seed-wrap .seed {
  width: 120px !important;
  font-family: var(--font-mono);
}
.versions,
.tasks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.versions li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12.5px;
}
.versions li.current {
  border-color: var(--accent-2-line);
  background: var(--accent-2-soft);
  box-shadow: inset 3px 0 0 var(--accent-2);
}
.versions li > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.versions strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.versions small {
  color: var(--text-3);
}
.v-num {
  font: 600 12px var(--font-mono);
  color: var(--text-3);
  min-width: 26px;
}
.facts {
  margin: 0;
  display: grid;
  gap: 0;
}
.facts div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
}
.facts dt {
  color: var(--text-3);
}
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.task {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12.5px;
}
.task small {
  color: var(--text-3);
}
.task-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-head small {
  margin-left: auto;
}
.pill {
  font-size: 11px;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-2);
}
.pill.s-done {
  color: var(--ok);
}
.pill.s-error {
  color: var(--danger);
}
.pill.s-running {
  color: var(--accent-2);
}
.task-error {
  margin: 4px 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  font: 11px/1.5 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-2);
}

/* ───────────── Compute dialog ───────────── */
.backend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.backend {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.backend.disabled {
  opacity: 0.6;
}
.backend .status-dot {
  margin-top: 6px;
}
.backend-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.backend-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.backend-url {
  font: 11.5px var(--font-mono);
  color: var(--text-3);
  overflow-wrap: anywhere;
}
.backend-status {
  font-size: 12px;
  color: var(--text-2);
}
.backend-status.s-error {
  color: var(--danger);
}
.backend-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.presets h3,
.backend-form h3 {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin-bottom: 10px;
}
.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.preset {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.preset:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.preset .icon {
  color: var(--accent);
}
.preset span {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}
.backend-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--accent-2-line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

/* ───────────── Overlays, toasts, uploads ───────────── */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  pointer-events: none;
  animation: fade-in var(--t) var(--ease);
}
.drop-overlay > div {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 44px 64px;
  border: 2px dashed var(--accent-2);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--accent-2);
  box-shadow: var(--shadow-lg);
  animation: pop-in var(--t-slow) var(--ease-out);
}
.drop-overlay strong {
  color: var(--text);
  font-size: 16px;
}
.drop-overlay span {
  color: var(--text-3);
  font-size: 13px;
}
.upload-progress {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 75;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 550;
}
.upload-progress .bar {
  height: 5px;
  border-radius: 0;
  background: var(--surface-3);
  overflow: hidden;
}
.upload-progress .bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent-2);
  transition: width var(--t-slow) var(--ease);
}
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  max-width: min(440px, calc(100vw - 40px));
  padding: 10px 10px 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--accent-2);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in var(--t-slow) var(--ease-out);
}
.toast[data-tone="error"] {
  background: var(--toast-error-bg);
  border-left-color: var(--ink);
  color: var(--toast-error-fg);
}
.toast button {
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  font-weight: 650;
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color var(--t-fast) var(--ease);
}
.toast button:hover {
  background: rgba(255, 255, 255, 0.24);
}
.toast-message { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-detail { display: block; margin-top: 4px; white-space: pre-line; font-weight: 400; }
.toast-actions { display: flex; flex-wrap: wrap; gap: 6px; order: 1; width: 100%; }
.toast .toast-close { padding: 5px; align-self: flex-start; }
.error-report-dialog { width: min(520px, calc(100vw - 40px)); }
.error-report-text { display: block; width: 100%; height: 220px; margin: 12px 0; }
.toast.leaving {
  opacity: 0;
  transform: translateX(12px);
  transition:
    opacity var(--t) var(--ease),
    transform var(--t) var(--ease);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* ───────────── Responsive ───────────── */
@media (max-width: 1180px) {
  .board {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
  .editor-body {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
}
@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .board {
    grid-template-columns: 1fr;
  }
  .settings-panel {
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .view-editor {
    flex: 1 0 auto;
    height: auto;
    overflow: visible;
  }
  .editor-body {
    grid-template-columns: 1fr;
  }
  .canvas-wrap {
    height: 70vh;
  }
  .inspector {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .crumbs {
    display: none;
  }
}
@media (max-width: 640px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .engine-pill {
    max-width: 200px;
  }
  .hero {
    padding: 18px;
  }
  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
  .pb-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }
  .pb-count {
    grid-column: 1 / -1;
  }
  .preset-grid,
  .two,
  .style-grid.compact {
    grid-template-columns: 1fr;
  }
  .eb-mid {
    order: 3;
    width: 100%;
  }
  .view-tabs {
    width: 100%;
  }
  .toasts {
    left: 16px;
    right: 16px;
    align-items: stretch;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  /* No lift on hover either: shadows may deepen, nothing moves. */
  .project-card:hover,
  .page-card:hover,
  .path-card:hover,
  .preset:hover,
  .btn:hover,
  .btn:active,
  .icon-btn:active {
    transform: none !important;
  }
}

/* ───── Manga creation ───── */
.create-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
  flex: 1;
}
.create-form .dialog-body {
  flex: 1;
  min-height: 0;
}
.composer-slot {
  margin-bottom: 16px;
}
.composer {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.composer:focus-within {
  border-color: var(--accent-2-line);
  box-shadow: 0 0 0 3px var(--accent-2-soft), var(--shadow);
}
.composer-icon {
  width: 20px;
  height: 20px;
  margin-top: 8px;
  color: var(--accent);
}
.composer .composer-input {
  border: 0;
  background: transparent;
  padding: 6px 2px;
  font-size: 14px;
  min-height: 44px;
  box-shadow: none;
}
.composer .composer-input:focus {
  box-shadow: none;
}
.composer-actions {
  grid-column: 2;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.page-prompt {
  margin: 0;
  padding: 0 8px 8px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 640px) {
  .composer {
    grid-template-columns: 1fr;
  }
  .composer-icon {
    display: none;
  }
  .composer-actions {
    grid-column: 1;
  }
}

/* ───── Library paths, create dialog, readiness ───── */
.hero-actions .link-btn.hero-folder {
  align-self: center;
  font-size: 13px;
}
.project-card .card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 650;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  background: var(--surface-2);
  width: fit-content;
}
.type-badge.create {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.meter-label {
  font-size: 11px;
  color: var(--text-3);
}
.create-form .dialog-actions {
  position: sticky;
  bottom: 0;
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.create-group {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.create-group > legend {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.create-group > legend::after {
  content: "";
  flex: 1;
  border-top: 1px dashed var(--line-strong);
}
.field-emph > .field-label::after {
  content: " · most important";
  font-weight: 500;
  color: var(--accent);
}
.page-count {
  font-size: 12px;
  color: var(--text-3);
}
.form-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
}
.form-error[hidden],
.ready-warn[hidden],
.page-count[hidden] {
  display: none;
}
.ready-warn {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--warn);
}
.composer-meta {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.composer-meta .form-error {
  padding: 4px 8px;
}
.tag.cap-missing {
  opacity: 0.55;
  text-decoration: line-through;
}
@media (max-width: 640px) {
  .composer-meta {
    grid-column: 1;
  }
}
.card-progress {
  display: grid;
  gap: 3px;
}

/* ───── Boot: skeleton while app.js starts, friendly failure (theme.js) ───── */
.view-boot {
  display: grid;
  place-items: start center;
  padding-inline: 20px;
}
@media (max-width: 640px) {
  .view-boot { padding-inline: 16px; }
}
.boot {
  width: min(1240px, 100%);
  padding: 32px 0;
  display: grid;
  gap: 18px;
}
.boot-skeleton {
  display: grid;
  gap: 14px;
  padding: 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.sk {
  display: block;
  height: 14px;
  border-radius: 0;
  background:
    linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--surface) 70%, transparent) 50%, transparent 100%) 0 0 / 200% 100% no-repeat,
    var(--surface-2);
  animation: sk-shimmer 1.4s linear infinite;
}
.sk-eyebrow { width: 160px; height: 10px; }
.sk-title { width: min(560px, 90%); height: 34px; border-radius: var(--radius); }
.sk-line { width: min(520px, 95%); }
.sk-short { width: min(320px, 60%); }
.sk-row { display: flex; gap: 10px; margin-top: 6px; }
.sk-btn { width: 150px; height: 44px; border-radius: var(--radius); }
@keyframes sk-shimmer {
  from { background-position: 200% 0, 0 0, 0 0; }
  to { background-position: -200% 0, 0 0, 0 0; }
}
.boot-status {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.boot-failed {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 20px 22px;
  border: 1px solid var(--danger);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--text);
  font-size: 14px;
}
.boot-failed[hidden] { display: none; }
.boot-failed strong { font-size: 16px; }
.boot-failed details { font-size: 12.5px; color: var(--text-2); }
.boot-failed code { display: block; margin-top: 6px; white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); }
.boot-error .boot-skeleton,
.boot-error .boot-status,
html:not(.js) .boot-skeleton,
html:not(.js) .boot-status {
  display: none;
}
@media (max-width: 640px) {
  .boot { padding: 16px 0; }
  .boot-skeleton { padding: 20px; }
  .sk-btn { width: 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}
.backend-details {
  font-size: 12px;
  color: var(--text-3);
}
.backend-details summary {
  cursor: pointer;
  width: max-content;
}
.backend-details code {
  display: block;
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ───── Compute dialog (compute.js): whole-token meta line, neutral capability chips ───── */
.backend-url.backend-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  min-width: 0;
  overflow-wrap: normal;
}
.backend-meta > span {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.backend-meta > span:not(:last-child)::after {
  content: " ·";
}
.tag.cap {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: var(--ok);
}
.tag.cap.cap-missing {
  background: var(--surface-3);
  color: var(--text-3);
}
.tag.tag-problem {
  background: var(--accent-3-soft);
  color: var(--warn);
}
.backend-form .model-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.backend-form .model-picker > select,
.backend-form .model-picker > input {
  width: 100%;
  min-width: 0;
}
/* ───── end Compute dialog ───── */

/* Hosted: AI provider out of capacity ("temporary downtime"), shown under the top bar on every page. */
.service-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  text-align: center;
  color: var(--text);
  background: var(--accent-3-soft);
  border-bottom: 1px solid var(--line);
}
.service-banner[hidden] { display: none; }
.service-banner .icon { flex: none; color: var(--warn); }

/* ───── Motion: views fade in; the first cards of a grid arrive in a short stagger ───── */
.view > * {
  animation: fade-in var(--t-slow) var(--ease);
}
.page-grid > .page-card:nth-child(2),
.project-grid > .project-card:nth-child(2) { animation-delay: 30ms; }
.page-grid > .page-card:nth-child(3),
.project-grid > .project-card:nth-child(3) { animation-delay: 60ms; }
.page-grid > .page-card:nth-child(4),
.project-grid > .project-card:nth-child(4) { animation-delay: 90ms; }
.page-grid > .page-card:nth-child(5),
.project-grid > .project-card:nth-child(5) { animation-delay: 120ms; }
.page-grid > .page-card:nth-child(n + 6),
.project-grid > .project-card:nth-child(n + 6) { animation-delay: 150ms; }
