  /* Theme colors live in index.html. The renderer alone owns the cinematic canvas. */
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }

  html {
    font: 16px/1.5 "Segoe UI", Aptos, Calibri, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--cp-text);
    background: var(--cp-bg);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }

  body { margin: 0; min-width: 320px; font-size: 13px; }
  h1, h2, h3, p { margin: 0; }
  button, input, select { font: inherit; }
  button, summary { -webkit-tap-highlight-color: var(--cp-highlight); }
  button { cursor: pointer; }
  button:disabled, input:disabled, select:disabled { cursor: not-allowed; }
  button:disabled { opacity: 0.5; }
  fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
  fieldset:disabled { opacity: 0.5; }
  ::selection { color: var(--cp-text); background: var(--cp-highlight); }
  :focus-visible { outline: 2px solid var(--cp-accent); outline-offset: 3px; }

  * { scrollbar-width: thin; scrollbar-color: var(--cp-border-strong) var(--cp-surface); }
  ::-webkit-scrollbar { width: 8px; height: 6px; }
  ::-webkit-scrollbar-track { background: var(--cp-surface); }
  ::-webkit-scrollbar-thumb { border: 2px solid var(--cp-surface); border-radius: 8px; background: var(--cp-border-strong); }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .lucide, [data-lucide] { display: inline-block; width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.7; }
  .eyebrow { color: var(--cp-text-soft); font-size: 9px; font-weight: 600; letter-spacing: 0.14em; line-height: 1.5; }
  .button, .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    flex-shrink: 0;
    padding: 8px 12px;
    border: 1px solid var(--cp-border);
    border-radius: 0.625rem;
    color: var(--cp-text);
    background: var(--cp-surface);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    transition: background 140ms, border-color 140ms, color 140ms;
  }
  .icon-button { width: 36px; height: 36px; padding: 8px; }
  .button:hover:not(:disabled), .icon-button:hover:not(:disabled) { border-color: var(--cp-border-strong); background: var(--cp-surface-soft); }
  .button-primary { color: var(--cp-accent-fg); border-color: var(--cp-accent); background: var(--cp-accent); }
  .button-primary:hover:not(:disabled) { color: var(--cp-accent-fg); border-color: var(--cp-accent-hover); background: var(--cp-accent-hover); }

  /* The stage keeps the available space; inspector and preset shelf never cover it on desktop. */
  #app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 620px; }
  .app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    height: 68px;
    flex: 0 0 68px;
    padding: 0 24px;
    border-bottom: 1px solid var(--cp-border);
    background: var(--cp-bg-elevated);
    z-index: 10;
  }
  .brand-group, .brand, .header-actions { display: flex; align-items: center; }
  .brand-group { gap: 28px; min-width: 0; }
  .brand { gap: 12px; flex-shrink: 0; }
  .brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--cp-highlight); border-radius: 10px; color: var(--cp-accent); background: var(--cp-accent-soft); }
  .brand-mark .lucide, .brand-mark [data-lucide] { width: 26px; height: 26px; stroke-width: 1.5; }
  .brand h1 { font-size: 20px; font-weight: 650; line-height: 1.2; letter-spacing: -0.045em; }
  .brand p { margin-top: 4px; color: var(--cp-text-soft); font-size: 8px; font-weight: 600; letter-spacing: 0.18em; }
  .workspace-tag { display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; border: 1px solid var(--cp-border); border-radius: 6px; color: var(--cp-text-soft); font-size: 10px; }
  .status-dot { width: 5px; height: 5px; flex-shrink: 0; border-radius: 50%; background: var(--cp-accent); }
  .header-actions { gap: 8px; }
  .save-status { margin-right: 12px; color: var(--cp-text-soft); font-size: 11px; }
  .header-actions > .icon-button { border: 0; background: none; color: var(--cp-text-soft); }
  #toggle-inspector { display: none; }
  .editor-layout { display: grid; grid-template-columns: 318px minmax(0, 1fr); min-height: 0; flex: 1; }
  .work-area { display: grid; grid-template-rows: minmax(380px, 1fr) auto; min-width: 0; min-height: 0; }

  /* Inspector */
  #inspector { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--cp-border); background: var(--cp-surface); }
  .inspector-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 16px; }
  .inspector-heading h2 { margin-top: 3px; font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
  .inspector-heading > .lucide, .inspector-heading > [data-lucide] { color: var(--cp-text-soft); }
  .inspector-tabs { display: grid; grid-template-columns: 1fr 1.25fr 1fr; flex-shrink: 0; padding: 0 12px; border-bottom: 1px solid var(--cp-border); }
  .inspector-tabs button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 4px;
    border: 0;
    border-bottom: 2px solid var(--cp-surface);
    color: var(--cp-text-soft);
    background: none;
    font-size: 11px;
  }
  .inspector-tabs .lucide, .inspector-tabs [data-lucide] { width: 14px; height: 14px; }
  .inspector-tabs button[aria-selected="true"] { border-bottom-color: var(--cp-accent); color: var(--cp-accent); font-weight: 600; }
  .inspector-tabs button:hover { background: var(--cp-surface-soft); }
  .inspector-tabs button:focus-visible { outline-offset: -4px; border-radius: 6px; }
  .inspector-scroll { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 0 16px 16px 20px; }
  [role="tabpanel"]:focus-visible { outline-offset: -2px; }
  .control-section { padding: 16px 0; border-bottom: 1px solid var(--cp-border); }
  .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 18px; margin-bottom: 12px; }
  .section-title { color: var(--cp-text); font-size: 11px; font-weight: 600; letter-spacing: 0.035em; }
  .identity-section { display: grid; gap: 10px; }
  .kind-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border: 1px solid var(--cp-border); border-radius: 10px; background: var(--cp-surface-soft); }
  .kind-switch button, .light-presets button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px; border: 0; border-radius: 7px; color: var(--cp-text-soft); background: none; font-size: 11px; }
  .kind-switch .lucide, .kind-switch [data-lucide], .light-presets .lucide, .light-presets [data-lucide] { width: 14px; height: 14px; }
  .kind-switch button[aria-pressed="true"] { color: var(--cp-text); background: var(--cp-surface); box-shadow: 0 0 0 1px var(--cp-border); font-weight: 600; }
  .kind-switch button[aria-pressed="true"] .lucide { color: var(--cp-accent); }
  .kind-switch button:hover:not([aria-pressed="true"]) { color: var(--cp-text); }
  .seed-control { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: end; gap: 8px; }
  #setting-seed { font-family: Consolas, "Courier New", Courier, monospace; letter-spacing: 0.025em; }
  .control-fields { display: grid; gap: 6px; }
  .control { min-width: 0; }
  .control label { color: var(--cp-text-soft); font-size: 11px; }
  .control-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 16px; }
  .control output { font-family: Consolas, "Courier New", Courier, monospace; font-size: 11px; font-variant-numeric: tabular-nums; }
  .range-control output { min-width: 44px; color: var(--cp-text); text-align: right; }
  .text-control, .select-control, .color-control { display: grid; gap: 5px; }
  input[type="text"], select { width: 100%; min-width: 0; min-height: 36px; padding: 7px 10px; border: 1px solid var(--cp-border); border-radius: 8px; color: var(--cp-text); background: var(--cp-bg-elevated); }
  input[type="text"]:hover, select:hover { border-color: var(--cp-border-strong); }
  select { cursor: pointer; }
  input[type="range"] { display: block; width: 100%; height: 36px; margin: 0; padding: 0; appearance: none; background: none; cursor: pointer; touch-action: pan-y; }
  input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--cp-accent) 0% var(--range-fill, 0%), var(--cp-border) var(--range-fill, 0%) 100%); }
  input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--cp-accent) 0% var(--range-fill, 0%), var(--cp-border) var(--range-fill, 0%) 100%); }
  input[type="range"]::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; appearance: none; border: 2px solid var(--cp-accent); border-radius: 50%; background: var(--cp-surface); box-shadow: 0 0 0 2px var(--cp-surface); }
  input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid var(--cp-accent); border-radius: 50%; background: var(--cp-surface); box-shadow: 0 0 0 2px var(--cp-surface); }
  input[type="range"]:active::-webkit-slider-thumb { background: var(--cp-accent); }
  input[type="range"]:active::-moz-range-thumb { background: var(--cp-accent); }
  .palette-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .color-field { display: flex; align-items: center; gap: 6px; min-height: 36px; padding-right: 8px; border: 1px solid var(--cp-border); border-radius: 8px; background: var(--cp-bg-elevated); }
  .color-field:focus-within { outline: 2px solid var(--cp-accent); outline-offset: 2px; }
  .color-field output { color: var(--cp-text-soft); font-size: 10px; }
  input[type="color"] { width: 36px; height: 36px; flex-shrink: 0; padding: 5px; border: 0; border-radius: 7px; background: none; cursor: pointer; }
  input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
  input[type="color"]::-webkit-color-swatch { border: 1px solid var(--cp-border); border-radius: 4px; }
  input[type="color"]::-moz-color-swatch { border: 1px solid var(--cp-border); border-radius: 4px; }
  .switch-control label { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; cursor: pointer; }
  .switch-control.compact label { width: 36px; }
  .switch-control input { position: relative; width: 34px; height: 20px; flex-shrink: 0; margin: 0; appearance: none; border: 1px solid var(--cp-border-strong); border-radius: 12px; background: var(--cp-surface-soft); cursor: pointer; transition: background 140ms; }
  .switch-control input::before { content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--cp-text-soft); transition: transform 140ms; }
  .switch-control input:checked { border-color: var(--cp-accent); background: var(--cp-accent); }
  .switch-control input:checked::before { transform: translateX(14px); background: var(--cp-accent-fg); }
  fieldset:disabled input, fieldset:disabled select { cursor: not-allowed; }
  .disclosure { padding: 0; }
  summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; list-style: none; cursor: pointer; }
  summary::-webkit-details-marker { display: none; }
  summary .lucide, summary [data-lucide] { width: 14px; height: 14px; color: var(--cp-text-soft); transition: transform 140ms; }
  details[open] > summary .lucide { transform: rotate(180deg); }
  .disclosure > summary { padding: 16px 0; }
  .disclosure-body { padding-bottom: 16px; }
  .advanced-controls { margin-top: 2px; }
  .advanced-controls > summary { color: var(--cp-text-soft); font-size: 11px; }
  .advanced-controls[open] > summary { margin-bottom: 6px; }
  .field-note { margin-top: 12px; color: var(--cp-text-soft); font-size: 11px; line-height: 1.65; }
  .light-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 16px; padding: 3px; border: 1px solid var(--cp-border); border-radius: 10px; }
  .light-presets button[aria-pressed="true"], .light-presets button[data-active="true"] { color: var(--cp-accent); background: var(--cp-accent-soft); }
  .light-presets button:hover { background: var(--cp-surface-soft); }
  .inspector-footnote { display: flex; align-items: center; gap: 6px; padding-top: 20px; color: var(--cp-text-soft); font-size: 10px; }
  .inspector-footnote .lucide, .inspector-footnote [data-lucide] { width: 13px; height: 13px; }

  /* Viewport overlays are small and non-blocking; there is no CSS planet artwork. */
  #viewport { position: relative; min-width: 0; min-height: 380px; overflow: hidden; isolation: isolate; background: var(--cp-bg-elevated); }
  #viewport:focus-visible { outline-offset: -3px; }
  #canvas-host { position: absolute; inset: 0; }
  #canvas-host canvas { display: block; width: 100%; height: 100%; touch-action: none; }
  .viewport-top { position: absolute; top: 24px; right: 24px; left: 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; pointer-events: none; }
  .world-caption { min-width: 0; max-width: min(440px, 65%); padding: 12px 16px; border: 1px solid var(--cp-border); border-radius: 10px; background: var(--cp-panel-strong); }
  #planet-name { overflow: hidden; margin-top: 4px; color: var(--cp-text); font-size: 28px; font-weight: 500; letter-spacing: -0.04em; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
  .world-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--cp-text-soft); font-size: 10px; white-space: nowrap; }
  #planet-type { flex-shrink: 0; }
  #planet-seed { overflow: hidden; font-family: Consolas, "Courier New", Courier, monospace; text-overflow: ellipsis; }
  .meta-separator { color: var(--cp-border-strong); }
  .stage-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .stage-badge { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 28px; padding: 5px 8px; border: 1px solid var(--cp-border); border-radius: 6px; color: var(--cp-text-soft); background: var(--cp-panel-strong); font-family: Consolas, "Courier New", Courier, monospace; font-size: 10px; line-height: 1.4; white-space: nowrap; }
  .stage-badge .lucide, .stage-badge [data-lucide] { width: 12px; height: 12px; }
  .render-status { color: var(--cp-text); font-size: 9px; letter-spacing: 0.08em; }
  .render-status::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--cp-accent); }
  .render-status[data-state="live"]::before { background: var(--cp-success); }
  .generation-status { position: absolute; bottom: 88px; left: 50%; width: 248px; max-width: calc(100% - 32px); padding: 10px 12px; transform: translateX(-50%); border: 1px solid var(--cp-border); border-radius: 10px; color: var(--cp-text-soft); background: var(--cp-panel-strong); pointer-events: none; }
  .generation-status > div { display: flex; align-items: center; gap: 8px; font-size: 11px; }
  .generation-spinner { width: 14px; height: 14px; color: var(--cp-accent); animation: spin 1.5s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  #generation-progress { display: block; width: 100%; height: 3px; overflow: hidden; margin-top: 8px; appearance: none; border: 0; border-radius: 3px; color: var(--cp-accent); background: var(--cp-border); }
  #generation-progress::-webkit-progress-bar { background: var(--cp-border); }
  #generation-progress::-webkit-progress-value { background: var(--cp-accent); }
  #generation-progress::-moz-progress-bar { background: var(--cp-accent); }
  .error-banner { position: absolute; top: 148px; left: 50%; z-index: 4; display: flex; align-items: center; gap: 12px; width: min(560px, calc(100% - 32px)); padding: 12px; transform: translateX(-50%); border: 1px solid var(--cp-danger); border-radius: 10px; color: var(--cp-text); background: var(--cp-panel-strong); }
  .error-banner > .lucide { color: var(--cp-danger); }
  #error-message { min-width: 0; flex: 1; font-size: 12px; overflow-wrap: anywhere; }
  .viewport-footer { position: absolute; right: 24px; bottom: 20px; left: 24px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
  .tool-dock { display: flex; align-items: center; gap: 4px; padding: 5px; border: 1px solid var(--cp-border); border-radius: 10px; background: var(--cp-panel-strong); pointer-events: auto; }
  .tool-dock .icon-button { border: 0; color: var(--cp-text-soft); background: none; }
  .tool-dock .icon-button:hover { color: var(--cp-text); background: var(--cp-surface-soft); }
  .tool-dock .icon-button[data-active="true"], .tool-dock .icon-button[aria-pressed="true"] { color: var(--cp-accent); background: var(--cp-accent-soft); }
  .dock-divider { width: 1px; height: 20px; margin: 0 2px; background: var(--cp-border); }
  .orbit-hint { position: absolute; left: 0; display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--cp-border); border-radius: 8px; color: var(--cp-text-soft); background: var(--cp-panel-strong); font-size: 10px; white-space: nowrap; }
  .orbit-hint .lucide, .orbit-hint [data-lucide] { width: 14px; height: 14px; }
  .orbit-hint span span { margin: 0 3px; }
  .axis-widget { position: absolute; right: 0; bottom: 0; width: 56px; height: 56px; padding: 4px; border: 1px solid var(--cp-border); border-radius: 10px; background: var(--cp-panel-strong); }
  .axis-widget svg { display: block; width: 100%; height: 100%; }
  .axis-line { fill: none; stroke: var(--cp-border-strong); stroke-width: 1.3; }
  .axis-widget circle { fill: var(--cp-text-soft); }
  .axis-widget text { fill: var(--cp-text-soft); font: 9px Consolas, "Courier New", Courier, monospace; }
  .axis-widget .axis-x { fill: var(--cp-accent); }
  #viewport:fullscreen { width: 100vw; height: 100dvh; }

  /* Six procedural previews, painted by main.js. Overflow stays inside the shelf. */
  .preset-shelf { min-width: 0; padding: 12px 20px; border-top: 1px solid var(--cp-border); background: var(--cp-bg-elevated); }
  .preset-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
  .preset-heading h2 { margin-top: 1px; font-size: 15px; font-weight: 500; letter-spacing: -0.02em; }
  .preset-heading .eyebrow { font-size: 8px; }
  .preset-heading .button { min-height: 36px; font-size: 11px; }
  .preset-heading .lucide, .preset-heading [data-lucide] { width: 14px; height: 14px; }
  .preset-gallery { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; padding: 3px; margin: -3px; scroll-snap-type: x proximity; scroll-padding-inline: 3px; }
  .preset-card { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; height: 80px; flex: 1 0 158px; padding: 7px; overflow: hidden; border: 1px solid var(--cp-border); border-radius: 16px; color: var(--cp-text); background: var(--cp-surface); text-align: left; scroll-snap-align: start; transition: border-color 140ms, background 140ms; }
  .preset-card:hover { border-color: var(--cp-border-strong); background: var(--cp-surface-soft); }
  .preset-card[aria-pressed="true"] { border-color: var(--cp-accent); background: var(--cp-accent-soft); box-shadow: inset 0 0 0 1px var(--cp-accent); }
  .preset-card:focus-visible { outline-offset: -4px; }
  .preset-card canvas { display: block; width: 64px; height: 64px; flex-shrink: 0; }
  .preset-copy { display: grid; gap: 5px; min-width: 0; }
  .preset-name { overflow: hidden; font-size: 12px; font-weight: 600; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
  .preset-tag { overflow: hidden; color: var(--cp-text-soft); font-size: 8px; font-weight: 500; letter-spacing: 0.06em; text-overflow: ellipsis; white-space: nowrap; }
  .preset-selected { position: absolute; top: 6px; right: 6px; display: grid; width: 13px; height: 13px; place-items: center; border-radius: 50%; color: var(--cp-accent-fg); background: var(--cp-accent); opacity: 0; }
  .preset-selected .lucide, .preset-selected [data-lucide] { width: 9px; height: 9px; stroke-width: 2.5; }
  .preset-card[aria-pressed="true"] .preset-selected { opacity: 1; }

  /* Native dialogs: only their body scrolls, so actions remain reachable. */
  .studio-dialog { position: fixed; width: min(480px, calc(100% - 32px)); max-width: none; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--cp-border); border-radius: 16px; color: var(--cp-text); background: var(--cp-surface); box-shadow: var(--cp-shadow); }
  .studio-dialog[open] { display: flex; flex-direction: column; }
  .studio-dialog::backdrop { background: var(--cp-overlay); }
  .dialog-heading { position: relative; flex-shrink: 0; padding: 24px 24px 20px; }
  .dialog-heading h2 { margin-top: 6px; font-size: 25px; font-weight: 550; letter-spacing: -0.04em; line-height: 1.25; }
  .dialog-heading > p:last-child { margin-top: 12px; color: var(--cp-text-soft); font-size: 12px; line-height: 1.65; }
  .dialog-mark { display: grid; width: 44px; height: 44px; place-items: center; margin-bottom: 20px; border-radius: 12px; color: var(--cp-accent); background: var(--cp-accent-soft); }
  .dialog-mark .lucide, .dialog-mark [data-lucide] { width: 28px; height: 28px; }
  .dialog-close { position: absolute; top: 16px; right: 16px; border: 0; }
  .dialog-form { display: flex; flex-direction: column; min-height: 0; }
  .dialog-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 0 24px 24px; }
  .export-options legend { margin-bottom: 4px; color: var(--cp-text-soft); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
  .export-options label { display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 14px 0; border-bottom: 1px solid var(--cp-border); cursor: pointer; }
  .export-options input { width: 18px; height: 18px; flex-shrink: 0; margin: 1px 0 0; accent-color: var(--cp-accent); }
  .export-options strong { display: block; font-size: 12px; font-weight: 600; }
  .export-options small { display: block; margin-top: 3px; color: var(--cp-text-soft); font-size: 11px; line-height: 1.55; }
  .info-note { display: flex; align-items: flex-start; gap: 10px; margin-top: 20px; padding: 12px; border: 1px solid var(--cp-border); border-radius: 10px; color: var(--cp-text-soft); background: var(--cp-surface-soft); font-size: 11px; line-height: 1.65; }
  .info-note .lucide, .info-note [data-lucide] { width: 16px; height: 16px; margin-top: 1px; }
  /* Account: the panel at the right end of the header and the email + authenticator-app sign-in dialog. */
  .account-menu { position: relative; display: flex; }
  .account-button { min-width: 0; max-width: 240px; border-color: transparent; color: var(--cp-text-soft); background: none; }
  .account-button[aria-expanded="true"] { border-color: var(--cp-border); color: var(--cp-text); background: var(--cp-surface-soft); }
  .account-button[data-signed-in="true"] > .lucide, .account-button[data-signed-in="true"] > [data-lucide] { color: var(--cp-accent); }
  #account-label { overflow: hidden; text-overflow: ellipsis; }
  .account-panel { position: absolute; top: calc(100% + 10px); right: 0; z-index: 20; display: grid; width: 260px; padding: 16px; border: 1px solid var(--cp-border); border-radius: 12px; background: var(--cp-panel-strong); box-shadow: var(--cp-shadow); }
  .account-panel > div { display: grid; gap: 10px; }
  .account-email { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
  .account-note { color: var(--cp-text-soft); font-size: 12px; line-height: 1.55; }
  .account-credits { color: var(--cp-text-soft); font-size: 12px; }
  .credits-note { margin-top: 12px; color: var(--cp-text-soft); font-size: 12px; line-height: 1.55; }
  .credits-note[data-empty="true"] { color: var(--cp-text); font-weight: 600; }
  #confirm-export[hidden], #buy-credits-export[hidden] { display: none; }
  /* The narrow-header rule squares every header button; the panel's actions keep their full width. */
  #account-panel .button { width: 100%; height: auto; padding: 8px 12px; }
  .account-panel[hidden], .account-panel > div[hidden], .dialog-form[hidden], .login-enroll[hidden], .login-message[hidden] { display: none; }
  .login-field { margin-top: 4px; }
  #login-email, #login-code { width: 100%; min-width: 0; min-height: 40px; padding: 7px 10px; border: 1px solid var(--cp-border); border-radius: 8px; color: var(--cp-text); background: var(--cp-bg-elevated); }
  #login-email:hover, #login-code:hover { border-color: var(--cp-border-strong); }
  #login-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 20px; letter-spacing: 0.3em; text-align: center; }
  .login-account { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
  .login-intro { margin: 6px 0 16px; color: var(--cp-text-soft); font-size: 12px; line-height: 1.6; }
  .login-enroll { display: grid; justify-items: center; gap: 10px; margin-bottom: 16px; padding: 16px; border: 1px solid var(--cp-border); border-radius: 12px; background: var(--cp-surface-soft); }
  .login-qr { width: 200px; height: 200px; max-width: 100%; border-radius: 8px; background: #ffffff; image-rendering: pixelated; }
  .login-key { color: var(--cp-text-soft); font-size: 11px; text-align: center; overflow-wrap: anywhere; }
  .login-key strong { color: var(--cp-text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; user-select: all; }
  .login-message { flex-shrink: 0; margin: 0 24px 16px; padding: 10px 12px; border: 1px solid var(--cp-border); border-radius: 10px; color: var(--cp-text); background: var(--cp-surface-soft); font-size: 12px; line-height: 1.5; }
  .login-message[data-kind="error"] { border-color: var(--cp-danger); }
  .login-sent { display: grid; justify-items: center; gap: 8px; padding-top: 4px; text-align: center; }
  .login-sent > .lucide, .login-sent > [data-lucide] { width: 40px; height: 40px; color: var(--cp-accent); }
  .login-sent > p { font-size: 13px; line-height: 1.6; }
  #login-sent-address { overflow-wrap: anywhere; }
  @media (max-width: 760px) { #login-email, #login-code { font-size: 16px; } }
  @media (max-width: 600px) { .account-button { max-width: none; } .account-panel { width: min(260px, calc(100vw - 16px)); } }
  .dialog-footer { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; flex-shrink: 0; padding: 16px 24px; border-top: 1px solid var(--cp-border); background: var(--cp-bg-elevated); }
  .dialog-footer .button { min-height: 40px; }
  #export-status { flex-basis: 100%; padding-bottom: 4px; color: var(--cp-text-soft); font-size: 12px; overflow-wrap: anywhere; }
  .help-navigation { display: flex; align-items: flex-start; gap: 12px; margin: 4px 0 20px; }
  .help-navigation > .lucide { color: var(--cp-accent); }
  .help-navigation strong { display: block; font-size: 12px; font-weight: 600; }
  .help-navigation span { display: block; margin-top: 4px; color: var(--cp-text-soft); font-size: 11px; }
  .shortcut-list { margin: 0; }
  .shortcut-list > div { display: flex; align-items: center; gap: 16px; min-height: 44px; border-top: 1px solid var(--cp-border); }
  .shortcut-list dt { width: 58px; flex-shrink: 0; }
  .shortcut-list dd { margin: 0; color: var(--cp-text-soft); font-size: 12px; }
  kbd { display: inline-block; min-width: 26px; padding: 3px 6px; border: 1px solid var(--cp-border); border-bottom-width: 2px; border-radius: 5px; color: var(--cp-text); background: var(--cp-bg-elevated); font: 11px/1.5 Consolas, "Courier New", Courier, monospace; text-align: center; }
  .toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(400px, calc(100% - 32px)); padding: 12px 16px; border: 1px solid var(--cp-border-strong); border-radius: 10px; color: var(--cp-text); background: var(--cp-panel-strong); font-size: 12px; overflow-wrap: anywhere; pointer-events: none; }

  @media (max-width: 1180px) {
    .workspace-tag { display: none; }
    .save-status { margin-right: 4px; }
    .stage-badges { flex-direction: column; align-items: flex-end; }
  }

  @media (max-width: 1100px) {
    .orbit-hint { bottom: 58px; right: 0; width: fit-content; margin-inline: auto; }
    .generation-status { bottom: 124px; }
    .save-status { display: none; }
  }

  @media (max-width: 900px) {
    .app-header { gap: 12px; padding-inline: 16px; }
    .brand p { font-size: 7px; }
    #save-project .button-label { display: none; }
    #save-project { width: 36px; padding: 8px; }
    .viewport-top { top: 16px; right: 16px; left: 16px; gap: 12px; }
    .world-caption { max-width: calc(100% - 120px); padding: 12px; }
    .world-caption .eyebrow { display: none; }
    #planet-name { margin-top: 0; font-size: 24px; }
    .world-meta { align-items: flex-start; flex-direction: column; gap: 2px; }
    .meta-separator { display: none; }
    #planet-seed { max-width: 100%; }
    .viewport-footer { right: 16px; left: 16px; }
    .preset-shelf { padding-inline: 16px; }
  }

  @media (max-width: 760px) {
    .editor-layout { position: relative; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
    .brand-group { gap: 12px; }
    #toggle-inspector { display: inline-flex; }
    .brand p { display: none; }
    .brand h1 { font-size: 19px; }
    #inspector { position: absolute; inset: 0 auto 0 0; z-index: 8; width: min(318px, calc(100% - 24px)); visibility: hidden; transform: translateX(-100%); transition: transform 180ms, visibility 180ms; }
    /* Main toggles aria-expanded on the header button; no competing drawer listener. */
    #app:has(#toggle-inspector[aria-expanded="true"]) #inspector { visibility: visible; transform: translateX(0); box-shadow: var(--cp-shadow); }
    input[type="text"], select { font-size: 16px; }
    .world-meta { flex-direction: row; gap: 6px; }
    .meta-separator { display: inline; }
    .stage-badges { flex-direction: row; }
    .world-caption { max-width: 60%; }
    .orbit-hint { bottom: 58px; }
    .generation-status { bottom: 124px; }
    .preset-card { flex-basis: 164px; }
  }

  @media (max-width: 600px) {
    .brand-mark { display: none; }
    .header-actions { gap: 4px; }
    .header-actions .button-label { display: none; }
    .header-actions .button { width: 36px; height: 36px; padding: 8px; }
    .stage-badges { flex-direction: column; }
    .world-caption { max-width: calc(100% - 116px); }
    .world-meta { flex-direction: column; gap: 2px; }
    .meta-separator { display: none; }
    #planet-name { font-size: 22px; }
    .axis-widget { display: none; }
    .preset-heading { gap: 8px; }
    .preset-heading h2 { font-size: 13px; }
    .preset-heading .button { gap: 6px; padding-inline: 8px; font-size: 10px; }
    .error-banner { align-items: flex-start; flex-wrap: wrap; }
    .error-banner .button { margin-left: auto; }
    .toast { right: 16px; bottom: 16px; }
  }

  @media (max-width: 400px) {
    .app-header { gap: 6px; padding-inline: 8px; }
    .brand-group { gap: 4px; }
    .brand h1 { font-size: 16px; }
    .header-actions { gap: 2px; }
    .viewport-top { right: 12px; left: 12px; }
    .stage-badge { font-size: 9px; }
    .world-caption { padding: 10px; }
    #planet-name { font-size: 20px; }
    .preset-shelf { padding-inline: 12px; }
    .preset-heading h2 { font-size: 12px; }
    .dialog-heading { padding: 20px 20px 16px; }
    .dialog-heading h2 { font-size: 22px; }
    .dialog-body { padding-inline: 20px; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  }
