:root {
  --bg: #0a0d14; --panel: #121724; --panel2: #171d2e; --line: #252d43; --text: #e7eaf3; --dim: #8b93aa;
  --accent: #5ee6ff; --accent2: #b56cff; --good: #5fd38d; --bad: #ff6b6b; --gold: #ffc857;
  --r0: #9aa3b5; --r1: #5fd38d; --r2: #4da3ff; --r3: #b56cff; --r4: #ffb23e; --r5: #ff4d8d;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --bar: #0c1019; --well: #0d111b; --fine: #6b7389; --track: #1d2437; --hov: #1c2338; --hov-line: #3a4566; --ph: #333c55;
  color-scheme: dark;
}
/* Light theme. Molecule windows turn light too (see "light windows" below). */
:root[data-theme="light"] {
  --bg: #f2f4f9; --panel: #ffffff; --panel2: #e8ecf5; --line: #d3d9e6; --text: #141a2a; --dim: #59627a;
  --accent: #0781a0; --accent2: #7440dc; --good: #1b8f4e; --bad: #d23636; --gold: #a06a00;
  --r0: #667086; --r1: #1b8f4e; --r2: #1f6fd0; --r3: #7440dc; --r4: #b86f00; --r5: #cf1c63;
  --bar: #ffffff; --well: #f6f8fc; --fine: #6d7589; --track: #dde2ee; --hov: #dfe4f0; --hov-line: #b4bdd2; --ph: #b3bbcc;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 'Space Grotesk', system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; } h2 { font-size: 17px; } h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--dim); }
.mono { font-family: var(--mono); font-size: 0.86em; }
.dim { color: var(--dim); }
.grow { flex: 1; min-width: 0; min-height: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }

/* ---- shell ---------------------------------------------------------------- */
#app { display: grid; grid-template-columns: 232px 1fr; height: 100dvh; }
#side { display: flex; flex-direction: column; gap: 18px; padding: 20px 16px; border-right: 1px solid var(--line); background: var(--bar); overflow-y: auto; }
#top, #tabs { display: none; }
#view { overflow-y: auto; padding: 26px 30px 40px; min-width: 0; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 21px; font-weight: 500; }
.logo img { width: 30px; height: 30px; }
.logo b { color: var(--accent); font-weight: 700; }
#nav { display: flex; flex-direction: column; gap: 3px; }
#nav a, #tabs a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--dim); font-weight: 500; }
#nav a:hover { background: var(--panel); color: var(--text); }
#nav a.on { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
#nav svg, #tabs svg { width: 19px; height: 19px; flex: none; }
#player { margin-top: auto; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: grid; gap: 9px; }
.fine { font-size: 11px; line-height: 1.4; color: var(--fine); margin: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.5s; }
.stat { display: flex; justify-content: space-between; font-size: 13px; }
.stat b { font-family: var(--mono); font-weight: 600; }
.cule { color: var(--gold); } .energy { color: var(--accent); }

/* ---- controls ------------------------------------------------------------- */
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: transform 0.08s, background 0.15s, border-color 0.15s; }
.btn:hover { border-color: var(--hov-line); background: var(--hov); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.pri { background: linear-gradient(135deg, #37c8ea, #8f5cf0); border: 0; color: #061018; }
.btn.pri:hover { filter: brightness(1.1); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.field { width: 100%; background: var(--well); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; min-width: 0; }
.field:focus { border-color: var(--accent); }
.seg { display: inline-flex; background: var(--well); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; color: var(--dim); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; padding: 2px 8px; border-radius: 99px; color: var(--rc); border: 1px solid color-mix(in srgb, var(--rc) 55%, transparent); background: color-mix(in srgb, var(--rc) 12%, transparent); white-space: nowrap; }
.r0 { --rc: var(--r0); } .r1 { --rc: var(--r1); } .r2 { --rc: var(--r2); } .r3 { --rc: var(--r3); } .r4 { --rc: var(--r4); } .r5 { --rc: var(--r5); }
.empty { color: var(--dim); text-align: center; padding: 40px 16px; grid-column: 1 / -1; }

/* ---- cards & paged grids ---------------------------------------------------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-content: start; }
.pager { display: none; }
.card { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; color: var(--text); transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; min-width: 0; }
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--rc) 60%, var(--line)); box-shadow: 0 8px 28px -12px var(--rc); }
.card .pic { aspect-ratio: 4 / 3; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--rc) 16%, #0e1320), #0c101a 75%); display: grid; place-items: center; position: relative; min-height: 0; }
.card .pic img { width: 100%; height: 100%; object-fit: contain; }
.card .pic .badge { position: absolute; left: 8px; top: 8px; }
.card .pic .score { position: absolute; right: 8px; top: 7px; font: 600 12px var(--mono); color: var(--rc); }
.card .meta { padding: 9px 11px 10px; display: grid; gap: 2px; border-top: 1px solid var(--line); }
.card .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--dim); white-space: nowrap; }
.card .price { color: var(--gold); font: 600 13px var(--mono); }

/* ---- lab -------------------------------------------------------------------- */
.lab { display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 16px; height: calc(100dvh - 66px); min-height: 520px; }
.lab .head { grid-column: 1 / -1; margin: 0; }
.tray { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.tray .frags { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 7px; overflow-y: auto; align-content: start; min-height: 0; flex: 1; padding-right: 2px; }
.frag { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 74px; padding: 3px 3px 5px; background: #0e1320; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; overflow: hidden; }
.frag:hover { border-color: var(--accent); }
.frag span { font-size: 10.5px; line-height: 1.15; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--dim); }
.frag .th { flex: 1; width: 100%; min-height: 0; display: grid; place-items: center; }
.frag .th svg { width: 100%; height: 100%; }
.frag.t2 { border-color: #24483c; } .frag.t3 { border-color: #2c3f6b; } .frag.t4 { border-color: #5a3a78; }
.frag.off { opacity: 0.28; cursor: not-allowed; }
.frag.locked { cursor: not-allowed; }
.frag.locked .th { opacity: 0.2; filter: blur(1px); }
.frag .lock { position: absolute; inset: 0 0 16px; display: grid; place-items: center; font: 600 11px var(--mono); color: var(--dim); }
.gentray { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.gentray .lbl { display: grid; gap: 4px; min-width: 0; }
.gentray .cap { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.gentray .dd { display: flex; }
.gentray .dd select { padding-top: 10px; padding-bottom: 10px; }
/* Flat drop-downs: no system chrome on the field, and our own plain list instead of the system picker. */
.dd { position: relative; display: inline-flex; min-width: 0; cursor: pointer; border-radius: 10px; outline: none; -webkit-tap-highlight-color: transparent; }
.dd[hidden] { display: none; }
.dd select { pointer-events: none; -webkit-appearance: none; appearance: none; width: 100%; min-width: 0; margin: 0; padding: 9px 32px 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--well); background-image: none; box-shadow: none; color: var(--text); font-weight: 600; text-overflow: ellipsis; outline: none; opacity: 1; }
.dd::after { content: ''; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--dim); border-bottom: 2px solid var(--dim); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.dd.open select, .dd:focus-visible select { border-color: var(--accent); }
.dd.open::after { transform: translateY(-25%) rotate(225deg); }
.dd.sm select { padding: 6px 28px 6px 9px; }
.dd.sm::after { right: 11px; }
.ddmenu { position: fixed; z-index: 70; display: flex; flex-direction: column; padding: 4px; overflow: hidden; background: var(--panel); border: 1px solid var(--hov-line); border-radius: 10px; }
.ddlist { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.ddlist::-webkit-scrollbar { display: none; }
.ddmenu.long .ddlist { padding-right: 12px; }
.ddbar { position: absolute; right: 4px; width: 6px; border-radius: 3px; background: var(--well); touch-action: none; cursor: pointer; }
.ddbar[hidden] { display: none; }
.ddbar::before { content: ''; position: absolute; inset: 0 -8px; }
.ddbar b { display: block; width: 100%; border-radius: 3px; background: var(--dim); }
.ddmenu button { flex: none; text-align: left; padding: 10px 11px; border: 0; border-radius: 7px; background: transparent; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.ddmenu button:hover { background: var(--hov); }
.ddmenu button.on { background: var(--hov); color: var(--accent); }
.ddmenu button.more { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 3px; border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; background: var(--panel); color: var(--dim); }
.ddmenu button.more:hover, .ddmenu button.more:active { color: var(--accent); }
.ddmenu button.more svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.gentray .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gentray .btn.pri { padding: 12px; }
/* The "similar in structure only" notice: a quiet info box with a bold lead. */
.gentray .note.fine { display: flex; gap: 9px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel2) 55%, transparent); line-height: 1.4; text-wrap: pretty; }
.gentray .note.fine i { flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--dim); font: 700 10px/13px var(--mono); text-align: center; font-style: normal; color: var(--dim); }
.gentray .note.fine b { color: var(--text); font-weight: 600; }
.gentray .note.left { text-align: center; font-weight: 600; margin-top: -4px; } .gentray .note.left:empty { display: none; }
.bench { display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }
.canvas { position: relative; flex: 1; min-height: 0; border-radius: 16px; border: 1px solid var(--line); background: radial-gradient(circle at 50% 45%, #141b2e, #0b0f18 78%); display: grid; place-items: center; overflow: hidden; }
.canvas > svg { width: 100%; height: 100%; }
.canvas .hint { color: var(--dim); text-align: center; padding: 20px; max-width: 320px; }
/* Shown over the canvas while Generate builds a structure and makes sure it is new. */
.canvas .building { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 6px; border-radius: inherit; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(5px); animation: fadein .15s; }
.canvas .building b { font-size: 15px; } .canvas .building span { color: var(--dim); font-size: 12.5px; }
.building .atoms { position: relative; width: 84px; height: 84px; margin-bottom: 6px; animation: rot 2.4s linear infinite; }
.building .atoms::before { content: ""; position: absolute; inset: 14px; border: 2px solid var(--line); border-radius: 50%; }
.building .atoms i { position: absolute; width: 18px; height: 18px; border-radius: 50%; left: 33px; top: 33px; background: var(--accent); box-shadow: 0 0 14px -2px currentColor; animation: bondin 1.2s ease-in-out infinite alternate; }
.building .atoms i:nth-child(1) { --x: 0px; --y: -28px; }
.building .atoms i:nth-child(2) { --x: 28px; --y: 0px; background: var(--accent2); animation-delay: .15s; }
.building .atoms i:nth-child(3) { --x: 0px; --y: 28px; background: #ff7a70; animation-delay: .3s; }
.building .atoms i:nth-child(4) { --x: -28px; --y: 0px; background: #7aa2ff; animation-delay: .45s; }
@keyframes bondin { from { transform: translate(0, 0) scale(.5); opacity: .4; } to { transform: translate(var(--x), var(--y)) scale(1); opacity: 1; } }
@keyframes fadein { from { opacity: 0; } }
.site { cursor: pointer; }
.site circle { fill: #0b0f18; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 2.5; }
.site path { stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; }
.site:hover circle { fill: #12324a; }
.site.sel circle { fill: var(--accent); stroke-dasharray: none; animation: pulse 1.3s infinite; }
.site.sel path { stroke: #061018; }
@keyframes pulse { 50% { stroke-width: 6; stroke-opacity: 0.3; } }
.live { position: absolute; left: 12px; bottom: 10px; right: 12px; display: flex; justify-content: center; gap: min(12px, 2vw); font: min(12px, 2.7vw) var(--mono); color: var(--dim); white-space: nowrap; overflow: hidden; pointer-events: none; }
.live b { color: var(--text); font-weight: 600; }
.actions { display: flex; gap: 8px; }
.actions .btn { flex: 1; padding: 11px 8px; }
.actions .btn.pri { flex: 1.6; }
.gen .actions .btn { flex: 1.3; }
.actions .btn.icon { flex: none; width: 46px; padding: 0; display: grid; place-items: center; }
.actions .btn.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.actions .btn.icon circle { fill: currentColor; stroke: none; }

/* ---- result modal ----------------------------------------------------------- */
#modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(4, 6, 10, 0.78); backdrop-filter: blur(6px); }
#modal[hidden] { display: none; }
.sheet { width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; animation: pop 0.25s; }
.sheet .row.wrap { flex-wrap: wrap; }
.sheet .row.wrap .btn { flex: 1 1 auto; text-align: center; }
.sheet h2 { overflow-wrap: anywhere; }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } }
/* The discovery sheet is a fixed card that never scrolls; extra detail sits behind its tabs. */
.sheet.disc { display: flex; flex-direction: column; height: min(640px, calc(100dvh - 32px)); overflow: hidden; }
.sheet.disc > * { flex: none; }
.sheet.disc { touch-action: none; overscroll-behavior: contain; padding-top: 8px; user-select: none; -webkit-user-select: none; }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto -4px; }
.sheet .x { border: 1px solid var(--line); background: var(--well); color: var(--dim); width: 32px; height: 32px; border-radius: 50%; font-size: 14px; line-height: 1; cursor: pointer; flex: none; }
.sheet .x:hover { color: var(--text); }
.sheet.disc .pic { position: relative; overflow: hidden; }
.sheet.disc .pic .view { position: absolute; top: 8px; right: 8px; z-index: 2; padding: 5px 11px; font-size: 12.5px; }
.sheet.disc .pic.d3 img, .sheet.disc .pic:not(.d3) .spin3d { display: none; }
.sheet.disc .seg { display: flex; } .sheet.disc .seg button { flex: 1; padding: 6px 4px; }
.sheet.disc section { display: none; flex: 1; min-height: 0; overflow: hidden; flex-direction: column; gap: 10px; }
.sheet.disc section.on { display: flex; }
.sheet.disc section > * { flex: none; }
.sheet.disc section .pic { flex: 1; min-height: 0; max-height: none; aspect-ratio: auto; }
.sheet.disc section .panel { padding: 12px; }
.sheet.disc section .panel.fill { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sheet.disc section .list { flex: 1; min-height: 0; overflow: hidden; grid-template-rows: repeat(5, minmax(0, 1fr)); }
.sheet.disc section .item { min-height: 0; overflow: hidden; padding-block: 4px; }
.sheet.disc section .item img { height: 100%; max-height: 46px; width: auto; aspect-ratio: 1; }
.sheet.disc h2 { overflow-wrap: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sheet .pic { border-radius: 14px; aspect-ratio: 4 / 3; max-height: 34dvh; width: 100%; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--rc) 20%, #0e1320), #0c101a 75%); display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--rc) 40%, var(--line)); }
.sheet .pic img { width: 100%; height: 100%; object-fit: contain; }
.banner { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--rc, var(--accent)); }
.meter { display: grid; grid-template-columns: 86px 1fr 30px; align-items: center; gap: 10px; font-size: 13px; }
.meter b { font-family: var(--mono); text-align: right; }
.spin { width: 54px; height: 54px; margin: 10px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.rewards { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 99px; background: var(--well); border: 1px solid var(--line); font: 600 12px var(--mono); }

/* ---- molecule page ---------------------------------------------------------- */
.mol { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.mol .head, .mol .subtabs { grid-column: 1 / -1; margin: 0; }
.mol .subtabs { display: none; }
.mol section { display: grid; gap: 12px; min-width: 0; }
.mol .hero { border-radius: 16px; aspect-ratio: 4 / 3; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--rc) 18%, #0e1320), #0b0f18 78%); border: 1px solid color-mix(in srgb, var(--rc) 45%, var(--line)); display: grid; place-items: center; box-shadow: 0 20px 60px -40px var(--rc); min-height: 0; }
.mol .hero { position: relative; overflow: hidden; }
.mol .hero img { position: absolute; inset: 0; width: 100%; height: 100%; padding: 4%; object-fit: contain; object-position: center; }
.spin3d { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.spin3d:active { cursor: grabbing; }
.canvas .view { position: absolute; top: 10px; right: 10px; z-index: 2; padding: 5px 11px; font-size: 12.5px; }
.human { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(4px); }
.lock { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; }
.lock .bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.lock .bar i { display: block; height: 100%; background: var(--accent); }
.lock span { color: var(--dim); }
.packs[hidden] { display: none; }
.cbar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.cbar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .6s ease; animation: cpulse 1.6s ease-in-out infinite; }
@keyframes cpulse { 50% { opacity: .55; } }
.csteps { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 7px; font-size: 13px; }
.csteps li { display: grid; grid-template-columns: 18px 1fr; column-gap: 8px; align-items: baseline; color: var(--fine); }
.csteps li::before { content: "○"; text-align: center; }
.csteps li b { font-weight: 500; }
.csteps li span { grid-column: 2; font-size: 12px; color: var(--dim); }
.csteps li.done { color: var(--dim); }
.csteps li.done::before { content: "✓"; color: var(--good); }
.csteps li.now { color: var(--text); }
.csteps li.now::before { content: "●"; color: var(--accent); animation: cpulse 1.2s ease-in-out infinite; }
.csteps li.now b { font-weight: 600; }
.canvas .pcok { position: absolute; top: 12px; left: 12px; z-index: 2; pointer-events: none; font: 600 11px var(--mono); color: var(--accent); white-space: nowrap; }
.canvas .tip { position: absolute; top: 34px; left: 0; right: 0; text-align: center; pointer-events: none; color: var(--dim); font-size: 12.5px; transition: opacity .4s; }
.canvas.used .tip { opacity: 0; }
.mol .hero.has3d:not(.flat) img, .mol .hero.flat .spin3d, .mol .hero.flat .hint, .mol .hero.flat .cap, .mol .hero:not(.has3d) .view { display: none; }
.mol .hero .view { position: absolute; top: 10px; right: 10px; z-index: 2; padding: 5px 11px; font-size: 12.5px; }
.mol .hero .hint, .mol .hero .cap { position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; color: var(--dim); }
.mol .hero .hint { top: 12px; font-size: 12.5px; transition: opacity .4s; }
.mol .hero.used .hint { opacity: 0; }
.mol .hero .cap { bottom: 8px; font-size: 11px; opacity: .75; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--dim); } .kv dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.big { font: 600 26px var(--mono); color: var(--gold); }
.list { display: grid; gap: 6px; align-content: start; }
.item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: var(--well); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; min-width: 0; color: var(--text); }
.item img { width: 46px; height: 46px; border-radius: 7px; background: #e9edf5; flex: none; }
.item .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.item .s { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .v { margin-left: auto; font: 600 12.5px var(--mono); white-space: nowrap; padding-left: 6px; }
.graph { width: 100%; aspect-ratio: 3 / 2; background: #0c1019; border: 1px solid var(--line); border-radius: 12px; min-height: 0; }
.graph text { fill: var(--dim); font: 10px 'Space Grotesk', sans-serif; pointer-events: none; }
.graph circle { cursor: pointer; }
.note { font-size: 12px; color: var(--dim); }
.tabs2 { display: grid; gap: 16px; }

/* ---- toasts ----------------------------------------------------------------- */
#toasts { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 10px; font-size: 14px; animation: pop 0.2s; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.toast.err { border-left-color: var(--bad); }

/* ---- mobile: one fixed screen, bottom navigation, nothing scrolls ------------- */
@media (max-width: 820px) {
  html, body { overflow: hidden; position: fixed; inset: 0; overscroll-behavior: none; touch-action: manipulation; }
  #app { grid-template-columns: 1fr; grid-template-rows: 46px minmax(0, 1fr) calc(58px + env(safe-area-inset-bottom)); }
  #side { display: none; }
  #top { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--bar); }
  #top .logo { font-size: 17px; } #top .logo img { width: 24px; height: 24px; }
  #topstats { display: flex; margin-left: auto; gap: 10px; font: 600 12px var(--mono); }
  #topme, #topinfo, #top .theme { flex: none; width: 32px; height: 32px; margin-left: 10px; display: grid; place-items: center; border-radius: 50%; color: var(--dim);
    background: var(--panel2); border: 1px solid var(--line); }
  #topme svg, #topinfo svg, #top .theme svg { width: 17px; height: 17px; }
  #topme, #topinfo { margin-left: 8px; }
  #topstats { white-space: nowrap; gap: 8px; }
  @media (max-width: 380px) { #topme, #topinfo, #top .theme { width: 29px; height: 29px; margin-left: 6px; } #top .logo { font-size: 16px; gap: 6px; } #top { padding: 0 10px; } }
  #topme.on, #topinfo.on { color: var(--accent); border-color: var(--accent); }
  #view { overflow: hidden; padding: 10px 12px; display: flex; flex-direction: column; }
  #view > * { flex: 1; min-height: 0; }
  #tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--bar); padding-bottom: env(safe-area-inset-bottom); }
  #tabs a { flex-direction: column; gap: 2px; justify-content: center; font-size: 10.5px; padding: 0; border-radius: 0; }
  #tabs a.on { color: var(--accent); }
  #tabs svg { width: 21px; height: 21px; }
  h1 { font-size: 19px; }
  .page { display: flex; flex-direction: column; gap: 9px; }
  .head { margin: 0; gap: 8px; flex: none; }
  .head .sub { display: none; }
  .grid { flex: 1; min-height: 0; gap: 9px; overflow: hidden; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 2), minmax(0, 1fr)); }
  .card:hover { transform: none; }
  .card .pic { aspect-ratio: auto; flex: 1; }
  .card .meta { padding: 6px 9px 7px; flex: none; }
  .pager { display: flex; align-items: center; justify-content: center; gap: 14px; flex: none; font: 12px var(--mono); color: var(--dim); }
  .pager .btn { padding: 5px 16px; }
  .list { flex: 1; min-height: 0; overflow: hidden; grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr)); }
  .lab { display: flex; flex-direction: column; gap: 8px; height: auto; min-height: 0; }
  .lab .head { display: none; }
  .bench { order: 1; flex: 1; gap: 8px; }
  .tray { order: 2; flex: none; gap: 6px; }
  .gentray { order: 2; flex: none; gap: 7px; }
  .gentray .note { font-size: 11px; }
  .tray .frags { flex: none; height: 136px; overflow: hidden; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 0; }
  .frag { height: auto; }
  .tray .seg { flex: 1; } .tray .seg button { flex: 1; padding: 6px 4px; }
  .tray .pager .btn { padding: 4px 11px; }
  .actions .btn { padding: 11px 4px; font-size: 14px; }
  .sheet { padding: 16px; gap: 10px; }
  .mol { display: flex; flex-direction: column; align-items: stretch; gap: 9px; }
  .mol .subtabs { display: flex; flex: none; width: 100%; } .mol .subtabs button { flex: 1; padding: 6px 2px; }
  .mol section { display: none; }
  .mol section.on { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 9px; }
  .mol .hero { aspect-ratio: auto; flex: 1; }
  .mol .panel { padding: 11px; }
  .graph { aspect-ratio: auto; flex: 1; }
  .kv { font-size: 12.5px; gap: 3px 12px; }
  .tabs2 { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 9px; }
  .tabs2 > .panel { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 9px; padding: 11px; }
  .big { font-size: 21px; }
  .seg button { padding: 6px 9px; }
  #toasts { bottom: 74px; }
  .hide-m { display: none !important; }
}
@media (min-width: 821px) { .hide-d { display: none !important; } }

/* Novelty class scale (How it works, molecule page) */
.scale { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 6px; padding-top: 6px; }
.scale span { display: grid; gap: 1px; padding: 6px 8px; border-radius: 9px; border: 1px solid var(--line); font-size: 12px; }
.scale b { color: var(--rc); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.scale i { font-style: normal; color: var(--dim); font-size: 11px; }
/* Nearest known compound: a small card with the name and a similarity pill. */
.near { display: grid; gap: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel2) 60%, transparent); }
.near .cap { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.near .nm { display: flex; align-items: center; gap: 10px; }
.near .nm b { flex: 1; min-width: 0; color: var(--text); font-size: 13.5px; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.near .pct { flex: none; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; color: var(--text); white-space: nowrap; }
.scale span { position: relative; opacity: .45; }
.scale span.on { opacity: 1; border-color: var(--rc); background: color-mix(in srgb, var(--rc) 12%, transparent); }
.scale em { position: absolute; top: -11px; right: 6px; padding: 1px 7px; border-radius: 99px; background: var(--rc); color: var(--bg); font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

/* ---- sign-in code --------------------------------------------------------- */
.field.code { font: 600 26px/1.2 var(--mono); letter-spacing: 0.3em; text-align: center; padding: 12px; }
.field.code::placeholder { color: var(--ph); }

/* ---- buy CULE --------------------------------------------------------------- */
.packs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pack { display: grid; gap: 2px; padding: 12px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--well); cursor: pointer; text-align: center; }
.pack b { color: var(--gold); font-size: 16px; } .pack span { color: var(--dim); font-size: 13px; }
.pack.on { border-color: var(--accent); background: var(--panel2); }
/* Payment asset: equal-width cards in the same style as the packs. */
.packs.assets { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; grid-auto-columns: 1fr; }
.packs.assets .pack { padding: 10px 6px; } .packs.assets .pack b { color: var(--text); font-size: 15px; }
.pay { word-break: break-all; background: var(--well); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; user-select: all; }
.orow { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--well); cursor: pointer; font-size: 13px; text-align: left; }

/* ---- landing (nobody signed in) ------------------------------------------------ */
body.out #side, body.out #top, body.out #tabs { display: none !important; }
body.out #app { display: block; }
body.out #view { display: block; height: 100dvh; padding: 0; overflow-y: auto; }
.land { max-width: 1040px; margin: 0 auto; padding: 26px 24px 40px; display: grid; gap: 22px; }
.land-hero { display: grid; grid-template-columns: 1fr 380px; gap: 26px 44px; align-items: start; padding: 4vh 0 1vh;
  grid-template-areas: "pitch card" "steps card"; }
.land-pitch { grid-area: pitch; display: grid; gap: 14px; }
.land-pitch h1 { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.08; letter-spacing: -0.02em; }
.land-pitch p { margin: 0; font-size: 17px; max-width: 46ch; }
.land-card { grid-area: card; padding: 22px; box-shadow: 0 20px 60px -30px var(--accent2); }
.land-card h2 { font-size: 19px; }
.land-steps { grid-area: steps; list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.land-steps li { display: flex; gap: 14px; align-items: baseline; }
.land-steps .mono { font-weight: 600; color: var(--c); }
.land-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.land-grid .card:hover { transform: none; }
.land-tabs, .land-foot { display: none; }
.land-terms { display: grid; gap: 10px; }
.land-terms p { margin: 0; }
.land-terms b { color: var(--text); }
.land-terms a { color: var(--accent); }
@media (max-width: 820px) {
  /* One locked screen: nothing scrolls, the tabs swap the lower half. */
  body.out #view { overflow: hidden; overscroll-behavior: none; }
  .land { height: 100dvh; padding: 16px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
  .land-hero { display: contents; }
  .land-pitch { gap: 9px; }
  .land-pitch h1 { font-size: clamp(23px, 7vw, 30px); }
  .land-pitch p { font-size: 14.5px; }
  .land-tabs { display: flex; flex: none; width: 100%; } .land-tabs button { flex: 1 1 auto; padding: 8px 2px; font-size: 13px; white-space: nowrap; }
  .land > *, .land-hero > * { min-width: 0; }
  .land-card { padding: 16px; grid-template-columns: minmax(0, 1fr); }
  .land-card .row { gap: 8px; } .land-card .row .btn { min-width: 0; padding: 9px 4px; font-size: 13.5px; white-space: normal; }
  .land-steps { flex: 0 1 372px; min-height: 0; gap: 10px; grid-auto-rows: minmax(0, 1fr); }
  .land-steps li { align-items: center; gap: 14px; padding: 10px 14px; min-height: 0; background: var(--panel); border: 1px solid var(--line);
    border-left: 3px solid var(--c); border-radius: 14px; }
  .land-steps .mono { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; font-size: 15px;
    background: color-mix(in srgb, var(--c) 14%, transparent); }
  .land-steps b { font-size: 16px; } .land-steps .dim { font-size: 13.5px; line-height: 1.4; margin-top: 2px; }
  .land-terms { margin: 0; padding: 6px 2px; font-size: 13px; line-height: 1.5; flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .land-foot { display: block; margin: auto 0 0; text-align: center; }
  .land-terms { padding-right: 8px; }
  .land > h3, .land-grid { display: none; }
  .land:not([data-tab="in"]) .land-card, .land:not([data-tab="how"]) .land-steps, .land:not([data-tab="terms"]) .land-terms:not(.land-chain), .land:not([data-tab="chain"]) .land-chain { display: none !important; }
}
@media (max-width: 820px) and (max-height: 640px) {
  .land { gap: 10px; padding-top: 12px; }
  .land-pitch p, .land-pitch .banner, .land-card .note:last-child { display: none; }
  .land-pitch h1 { font-size: 21px; }
  .land-card { padding: 13px; gap: 8px !important; }
}

/* ---- computer notice (the game is phone only) ----------------------------------- */
body.desk #side, body.desk #top, body.desk #tabs { display: none !important; }
body.desk #app { display: block; }
body.desk #view { display: block; height: 100dvh; padding: 0; overflow: hidden; }
/* One locked screen: logo, one card (pitch + QR beside the promo video), fine print. Never scrolls. */
.desk-note { height: 100dvh; max-width: 1240px; margin: 0 auto; padding: 24px 32px 18px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 16px; overflow: hidden; }
.desk-card { align-self: center; min-height: 0; max-height: 100%; display: grid; grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr); gap: clamp(28px, 3.5vw, 48px); align-items: center;
  padding: clamp(24px, 3.5vh, 40px); border-radius: 22px; border: 1px solid var(--line);
  background: radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--accent2) 16%, transparent), transparent 60%), var(--panel); box-shadow: 0 30px 80px -50px var(--accent2); }
.desk-text { display: grid; gap: clamp(10px, 1.8vh, 16px); align-content: center; }
.desk-text h1 { font-size: clamp(26px, min(3vw, 4.6vh), 40px); line-height: 1.08; letter-spacing: -0.02em; }
.desk-text p { margin: 0; font-size: clamp(14px, 1.9vh, 16px); max-width: 44ch; }
.desk-link { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.desk-link a { font: 600 20px var(--mono); color: var(--accent); text-decoration: none; }
.desk-link a:hover { text-decoration: underline; }
.desk-qr { display: flex; gap: 14px; align-items: center; margin-top: 2px; }
.desk-qr img { display: block; flex: none; width: clamp(96px, 15vh, 132px); height: auto; aspect-ratio: 1; padding: 8px; background: #fff; border-radius: 14px; image-rendering: pixelated; }
.desk-qr span { font-size: 12.5px; color: var(--dim); max-width: 18ch; }
.desk-note .fine { text-align: center; margin: 0; }
.desk-video { margin: 0; min-width: 0; display: grid; gap: 8px; justify-items: center; }
/* As wide as the column allows, but never taller than the screen leaves room for. */
.desk-video video { display: block; width: min(100%, calc((100dvh - 230px) * 16 / 9)); height: auto; aspect-ratio: 16 / 9; border-radius: 16px; border: 1px solid var(--line);
  background: #e9edf6; }
.desk-video figcaption { font-size: 12.5px; color: var(--dim); }

/* ---- theme toggle ----------------------------------------------------------------- */
.theme { padding: 0; cursor: pointer; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--dim);
  background: var(--panel2); border: 1px solid var(--line); }
.theme svg { width: 17px; height: 17px; }
.theme .moon, :root[data-theme="light"] .theme .sun { display: none; }
:root[data-theme="light"] .theme .moon { display: block; }
.theme.float { position: absolute; top: 14px; right: 16px; z-index: 2; }
.land, .desk-note { position: relative; }
/* light windows: stored drawings are light on dark, so in the light theme they are flipped to dark on light (hues kept) */
:root[data-theme="light"] :is(.card .pic, .sheet .pic, .mol .hero) { background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--rc) 13%, #fff), #edf0f7 78%); }
:root[data-theme="light"] .canvas { background: radial-gradient(circle at 50% 45%, #fff, #e9edf6 78%); }
:root[data-theme="light"] .frag, :root[data-theme="light"] .graph { background: var(--well); }
:root[data-theme="light"] .frag.t2 { border-color: #b5dcc8; }
:root[data-theme="light"] .frag.t3 { border-color: #b9c9ee; }
:root[data-theme="light"] .frag.t4 { border-color: #d8c2ee; }
:root[data-theme="light"] :is(.pic, .hero, .item) > img[src^="/api/svg"] { filter: invert(1) hue-rotate(180deg); }
:root[data-theme="light"] .site circle { fill: #fff; }
:root[data-theme="light"] .site:hover circle { fill: #d6f0f7; }
:root[data-theme="light"] .site.sel circle { fill: var(--accent); }
:root[data-theme="light"] .site.sel path { stroke: #fff; }
:root[data-theme="light"] .land-card, :root[data-theme="light"] .desk-card { box-shadow: 0 18px 50px -34px #4a3a8a; }
.actions .btn.pri:disabled { background: var(--panel2); border: 1px solid var(--line); color: var(--dim); opacity: .7; }
