/* Strange Attractors: the suite's shared look (copied from Tilings, which matches the Polyhedra
   Atlas): Catppuccin Mocha / Latte tokens, glass islands floating over a full-window canvas, Inter
   type. Keep the token names; see ../WEBAPPS.md. */
:root {
  --rosewater: #f5e0dc; --rosewater-rgb: 245 224 220;
  --flamingo: #f2cdcd; --flamingo-rgb: 242 205 205;
  --pink: #f5c2e7; --pink-rgb: 245 194 231;
  --mauve: #cba6f7; --mauve-rgb: 203 166 247;
  --red: #f38ba8; --red-rgb: 243 139 168;
  --maroon: #eba0ac; --maroon-rgb: 235 160 172;
  --peach: #fab387; --peach-rgb: 250 179 135;
  --yellow: #f9e2af; --yellow-rgb: 249 226 175;
  --green: #a6e3a1; --green-rgb: 166 227 161;
  --teal: #94e2d5; --teal-rgb: 148 226 213;
  --sky: #89dceb; --sky-rgb: 137 220 235;
  --sapphire: #74c7ec; --sapphire-rgb: 116 199 236;
  --blue: #89b4fa; --blue-rgb: 137 180 250;
  --lavender: #b4befe; --lavender-rgb: 180 190 254;
  --text: #cdd6f4; --text-rgb: 205 214 244;
  --subtext1: #bac2de; --subtext1-rgb: 186 194 222;
  --subtext0: #a6adc8; --subtext0-rgb: 166 173 200;
  --overlay2: #9399b2; --overlay2-rgb: 147 153 178;
  --overlay1: #7f849c; --overlay1-rgb: 127 132 156;
  --overlay0: #6c7086; --overlay0-rgb: 108 112 134;
  --surface2: #585b70; --surface2-rgb: 88 91 112;
  --surface1: #45475a; --surface1-rgb: 69 71 90;
  --surface0: #313244; --surface0-rgb: 49 50 68;
  --base: #1e1e2e; --base-rgb: 30 30 46;
  --mantle: #181825; --mantle-rgb: 24 24 37;
  --crust: #11111b; --crust-rgb: 17 17 27;
  --deep-rgb: 11 11 18; --shine-rgb: 255 255 255; --shadow-rgb: 17 17 27; --on-accent: #11111b;
  --glass: rgb(var(--base-rgb) / 0.52);
  --glass-strong: rgb(var(--mantle-rgb) / 0.72);
  --glass-card: rgb(var(--surface0-rgb) / 0.38);
  --glass-hover: rgb(var(--surface1-rgb) / 0.55);
  --edge: rgb(var(--text-rgb) / 0.10);
  --edge-strong: rgb(var(--text-rgb) / 0.18);
  --shine: inset 0 1px 0 rgb(var(--shine-rgb) / 0.06);
  --blur: blur(18px) saturate(150%);
  --radius: 16px;
  --topbar-h: 56px;
  --below-bar: 80px;
  --panel-w: clamp(360px, 25vw, 540px);
  --info-w: clamp(280px, 17vw, 380px);
  --dock-h: 0px; /* measured: the dock's height, so the picture sits above it */

  --mono: ui-monospace, "JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

/* Catppuccin Latte (light), as in the Atlas */
:root[data-theme="light"] {
  --rosewater: #dc8a78; --rosewater-rgb: 220 138 120;
  --flamingo: #dd7878; --flamingo-rgb: 221 120 120;
  --pink: #ea76cb; --pink-rgb: 234 118 203;
  --mauve: #8839ef; --mauve-rgb: 136 57 239;
  --red: #d20f39; --red-rgb: 210 15 57;
  --maroon: #e64553; --maroon-rgb: 230 69 83;
  --peach: #fe640b; --peach-rgb: 254 100 11;
  --yellow: #df8e1d; --yellow-rgb: 223 142 29;
  --green: #40a02b; --green-rgb: 64 160 43;
  --teal: #179299; --teal-rgb: 23 146 153;
  --sky: #04a5e5; --sky-rgb: 4 165 229;
  --sapphire: #209fb5; --sapphire-rgb: 32 159 181;
  --blue: #1e66f5; --blue-rgb: 30 102 245;
  --lavender: #7287fd; --lavender-rgb: 114 135 253;
  --text: #4c4f69; --text-rgb: 76 79 105;
  --subtext1: #5c5f77; --subtext1-rgb: 92 95 119;
  --subtext0: #6c6f85; --subtext0-rgb: 108 111 133;
  --overlay2: #7c7f93; --overlay2-rgb: 124 127 147;
  --overlay1: #8c8fa1; --overlay1-rgb: 140 143 161;
  --overlay0: #9ca0b0; --overlay0-rgb: 156 160 176;
  --surface2: #acb0be; --surface2-rgb: 172 176 190;
  --surface1: #bcc0cc; --surface1-rgb: 188 192 204;
  --surface0: #ccd0da; --surface0-rgb: 204 208 218;
  --base: #eff1f5; --base-rgb: 239 241 245;
  --mantle: #e6e9ef; --mantle-rgb: 230 233 239;
  --crust: #dce0e8; --crust-rgb: 220 224 232;
  --deep-rgb: 210 214 224; --shine-rgb: 255 255 255; --shadow-rgb: 76 79 105; --on-accent: #eff1f5;
  color-scheme: light;
  --glass: rgb(var(--base-rgb) / 0.62);
  --glass-strong: rgb(var(--base-rgb) / 0.82);
  --glass-card: rgb(var(--shine-rgb) / 0.45);
  --glass-hover: rgb(var(--surface0-rgb) / 0.7);
  --edge: rgb(var(--text-rgb) / 0.12);
  --edge-strong: rgb(var(--text-rgb) / 0.2);
  --shine: inset 0 1px 0 rgb(var(--shine-rgb) / 0.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 var(--sans);
  color: var(--text);
  background: var(--crust);
  overflow: hidden;
}
/* aurora backdrop that the glass blurs (as in the Atlas) */
body::before {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(38% 42% at 18% 22%, rgb(var(--mauve-rgb) / 0.09), transparent 70%),
    radial-gradient(34% 38% at 78% 18%, rgb(var(--blue-rgb) / 0.07), transparent 70%),
    radial-gradient(40% 40% at 70% 82%, rgb(var(--pink-rgb) / 0.05), transparent 70%),
    radial-gradient(36% 40% at 22% 85%, rgb(var(--teal-rgb) / 0.05), transparent 70%),
    linear-gradient(160deg, var(--mantle) 0%, var(--crust) 60%, rgb(var(--deep-rgb)) 100%);
  animation: aurora 40s ease-in-out infinite alternate;
}
@keyframes aurora {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(3%, -2%) rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }

/* ---------- buttons (Atlas style) */
button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--edge);
  background: var(--glass-card);
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: var(--shine);
  transition: background 0.18s, border-color 0.18s, transform 0.1s, box-shadow 0.18s, color 0.18s;
}
button:hover:not(:disabled) { border-color: rgb(var(--lavender-rgb) / 0.45); background: var(--glass-hover); box-shadow: var(--shine), 0 0 18px rgb(var(--lavender-rgb) / 0.12); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary {
  background: linear-gradient(135deg, rgb(var(--mauve-rgb) / 0.85), rgb(var(--blue-rgb) / 0.85));
  border-color: rgb(var(--shine-rgb) / 0.15); color: var(--on-accent); font-weight: 700;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(135deg, rgb(var(--mauve-rgb) / 0.95), rgb(var(--blue-rgb) / 0.95)); }

/* ---------- top bar */
.topbar {
  position: fixed;
  top: 12px; left: 12px; right: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 9px 14px 9px 18px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shine), 0 10px 40px rgb(var(--shadow-rgb) / 0.45);
}
.brand { font-weight: 700; letter-spacing: 0.3px; font-size: 17px; white-space: nowrap; }
.logo { color: var(--mauve); text-shadow: 0 0 14px rgb(var(--mauve-rgb) / 0.8); }
.top-actions { display: flex; gap: 8px; }
.top-actions button:not(.primary) { background: rgb(var(--surface0-rgb) / 0.25); }
.theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: inline; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }

/* ---------- floating side panel */
#panel {
  position: absolute;
  --panel-gap: 10px;
  top: var(--below-bar); right: 12px; bottom: 12px;
  width: var(--panel-w);
  z-index: 2;
  overflow-y: auto; overflow-x: hidden;
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  border-radius: calc(var(--radius) + 4px);
  background: var(--glass);
  border: 1px solid var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shine), 0 14px 50px rgb(var(--shadow-rgb) / 0.55);
  scrollbar-width: thin;
  scrollbar-color: var(--surface1) transparent;
}
.card {
  background: var(--glass-card);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shine);
  flex-shrink: 0;
}
h2 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--subtext0);
}

.hint {
  margin: -4px 0 10px;
  font-size: 12px;
  color: var(--overlay1);
}

.field {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.field > span, .rows-head, .param > span {
  font-size: 12px;
  color: var(--subtext0);
}
.rows-head { margin: 12px 0 6px; }

input, select { font: inherit; color: var(--text); }

/* text fields as the Atlas's notation input */
input:not([type="range"]):not([type="checkbox"]), select {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  background: rgb(var(--crust-rgb) / 0.4);
  border: 1px solid var(--edge-strong);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:not([type="range"]):not([type="checkbox"]):hover, select:hover { border-color: rgb(var(--lavender-rgb) / 0.35); }
input:not([type="range"]):not([type="checkbox"]):focus, select:focus {
  border-color: var(--lavender);
  box-shadow: 0 0 12px rgb(var(--lavender-rgb) / 0.15);
}
input:disabled { opacity: 0.35; }
input::placeholder { color: var(--overlay0); }
select option { background: var(--mantle); }

.mono { font: 500 13px var(--mono); }
input.mono { font: 500 13px var(--mono); }

input[type="range"] { width: 100%; accent-color: var(--mauve); }
input[type="checkbox"] { accent-color: var(--mauve); }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { display: none; }

/* themed dropdowns (selectmenu.js): the native <select> stays as the hidden source of truth */
.sm { position: relative; display: block; min-width: 0; }
.sm-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.sm-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-width: 0; height: 32px;
  padding: 0 10px;
  background: rgb(var(--crust-rgb) / 0.4);
  border: 1px solid var(--edge-strong);
  border-radius: 10px;
  box-shadow: none;
  backdrop-filter: none;
  color: var(--text);
  font: inherit;
  text-align: left;
}
.sm-btn .sm-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-btn svg { flex-shrink: 0; color: var(--overlay1); transition: transform 0.15s; }
.sm-btn:hover:not(:disabled) { background: rgb(var(--crust-rgb) / 0.4); border-color: rgb(var(--lavender-rgb) / 0.35); box-shadow: none; }
.sm-btn:focus-visible, .sm-btn.on { outline: none; border-color: var(--lavender); box-shadow: 0 0 12px rgb(var(--lavender-rgb) / 0.15); }
.sm-btn.on svg { transform: rotate(180deg); color: var(--lavender); }
.sm-btn:active:not(:disabled) { transform: none; }
.sm-pop {
  position: fixed; z-index: 100;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 5px;
  background: var(--glass-strong);
  border: 1px solid var(--edge-strong);
  border-radius: 12px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shine), 0 14px 40px rgb(var(--shadow-rgb) / 0.5);
  font-size: 13.5px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface1) transparent;
}
.sm-group {
  padding: 8px 10px 3px;
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--overlay1);
}
.sm-opt {
  position: relative;
  padding: 6px 10px 6px 26px;
  border-radius: 8px;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.sm-opt.act { background: var(--glass-hover); }
.sm-opt.sel { color: var(--mauve); font-weight: 600; }
.sm-opt.sel::before { content: '✓'; position: absolute; left: 9px; color: var(--mauve); }
.sm-opt.sel.act { background: rgb(var(--mauve-rgb) / 0.14); }
.sm-opt.dis { opacity: 0.4; cursor: default; }

/* ---------- stage: the full window, under the islands */
#stage { position: fixed; inset: 0; }
#stage::before {
  /* faint dot grid, as behind the Atlas's solid */
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle, rgb(var(--overlay0-rgb) / 0.32) 1.1px, transparent 1.6px) 0 0 / 30px 30px,
    radial-gradient(70% 70% at 55% 50%, rgb(var(--crust-rgb) / 0.15), rgb(var(--deep-rgb) / 0.55));
  pointer-events: none;
}
:root[data-theme="light"] #stage::before {
  background:
    radial-gradient(circle, rgb(var(--overlay1-rgb) / 0.45) 1.1px, transparent 1.6px) 0 0 / 30px 30px,
    radial-gradient(70% 70% at 55% 50%, rgb(var(--shine-rgb) / 0.25), rgb(var(--crust-rgb) / 0.5));
}
#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#canvas.dragging { cursor: grabbing; }


/* ---------- this app
   Three islands around the picture, as in the Atlas: what the attractor IS on the left (its code is the
   title), what you can DO with it on the right (the parameter map with the sliders that drive it), and
   under the picture the dock, to hunt for new ones; on the left under it the library. Panel
   widths grow with the screen, so a large monitor is not left empty. */
kbd { font: 600 11px var(--mono); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; opacity: 0.6; }
#canvas { cursor: default; }
button.small { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.empty-msg { position: absolute; color: var(--overlay1); font-size: 14px; text-align: center; pointer-events: none; transform: translate(-50%, -50%); max-width: 320px; }
.empty-msg b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.island {
  border-radius: calc(var(--radius) + 4px); background: var(--glass); border: 1px solid var(--edge);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shine), 0 14px 50px rgb(var(--shadow-rgb) / 0.45);
}
.chip {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase;
  padding: 3px 10px; border-radius: 99px;
  background: color-mix(in srgb, var(--c, #7f849c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, #7f849c) 55%, transparent);
  color: var(--c, var(--subtext0));
  box-shadow: 0 0 14px color-mix(in srgb, var(--c, #11111b) 25%, transparent);
}
.chip.sym { text-transform: none; font: 700 12px var(--mono); letter-spacing: 0.3px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.seg { display: flex; border: 1px solid var(--edge-strong); border-radius: 12px; overflow: hidden; background: rgb(var(--crust-rgb) / 0.3); }
.seg button { flex: 1; border: 0; border-radius: 0; padding: 7px 12px; font-size: 13px; background: transparent; box-shadow: none; backdrop-filter: none; white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--edge-strong); }
.seg button.on { background: rgb(var(--mauve-rgb) / 0.2); color: var(--mauve); font-weight: 700; box-shadow: inset 0 0 14px rgb(var(--mauve-rgb) / 0.15); }

/* ---------- left: the attractor */
.info-panel {
  position: absolute; top: var(--below-bar); left: 12px; width: var(--info-w); z-index: 2;
  bottom: 12px; display: flex; flex-direction: column; gap: 10px;
  overflow: hidden; padding: 10px;
  border-radius: calc(var(--radius) + 4px); background: var(--glass); border: 1px solid var(--edge);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shine), 0 14px 50px rgb(var(--shadow-rgb) / 0.45);
  scrollbar-width: thin; scrollbar-color: var(--surface1) transparent;
}
.code-title { position: relative; margin: 10px 0 2px; }
.code-title input {
  width: 100%; height: auto; padding: 4px 8px; margin: 0 -8px; width: calc(100% + 16px);
  font: 700 var(--code-size, 24px)/1.3 var(--mono); letter-spacing: 0.3px; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: 10px;
}
.code-title input:hover { border-color: var(--edge-strong); background: rgb(var(--crust-rgb) / 0.25); }
.code-title input:focus { border-color: var(--lavender); background: rgb(var(--crust-rgb) / 0.4); box-shadow: 0 0 12px rgb(var(--lavender-rgb) / 0.15); }
.code-title button { position: absolute; right: -4px; top: 50%; transform: translateY(-50%); }
.code-hint { font-size: 11.5px; color: var(--subtext0); overflow-wrap: anywhere; }
.code-hint:not(:empty) { margin: 2px 0 6px; }
.code-hint .bad { color: var(--red); }
.pbar { height: 3px; margin: 6px 0 12px; border-radius: 3px; background: rgb(var(--overlay0-rgb) / 0.25); overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mauve), var(--blue)); transition: width 0.2s; }
.pbar.done i { opacity: 0.35; }
.pbar[hidden] { display: block; visibility: hidden; }
.stats { display: flex; gap: 8px; margin: 0 0 10px; }
.stat { flex: 1; min-width: 0; text-align: center; background: rgb(var(--crust-rgb) / 0.28); border: 1px solid var(--edge); border-radius: 10px; padding: 6px 0; }
.stat b { display: block; font: 600 17px var(--mono); }
.stat span { font-size: 11px; color: var(--subtext0); }
.formula { font: 12.5px/1.7 var(--mono); color: var(--subtext1); overflow-wrap: anywhere; background: rgb(var(--crust-rgb) / 0.3); border: 1px solid var(--edge); border-radius: 8px; padding: 6px 9px; }
.formula b { color: var(--text); font-weight: 600; }
.desc { font-size: 12.5px; color: var(--subtext1); line-height: 1.45; margin: 10px 0 0; }

/* ---------- under the picture: the dock */
.dock {
  position: absolute; z-index: 3; bottom: 12px;
  left: calc(var(--info-w) + 24px); right: calc(var(--panel-w) + 24px);
  margin: 0 auto; max-width: 1100px;
  padding: 10px 12px 8px;
  border-radius: calc(var(--radius) + 4px); background: var(--glass); border: 1px solid var(--edge);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shine), 0 14px 50px rgb(var(--shadow-rgb) / 0.45);
}
.dock-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#kindSeg button { padding: 6px 10px; font-size: 12.5px; }
/* narrow windows: the row of map types scrolls rather than spilling out of the dock */
#kindSeg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
#kindSeg button { flex: 0 0 auto; }
.hunt-btn { padding: 7px 16px; font-size: 14px; }
.hunt-stats { flex: 1; min-width: 0; text-align: right; font-size: 11.5px; color: var(--overlay1); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-opts { display: flex; gap: 8px; align-items: center; }
.icon-opts.hidden { display: none; }
.icon-opts label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--subtext0); }
.icon-opts .sm { width: 86px; }
.icon-opts label:first-child .sm { width: 64px; }
.tw { position: relative; min-width: 0; }
.tw.new { animation: thumbIn 0.4s ease-out; }
.thumb {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1; padding: 0; border-radius: 10px; overflow: hidden;
  background: rgb(var(--crust-rgb) / 0.35); backdrop-filter: none;
}
.thumb canvas { max-width: 90%; max-height: 90%; display: block; }
.tw .tsym { position: absolute; left: 5px; bottom: 2px; font: 700 9.5px var(--mono); color: var(--subtext0); pointer-events: none; }
.tw.on .thumb { border-color: var(--mauve); box-shadow: 0 0 14px rgb(var(--mauve-rgb) / 0.35); }
.tw.unseen .thumb::after { content: ''; position: absolute; right: 5px; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--mauve); box-shadow: 0 0 6px var(--mauve); }
.thumb-morph {
  position: absolute; right: 2px; bottom: 2px; width: 22px; height: 22px; padding: 0; font-size: 12px; line-height: 1;
  border-radius: 7px; background: var(--glass-strong); opacity: 0; transition: opacity 0.15s;
}
.tw.can-morph:hover .thumb-morph, .tw.can-morph:focus-within .thumb-morph { opacity: 1; }
.tw:not(.can-morph) .thumb-morph { display: none; }
@keyframes thumbIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: none; } }

/* ---------- right: explore (the parameter map and the sliders that drive it) */
#panel { display: flex; flex-direction: column; gap: 10px; }
.explore { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; container: explore / inline-size; padding: 12px; }
.explore-tools { flex: 1; display: flex; justify-content: flex-end; align-items: center; gap: 10px; font-size: 12px; color: var(--subtext0); min-width: 0; }
.explore-tools label { display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.explore-tools .sm { width: 64px; }
.pmap-wrap { position: relative; flex: 1 1 auto; min-height: 160px; display: flex; justify-content: center; align-items: flex-start; }
#pmapCanvas {
  display: block; width: 100px; height: 100px; border-radius: 12px; cursor: grab; touch-action: none;
  background: rgb(var(--crust-rgb) / 0.35); border: 1px solid var(--edge); transition: opacity 0.2s;
}
#pmapCanvas.stale { opacity: 0.55; }
#pmapCanvas.panning { cursor: grabbing; }
#pmapCanvas.on-ring { cursor: move; }
.pmap-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.pmap-zoom button { width: 28px; height: 28px; padding: 0; font-size: 14px; line-height: 1; border-radius: 8px; background: var(--glass-strong); }
.pmap-foot { display: flex; align-items: center; gap: 10px; margin: 6px 0 8px; min-height: 18px; flex-shrink: 0; }
.pmap-info { flex: 1; min-width: 0; font: 11.5px var(--mono); color: var(--subtext0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmap-legend { display: flex; gap: 5px; }
.pmap-legend span { display: inline-flex; }
.pmap-legend i { width: 11px; height: 11px; border-radius: 3px; }
.pmap-legend .ch i { background: linear-gradient(90deg, var(--blue), var(--mauve), var(--peach)); }
.pmap-legend .pe i { background: var(--surface1); }
.pmap-legend .di i { border: 1px dashed var(--overlay0); }
#coeffs { flex-shrink: 0; }
.seg.mini button { padding: 4px 10px; font-size: 12px; }
.trig { font: 12.5px/2 var(--mono); color: var(--subtext1); margin: 0 0 6px; padding: 4px 8px; border-radius: 8px; background: rgb(var(--crust-rgb) / 0.3); border: 1px solid var(--edge); }
.trig .sm { display: inline-block; width: 62px; vertical-align: middle; }
.trig .sm-btn { height: 24px; padding: 0 6px; font: 600 12px var(--mono); color: var(--mauve); }
/* quadratic maps: x′ and y′ side by side when the panel is wide enough */
.cgroups { display: grid; grid-template-columns: 1fr; gap: 6px 14px; }
@container explore (min-width: 420px) { .cgroups.two { grid-template-columns: 1fr 1fr; } }
.cgroup-head { font: 600 12px var(--mono); color: var(--subtext0); margin: 0 0 1px 46px; }
.crow { display: grid; grid-template-columns: 40px 24px 1fr 54px; align-items: center; gap: 6px; height: 23px; border-radius: 7px; }
.crow.x, .crow.y { background: rgb(var(--crust-rgb) / 0.3); }
.crow .ax { display: flex; gap: 2px; }
.crow .ax button { width: 19px; height: 19px; padding: 0; font-size: 11px; line-height: 1; border-radius: 5px; background: transparent; box-shadow: none; backdrop-filter: none; border-color: transparent; color: var(--overlay0); }
.crow .ax button:hover:not(:disabled) { color: var(--text); border-color: var(--edge-strong); box-shadow: none; }
.crow .ax button.on { font-weight: 700; }
.crow .ax button.on[data-ax="x"] { color: var(--sky); border-color: rgb(var(--sky-rgb) / 0.6); background: rgb(var(--sky-rgb) / 0.14); }
.crow .ax button.on[data-ax="y"] { color: var(--peach); border-color: rgb(var(--peach-rgb) / 0.6); background: rgb(var(--peach-rgb) / 0.14); }
.crow .cterm { font: 600 12.5px var(--mono); color: var(--text); text-align: right; }
.crow input[type="range"] { margin: 0; height: 18px; min-width: 0; }
.crow.x input[type="range"] { accent-color: var(--sky); }
.crow.y input[type="range"] { accent-color: var(--peach); }
.crow output { font: 12px var(--mono); color: var(--subtext1); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.crow output b { color: var(--mauve); font-weight: 700; margin-right: 4px; }

.morph-card { flex-shrink: 0; padding: 10px 12px 12px; }
.morph-card[hidden] { display: none; }
.morph-card .card-head { margin-bottom: 8px; }
.morph-ends { flex: 1; min-width: 0; font: 11.5px var(--mono); color: var(--subtext0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.morph-modes { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.morph-modes .seg { flex: 1; min-width: 0; }
.morph-modes .seg[hidden], .detour[hidden] { display: none; }
.morph-modes .seg button { padding: 5px 8px; font-size: 12px; }
.morph-modes .pct { font: 500 11px var(--mono); opacity: 0.8; margin-left: 3px; }
.morph-modes .pct.busy { opacity: 0.55; }
.detour { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--subtext0); }
.detour .sm { width: 74px; }
#morphStrip { display: block; width: 100%; height: 64px; border-radius: 8px; background: rgb(var(--crust-rgb) / 0.35); border: 1px solid var(--edge); cursor: pointer; touch-action: none; }
.morph-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.morph-row input { flex: 1; }
#morphPlay { width: 34px; padding: 5px 0; }
#morphPlay.on { color: var(--mauve); border-color: rgb(var(--mauve-rgb) / 0.6); }

/* toasts */
.toasts { position: fixed; right: calc(var(--panel-w) + 30px); bottom: calc(var(--dock-h) + 24px); z-index: 5; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  background: var(--glass-strong); border: 1px solid var(--edge-strong); border-radius: 12px; padding: 10px 14px; backdrop-filter: var(--blur);
  font-size: 13px; max-width: 340px; animation: toastIn 0.35s ease-out; box-shadow: var(--shine), 0 8px 24px rgb(var(--shadow-rgb) / 0.45);
}
.toast.act { pointer-events: auto; }
.toast .undo { margin-left: 8px; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all 0.4s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* short windows (laptops): tighter slider rows, so the map keeps its height */
@media (max-height: 860px) { .crow { height: 20px; } .cgroup-head { font-size: 11px; } }

/* narrower windows: thinner panels, smaller thumbnails */
@media (max-width: 1250px) { :root { --info-w: 260px; --panel-w: 350px; } }
@media (max-width: 1000px) { :root { --info-w: 230px; --panel-w: 320px; } .hunt-stats { display: none; } }

/* Lite mode, switched on when frames stay slow (weak GPU, see adaptQuality in js/app.js): the glass
   panels stop blurring what is behind them and turn nearly opaque, and the backdrop stops drifting. */
:root.lite {
  --blur: none;
  --glass: rgb(var(--base-rgb) / 0.9);
  --glass-strong: rgb(var(--mantle-rgb) / 0.95);
}
:root.lite *, :root.lite *::before, :root.lite *::after { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
:root.lite body::before { animation: none; }

/* ---------- phones: the picture on top, then the dock, the attractor and the explore panel */
@media (max-width: 760px) {
  :root { --panel-w: 0px; --info-w: 0px; }
  .brand-name { display: none; }
  .brand .logo { font-size: 20px; }
  #stage { bottom: auto; height: 55vh; }
  body { overflow-y: auto; height: auto; }
  .dock { position: relative; left: auto; right: auto; bottom: auto; margin: calc(55vh + 8px) 8px 8px; }
  .hunt-stats { display: none; }
  .info-panel { position: relative; top: auto; left: auto; bottom: auto; width: auto; max-height: none; margin: 0 8px 8px; overflow: visible; }

  #panel { position: relative; top: auto; left: auto; right: auto; bottom: auto; width: auto; margin: 0 8px 8px; overflow: visible; }
  .explore { min-height: 0; }
  .toasts { right: 12px; bottom: 18px; }
}

/* ---------- the left column: the attractor, then the library */
#infoCard { flex: 0 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--surface1) transparent; }
.info-actions { display: flex; gap: 6px; margin: -4px 0 10px; }
.info-actions button { flex: 1; }
#btnSave[aria-pressed="true"] { color: var(--yellow); border-color: rgb(var(--yellow-rgb) / 0.55); background: rgb(var(--yellow-rgb) / 0.12); }
#btnExport[aria-expanded="true"] { color: var(--mauve); border-color: rgb(var(--mauve-rgb) / 0.5); }
.export-box { margin: 0 0 12px; padding: 10px; border-radius: 10px; background: rgb(var(--crust-rgb) / 0.3); border: 1px solid var(--edge); }
.export-box[hidden] { display: none; }
.export-box .field { grid-template-columns: 76px 1fr; margin-bottom: 6px; }
.export-note { font-size: 11.5px; color: var(--subtext0); margin: 2px 0 8px; min-height: 15px; }
.export-row { display: flex; align-items: center; gap: 8px; }
.export-row .pbar { flex: 1; margin: 0; }
.export-row .pbar[hidden] { display: none; }
.library { flex: 1 1 auto; min-height: 170px; display: flex; flex-direction: column; padding: 10px; }
.lib-tabs { flex-shrink: 0; margin-bottom: 10px; }
.lib-tabs .count { font: 500 11px var(--mono); opacity: 0.75; }
.lib-tabs .count:empty { display: none; }
.lib-pane { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--surface1) transparent; }
.lib-pane[hidden] { display: none; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.thumbs:empty { display: none; }
.lib-empty { margin: 4px 2px; font-size: 12px; color: var(--overlay1); line-height: 1.45; }
.lib-empty b { color: var(--subtext1); font-weight: 600; }
.lib-empty[hidden] { display: none; }
.saved-list { display: flex; flex-direction: column; gap: 6px; }
.saved-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: center; padding: 4px; border-radius: 12px; border: 1px solid transparent; }
.saved-row.on { border-color: rgb(var(--mauve-rgb) / 0.5); background: rgb(var(--mauve-rgb) / 0.08); }
.saved-row .tw { width: 52px; }
.saved-row .meta { min-width: 0; }
.saved-row input.name { height: 24px; padding: 0 6px; margin-left: -6px; width: calc(100% + 6px); font: 600 13px var(--sans); background: transparent; border-color: transparent; }
.saved-row input.name:hover { border-color: var(--edge-strong); }
.saved-row .code { font: 11px var(--mono); color: var(--overlay1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-row .acts { display: flex; gap: 4px; }
.saved-row .acts button { width: 26px; height: 26px; padding: 0; font-size: 12px; border-radius: 8px; }
@media (max-width: 760px) {
  #infoCard { overflow: visible; }
  .library { min-height: 0; }
  .lib-pane { max-height: 360px; }
}
