/* LIFE Studio — two visual worlds, one exact simulation. */
:root {
  --studio-radius: 16px;
  --studio-ink-on-accent: #142619;
  --studio-field: radial-gradient(ellipse at 48% 45%, color-mix(in srgb, var(--life) 9%, transparent), transparent 72%);
}
:root[data-world="organic"] { --studio-radius: 18px; }
:root[data-world="techno"] {
  --void: #080b16; --abyss: #0b1020; --deep: #0d1427;
  --surface: #121c32; --elevated: #1a2942;
  --border: #2b3e58; --border-light: #47617d;
  --life: #79ecd3; --life-dim: #55cdb6; --energy: #8dbdff; --mutation: #c2a4ff;
  --text: #edf5ff; --text-dim: #b0c2d9; --text-muted: #8da3c0;
  --cell-new: #baffed; --cell-young: #79ecd3; --cell-mature: #58c8d7; --cell-old: #76a8fa; --cell-ancient: #b7b0f0;
  --life-glow: #79ecd326; --life-pulse: #79ecd30a;
  --studio-radius: 7px; --studio-ink-on-accent: #09231e;
  --studio-field: radial-gradient(ellipse at 50% 50%, #477ad414, transparent 68%);
}
:root[data-world="techno"][data-palette="tide"] {
  --life: #bdadff; --life-dim: #a18de9; --energy: #83d5ff;
  --cell-new: #ece1ff; --cell-young: #c3a6ff; --cell-mature: #a18df4; --cell-old: #7aaafa; --cell-ancient: #8cd7f4;
  --life-glow: #bdadff26; --studio-ink-on-accent: #211536;
}
:root[data-world="techno"][data-palette="ember"] {
  --life: #ffd290; --life-dim: #e8b76b; --energy: #ff9eaf;
  --cell-new: #fff2b7; --cell-young: #ffd290; --cell-mature: #ffac77; --cell-old: #f28ea0; --cell-ancient: #c4a2ef;
  --life-glow: #ffd29026; --studio-ink-on-accent: #302013;
}
:root[data-world="techno"][data-theme="light"] {
  --void: #edf2fa; --abyss: #edf2fa; --deep: #e4edf7; --surface: #f8fbff; --elevated: #dae6f4;
  --border: #bdccdf; --border-light: #91a7c1;
  --life: #08695e; --life-dim: #09554d; --energy: #255c9f; --mutation: #68469e;
  --text: #14283f; --text-dim: #405a74; --text-muted: #526a83;
  --cell-new: #075d4f; --cell-young: #08776a; --cell-mature: #116f87; --cell-old: #3567b1; --cell-ancient: #685597;
  --studio-ink-on-accent: #ffffff;
}
:root[data-world="techno"][data-theme="light"][data-palette="tide"] {
  --life: #633ab1; --life-dim: #4f288f; --energy: #226397;
  --cell-new: #492182; --cell-young: #633ab1; --cell-mature: #7256b1; --cell-old: #416da9; --cell-ancient: #2c7b95;
}
:root[data-world="techno"][data-theme="light"][data-palette="ember"] {
  --life: #98501e; --life-dim: #793d18; --energy: #a53558;
  --cell-new: #783c15; --cell-young: #98501e; --cell-mature: #ac6333; --cell-old: #a14467; --cell-ancient: #815d99;
}
:root[data-world="organic"][data-theme="light"] { --studio-ink-on-accent: #ffffff; }
.observatory .main { border-radius: var(--studio-radius); }
.observatory .canvas-container { background: var(--studio-field); }
[data-world="techno"] .observatory .canvas-container::before { border-radius: 0; border-color: var(--border); opacity: .2; }
[data-world="techno"] .intro-copy h1, [data-world="techno"] .field-guide h2, [data-world="techno"] .time-view-story h2 {
  font-family: var(--font-display); font-weight: 500; letter-spacing: -.05em;
}
[data-world="techno"] .intro-copy h1 em, [data-world="techno"] .field-guide h2 em { font-style: normal; }
[data-world="techno"] .observatory .logo-title { font-family: var(--font-mono); font-size: 23px; }
[data-world="techno"] .scene-thumbnails button, [data-world="techno"] .observatory .transport-btn, [data-world="techno"] .pattern-card { border-radius: 5px; }
[data-world="techno"] .observatory .header-manifesto { color: var(--energy); }
.observatory .transport-btn.primary { color: var(--studio-ink-on-accent); background: var(--life); }
.observatory .transport-btn.primary:hover { background: var(--life); filter: brightness(1.08); }
.observatory .transport-btn.primary.playing { color: var(--studio-ink-on-accent); }
.palette-picker[hidden] { display: none !important; }
/* The persistent navigation keeps depth and appearance within one gesture. */
.studio-navigation { flex: 0 0 auto; display: flex; align-items: center; gap: 18px; padding: 0 0 14px; }
.studio-workspaces { display: flex; gap: 3px; border: 1px solid var(--border); border-radius: 10px; padding: 3px; background: var(--surface); }
.studio-workspaces button { min-height: 40px; padding: 0 17px; border-radius: 7px; color: var(--text-dim); font-size: 12px; font-weight: 500; }
.studio-workspaces button[aria-pressed="true"] { background: var(--life); color: var(--studio-ink-on-accent); }
.studio-workspaces button:hover:not([aria-pressed="true"]) { background: var(--elevated); color: var(--text); }
.studio-workspace-hint { color: var(--text-dim); font-size: 11px; line-height: 1.6; }
.studio-open { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 13px; border: 1px solid var(--border-light); border-radius: 9px; color: var(--text); background: var(--surface); font-size: 12px; }
.studio-open:hover { border-color: var(--life); background: var(--elevated); }
.studio-orb { width: 17px; height: 17px; display: inline-block; flex: 0 0 auto; border: 1px solid var(--border-light); border-radius: 50%; background: conic-gradient(from 40deg, var(--life), var(--energy), var(--mutation), var(--life)); }
.field-actions .studio-field-open { min-width: 44px; min-height: 36px; }
.studio-navigation :is(button, a):focus-visible, .studio-modal :is(button, input, select):focus-visible, .studio-create-hint button:focus-visible, #studioLearn:focus-visible { outline: 2px solid var(--life); outline-offset: 3px; }
.studio-create-hint { padding: 0 22px 20px; }
.studio-create-hint p { color: var(--text-dim); font-size: 12px; line-height: 1.65; margin: 0 0 12px; }
.studio-create-hint button, #studioLearn { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 10px; border: 1px solid var(--border-light); border-radius: 9px; padding: 10px 12px; font-size: 12px; color: var(--text); }
#studioLearn { margin-top: 8px; color: var(--life); }
.studio-create-hint button:hover, #studioLearn:hover { background: var(--elevated); }
.studio-create-hint[hidden] { display: none; }
[data-workspace="explore"] .panel .patterns-section,
[data-workspace="explore"] .panel .studio-drawing,
[data-workspace="explore"] .panel #discoverBtn,
[data-workspace="explore"] .panel .edit-history { display: none !important; }
[data-workspace="create"] .panel.simple-mode #rulesSection { display: block !important; }
[data-workspace="explore"] .panel .transport { padding-bottom: 20px; }
/* Do not hide mathematical controls while a finite experiment needs them. */
[data-workspace="explore"] .evolution-trial-hud, [data-workspace="explore"] .expedition-hud { visibility: visible; }
/* Appearance studio uses the simulator's tested modal/focus management. */
.studio-modal { z-index: 10000; }
.studio-modal .studio-dialog { width: min(920px, calc(100vw - 48px)); max-width: 920px; max-height: min(820px, calc(100dvh - 48px)); overflow: auto; padding: 0; border-radius: 22px; background: var(--abyss); border: 1px solid var(--border-light); color: var(--text); box-shadow: 0 24px 100px #0006; }
.studio-heading { display: flex; justify-content: space-between; align-items: flex-start; padding: 28px 30px 22px; border-bottom: 1px solid var(--border); gap: 20px; }
.studio-heading .eyebrow { color: var(--life); letter-spacing: .16em; font-size: 9px; }
.studio-heading h2 { font: 400 38px/1.15 var(--font-editorial); letter-spacing: -.025em; margin: 8px 0 6px; color: var(--text); }
.studio-heading p { font-size: 12px; color: var(--text-dim); margin: 0; line-height: 1.6; }
#studioClose { position: static; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; flex: 0 0 auto; color: var(--text); font-size: 25px; }
#studioClose:hover { background: var(--elevated); }
.studio-body { display: grid; grid-template-columns: 1fr 1.15fr; }
.studio-preview { padding: 24px; background: var(--deep); border-right: 1px solid var(--border); display: flex; flex-direction: column; justify-content: center; align-items: stretch; }
.studio-preview-frame { border: 1px solid var(--border); border-radius: var(--studio-radius); overflow: hidden; background: var(--deep); }
.studio-preview-bar { display: flex; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); font: 8px var(--font-mono); text-transform: uppercase; letter-spacing: .1em; }
.studio-preview-bar i { width: 5px; height: 5px; display: inline-block; background: var(--life); border-radius: 50%; margin-right: 5px; }
#studioPreview { width: 100%; height: auto; display: block; }
.studio-preview h3 { font: 400 33px/1.2 var(--font-editorial); color: var(--text); margin: 20px 0 8px; }
.studio-preview p { color: var(--text-dim); font-size: 12px; line-height: 1.75; margin: 0; }
.studio-preview .studio-preview-footnote { font: 9px/1.6 var(--font-mono); margin-top: 18px; color: var(--text-muted); }
.studio-controls { padding: 22px 26px; }
.studio-controls fieldset { border: 0; padding: 0; margin: 0 0 21px; min-width: 0; }
.studio-controls legend, .studio-setting > span { display: block; color: var(--text); font-size: 12px; font-weight: 500; margin-bottom: 9px; }
.studio-worlds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.studio-world-card { text-align: left; border: 1px solid var(--border-light); border-radius: 12px; overflow: hidden; padding: 0; color: var(--text); background: var(--surface); }
.studio-world-card[aria-pressed="true"] { border-color: var(--life); box-shadow: 0 0 0 1px var(--life); }
.studio-world-card > span { display: block; padding: 10px 12px; }
.studio-world-card strong { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; }
.studio-world-card[aria-pressed="true"] strong::after { content: '✓'; color: var(--life); }
.studio-world-card small { display: block; font-size: 10px; line-height: 1.5; color: var(--text-dim); margin-top: 4px; }
.studio-world-card svg { display: block; width: 100%; height: 64px; }
.studio-segments { display: flex; gap: 7px; }
.studio-segments button { display: flex; align-items: center; justify-content: center; gap: 7px; flex: 1; min-height: 44px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-dim); font-size: 12px; background: var(--surface); }
.studio-segments button[aria-pressed="true"] { color: var(--text); border-color: var(--life); background: var(--elevated); box-shadow: inset 0 -2px var(--life); }
.studio-palette-dot { display: block; width: 10px; height: 10px; border-radius: 50%; background: #b7dfae; }
[data-studio-palette="tide"] .studio-palette-dot { background: #9ecbc9; }
[data-studio-palette="ember"] .studio-palette-dot { background: #e6bd96; }
[data-world="techno"] [data-studio-palette="moss"] .studio-palette-dot { background: #79ecd3; }
[data-world="techno"] [data-studio-palette="tide"] .studio-palette-dot { background: #bdadff; }
[data-world="techno"] [data-studio-palette="ember"] .studio-palette-dot { background: #ffd290; }
.studio-fine-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.studio-setting { display: block; min-width: 0; }
.studio-setting select { width: 100%; min-height: 44px; border: 1px solid var(--border-light); border-radius: 8px; padding: 8px; font: 12px var(--font-display); color: var(--text); background: var(--surface); }
.studio-motion { display: flex; align-items: center; gap: 12px; padding-top: 20px; cursor: pointer; }
.studio-motion > span { flex: 1; font-size: 12px; color: var(--text); line-height: 1.6; }
.studio-motion small { display: block; color: var(--text-dim); font-size: 10px; }
.studio-motion input { width: 22px; height: 22px; accent-color: var(--life); flex-shrink: 0; }
.studio-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 26px; border-top: 1px solid var(--border); }
.studio-footer p { font-size: 11px; color: var(--text-dim); margin: 0; }
#studioDone { padding: 12px 25px; min-height: 44px; border-radius: 8px; background: var(--life); color: var(--studio-ink-on-accent); font-size: 12px; font-weight: 600; }
[data-world="techno"] .studio-heading h2, [data-world="techno"] .studio-preview h3 { font-family: var(--font-display); font-weight: 500; font-size: 30px; }
[data-world="techno"] .studio-modal .studio-dialog { border-radius: 12px; }
@media (max-width: 1100px) {
  .studio-workspace-hint { display: none; }
  .observatory-intro { padding-top: 14px; padding-bottom: 14px; }
}
@media (max-width: 700px) {
  .studio-navigation { gap: 10px; padding-bottom: 10px; }
  .studio-workspaces { flex: 1; }
  .studio-workspaces button { flex: 1; min-height: 38px; padding: 0 10px; font-size: 11px; }
  .studio-open { padding: 0 10px; font-size: 11px; min-height: 44px; }
  .studio-modal .studio-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 16px; }
  .studio-heading { padding: 20px; }
  .studio-heading h2 { font-size: 32px; }
  .studio-body { grid-template-columns: 1fr; }
  .studio-preview { display: none; }
  .studio-controls { padding: 20px; }
  .studio-world-card svg { height: 70px; }
  .studio-footer { padding: 16px 20px; }
  .studio-heading p { max-width: 28ch; }
}
@media (max-width: 380px) {
  .studio-navigation { gap: 6px; }
  .studio-workspaces button { padding: 0 8px; }
  .studio-open { padding: 0 8px; gap: 5px; }
  .studio-open .studio-orb { width: 13px; height: 13px; }
  .studio-controls { padding: 16px; }
}
@media (max-height: 600px) and (orientation: landscape) {
  .studio-modal .studio-dialog { max-height: calc(100dvh - 16px); }
  .studio-heading { padding: 14px 20px; }
  .studio-heading h2 { font-size: 26px; }
  .studio-body { grid-template-columns: 1fr; }
  .studio-preview { display: none; }
  .studio-world-card svg { height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .studio-modal, .studio-dialog, .studio-navigation * { animation: none !important; transition: none !important; }
}

.focus-mode .studio-navigation { display: none; }
