/* ==========================================================================
   BLOCKFORGE TOOL STATION
   Dense, task-first UI · Apple polish × functional voxel details
   Theme modes: auto / light / dark via [data-theme] on <html>
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root,
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f1f1f4;
  --surface: #ffffff;
  --surface-2: #f7f7fa;
  --surface-3: #ececf1;
  --surface-glass: rgba(255, 255, 255, 0.84);

  --text: #1d1d1f;
  --text-2: #4a4a50;
  --muted: #73737b;
  --faint: #9a9aa2;

  --border: #e3e3e9;
  --border-strong: #cfcfd8;

  --accent: #3f6b22;
  --accent-strong: #2d4f16;
  --accent-soft: rgba(63, 107, 34, 0.09);
  --accent-line: rgba(63, 107, 34, 0.32);
  --accent-contrast: #ffffff;

  --ok: #2c8554;
  --ok-soft: rgba(44, 133, 84, 0.10);
  --warn: #a8690f;
  --warn-soft: rgba(168, 105, 15, 0.10);
  --danger: #c24949;
  --info: #356fb3;

  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 6px 18px rgba(20, 20, 30, 0.04);
  --shadow-pop: 0 18px 50px rgba(20, 20, 30, 0.18);
  --pixel-shadow-color: #1d1d1f;

  --grid: rgba(20, 20, 30, 0.045);
  --checker-a: #e9e9ee;
  --checker-b: #f6f6f9;
  --canvas-bg: #0b0b0f;
  --hover: rgba(20, 20, 30, 0.045);
  --active: rgba(20, 20, 30, 0.07);
  --focus: #356fb3;

  --code-bg: #111116;
  --code-text: #d8d8e0;
  --selection: rgba(63, 107, 34, 0.18);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0a0d;
  --surface: #121216;
  --surface-2: #17171c;
  --surface-3: #202027;
  --surface-glass: rgba(18, 18, 22, 0.84);

  --text: #f2f2f6;
  --text-2: #c4c4cd;
  --muted: #92929c;
  --faint: #66666f;

  --border: #27272f;
  --border-strong: #3a3a45;

  --accent: #c9ff4e;
  --accent-strong: #dbff8a;
  --accent-soft: rgba(201, 255, 78, 0.11);
  --accent-line: rgba(201, 255, 78, 0.35);
  --accent-contrast: #0a0a0d;

  --ok: #63f5c6;
  --ok-soft: rgba(99, 245, 198, 0.10);
  --warn: #ffb454;
  --warn-soft: rgba(255, 180, 84, 0.10);
  --danger: #ff7070;
  --info: #7cc4ff;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.55);
  --pixel-shadow-color: #000000;

  --grid: rgba(255, 255, 255, 0.045);
  --checker-a: #1b1b22;
  --checker-b: #141419;
  --canvas-bg: #08080c;
  --hover: rgba(255, 255, 255, 0.045);
  --active: rgba(255, 255, 255, 0.075);
  --focus: #c9ff4e;

  --code-bg: #0a0a0e;
  --code-text: #cfcfd8;
  --selection: rgba(201, 255, 78, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0a0a0d;
    --surface: #121216;
    --surface-2: #17171c;
    --surface-3: #202027;
    --surface-glass: rgba(18, 18, 22, 0.84);

    --text: #f2f2f6;
    --text-2: #c4c4cd;
    --muted: #92929c;
    --faint: #66666f;

    --border: #27272f;
    --border-strong: #3a3a45;

    --accent: #c9ff4e;
    --accent-strong: #dbff8a;
    --accent-soft: rgba(201, 255, 78, 0.11);
    --accent-line: rgba(201, 255, 78, 0.35);
    --accent-contrast: #0a0a0d;

    --ok: #63f5c6;
    --ok-soft: rgba(99, 245, 198, 0.10);
    --warn: #ffb454;
    --warn-soft: rgba(255, 180, 84, 0.10);
    --danger: #ff7070;
    --info: #7cc4ff;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.55);
    --pixel-shadow-color: #000000;

    --grid: rgba(255, 255, 255, 0.045);
    --checker-a: #1b1b22;
    --checker-b: #141419;
    --canvas-bg: #08080c;
    --hover: rgba(255, 255, 255, 0.045);
    --active: rgba(255, 255, 255, 0.075);
    --focus: #c9ff4e;

    --code-bg: #0a0a0e;
    --code-text: #cfcfd8;
    --selection: rgba(201, 255, 78, 0.2);
  }
}

:root {
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --topbar-h: 52px;
  --status-h: 30px;
  --left-w: 228px;
  --right-w: 296px;
  --gap: 14px;
  --pad: 18px;
  --radius: 10px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- 2. Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: calc(var(--status-h) + 2px);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-locked,
body.drawer-open {
  overflow: hidden;
}

body,
.topbar,
.panel,
.rail-section,
.statusbar,
.mobile-actions,
.popover,
.palette__dialog,
.input,
.select,
.textarea {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

::selection {
  background: var(--selection);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 3. Utilities ---------- */
.mono {
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 500;
  height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 10px;
}

kbd,
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.dot {
  width: 5px;
  height: 5px;
  flex: none;
  background: var(--accent);
}

.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--faint { background: var(--faint); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.badge--accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge--ok {
  border-color: var(--ok-soft);
  background: var(--ok-soft);
  color: var(--ok);
}

.badge--warn {
  border-color: var(--warn-soft);
  background: var(--warn-soft);
  color: var(--warn);
}

/* ---------- 4. Controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s,
    box-shadow 0.18s;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn:active {
  transform: translateY(1px);
}

.btn--sm {
  height: 27px;
  padding: 0 9px;
  font-size: 10.5px;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 2px 2px 0 var(--pixel-shadow-color);
}

.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-contrast);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--pixel-shadow-color);
}

.btn--primary kbd {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: var(--accent-contrast);
  border-color: color-mix(in srgb, var(--accent-contrast) 30%, transparent);
  background: color-mix(in srgb, var(--accent-contrast) 14%, transparent);
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  color: var(--danger);
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 550;
  white-space: nowrap;
}

.link-btn:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.segmented button {
  height: 24px;
  padding: 0 5px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] .segmented button.is-active {
  background: var(--surface-3);
}

.switch {
  position: relative;
  width: 30px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-3);
  flex: none;
  transition: background 0.2s, border-color 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--faint);
  transition: transform 0.2s var(--ease), background 0.2s;
}

.switch[aria-checked="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.switch[aria-checked="true"]::after {
  transform: translateX(12px);
  background: var(--accent);
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 11.5px;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.input,
.select {
  height: 28px;
  padding: 0 8px;
}

.textarea {
  min-height: 84px;
  padding: 8px 9px;
  line-height: 1.55;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 12px, calc(100% - 9px) 12px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: var(--text-2);
}

/* ---------- 5. Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  width: 100%;
  max-width: 1720px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--pad);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  color: var(--text);
}

.brand__mark {
  display: grid;
  grid-template-columns: repeat(3, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 1px;
  flex: none;
}

.brand__mark i {
  background: var(--accent);
  opacity: 0.92;
}

.brand__mark i:nth-child(2),
.brand__mark i:nth-child(4),
.brand__mark i:nth-child(6),
.brand__mark i:nth-child(8) {
  opacity: 0.34;
}

.brand__mark i:nth-child(5) {
  opacity: 0.65;
}

.brand__word {
  font-size: 12.5px;
  font-weight: 760;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.brand__beta {
  height: 16px;
  padding: 0 4px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 7px;
  line-height: 14px;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 auto;
  max-width: 420px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--faint);
  text-align: left;
  transition: background 0.18s, border-color 0.18s;
}

.search-trigger:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.search-trigger svg {
  width: 13px;
  height: 13px;
  flex: none;
}

.search-trigger__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.search-trigger kbd {
  flex: none;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  flex: none;
}

.lang-switch {
  display: flex;
  gap: 2px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.lang-switch button {
  height: 20px;
  min-width: 25px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.04em;
}

.lang-switch button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] .lang-switch button.is-active {
  background: var(--surface-3);
}

.local-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.local-pill i {
  width: 4px;
  height: 4px;
  background: var(--ok);
}

.theme-wrap {
  position: relative;
}

.theme-icon {
  display: none;
}

html[data-theme="light"] .theme-icon--light,
html[data-theme="dark"] .theme-icon--dark,
html[data-theme="auto"] .theme-icon--auto,
html:not([data-theme]) .theme-icon--auto {
  display: block;
}

.menu-btn {
  display: none;
}

/* ---------- 6. Theme popover ---------- */
.popover {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 210;
  min-width: 166px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
}

.popover__label {
  display: block;
  padding: 4px 8px 5px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

.popover button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  text-align: left;
}

.popover button:hover {
  background: var(--hover);
  color: var(--text);
}

.popover button[aria-checked="true"] {
  background: var(--accent-soft);
  color: var(--text);
}

.popover .check {
  margin-left: auto;
  color: var(--accent-strong);
  opacity: 0;
  font-size: 10px;
}

.popover button[aria-checked="true"] .check {
  opacity: 1;
}

.theme-swatch {
  width: 14px;
  height: 14px;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}

.theme-swatch--auto {
  background: linear-gradient(135deg, var(--text) 50%, var(--surface) 50%);
}

.theme-swatch--light {
  background: linear-gradient(135deg, #ffffff 50%, #e6e6ea 50%);
}

.theme-swatch--dark {
  background: #121216;
}

/* ---------- 7. Mobile workspace tabs ---------- */
.mobile-tabs {
  display: none;
}

.mtab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.mtab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-strong);
}

.mtab svg {
  width: 12px;
  height: 12px;
}

/* ---------- 8. App shell ---------- */
.app {
  width: 100%;
  max-width: 1720px;
  margin: 0 auto;
  padding: 14px var(--pad) calc(var(--status-h) + 14px);
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  gap: var(--gap);
  align-items: start;
}

.rail-backdrop {
  display: none;
}

/* ---------- 9. Left rail ---------- */
.rail {
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - var(--topbar-h) - var(--status-h) - 28px);
  overflow: auto;
  padding-right: 2px;
}

.rail-section {
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 7px 6px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--faint);
}

.rail__head .count {
  color: var(--faint);
}

.rail__head-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rail__head .rail__close {
  display: none;
}

.tool-row {
  position: relative;
  display: grid;
  grid-template-columns: 15px 20px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  width: 100%;
  min-height: 35px;
  padding: 4px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  transition: background 0.16s, color 0.16s;
}

.tool-row:hover {
  background: var(--hover);
  color: var(--text);
}

.tool-row.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

.tool-row.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.tool-row__num {
  font-family: var(--mono);
  font-size: 7.5px;
  color: var(--faint);
}

.tool-row__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--ws-color, var(--muted));
}

.tool-row.is-active .tool-row__icon {
  color: var(--ws-color, var(--accent-strong));
}

.tool-row__icon svg {
  width: 16px;
  height: 16px;
  shape-rendering: crispEdges;
}

.tool-row__body {
  min-width: 0;
}

.tool-row__name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-row__meta {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.07em;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-row__badge {
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 6.5px;
  letter-spacing: 0.05em;
  color: var(--warn);
  white-space: nowrap;
}

.quick-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  height: 29px;
  padding: 0 7px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: 10px;
  text-align: left;
}

.quick-row:hover {
  background: var(--hover);
  color: var(--text);
}

.quick-dot {
  width: 6px;
  height: 6px;
  flex: none;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}

.quick-row span:nth-child(2) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-arrow {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--faint);
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.recent-row:hover {
  background: var(--hover);
}

.recent-thumb {
  width: 28px;
  height: 28px;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--canvas-bg);
}

.recent-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.recent-row__body {
  min-width: 0;
}

.recent-row b {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-row small {
  display: block;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 7px;
  color: var(--faint);
}

.rail__foot {
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.engine-card {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.engine-card__dot {
  width: 6px;
  height: 6px;
  flex: none;
  background: var(--ok);
  animation: pulse 2.4s steps(2, end) infinite;
}

.engine-card__body {
  min-width: 0;
}

.engine-card b {
  display: block;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-2);
}

.engine-card small {
  display: block;
  font-size: 8px;
  color: var(--faint);
}

.engine-card .mono {
  margin-left: auto;
  font-size: 7.5px;
  color: var(--faint);
}

.legal-mini {
  margin: 6px 2px 0;
  font-size: 7.5px;
  line-height: 1.45;
  color: var(--faint);
}

/* ---------- 10. Workspace header ---------- */
.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ws-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-top: 2px;
}

.ws-head__left {
  min-width: 0;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.crumbs .mono {
  color: var(--muted);
}

.ws-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.ws-title-row h1 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-weight: 700;
}

.ws-desc {
  max-width: 620px;
  margin: 5px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.ws-head__actions {
  display: flex;
  gap: 6px;
  flex: none;
  padding-top: 19px;
}

/* ---------- 11. Prompt + params ---------- */
.compose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(286px, 0.85fr);
  gap: 12px;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
}

.panel__title {
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel__hint {
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.prompt-panel {
  display: flex;
  flex-direction: column;
}

.prompt-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 9px;
}

.prompt-textarea {
  flex: 1;
  width: 100%;
  min-height: 86px;
  max-height: 150px;
  resize: vertical;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.55;
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.prompt-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chip-btn {
  height: 21px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.chip-btn:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.char-count {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--faint);
  white-space: nowrap;
}

.params-panel {
  display: flex;
  flex-direction: column;
}

.params-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  padding: 8px 10px 9px;
}

.seed-row {
  display: flex;
  gap: 4px;
}

.seed-row .input {
  flex: 1;
  min-width: 0;
}

.seed-row .icon-btn {
  width: 28px;
  height: 28px;
  flex: none;
}

.seed-row .icon-btn svg {
  width: 13px;
  height: 13px;
}

/* ---------- 12. Generate row ---------- */
.generate-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 2px;
}

.generate-row__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}

.generate-row__meta .dot--ok {
  animation: pulse 2s steps(2, end) infinite;
}

.generate-row .btn--primary {
  margin-left: auto;
  height: 34px;
  padding: 0 13px;
  font-size: 11.5px;
}

.generate-row > .icon-btn {
  width: 34px;
  height: 34px;
}

/* ---------- 13. Output panel ---------- */
.output-panel {
  overflow: hidden;
}

.output-head {
  padding: 0 10px;
}

.tabs {
  display: flex;
  gap: 2px;
}

.tabs button {
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.tabs button:hover {
  color: var(--text);
}

.tabs button.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.output-head__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--faint);
}

.output-body {
  position: relative;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  padding: 8px;
}

.asset-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.asset-card:hover {
  border-color: var(--border-strong);
}

.asset-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.asset-card__view {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--canvas-bg);
}

.asset-checker {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: var(--checker-b);
  background-image: linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.asset-card__view canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.asset-card__badge {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 16px;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 3px;
  background: rgba(8, 8, 12, 0.74);
  color: #fff;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.04em;
}

.asset-card__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  height: 22px;
  padding: 0 5px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 7px;
  color: var(--faint);
}

.asset-card__bar .seed {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-card__bar button {
  padding: 1px 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.asset-card__bar button:hover {
  color: var(--accent-strong);
}

.progress {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.progress__blocks {
  display: flex;
  gap: 3px;
}

.progress__blocks i {
  width: 7px;
  height: 7px;
  background: var(--surface-3);
  animation: blocks 1.1s steps(1, end) infinite;
}

.progress__blocks i:nth-child(2) { animation-delay: 0.08s; }
.progress__blocks i:nth-child(3) { animation-delay: 0.16s; }
.progress__blocks i:nth-child(4) { animation-delay: 0.24s; }
.progress__blocks i:nth-child(5) { animation-delay: 0.32s; }
.progress__blocks i:nth-child(6) { animation-delay: 0.4s; }
.progress__blocks i:nth-child(7) { animation-delay: 0.48s; }
.progress__blocks i:nth-child(8) { animation-delay: 0.56s; }

.progress__label {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.spec-table {
  padding: 6px 10px 9px;
  margin: 0;
}

.spec-table div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-top: 1px solid var(--border);
  font-size: 10px;
}

.spec-table div:first-child {
  border-top: 0;
}

.spec-table dt {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.spec-table dd {
  margin: 0;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
}

.code-wrap {
  position: relative;
  padding: 8px;
}

.code-block {
  position: relative;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.65;
  white-space: pre;
}

.code-copy {
  position: absolute;
  top: 13px;
  right: 13px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.06em;
}

.code-copy:hover {
  color: #fff;
}

/* ---------- 14. History ---------- */
.history-list {
  padding: 4px 8px 8px;
}

.history-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 74px 50px auto;
  gap: 7px;
  align-items: center;
  padding: 5px 0;
  border-top: 1px solid var(--border);
}

.history-row:first-child {
  border-top: 0;
}

.history-thumb {
  width: 26px;
  height: 26px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--canvas-bg);
}

.history-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.history-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta,
.history-time,
.history-ws {
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.02em;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-restore {
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 8px;
}

.history-restore:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ---------- 15. Inspector ---------- */
.inspector {
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - var(--topbar-h) - var(--status-h) - 28px);
  overflow: auto;
  padding-right: 2px;
}

.side-card {
  overflow: hidden;
}

.side-card .panel__head {
  min-height: 31px;
}

.spec-rows {
  padding: 3px 10px 8px;
  margin: 0;
}

.spec-rows div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-top: 1px solid var(--border);
}

.spec-rows div:first-child {
  border-top: 0;
}

.spec-rows dt {
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.spec-rows dd {
  max-width: 160px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 3px 10px 8px;
}

.checklist li {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 5px 0;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 9.5px;
}

.checklist li:first-child {
  border-top: 0;
}

.checklist i {
  width: 5px;
  height: 5px;
  background: var(--ok);
}

.checklist em {
  color: var(--ok);
  font-family: var(--mono);
  font-size: 7px;
  font-style: normal;
  letter-spacing: 0.04em;
}

.checklist li.is-off i {
  background: var(--faint);
}

.checklist li.is-off em {
  color: var(--faint);
}

.side-recent {
  padding: 2px 6px 7px;
}

.side-recent__row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 3px 4px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  text-align: left;
}

.side-recent__row:hover {
  background: var(--hover);
}

.side-recent__thumb {
  width: 24px;
  height: 24px;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--canvas-bg);
}

.side-recent__thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.side-recent__body {
  min-width: 0;
}

.side-recent__body b {
  display: block;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-recent__body small {
  display: block;
  font-family: var(--mono);
  font-size: 7px;
  color: var(--faint);
}

.shortcuts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 9px;
  padding: 4px 10px 9px;
}

.shortcuts div {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
}

.shortcuts kbd {
  min-width: 22px;
}

.tip-body {
  margin: 0;
  padding: 8px 10px 4px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.55;
}

.tip-card .link-btn {
  margin: 0 10px 9px;
}

/* ---------- 16. Status bar ---------- */
.statusbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--status-h);
  padding: 0 var(--pad);
  border-top: 1px solid var(--border);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.statusbar__item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.statusbar__spacer {
  flex: 1;
}

/* ---------- 17. Mobile action bar ---------- */
.mobile-actions {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 96;
  height: 54px;
  padding: 0 11px;
  align-items: center;
  gap: 7px;
  border-top: 1px solid var(--border);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.mobile-actions__meta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--faint);
}

.mobile-actions__cost {
  margin-left: 3px;
  color: var(--warn);
  white-space: nowrap;
}

.mobile-actions__cost::before {
  content: "·";
  margin-right: 4px;
  color: var(--faint);
}

.mobile-actions .btn {
  height: 36px;
  flex: none;
}

.mobile-actions .btn--primary {
  min-width: 112px;
}

/* ---------- 18. Command palette ---------- */
.palette {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 11vh 12px 0;
}

.palette__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 12, 0.44);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.palette__dialog {
  position: relative;
  width: min(560px, 100%);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  animation: palette-in 0.16s var(--ease);
}

.palette__search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}

.palette__search svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex: none;
}

.palette__search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12.5px;
  outline: none;
}

.palette__list {
  max-height: 50vh;
  overflow: auto;
  padding: 5px;
}

.palette__group-label {
  padding: 6px 8px 3px;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.palette__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  font-size: 11px;
}

.palette__item:hover,
.palette__item.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

.palette__item svg {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--muted);
}

.palette__item .pico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex: none;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
}

.palette__item .meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 7.5px;
  color: var(--faint);
}

.palette__item .check-inline {
  width: 5px;
  height: 5px;
  background: var(--accent);
}

.palette__empty {
  padding: 24px 10px;
  text-align: center;
  color: var(--faint);
  font-size: 11px;
}

.palette__foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.04em;
  color: var(--faint);
}

/* ---------- 19. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--status-h) + 14px);
  z-index: 400;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 24px);
  padding: 9px 13px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.03em;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast .dot {
  background: var(--accent);
}

/* ---------- 20. Motion ---------- */
@keyframes pulse {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.25; }
}

@keyframes blocks {
  0%, 100% { background: var(--surface-3); }
  50% { background: var(--accent); }
}

@keyframes palette-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* ---------- 21. Responsive ---------- */
@media (max-width: 1280px) {
  :root {
    --left-w: 212px;
    --right-w: 276px;
  }
  .search-trigger { max-width: 340px; }
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: var(--left-w) minmax(0, 1fr);
  }
  .inspector {
    grid-column: 1 / -1;
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 900px) {
  body {
    padding-bottom: 66px;
  }
  .search-trigger {
    flex: none;
    width: 30px;
    max-width: none;
    padding: 0;
    justify-content: center;
  }
  .search-trigger__text,
  .search-trigger kbd,
  .local-pill {
    display: none;
  }
  .brand__beta {
    display: none;
  }
  .menu-btn {
    display: inline-flex;
  }
  .mobile-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 7px var(--pad);
    position: sticky;
    top: var(--topbar-h);
    z-index: 80;
    border-bottom: 1px solid var(--border);
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
    scrollbar-width: none;
  }
  .mobile-tabs::-webkit-scrollbar {
    display: none;
  }
  .app {
    grid-template-columns: 1fr;
    padding-top: 12px;
    padding-bottom: 16px;
  }
  .rail {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    z-index: 120;
    width: min(300px, 86vw);
    max-height: none;
    padding: 10px;
    overflow: auto;
    border-right: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    transform: translateX(-102%);
    transition: transform 0.25s var(--ease);
  }
  .rail.is-open {
    transform: none;
  }
  .rail__head .rail__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
  }
  .rail-backdrop {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0;
    z-index: 110;
    border: 0;
    background: rgba(8, 8, 12, 0.38);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
  .rail-backdrop[hidden] {
    display: none;
  }
  .ws-head {
    display: block;
  }
  .ws-head__actions {
    padding-top: 8px;
  }
  .prompt-textarea {
    min-height: 78px;
  }
  .generate-row {
    display: none;
  }
  .mobile-actions {
    display: flex;
  }
  .statusbar {
    display: none;
  }
  .toast {
    bottom: 66px;
  }
  .panel__head {
    min-height: 34px;
  }
}

@media (max-width: 760px) {
  .compose-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --pad: 12px;
    --gap: 10px;
  }
  .topbar__inner {
    gap: 7px;
  }
  .brand__word {
    font-size: 11.5px;
  }
  .topbar__actions {
    gap: 5px;
  }
  .lang-switch button {
    min-width: 23px;
    padding: 0 4px;
  }
  .ws-title-row h1 {
    font-size: 24px;
  }
  .ws-desc {
    font-size: 11px;
  }
  .field-row {
    gap: 6px;
  }
  .inspector {
    grid-template-columns: 1fr;
  }
  .asset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
  }
  .asset-card__bar {
    height: 24px;
    font-size: 7px;
  }
  .output-head__actions .output-count {
    display: none;
  }
  .history-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
  }
  .history-ws,
  .history-time {
    display: none;
  }
  .history-meta {
    display: block;
  }
  .shortcuts {
    grid-template-columns: 1fr;
  }
  .mobile-actions .btn--primary {
    min-width: 96px;
  }
  .palette {
    padding-top: 8px;
  }
  .palette__dialog {
    width: 100%;
  }
  .toast {
    width: calc(100% - 24px);
    justify-content: center;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
