.fractals-page .page { height: 100svh; min-height: 0; }
.fractals-page .header { flex: none; }
.fractals-page main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 28px 0 28px; }
.lab-heading { position: relative; text-align: center; margin-bottom: 26px; flex: none; }
.lab-heading h1 { font-size: 32px; font-weight: 300; letter-spacing: -.045em; }
.lab-back { position: absolute; left: 0; top: 0; font-size: 22px; color: var(--muted); }
.fractal-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 260px; grid-template-rows: minmax(180px, 1fr) minmax(180px, .58fr); gap: 20px 42px; }
.drawing { grid-column: 1; grid-row: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.canvas-frame.artwork { position: relative; display: block; width: 100%; flex: 1; min-height: 0; aspect-ratio: auto; border: 0; padding: 0; background: transparent; color: var(--text); cursor: zoom-in; }
.split-view #zoom { cursor: crosshair; touch-action: none; }
#detail-frame { cursor: default; }
.canvas-frame .sleeve { display: block; overflow: hidden; box-shadow: none; transform: translateY(var(--lift)) rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--hover-scale, 1)); }
.canvas-frame.is-active { --hover-scale: 1.025; }
.canvas-frame .sleeve::after { display: none; }
#fractal, #detail { display: block; width: 100%; height: 100%; color: var(--text); }
.corner { position: absolute; font: 12px/1 monospace; color: var(--muted); pointer-events: none; }
.nw { top: -6px; left: -4px; }.ne { top: -6px; right: -4px; }.sw { bottom: -6px; left: -4px; }.se { bottom: -6px; right: -4px; }
.drawing-caption { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font: 10px/1.5 monospace; color: var(--muted); }
#zoom-hint { margin-left: auto; }
.controls { grid-column: 2; grid-row: 1 / 3; min-width: 0; min-height: 0; overflow-y: auto; padding: 0 5px 6px; display: flex; flex-direction: column; gap: 9px; font-size: 12px; }
.panel-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 5px; }
.controls label { margin-top: 4px; }
.fractals-page input:not([type="range"]), .fractals-page select, .fractals-page textarea { width: 100%; min-width: 0; border: 1px solid var(--rule); border-radius: 0; background: var(--background); color: var(--text); padding: 8px; font: inherit; }
.fractals-page select { min-height: 36px; }
.fractals-page textarea, #axiom { font: 13px/1.5 monospace; }
.fractals-page textarea { resize: vertical; min-height: 64px; }
.fractals-page input:focus-visible, .fractals-page textarea:focus-visible, .fractals-page select:focus-visible, summary:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.fractals-page input[type="range"] { width: 100%; margin: 0; height: 24px; accent-color: var(--accent); }
.range-label { display: flex; justify-content: space-between; }
.number-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.number-fields input { margin-top: 8px; }
.fractals-page button:not(.theme-toggle, .canvas-frame) { color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--rule); min-height: 36px; padding: 6px 0; font: inherit; cursor: pointer; transition: color 160ms, border-color 160ms; }
.fractals-page button:not(.canvas-frame):hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.fractals-page button:disabled { opacity: .4; cursor: default; }
.actions { display: flex; gap: 16px; flex-wrap: wrap; }
.note, details { font-size: 11px; line-height: 1.7; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
#error { color: var(--text); font-size: 12px; line-height: 1.5; margin: 0; }
#error:not(:empty) { border-left: 2px solid var(--accent); padding-left: 12px; }
summary { cursor: pointer; min-height: 36px; padding-top: 10px; }
.rule-section { grid-column: 1; grid-row: 2; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rule-tiles { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(var(--columns, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 14px; font-size: 12px; color: var(--muted); }
.rule-tile { position: relative; margin: 0; min-width: 0; min-height: 0; border: 1px solid var(--rule); padding: 10px; display: flex; flex-direction: column; }
.rule-tile figcaption { flex: none; font: 11px/1.4 monospace; color: var(--text); max-height: 2.8em; overflow: auto; overflow-wrap: anywhere; }
.rule-tile canvas { display: block; width: 100%; min-height: 0; flex: 1; color: var(--text); }
.empty-rule { position: absolute; top: 55%; left: 12px; right: 12px; text-align: center; font-size: 10px; }
.fractals-page .skip-link { position: absolute; left: 24px; top: 8px; transform: translateY(-200%); z-index: 10; background: var(--background); padding: 10px; }
.fractals-page .skip-link:focus { transform: none; }
@media (max-width: 1000px) { .fractal-layout { gap: 18px 26px; grid-template-columns: minmax(0, 1fr) 230px; } }
@media (max-width: 700px) {
  .fractals-page .page { height: auto; min-height: 100svh; }
  .fractals-page main { padding-top: 24px; }
  .lab-heading { margin-bottom: 24px; }
  .fractal-layout { display: flex; flex-direction: column; gap: 24px; }
  .drawing { height: clamp(200px, 35svh, 320px); flex: none; order: 0; }
  .drawing-caption { gap: 0 8px; }
  #zoom-hint { font-size: 9px; }
  .rule-section { height: 210px; flex: none; order: 1; }
  .controls { order: 2; overflow: visible; padding: 0; gap: 10px; }
  .fractals-page input:not([type="range"]), .fractals-page select, .fractals-page textarea { font-size: 16px; }
  .fractals-page button:not(.theme-toggle, .canvas-frame), .fractals-page select, summary { min-height: 44px; }
  .rule-tile { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .fractals-page button { transition: none; }
  .canvas-frame .sleeve { transform: none; }
}

@media (max-width: 700px) and (max-height: 700px) {
  .drawing { height: 185px; }
  .rule-section { height: 165px; }
  .fractal-layout { gap: 18px; }
  .lab-heading { margin-bottom: 18px; }
}

.view-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.view-grid.split-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.canvas-frame[hidden], #zoom-controls[hidden], #selection-box[hidden] { display: none; }
#selection-box { position: absolute; border: 1px solid var(--text); background: color-mix(in srgb, var(--accent) 12%, transparent); pointer-events: none; }
.view-label { position: absolute; top: 8px; left: 8px; font: 10px/1.4 monospace; color: var(--muted); pointer-events: none; }
.overview-label { display: none; }
.split-view .overview-label { display: block; }
.zoom-controls { display: flex; align-items: center; gap: 18px; font-size: 11px; color: var(--muted); }
.zoom-controls label { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 270px; }
.zoom-controls input { min-width: 0; flex: 1; }
.zoom-controls output { min-width: 4ch; }
.split-view .canvas-frame .sleeve { transform: none; }
.split-view .canvas-frame { --hover-scale: 1; }
@media (max-width: 700px) {
  .view-grid { gap: 12px; }
  .view-label { top: 5px; left: 5px; font-size: 9px; }
  .drawing:has(.split-view) { height: clamp(240px, 39svh, 350px); }
  .zoom-controls { gap: 10px; }
  .zoom-controls label { max-width: none; }
}

#detail { cursor: grab; touch-action: none; }
#detail.panning { cursor: grabbing; }
#detail:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }
#detail-frame .zoom-controls { position: absolute; z-index: 3; top: 6px; left: 8px; width: min(180px, calc(100% - 52px)); padding: 2px 5px; background: var(--background); }
#detail-frame .zoom-controls label { min-width: 0; gap: 6px; }
#detail-frame .zoom-controls output { min-width: 3ch; font: 10px monospace; }
.fractals-page #close-detail { position: absolute; z-index: 3; top: 0; right: 0; width: 36px; min-height: 36px; padding: 0; border: 0; background: var(--background); font: 20px/1 sans-serif; }
.field-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.controls .field-heading label { margin: 0; }
.fractals-page .field-heading button { flex: none; font-size: 10px; min-height: 28px; padding: 0; border: 0; color: var(--muted); }
@media (max-width: 700px) {
  .fractals-page #close-detail { width: 40px; min-height: 44px; }
  #detail-frame .zoom-controls { left: 4px; top: 6px; width: min(180px, calc(100% - 46px)); padding-inline: 2px; }
  #detail-frame .zoom-controls input { height: 32px; }
  .fractals-page .field-heading button { min-height: 44px; font-size: 12px; }
}

.active-symbols { margin-top: 4px; }
.active-symbols h3 { font: inherit; margin: 0; }
#active-symbols { margin: 4px 0 2px; font: 13px/1.7 monospace; overflow-wrap: anywhere; word-spacing: 5px; color: var(--muted); }
.symbol-actions { display: flex; gap: 12px; }
.fractals-page .symbol-actions button { font: 12px monospace; min-width: 28px; }

#active-symbols { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; word-spacing: normal; }
.fractals-page #active-symbols button { min-width: 28px; min-height: 28px; padding: 3px; border: 0; font: 13px monospace; color: var(--muted); }
.fractals-page #active-symbols button:hover { text-decoration: line-through; color: var(--text); }
@media (max-width: 700px) { .fractals-page #active-symbols button { min-width: 36px; min-height: 44px; } }
