/* Catppuccin Mocha + glassmorphism */
:root {
  /* Catppuccin Mocha (dark) */
  --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;           /* height of the floating top bar */
  --below-bar: 80px;          /* where content starts beneath it */
  --muted: var(--subtext0);
  --accent: var(--lavender);
  color-scheme: dark;
}

/* Catppuccin Latte (light) */
: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-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--crust);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* aurora backdrop that the glass blurs */
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); }
}

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;
}
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)); }
button.ghost { background: rgb(var(--surface0-rgb) / 0.25); }
button.small { padding: 4px 10px; font-size: 13px; }
button.danger { color: var(--red); }
kbd {
  font: 600 11px ui-monospace, monospace;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 4px;
  opacity: 0.6;
}
.hidden { display: none !important; }

/* ---------- top bar */
.topbar {
  /* floats over the full-height 3D stage, so its backdrop blur has the scene to frost */
  position: fixed;
  top: 12px; left: 12px; right: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  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); }
.progress { flex: 1; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 12px; color: var(--subtext0); }
.progress .pg { display: flex; align-items: center; gap: 6px; }
.progress .bar { width: 50px; height: 5px; border-radius: 3px; background: rgb(var(--surface2-rgb) / 0.5); overflow: hidden; }
.progress .bar i { display: block; height: 100%; border-radius: 3px; transition: width 0.6s; }
.top-actions { display: flex; gap: 8px; }

/* ---------- main layout: full-bleed stage with a floating glass panel */
.layout { flex: 1; position: relative; min-height: 0; }
.stage { position: absolute; inset: 0; }
#viewport {
  position: absolute; inset: 0;
  /* faint dot grid (as on the map) gives the floating glass something to frost */
  background:
    radial-gradient(circle, rgb(var(--overlay0-rgb) / 0.32) 1.1px, transparent 1.6px) 0 0 / 30px 30px,
    radial-gradient(70% 70% at 40% 50%, rgb(var(--crust-rgb) / 0.15), rgb(var(--deep-rgb) / 0.55));
}
:root[data-theme="light"] #viewport { background-image: radial-gradient(circle, rgb(var(--overlay1-rgb) / 0.45) 1.1px, transparent 1.6px), radial-gradient(70% 70% at 40% 50%, rgb(var(--shine-rgb) / 0.25), rgb(var(--crust-rgb) / 0.5)); }
#viewport canvas { display: block; touch-action: none; }
.stage-title { position: absolute; left: 26px; bottom: 22px; pointer-events: none; max-width: calc(100% - 460px); }
.stage-title h1 {
  margin: 6px 0 2px; font-size: 32px; font-weight: 700; letter-spacing: -0.4px;
  text-shadow: 0 2px 24px rgb(var(--crust-rgb) / 0.9);
}
.notation { color: var(--overlay2); font: 500 13px ui-monospace, monospace; }
.family-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);
}
.stage-tools { position: absolute; top: var(--below-bar); left: calc(var(--info-w) + 26px); right: 420px; display: flex; justify-content: space-between; gap: 10px; pointer-events: none; }
.stage-tools > * { pointer-events: auto; }
.platonic-row { display: flex; gap: 6px; flex-wrap: wrap; }
.platonic-row button { flex: 1 1 auto; padding: 5px 9px; font-size: 12.5px; }
/* the stage's tool buttons (Back, Net, SVG, 3D): one size, frosted over the solid */
.tool-group > button { padding: 6px 12px; font-size: 13px; line-height: 1.2; background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }

.pick-banner {
  position: absolute; top: calc(var(--below-bar) + 46px); left: calc(50% + (var(--info-w) - 392px) / 2); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 9px 12px 9px 16px;
  background: var(--glass-strong); border: 1px solid rgb(var(--lavender-rgb) / 0.4); border-radius: 12px;
  backdrop-filter: var(--blur);
  box-shadow: var(--shine), 0 8px 30px rgb(var(--shadow-rgb) / 0.5), 0 0 24px rgb(var(--lavender-rgb) / 0.12);
  font-size: 14px; max-width: calc(100% - 460px);
}
.pick-text b { color: var(--lavender); }
.pick-preview { color: var(--subtext0); font-size: 13px; min-width: 160px; }
.pick-preview .new { color: var(--yellow); font-weight: 600; }

.toasts { position: absolute; right: 420px; bottom: 18px; 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.discover {
  border-color: rgb(var(--yellow-rgb) / 0.55);
  background: linear-gradient(135deg, rgb(var(--peach-rgb) / 0.22), rgb(var(--mauve-rgb) / 0.22)), var(--glass-strong);
  box-shadow: var(--shine), 0 0 30px rgb(var(--yellow-rgb) / 0.18);
}
.toast.discover b { color: var(--yellow); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all 0.4s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } }

.loader { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: var(--subtext0); background: var(--base); z-index: 50; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgb(var(--overlay2-rgb) / 0.25); border-top-color: var(--mauve); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- floating info panel (left): the current solid, Wikipedia */
:root { --info-w: 304px; }
@media (max-width: 1250px) { :root { --info-w: 260px; } }
.info-panel {
  position: absolute; top: var(--below-bar); left: 12px; width: var(--info-w); z-index: 2;
  max-height: calc(100% - var(--below-bar) - 128px); /* ends above the solid's big title */
  overflow-y: auto; overflow-x: hidden; padding: 10px; 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.45);
  scrollbar-width: thin; scrollbar-color: var(--surface1) transparent;
}
.wiki-card .wk-img { display: block; width: 100%; max-height: 200px; object-fit: cover; border-radius: 10px; margin: 2px 0 8px; background: rgb(var(--crust-rgb) / 0.3); }
.wiki-card .wk-cap { font-size: 11px; color: var(--overlay1); margin: -4px 0 8px; }
.wiki-card .wk-text { font-size: 12.5px; line-height: 1.5; color: var(--subtext1); margin: 0; }
.wiki-card .wk-src { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 11px; color: var(--overlay1); }
.wiki-card a { color: var(--blue); text-decoration: none; }
.wiki-card a:hover { text-decoration: underline; }
.wiki-card .wk-sight { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--edge); }
.nav-card .card-head { margin-bottom: 8px; }

/* ---------- floating side panel */
.panel {
  position: absolute; top: var(--below-bar); right: 12px; bottom: 12px; width: 392px; 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; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--subtext0); font-weight: 700; }
.hint { font-size: 11px; color: var(--overlay1); }
.note { font-size: 12px; color: var(--subtext0); margin: 10px 0 0; }
.note:empty { display: none; }

.info-title { overflow-wrap: anywhere; font-size: 19px; font-weight: 700; margin: 8px 0 4px; }
.stats { display: flex; gap: 8px; margin: 10px 0; }
.stat { flex: 1; 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-size: 18px; }
.stat span { font-size: 11px; color: var(--subtext0); }
.faces { display: flex; flex-wrap: wrap; gap: 6px; }
.facechip { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 99px; background: rgb(var(--crust-rgb) / 0.25); border: 1px solid var(--edge); }
.facechip.kp { color: var(--peach); border-color: rgb(var(--peach-rgb) / 0.5); box-shadow: 0 0 12px rgb(var(--peach-rgb) / 0.2); }
.facechip .sw + .sw { margin-left: -3px; }
.facechip { flex-wrap: wrap; max-width: 100%; }
.facechip .sw-more { margin-left: -3px; color: var(--overlay1); font-size: 11px; line-height: 1; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); vertical-align: -1px; box-shadow: 0 0 6px var(--c); }
.configs { margin-top: 8px; font: 12px ui-monospace, monospace; color: var(--subtext0); line-height: 1.6; }
.desc { font-size: 13px; color: var(--subtext1); line-height: 1.45; margin: 8px 0 0; }
.desc.warn { color: var(--yellow); font-size: 12px; }

.ops { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.op { min-width: 0; text-align: left; display: flex; gap: 9px; align-items: center; padding: 7px 9px; min-height: 48px; background: rgb(var(--crust-rgb) / 0.22); }
.op .letter {
  flex-shrink: 0; width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center;
  font: 700 14px ui-monospace, monospace; background: rgb(var(--blue-rgb) / 0.14); color: var(--blue);
  border: 1px solid rgb(var(--blue-rgb) / 0.25);
}
.johnson .op .letter { background: rgb(var(--red-rgb) / 0.13); color: var(--red); border-color: rgb(var(--red-rgb) / 0.25); font-size: 15px; }
#stellOps .op .letter { background: rgb(var(--peach-rgb) / 0.14); color: var(--peach); border-color: rgb(var(--peach-rgb) / 0.3); font-size: 15px; }
.op .txt { flex: 1; min-width: 0; overflow: hidden; }
.op .nm { font-size: 13px; font-weight: 600; }
.op .res { font-size: 11px; color: var(--subtext0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op .res.new { color: var(--yellow); }
.op .res.unch { color: var(--overlay1); font-style: italic; }
.op.active { border-color: var(--lavender); background: rgb(var(--lavender-rgb) / 0.14); box-shadow: 0 0 16px rgb(var(--lavender-rgb) / 0.2); }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; }
.toggles label { display: flex; gap: 7px; align-items: center; cursor: pointer; }
.slider { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; font-size: 12px; color: var(--subtext0); }
input[type=range], input[type=checkbox] { accent-color: var(--mauve); }

/* ---------- overlays */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgb(var(--crust-rgb) / 0.55); backdrop-filter: blur(10px); display: flex; flex-direction: column; }
#mapOverlay { background: var(--crust); }
#encOverlay { background: rgb(var(--crust-rgb) / 0.72); backdrop-filter: blur(16px); }
.map-head {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 2;
  display: flex; align-items: center; gap: 14px; padding: 8px 12px 8px 16px; flex-wrap: wrap;
  border-radius: var(--radius); background: var(--glass); border: 1px solid var(--edge);
  backdrop-filter: var(--blur); box-shadow: var(--shine), 0 10px 40px rgb(var(--shadow-rgb) / 0.5);
}
.map-head h2 { margin: 0; font-size: 17px; }
.map-sub { font-size: 12px; color: var(--subtext0); }
.map-counts { flex: 1; display: flex; gap: 6px 12px; justify-content: center; flex-wrap: wrap; font-size: 11px; color: var(--subtext0); }
.map-counts .mc { white-space: nowrap; cursor: default; }
.map-counts .mc b { font-size: 13px; color: var(--text); }
.map-counts .mc-tot { opacity: 0.7; }
.map-actions { display: flex; gap: 8px; }
#mapCanvas { flex: 1; width: 100%; min-height: 0; display: block; touch-action: none; }
.map-legend {
  max-width: calc(100% - 28px); position: absolute; left: 14px; bottom: 14px; font-size: 11px; color: var(--subtext0);
  background: var(--glass); border: 1px solid var(--edge); border-radius: 12px; padding: 9px 12px; line-height: 1.7; pointer-events: none;
  backdrop-filter: var(--blur); box-shadow: var(--shine);
}
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

.help {
  position: relative; margin: auto; max-width: 660px; max-height: 86vh; overflow: auto; padding: 22px 26px; font-size: 14px; line-height: 1.55;
  background: var(--glass-strong); border: 1px solid var(--edge-strong); border-radius: 20px;
  backdrop-filter: var(--blur); box-shadow: var(--shine), 0 20px 60px rgb(var(--shadow-rgb) / 0.6);
}
.help h2 { margin-top: 0; }
.help h3 { margin-bottom: 4px; font-size: 14px; color: var(--mauve); }
.help b { color: var(--lavender); }
.help ul { padding-left: 18px; margin: 4px 0; }
.help .close { position: absolute; top: 12px; right: 12px; }
.muted { color: var(--subtext0); }
.nogl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--subtext0); padding: 30px 440px 30px calc(var(--info-w) + 40px); line-height: 1.6; }

@media (max-width: 1250px) {
  .map-sub { display: none; }
  .map-counts .mc-name { display: none; }
}
@media (max-width: 860px) {
  .topbar { position: sticky; top: 8px; margin: 8px 8px 0; left: auto; right: auto; }
  .stage-tools { top: 14px; }
  .pick-banner { top: 60px; }
  body { overflow: auto; }
  .layout { display: flex; flex-direction: column; }
  .stage { position: relative; min-height: 62vh; }
  .panel { position: relative; inset: auto; width: auto; margin: 0 12px 12px; overflow: visible; }
  .progress { display: none; }
  .stage-title { max-width: calc(100% - 40px); }
  .stage-title h1 { font-size: 22px; }
  .stage-tools { right: 14px; left: 14px; }
  .info-panel { position: relative; inset: auto; width: auto; max-height: none; margin: 0 12px 10px; overflow: visible; }
  .toasts { right: 16px; }
  .pick-banner { left: 50%; max-width: calc(100% - 32px); }
  .nogl { padding: 30px; }
}

#mapLinks.on { border-color: var(--lavender); background: rgb(var(--lavender-rgb) / 0.18); color: var(--lavender); }

.busy {
  position: absolute; left: calc(50% + (var(--info-w) - 392px) / 2); bottom: 24px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; font-size: 13px; color: var(--subtext1);
  background: var(--glass-strong); border: 1px solid var(--edge-strong); border-radius: 99px; backdrop-filter: var(--blur);
}
.spinner.small { width: 16px; height: 16px; border-width: 2px; }
@media (max-width: 860px) { .busy { transform: translateX(-50%); } }

/* ---------- encyclopedia */
.enc {
  position: relative; margin: 18px; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px;
  background: rgb(var(--mantle-rgb) / 0.9); border: 1px solid var(--edge-strong); border-radius: 20px;
  backdrop-filter: var(--blur); box-shadow: var(--shine), 0 20px 60px rgb(var(--shadow-rgb) / 0.6);
}
.enc-head { display: flex; align-items: center; gap: 14px; }
.enc-head h2 { margin: 0; font-size: 18px; }
#encSearch {
  flex: 1; max-width: 380px; font: inherit; font-size: 13px; color: var(--text); padding: 7px 12px; border-radius: 10px;
  background: rgb(var(--crust-rgb) / 0.45); border: 1px solid var(--edge-strong); outline: none;
}
#encSearch:focus { border-color: var(--lavender); }
.enc-head .primary { margin-left: auto; }
.enc-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.enc-chip { font-size: 12px; padding: 4px 10px; border-radius: 99px; display: flex; gap: 6px; align-items: center; background: rgb(var(--crust-rgb) / 0.3); }
.enc-chip.on { border-color: var(--c, var(--lavender)); background: color-mix(in srgb, var(--c, #b4befe) 18%, transparent); }
.enc-chip .dot { margin: 0; }
.enc-body { flex: 1; min-height: 0; display: flex; gap: 14px; }
.enc-grid {
  flex: 1; min-width: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  align-content: start; grid-auto-rows: max-content; gap: 10px; padding: 2px 4px 2px 0; scrollbar-width: thin; scrollbar-color: var(--surface1) transparent;
}
.enc-card { padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; background: rgb(var(--crust-rgb) / 0.28); border-radius: 14px; }
.enc-card.sel { border-color: var(--c); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 30%, transparent); }
.enc-thumb { width: 104px; height: 104px; display: grid; place-items: center; }
.enc-thumb img { width: 100%; height: 100%; object-fit: contain; }
.enc-ph { width: 60%; height: 60%; border-radius: 50%; background: radial-gradient(circle, rgb(var(--lavender-rgb) / 0.18), transparent 70%); }
.enc-card { min-width: 0; }
.enc-name {
  font-size: 12px; font-weight: 600; line-height: 1.25; max-width: 100%;
  overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.enc-name.long { font-size: 11px; }
.enc-sub { font-size: 11px; color: var(--subtext0); font-family: ui-monospace, monospace; }
.enc-locked { grid-column: 1 / -1; text-align: center; padding: 18px; color: var(--overlay2); font-size: 13px; border: 1px dashed var(--edge-strong); border-radius: 14px; }
.enc-detail {
  width: 360px; flex-shrink: 0; overflow-y: auto; padding: 14px; border-radius: 16px; background: rgb(var(--base-rgb) / 0.85); border: 1px solid var(--edge);
  scrollbar-width: thin; scrollbar-color: var(--surface1) transparent;
}
.enc-detail h2 { margin: 8px 0 4px; font-size: 19px; }
.enc-big { width: 100%; height: 210px; display: grid; place-items: center; }
.enc-big img { max-width: 100%; max-height: 100%; width: auto; height: auto; }
.enc-empty { color: var(--overlay2); text-align: center; margin-top: 40%; font-size: 13px; }
.enc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 10px; }
.enc-table th { text-align: left; font-weight: 600; color: var(--subtext0); padding: 6px 10px 6px 0; vertical-align: top; width: 38%; }
.enc-table td { padding: 6px 0; border-top: 1px solid var(--edge); }
.enc-table th { border-top: 1px solid var(--edge); }
.enc-actions { display: flex; gap: 8px; margin-top: 12px; }
@media (max-width: 860px) {
  .enc { margin: 8px; }
  .enc-body { flex-direction: column; }
  .enc-detail { width: auto; max-height: 45%; }
}

.notation-row { display: flex; gap: 6px; margin-bottom: 6px; }
#notationInput {
  flex: 1; min-width: 0; font: 500 13px ui-monospace, monospace; color: var(--text); padding: 7px 10px; border-radius: 10px;
  background: rgb(var(--crust-rgb) / 0.4); border: 1px solid var(--edge-strong); outline: none;
}
#notationInput:focus { border-color: var(--lavender); box-shadow: 0 0 12px rgb(var(--lavender-rgb) / 0.15); }
.notation-hint { font-size: 11.5px; color: var(--subtext0); min-height: 15px; margin-bottom: 8px; overflow-wrap: anywhere; }
.notation-hint .bad { color: var(--red); }
.help code { font: 600 12px ui-monospace, monospace; color: var(--peach); background: rgb(var(--crust-rgb) / 0.4); padding: 1px 5px; border-radius: 4px; }

.enc-tagrow { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.enc-taglabel { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--overlay1); margin-right: 4px; }
.enc-chip.tag.on { border-color: var(--yellow); background: rgb(var(--yellow-rgb) / 0.14); }
.enc-badges { font-size: 12px; color: var(--yellow); min-height: 14px; letter-spacing: 2px; }
.enc-tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; margin: 1px 0; border-radius: 99px; border: 1px solid var(--edge-strong); background: rgb(var(--crust-rgb) / 0.3); }

.progress { gap: 10px; align-items: center; }
.pgbar { display: flex; width: min(340px, 34vw); height: 8px; border-radius: 4px; overflow: hidden; background: rgb(var(--surface2-rgb) / 0.45); }
.pgbar i { display: block; height: 100%; transition: width 0.6s; }
.pgtext { white-space: nowrap; }
.pgtext b { color: var(--text); font-size: 13px; }

.facet-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 260px; overflow-y: auto; scrollbar-width: thin; }
.facet-item { display: flex; justify-content: space-between; gap: 8px; text-align: left; font-size: 12.5px; padding: 6px 10px; background: rgb(var(--crust-rgb) / 0.3); }
.facet-item span { color: var(--overlay1); font-size: 11px; white-space: nowrap; }
.facet-item.new { color: var(--yellow); }
.stats .stat { min-width: 0; }

/* theme toggle */
.theme-toggle { width: 38px; padding: 6px 0; font-size: 16px; line-height: 1; }
.theme-toggle .sun { display: none; color: var(--yellow); }
.theme-toggle .moon { color: var(--lavender); }
:root[data-theme="light"] .theme-toggle .sun { display: inline; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }
body, .panel, .topbar, .card, button, .map-head, .help, .enc, .toast { transition: background-color 0.3s, border-color 0.3s, color 0.3s; }

/* map zoom buttons (also the main way to zoom on touch screens besides pinching) */
.map-zoom { position: absolute; right: 14px; bottom: 14px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.map-zoom button {
  width: 40px; height: 40px; padding: 0; font-size: 20px; line-height: 1; border-radius: 12px;
  background: var(--glass); backdrop-filter: var(--blur); box-shadow: var(--shine);
}

/* ---------- phones and narrow windows */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  .topbar { gap: 8px; padding: 6px 8px 6px 12px; }
  .top-actions { gap: 6px; margin-left: auto; }
  .top-actions button { padding: 7px 10px; }
  .top-actions kbd, .map-actions kbd, .pick-banner kbd { display: none; }
  .help { margin: auto 10px; padding: 18px 16px; max-height: calc(100dvh - 20px); font-size: 13.5px; }
  .map-head { top: 8px; left: 8px; right: 8px; gap: 8px; padding: 8px 10px; }
  .map-head h2 { font-size: 15px; }
  .map-sub, .map-counts { display: none; }
  .map-actions { margin-left: auto; gap: 6px; }
  .map-actions .lbl { display: none; }
  .map-legend { left: 8px; bottom: 8px; max-width: calc(100% - 76px); line-height: 1.5; }
  .map-zoom { right: 8px; bottom: 8px; }
  .enc-head { flex-wrap: wrap; gap: 8px; }
  .enc-head h2 { font-size: 16px; }
  #encSearch { order: 3; flex-basis: 100%; max-width: none; }
  .enc-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
  .enc-thumb { width: 76px; height: 76px; }
  .stage { min-height: 56vh; min-height: 56dvh; }
  #viewport canvas { touch-action: none; }
}
@media (max-width: 520px) {
  .brand-name, .top-actions .lbl { display: none; }
  .brand .logo { font-size: 20px; }
  .top-actions button { min-width: 40px; }
}
@media (max-width: 860px) {
  /* filter chips: one horizontally scrolling row instead of a wall of chips */
  .enc-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .enc-filters::-webkit-scrollbar { display: none; }
  .enc-tagrow { flex-basis: auto; flex-wrap: nowrap; margin-top: 0; padding-left: 6px; border-left: 1px solid var(--edge-strong); }
  .enc-chip { flex-shrink: 0; white-space: nowrap; }
  .enc-detail { max-height: 40%; }
}

/* ---------- element popup (click a vertex / edge / face) */
.elem-menu {
  position: absolute; z-index: 6; width: 290px; max-height: min(520px, calc(100% - 24px)); overflow-y: auto;
  padding: 10px; border-radius: 16px; display: flex; flex-direction: column; gap: 4px;
  background: var(--glass-strong); border: 1px solid var(--edge-strong);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shine), 0 18px 50px rgb(var(--shadow-rgb) / 0.55);
  scrollbar-width: thin; scrollbar-color: var(--surface1) transparent;
  animation: em-in 0.16s ease-out;
}
@keyframes em-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }
.em-head { display: flex; align-items: center; gap: 9px; padding: 2px 2px 6px; }
.em-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; background: var(--c); box-shadow: 0 0 12px var(--c); }
.em-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.em-title b { font-size: 14px; overflow-wrap: anywhere; }
.em-title span { font-size: 11.5px; color: var(--subtext0); }
.em-close { flex-shrink: 0; }
.em-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.9px; color: var(--overlay1); margin: 6px 2px 2px; }
.em-op {
  display: flex; align-items: center; gap: 9px; text-align: left; padding: 6px 8px; min-height: 42px;
  background: rgb(var(--crust-rgb) / 0.22); transition: transform 0.08s, background-color 0.15s, border-color 0.15s;
}
.em-op:hover:not(:disabled), .em-op.armed { border-color: var(--lavender); background: rgb(var(--lavender-rgb) / 0.14); }
.em-op:active:not(:disabled) { transform: scale(0.98); }
.em-op .letter {
  width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; font: 700 14px ui-monospace, monospace;
  color: var(--mauve); background: rgb(var(--mauve-rgb) / 0.13); border: 1px solid rgb(var(--mauve-rgb) / 0.25);
}
.em-op .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.em-op .nm { font-size: 12.5px; font-weight: 600; }
.em-op .res { font-size: 11px; color: var(--subtext0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.em-op .res.new { color: var(--yellow); }
.em-op .res.unch { color: var(--overlay1); }
.em-op.armed .res::after { content: '  · tap again'; color: var(--lavender); }
.em-empty { font-size: 12px; color: var(--subtext0); padding: 6px; }
.em-hint { font-size: 10.5px; color: var(--overlay1); margin-top: 6px; text-align: center; }
/* phones: a bottom sheet instead of a popover */
.elem-menu.sheet {
  position: fixed; left: 8px !important; right: 8px; top: auto !important; bottom: 8px; width: auto; max-height: 52vh; max-height: 52dvh;
  border-radius: 20px 20px 16px 16px; animation: em-sheet 0.22s ease-out;
  background: rgb(var(--mantle-rgb) / 0.95); /* it sits over the page text, not just the 3D view */
}
.elem-menu.sheet::before { content: ''; align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--surface2); margin-bottom: 4px; }
@keyframes em-sheet { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }
.elem-menu.sheet .em-op { min-height: 48px; }

/* ---------- Wythoff blend triangle */
.blend-wrap { display: flex; justify-content: center; }
#blendSvg { width: 100%; max-width: 270px; touch-action: none; user-select: none; cursor: pointer; color: var(--mauve); overflow: visible; }
.bl-tri {
  fill: rgb(var(--lavender-rgb) / 0.07); stroke: rgb(var(--lavender-rgb) / 0.45); stroke-width: 1.4; stroke-linejoin: round;
}
.bl-lab { font: 700 12px ui-monospace, monospace; fill: var(--subtext0); text-anchor: middle; transition: fill 0.15s; }
.bl-lab.corner { font-size: 11.5px; }
.bl-lab.inner { fill: var(--overlay1); }
.bl-lab.known { fill: var(--mauve); }
.bl-lab.new { fill: var(--yellow); }
.bl-lab.unch { fill: var(--overlay0); }
.bl-lab.on { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.bl-tick { fill: var(--surface2); stroke: var(--base); stroke-width: 1; }
.bl-tick.known { fill: var(--mauve); }
.bl-tick.new { fill: var(--yellow); }
.bl-tick.unch { fill: var(--overlay0); }
#blendDot { fill: var(--mauve); stroke: var(--base); stroke-width: 2; filter: drop-shadow(0 0 6px rgb(var(--mauve-rgb) / 0.8)); transition: r 0.12s; }
#blendDot.tick { animation: bl-tick 0.28s ease-out; }
@keyframes bl-tick { 0% { r: 7; } 40% { r: 10; } 100% { r: 7; } }
.blend-status { font-size: 12px; line-height: 1.45; min-height: 34px; margin-top: 2px; }
.blend-status .new { color: var(--yellow); }
.blend-status .unch { color: var(--overlay1); font-style: italic; }
.blend-card.disabled #blendSvg { opacity: 0.35; pointer-events: none; }
.pull-wrap { display: flex; flex-direction: column; align-items: center; margin-top: 4px; }
.pull-name { align-self: flex-start; font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--overlay1); }
.track-svg { width: 100%; max-width: 300px; touch-action: none; user-select: none; cursor: pointer; overflow: visible; }
.pl-track { stroke: rgb(var(--lavender-rgb) / 0.45); stroke-width: 3; stroke-linecap: round; }
.trk-dot { fill: var(--peach); stroke: var(--base); stroke-width: 2; filter: drop-shadow(0 0 6px rgb(var(--peach-rgb) / 0.8)); }
.trk-dot.tick { animation: bl-tick 0.28s ease-out; }
.trk-row { display: grid; grid-template-columns: 92px 1fr; align-items: center; column-gap: 6px; }
.trk-row .pull-name { align-self: center; font-size: 10.5px; }
.trk-row.off .track-svg { opacity: 0.3; pointer-events: none; }
.trk-row.off .pull-name { opacity: 0.45; }

/* legend for the reachable-stop colours */
.reach-legend { display: flex; gap: 12px; justify-content: center; font-size: 11px; color: var(--subtext0); margin-top: 4px; }
.reach-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
.reach-legend .known i { background: var(--mauve); }
.reach-legend .new i { background: var(--yellow); }
.reach-legend .unch i { background: var(--overlay0); }

/* ---------- settings */
.settings { width: min(520px, calc(100vw - 24px)); }
.settings .toggles { margin-top: 6px; }
.seg { display: flex; gap: 0; 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: 9px 6px; font-size: 13px; background: transparent; }
.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); }
.mode-desc { font-size: 12.5px; min-height: 36px; margin: 8px 2px 0; }
/* interaction modes */
body[data-mode="haptic"] #conwayOps, body[data-mode="haptic"] #stellCard, body[data-mode="haptic"] #johnsonCard { display: none; }
body[data-mode="haptic"] #conwayCard .card-head .hint { display: none; }
body[data-mode="buttons"] #blendCard { display: none; }
.top-actions button { white-space: nowrap; }
@media (max-width: 1000px) { .top-actions .lbl { display: none; } }

/* snub flap below the triangle, kis–chamfer lens */
.bl-flap { fill: rgb(var(--peach-rgb) / 0.07); stroke: rgb(var(--peach-rgb) / 0.4); stroke-width: 1.2; stroke-dasharray: 4 3; stroke-linejoin: round; }
.blend-wrap { position: relative; }
.bl-dual { position: absolute; top: 2px; left: 0; z-index: 1; font-size: 11.5px; padding: 3px 8px; }
.bl-dual.on { color: var(--mauve); border-color: rgb(var(--mauve-rgb) / 0.6); box-shadow: 0 0 10px rgb(var(--mauve-rgb) / 0.25); }
.blend-wrap.dual .bl-tri, .blend-wrap.dual .bl-flap { stroke-dasharray: 4 3; }
.bl-crys { position: absolute; top: 30px; left: 0; z-index: 1; font-size: 11.5px; padding: 3px 8px; }
.bl-crys.on { color: var(--blue); border-color: rgb(var(--blue-rgb) / 0.6); box-shadow: 0 0 10px rgb(var(--blue-rgb) / 0.25); }
.bl-groups { position: absolute; top: 2px; right: 0; z-index: 1; display: none; flex-direction: column; gap: 4px; align-items: flex-end; }
.bl-system { font: 600 11px Inter, sans-serif; padding: 2px 4px; border-radius: 8px; border: 1px solid var(--edge); background: rgb(var(--crust-rgb) / 0.35); color: var(--text); max-width: 104px; }
.bl-groups button { font: 600 11px ui-monospace, monospace; padding: 2px 7px; min-width: 34px; }
.bl-groups button.on { color: var(--blue); border-color: rgb(var(--blue-rgb) / 0.6); background: rgb(var(--blue-rgb) / 0.12); }
.blend-wrap.crystal .bl-groups { display: flex; }
.blend-wrap.crystal .bl-lab { cursor: pointer; }
.blend-wrap.crystal .bl-flap, .blend-wrap.crystal .bl-hint, .blend-wrap.crystal .bl-lab[data-k="s"] { display: none; }
.bl-cry-note { display: none; font: 600 11px Inter, sans-serif; fill: var(--subtext0); text-anchor: middle; pointer-events: none; }
.bl-cry-note.sub { font-weight: 400; font-style: italic; font-size: 10px; fill: var(--overlay1); }
.blend-wrap.crystal .bl-cry-note { display: block; }
.blend-wrap.crystal .bl-tri { stroke: rgb(var(--blue-rgb) / 0.7); }
.bl-hint { font: italic 10px Inter, sans-serif; fill: var(--overlay1); text-anchor: middle; pointer-events: none; }
.bl-lab.end { text-anchor: end; }
.bl-lab.start { text-anchor: start; }
.lens-wrap { display: flex; flex-direction: column; align-items: center; margin: 2px 0 6px; }
.lens-wrap .pull-name { align-self: flex-start; }
#lensSvg { width: 100%; max-width: 270px; touch-action: none; user-select: none; cursor: pointer; overflow: visible; }
#lensDot { fill: var(--peach); stroke: var(--base); stroke-width: 2; filter: drop-shadow(0 0 6px rgb(var(--peach-rgb) / 0.8)); }
#lensDot.tick { animation: bl-tick 0.28s ease-out; }
.lens-wrap.off #lensSvg { opacity: 0.3; pointer-events: none; }
.bl-tick.here { stroke: var(--text); stroke-width: 1.5; }

#btnNet.on { border-color: var(--lavender); color: var(--lavender); background: rgb(var(--lavender-rgb) / 0.14); }
.tool-group { display: flex; gap: 6px; align-items: flex-start; }

/* 3D export popover */
.tool-group { position: relative; }
.export-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 7; width: 280px; padding: 12px; display: flex; flex-direction: column; gap: 6px;
  background: rgb(var(--mantle-rgb) / 0.94); border: 1px solid var(--edge-strong); border-radius: 14px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shine), 0 14px 40px rgb(var(--shadow-rgb) / 0.5);
  animation: em-in 0.16s ease-out;
}
.ex-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.9px; color: var(--overlay1); }
.ex-size { font-size: 12.5px; color: var(--subtext0); display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.ex-size input { width: 70px; font: inherit; color: var(--text); padding: 4px 8px; border-radius: 8px; background: rgb(var(--crust-rgb) / 0.4); border: 1px solid var(--edge-strong); }
.ex-fmt { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 7px 10px; }
.ex-fmt b { font-size: 13px; }
.ex-fmt span { font-size: 11px; color: var(--subtext0); }
.ex-note { font-size: 11px; color: var(--yellow); line-height: 1.4; }
.ex-note:empty { display: none; }
@media (max-width: 860px) { .export-pop { width: min(280px, calc(100vw - 32px)); } }

/* themed dropdowns (js/selectmenu.js, same as in the L-system Explorer): 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; }

/* the crystal-system choice on the Blend pad: compact, like the group chips under it */
.bl-groups .sm { display: inline-block; }
.bl-groups .sm-btn { height: auto; gap: 5px; padding: 3px 7px 3px 8px; max-width: 120px; border-radius: 8px; border-color: var(--edge); background: rgb(var(--crust-rgb) / 0.35); font: 600 11px Inter, sans-serif; }
