/* ============================================================
   The Interactive Periodic Table — styles
   ============================================================ */

:root {
  --bg: #070912;
  --bg-2: #0c1022;
  --panel: rgba(18, 23, 44, 0.72);
  --panel-solid: #11152b;
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-soft: rgba(255, 255, 255, 0.06);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --muted-2: #6b7299;

  --c-alkali-metal: #ff6b6b;
  --c-alkaline-earth-metal: #ffa94d;
  --c-transition-metal: #ffd43b;
  --c-post-transition-metal: #69db7c;
  --c-metalloid: #38d9a9;
  --c-reactive-nonmetal: #4dabf7;
  --c-noble-gas: #b197fc;
  --c-lanthanide: #f783ac;
  --c-actinide: #e599f7;
  --c-unknown: #868e96;

  --radius: 16px;
  --radius-sm: 9px;
  --tile-gap: clamp(2px, 0.35vw, 6px);
  --shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 15% -10%, #1a2050 0%, transparent 55%),
    radial-gradient(1000px 600px at 95% 0%, #2a1644 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 60%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; width: 100%; height: 100%; }
.bg-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(420px 420px at 20% 30%, rgba(77, 171, 247, 0.10), transparent 70%),
    radial-gradient(380px 380px at 80% 70%, rgba(177, 151, 252, 0.10), transparent 70%),
    radial-gradient(300px 300px at 60% 15%, rgba(56, 217, 169, 0.07), transparent 70%);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(0, -28px, 0) scale(1.06); } }

main, .site-header, .site-footer, .compare-tray { position: relative; z-index: 1; }
a { color: #9ec1ff; }

/* ---------- header ---------- */
.site-header { padding: clamp(26px, 5vw, 60px) 20px 8px; text-align: center; }
.header-inner { max-width: 1240px; margin: 0 auto; }

.title {
  font-family: "Sora", sans-serif; font-weight: 800;
  font-size: clamp(2rem, 6vw, 4rem); letter-spacing: -0.02em; margin: 0; line-height: 1.02;
}
.title-mark { display: inline-block; animation: spin 14s linear infinite; filter: drop-shadow(0 0 18px rgba(120, 160, 255, 0.6)); }
@keyframes spin { to { transform: rotate(360deg); } }
.grad { background: linear-gradient(100deg, #6ea8ff, #b197fc 45%, #ff8fc7); -webkit-background-clip: text; background-clip: text; color: transparent; }
.subtitle { color: var(--muted); font-size: clamp(0.92rem, 1.6vw, 1.12rem); margin: 14px auto 0; max-width: 640px; }

/* ---------- fact bar ---------- */
.fact-bar {
  display: inline-flex; align-items: center; gap: 12px;
  max-width: 720px; margin: 22px auto 0; padding: 11px 16px;
  background: linear-gradient(100deg, rgba(110,168,255,0.12), rgba(177,151,252,0.10));
  border: 1px solid var(--stroke); border-radius: 999px; backdrop-filter: blur(10px);
}
.fact-ico { font-size: 1.05rem; }
.fact-text { font-size: 0.9rem; color: #dbe2ff; text-align: left; line-height: 1.35; }
.fact-shuffle {
  flex: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--stroke); background: rgba(255,255,255,0.06); color: var(--text);
  font-size: 0.95rem; transition: transform 0.4s var(--ease), background 0.2s;
}
.fact-shuffle:hover { background: rgba(255,255,255,0.14); transform: rotate(180deg); }

/* ---------- controls ---------- */
.controls { margin: 22px auto 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted-2); }
#search {
  width: min(320px, 78vw); padding: 13px 16px 13px 42px; border-radius: 999px;
  border: 1px solid var(--stroke); background: var(--panel); color: var(--text);
  font: inherit; font-size: 0.96rem; outline: none; backdrop-filter: blur(10px);
  transition: border-color 0.25s, box-shadow 0.25s;
}
#search::placeholder { color: var(--muted-2); }
#search:focus { border-color: rgba(124, 161, 255, 0.7); box-shadow: 0 0 0 4px rgba(110, 168, 255, 0.16); }

.select-wrap {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 14px;
  background: var(--panel); border: 1px solid var(--stroke); border-radius: 999px; backdrop-filter: blur(10px);
}
.select-label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
#colorBy {
  border: 0; background: transparent; color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 600;
  padding: 6px 4px; cursor: pointer; outline: none;
}
#colorBy option { background: #11152b; color: var(--text); }

.action-btns { display: inline-flex; gap: 8px; }
.abtn {
  display: inline-flex; align-items: center; gap: 7px; padding: 11px 15px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--stroke); background: var(--panel); color: var(--text);
  font: inherit; font-size: 0.88rem; font-weight: 600; backdrop-filter: blur(10px);
  transition: transform 0.18s var(--ease), background 0.25s, border-color 0.25s;
}
.abtn span { font-size: 1rem; }
.abtn:hover { transform: translateY(-2px); border-color: rgba(124,161,255,0.6); }
.abtn.is-on { background: linear-gradient(180deg, #cfe0ff, #a9c4ff); color: #0a0c18; border-color: transparent; }

.temp-control { max-width: 540px; margin: 18px auto 0; background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 16px 20px; backdrop-filter: blur(10px); }
.temp-control label { font-size: 0.92rem; color: var(--muted); }
.temp-control strong { color: var(--text); font-variant-numeric: tabular-nums; }
#tempRange { width: 100%; margin: 12px 0 4px; accent-color: #6ea8ff; }
.temp-ticks { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted-2); }

/* heatmap legend */
.heat-legend[hidden] { display: none; }
.heat-legend { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 18px auto 0; font-size: 0.8rem; color: var(--muted); flex-wrap: wrap; }
.heat-bar { width: min(360px, 60vw); height: 12px; border-radius: 999px; border: 1px solid var(--stroke);
  background: linear-gradient(90deg, #2c1e8c, #2667ce 25%, #1fb6a6 50%, #f2c14e 75%, #ef5d4e); }
.heat-min, .heat-max { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.heat-unit { color: var(--muted-2); }

/* ---------- legend ---------- */
.legend { max-width: 1200px; margin: 24px auto 16px; padding: 0 16px; display: flex; flex-wrap: wrap; gap: 8px 10px; justify-content: center; }
.legend-item {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--stroke-soft); font-size: 0.82rem; color: var(--muted); font-weight: 500;
  transition: transform 0.2s, color 0.2s, border-color 0.2s, background 0.2s; user-select: none;
}
.legend-item:hover { transform: translateY(-2px); color: var(--text); }
.legend-item .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--lc); box-shadow: 0 0 10px var(--lc); }
.legend-item.is-active { color: #0a0c18; background: var(--lc); border-color: transparent; font-weight: 700; }
.legend-item.is-active .dot { background: #0a0c18; box-shadow: none; }
.legend.dimmed { opacity: 0.4; pointer-events: none; }

/* ---------- the table ---------- */
.table-scroll { width: 100%; overflow-x: auto; padding: 6px 16px 26px; -webkit-overflow-scrolling: touch; }
.ptable {
  display: grid;
  grid-template-columns: 24px repeat(18, minmax(46px, 1fr));
  grid-template-rows: 16px repeat(10, 1fr); gap: var(--tile-gap);
  max-width: 1300px; margin: 0 auto; min-width: 900px;
}
/* axis labels */
.axis { display: flex; align-items: center; justify-content: center; font-size: 0.64rem; color: var(--muted-2); font-weight: 600; }
.axis-row1 { aspect-ratio: auto; }

/* element tile */
.el {
  --c: var(--c-unknown);
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 26%, #0d1124) 0%, color-mix(in srgb, var(--c) 8%, #0b0e1d) 100%);
  color: var(--text); cursor: pointer; padding: 5px 4px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow: hidden;
  transition: transform 0.18s var(--ease), box-shadow 0.25s, border-color 0.25s, opacity 0.3s, filter 0.3s, background 0.4s;
  will-change: transform;
}
.el.enter { animation: tileIn 0.5s var(--ease) both; }
@keyframes tileIn { from { opacity: 0; transform: translateY(12px) scale(0.9); } to { opacity: 1; transform: none; } }
.el::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--c) 35%, transparent), transparent 60%); opacity: 0.5; transition: opacity 0.25s; }
.el > * { position: relative; z-index: 1; }
.el .num { font-size: 0.6rem; color: color-mix(in srgb, var(--c) 70%, #fff); font-weight: 600; line-height: 1; align-self: flex-start; opacity: 0.95; }
.el .sym { font-family: "Sora", sans-serif; font-weight: 700; font-size: clamp(0.95rem, 1.5vw, 1.45rem); line-height: 1.05; margin: 1px 0; letter-spacing: -0.01em; }
.el .nm { font-size: 0.5rem; color: var(--muted); line-height: 1.05; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.el .ms { font-size: 0.46rem; color: var(--muted-2); line-height: 1; margin-top: 1px; }
.el .hval { font-size: 0.5rem; color: #fff; font-weight: 700; line-height: 1; margin-top: 1px; opacity: 0; height: 0; }
.ptable.heat .el .hval { opacity: 0.95; height: auto; }
.ptable.heat .el .nm, .ptable.heat .el .ms { opacity: 0.45; }

.el:hover, .el:focus-visible {
  transform: translateY(-5px) scale(1.06); border-color: var(--c);
  box-shadow: 0 14px 34px -10px color-mix(in srgb, var(--c) 60%, transparent), 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent);
  z-index: 5; outline: none;
}
.el:hover::before { opacity: 0.95; }
.el.no-data { --c: #3a4060; opacity: 0.5; }

/* placeholder cells */
.series-link {
  display: flex; align-items: center; justify-content: center; font-size: 0.56rem; text-align: center; color: var(--muted);
  border: 1px dashed var(--stroke); border-radius: var(--radius-sm); aspect-ratio: 1/1; background: rgba(255,255,255,0.015); line-height: 1.1; padding: 4px;
}

/* filtered states */
.ptable.is-filtering .el { opacity: 0.16; filter: grayscale(0.6) brightness(0.8); }
.ptable.is-filtering .el.match { opacity: 1; filter: none; transform: translateY(-2px); }
.el.search-hit { box-shadow: 0 0 0 2px #fff, 0 0 24px 2px var(--c); }

/* discovery timeline */
.el.year-hidden { opacity: 0.08; filter: grayscale(1) brightness(0.6); pointer-events: none; transform: scale(0.94); }

/* compare selection */
.el.cmp-pick { box-shadow: 0 0 0 3px #fff, 0 0 26px 2px var(--c); transform: translateY(-3px) scale(1.04); z-index: 6; }
.ptable.compare-mode .el:hover { transform: translateY(-3px) scale(1.05); }

/* state badges */
.el .phase-dot { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; z-index: 2; opacity: 0; transition: opacity 0.3s; }
.ptable.show-state .el .phase-dot { opacity: 1; }
.phase-solid { background: #8aa0c0; box-shadow: 0 0 6px #8aa0c0; }
.phase-liquid { background: #4dabf7; box-shadow: 0 0 8px #4dabf7; }
.phase-gas { background: #ff8f6b; box-shadow: 0 0 8px #ff8f6b; }
.ptable.show-state .el.is-liquid { border-color: #4dabf7; }
.ptable.show-state .el.is-gas { border-color: #ff8f6b; }

/* ---------- modal ---------- */
.modal-overlay[hidden] { display: none; }
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: rgba(4, 6, 14, 0.66); backdrop-filter: blur(8px); animation: fade 0.25s var(--ease); }
.modal-overlay.closing { animation: fade 0.2s var(--ease) reverse; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal { position: relative; width: min(920px, 96vw); max-height: 92vh; overflow-y: auto; border-radius: var(--radius); border: 1px solid var(--stroke); background: var(--panel-solid); box-shadow: var(--shadow); animation: pop 0.34s var(--ease); }
.modal-wide { width: min(1020px, 97vw); }
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-overlay.closing .modal { animation: pop 0.2s var(--ease) reverse; }

.modal-close { position: absolute; top: 14px; right: 14px; z-index: 6; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--stroke); background: rgba(10, 12, 26, 0.6); color: var(--text); font-size: 1rem; cursor: pointer; display: grid; place-items: center; transition: background 0.2s, transform 0.2s; }
.modal-close:hover { background: rgba(255,255,255,0.12); transform: rotate(90deg); }

.m-hero { --c: var(--c-unknown); position: relative; padding: 30px 30px 24px; display: grid; grid-template-columns: 150px 1fr; gap: 26px; align-items: center;
  background: radial-gradient(140% 120% at 0% 0%, color-mix(in srgb, var(--c) 30%, transparent), transparent 55%), linear-gradient(180deg, color-mix(in srgb, var(--c) 12%, transparent), transparent); border-bottom: 1px solid var(--stroke-soft); }
.m-badge { position: relative; width: 150px; height: 150px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 32%, #0d1124), color-mix(in srgb, var(--c) 8%, #0b0e1d)); box-shadow: 0 0 40px -6px color-mix(in srgb, var(--c) 55%, transparent); }
.m-badge .b-num { position: absolute; top: 10px; left: 12px; font-size: 0.85rem; color: color-mix(in srgb, var(--c) 75%, #fff); font-weight: 600; }
.m-badge .b-sym { font-family: "Sora", sans-serif; font-weight: 800; font-size: 3.4rem; line-height: 1; }
.m-badge .b-mass { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.m-headtext h2 { font-family: "Sora", sans-serif; font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 0 0 6px; letter-spacing: -0.02em; }
.m-cat { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 600; color: #0a0c18; background: var(--c); padding: 5px 12px; border-radius: 999px; text-transform: capitalize; }
.m-quickfacts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; color: var(--muted); font-size: 0.86rem; }
.m-quickfacts b { color: var(--text); font-weight: 600; }
.m-didyouknow { grid-column: 1 / -1; margin-top: 4px; font-size: 0.9rem; color: #dbe2ff; background: rgba(255,255,255,0.04); border: 1px solid var(--stroke-soft); border-radius: 10px; padding: 10px 14px; }
.m-didyouknow b { color: #ffd87a; }

.m-content { padding: 8px 30px 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.m-section { min-width: 0; }
.m-section h3 { font-family: "Sora", sans-serif; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted-2); margin: 22px 0 12px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.m-summary { grid-column: 1 / -1; }
.m-summary p { line-height: 1.65; color: #d6dcf5; margin: 0; font-size: 0.98rem; }

.m-photo { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--stroke); background: #0a0c18; aspect-ratio: 4 / 3; }
.m-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.6s var(--ease); }
.m-photo:hover img { transform: scale(1.07); }
.m-photo .attr { position: absolute; bottom: 0; left: 0; right: 0; padding: 14px 12px 7px; font-size: 0.66rem; color: rgba(255,255,255,0.78); line-height: 1.3; background: linear-gradient(180deg, transparent, rgba(0,0,0,0.82)); }
.m-photo .attr a { color: #cfe0ff; }
.m-photo .ph-fallback { position: absolute; inset: 0; display: none; place-items: center; flex-direction: column; color: var(--muted); font-size: 0.85rem; text-align: center; gap: 6px; padding: 16px; }
.m-photo.no-img img { display: none; }
.m-photo.no-img .ph-fallback { display: grid; }

.props { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.prop { background: rgba(255,255,255,0.03); border: 1px solid var(--stroke-soft); border-radius: 10px; padding: 10px 12px; }
.prop .k { font-size: 0.68rem; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.06em; }
.prop .v { font-size: 0.98rem; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.prop.wide { grid-column: 1 / -1; }

/* ---------- atom model ---------- */
.atom-tools { display: inline-flex; gap: 4px; padding: 3px; background: rgba(255,255,255,0.05); border-radius: 999px; border: 1px solid var(--stroke-soft); }
.atom-tools button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.72rem; font-weight: 700; padding: 4px 11px; border-radius: 999px; cursor: pointer; }
.atom-tools button.on { background: var(--text); color: #0a0c18; }

.atom-stage { perspective: 900px; }
.atom { position: relative; width: 100%; aspect-ratio: 1/1; max-width: 320px; margin: 0 auto; transform-style: preserve-3d; transition: transform 0.5s var(--ease); }
.atom.is-3d { animation: atomspin 18s linear infinite; }
@keyframes atomspin { to { transform: rotateX(-18deg) rotateY(360deg); } }
.atom .nucleus { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 17%; height: 17%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--c)); box-shadow: 0 0 24px 4px color-mix(in srgb, var(--c) 70%, transparent); display: grid; place-items: center; font-size: 0.72rem; font-weight: 800; color: #0a0c18; z-index: 3; }
.atom .shell { position: absolute; inset: 0; margin: auto; transform-style: preserve-3d; }
.atom.is-3d .shell { transform: rotateX(var(--tx, 0deg)) rotateY(var(--ty, 0deg)); }
.atom .ring { position: absolute; inset: 0; margin: auto; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--c) 32%, transparent); animation: orbit var(--dur, 16s) linear infinite; }
.atom .orbit { position: absolute; inset: 0; }
.atom .electron { position: absolute; top: -3.5px; left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: #cfe0ff; box-shadow: 0 0 8px 1px #9ec1ff; }
@keyframes orbit { to { transform: rotate(360deg); } }
.shell-counts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.shell-counts span { font-size: 0.72rem; color: var(--muted); background: rgba(255,255,255,0.04); padding: 3px 9px; border-radius: 999px; }
.econf { text-align: center; margin-top: 8px; color: var(--muted); font-size: 0.82rem; }
.econf b { color: var(--text); font-weight: 600; }

/* ---------- compare ---------- */
.compare-tray {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; z-index: 40;
  background: rgba(17,21,43,0.92); border: 1px solid var(--stroke); border-radius: 16px; box-shadow: var(--shadow); backdrop-filter: blur(12px);
}
.compare-tray[hidden] { display: none; }
.ct-hint { font-size: 0.84rem; color: var(--muted); }
.ct-slots { display: flex; gap: 8px; }
.ct-slot { width: 46px; height: 46px; border-radius: 10px; border: 1px dashed var(--stroke); display: grid; place-items: center; font-size: 0.7rem; color: var(--muted-2); }
.ct-slot.filled { border-style: solid; border-color: var(--c); background: color-mix(in srgb, var(--c) 20%, #11152b); color: var(--text); font-family: "Sora"; font-weight: 800; font-size: 1.1rem; }
.ct-go, .ct-cancel { border: 0; border-radius: 999px; font: inherit; font-weight: 700; font-size: 0.85rem; padding: 10px 16px; cursor: pointer; }
.ct-go { background: linear-gradient(180deg, #cfe0ff, #a9c4ff); color: #0a0c18; }
.ct-go:disabled { opacity: 0.4; cursor: not-allowed; }
.ct-cancel { background: rgba(255,255,255,0.08); color: var(--text); }

.cmp-head { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 28px 30px 18px; }
.cmp-card { text-align: center; }
.cmp-badge { --c: var(--c-unknown); width: 96px; height: 96px; margin: 0 auto 10px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 32%, #0d1124), color-mix(in srgb, var(--c) 8%, #0b0e1d)); box-shadow: 0 0 30px -8px color-mix(in srgb, var(--c) 55%, transparent); }
.cmp-badge .s { font-family: "Sora"; font-weight: 800; font-size: 2rem; }
.cmp-badge .n { font-size: 0.7rem; color: var(--muted); }
.cmp-card h3 { margin: 0; font-family: "Sora"; font-size: 1.1rem; }
.cmp-card .cmp-cat { font-size: 0.74rem; color: var(--muted); }
.cmp-rows { padding: 6px 30px 30px; display: flex; flex-direction: column; gap: 14px; }
.cmp-row { }
.cmp-row .lbl { font-size: 0.74rem; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.06em; text-align: center; margin-bottom: 6px; }
.cmp-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }
.cmp-bar { height: 26px; border-radius: 7px; background: rgba(255,255,255,0.05); position: relative; overflow: hidden; }
.cmp-bar.r > i { right: 0; }
.cmp-bar > i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 7px; background: linear-gradient(90deg, color-mix(in srgb, var(--c) 60%, #1a1f3a), var(--c)); transition: width 0.6s var(--ease); }
.cmp-bar .bv { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 9px; font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums; z-index: 1; }
.cmp-bar.l .bv { justify-content: flex-end; }
.cmp-bar.win::after { content: "▲"; position: absolute; top: 3px; right: 5px; font-size: 0.55rem; color: #ffd87a; z-index: 2; }

/* ---------- quiz ---------- */
.quiz { padding: 30px; text-align: center; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; padding-right: 36px; font-size: 0.85rem; color: var(--muted); }
.quiz-score b { color: #6ee7b7; font-size: 1.05rem; }
.quiz-streak b { color: #ffd87a; font-size: 1.05rem; }
.quiz-q { font-size: 1.15rem; font-weight: 600; margin: 6px 0 4px; line-height: 1.4; }
.quiz-prompt { font-family: "Sora"; font-weight: 800; font-size: clamp(2.4rem, 8vw, 3.6rem); margin: 8px 0 6px; background: linear-gradient(100deg, #6ea8ff, #b197fc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.quiz-photo { width: 200px; height: 150px; object-fit: cover; border-radius: 12px; border: 1px solid var(--stroke); margin: 8px auto; display: block; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0 8px; }
.quiz-opt { padding: 16px; border-radius: 12px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.04); color: var(--text); font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s; }
.quiz-opt:hover:not(:disabled) { transform: translateY(-3px); border-color: rgba(124,161,255,0.7); }
.quiz-opt.correct { background: linear-gradient(180deg, #2bd07f, #1fa968); color: #04140c; border-color: transparent; }
.quiz-opt.wrong { background: linear-gradient(180deg, #ff7a7a, #e64f4f); color: #1a0606; border-color: transparent; }
.quiz-opt:disabled { cursor: default; }
.quiz-next { margin-top: 16px; border: 0; border-radius: 999px; padding: 12px 26px; font: inherit; font-weight: 700; cursor: pointer; background: linear-gradient(180deg, #cfe0ff, #a9c4ff); color: #0a0c18; }
.quiz-feedback { min-height: 22px; margin-top: 12px; font-size: 0.9rem; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { text-align: center; padding: 30px 20px 90px; color: var(--muted-2); font-size: 0.82rem; }
.site-footer a { color: var(--muted); }
.site-footer kbd { background: rgba(255,255,255,0.08); border: 1px solid var(--stroke); border-radius: 5px; padding: 1px 6px; font-size: 0.75rem; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .m-hero { grid-template-columns: 110px 1fr; gap: 16px; padding: 26px 20px 20px; }
  .m-badge { width: 110px; height: 110px; }
  .m-badge .b-sym { font-size: 2.5rem; }
  .m-content { grid-template-columns: 1fr; padding: 6px 20px 26px; gap: 18px; }
  .cmp-rows { padding: 6px 18px 26px; }
  .quiz-opts { grid-template-columns: 1fr; }
  .fact-text { font-size: 0.84rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .atom .ring, .atom.is-3d { animation: none; }
  .el.enter { animation: none; }
}

.modal::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { height: 10px; width: 10px; }
.modal::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 999px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   v3 additions — nav, learn content, charts, flashcards, themes
   ============================================================ */

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: #fff; color: #0a0c18; padding: 8px 14px; border-radius: 8px; font-weight: 700; }
.skip-link:focus { left: 12px; }

/* top nav */
.topnav { display: flex; align-items: center; justify-content: space-between; max-width: 1240px; margin: 0 auto 8px; gap: 16px; }
.brand { font-family: "Sora", sans-serif; font-weight: 800; font-size: 1.05rem; color: var(--text); letter-spacing: -0.01em; }
.topnav-links { display: flex; align-items: center; gap: 6px; }
.topnav-links a { color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600; padding: 7px 12px; border-radius: 999px; transition: color 0.2s, background 0.2s; }
.topnav-links a:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.theme-btn { border: 1px solid var(--stroke); background: var(--panel); color: var(--text); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1rem; transition: transform 0.3s, background 0.2s; }
.theme-btn:hover { transform: scale(1.08); background: rgba(255,255,255,0.1); }

/* orbital diagram */
.orbitals { display: flex; flex-wrap: wrap; gap: 12px 16px; }
.orb-sub { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.orb-label { font-size: 0.74rem; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.orb-boxes { display: flex; gap: 3px; }
.orb-box { width: 22px; height: 22px; border: 1px solid color-mix(in srgb, var(--c) 50%, var(--stroke)); border-radius: 4px; display: grid; place-items: center; font-size: 0.7rem; color: var(--text); background: color-mix(in srgb, var(--c) 10%, transparent); line-height: 1; }
.orb-box.filled { background: color-mix(in srgb, var(--c) 26%, transparent); }

/* ============ Learn / content section ============ */
.content { max-width: 1100px; margin: 40px auto 0; padding: 0 20px; }
.content-inner > * { margin-bottom: 18px; }
.intro h2 { font-family: "Sora", sans-serif; font-size: clamp(1.5rem, 3.4vw, 2.2rem); letter-spacing: -0.02em; margin: 10px 0 14px; }
.intro p { color: #c7cdec; line-height: 1.75; font-size: 1.02rem; max-width: 80ch; }
.content-block { margin: 46px 0; }
.content-block > h2 { font-family: "Sora", sans-serif; font-size: clamp(1.4rem, 3vw, 2rem); margin: 0 0 6px; letter-spacing: -0.01em; }
.content-block > .sub { color: var(--muted); margin: 0 0 22px; font-size: 1rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.info-card { text-align: left; background: var(--panel); border: 1px solid var(--stroke); border-radius: 14px; padding: 18px; cursor: pointer; transition: transform 0.18s var(--ease), border-color 0.2s, background 0.2s; color: var(--text); font: inherit; }
.info-card:hover { transform: translateY(-4px); border-color: rgba(124,161,255,0.55); }
.info-card h3 { font-family: "Sora", sans-serif; margin: 0 0 8px; font-size: 1.08rem; display: flex; align-items: center; gap: 9px; }
.info-card .swatch { width: 14px; height: 14px; border-radius: 5px; background: var(--c); box-shadow: 0 0 10px var(--c); flex: none; }
.info-card p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.info-card .more { margin-top: 10px; font-size: 0.8rem; color: #9ec1ff; font-weight: 600; }

/* trends cards */
.trend-card { background: var(--panel); border: 1px solid var(--stroke); border-radius: 14px; padding: 18px 20px; }
.trend-card h3 { font-family: "Sora"; margin: 0 0 8px; font-size: 1.12rem; }
.trend-card p { margin: 0 0 10px; color: #c7cdec; font-size: 0.94rem; line-height: 1.6; }
.trend-card .tdir { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.tdir span { font-size: 0.8rem; background: rgba(255,255,255,0.05); border: 1px solid var(--stroke-soft); border-radius: 8px; padding: 6px 10px; color: var(--muted); }
.tdir b { color: var(--text); }

/* lessons accordion */
.accordion { display: flex; flex-direction: column; gap: 10px; }
.acc-item { background: var(--panel); border: 1px solid var(--stroke); border-radius: 14px; overflow: hidden; }
.acc-head { width: 100%; text-align: left; background: transparent; border: 0; color: var(--text); font: inherit; cursor: pointer; padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
.acc-head:hover { background: rgba(255,255,255,0.03); }
.acc-head .acc-title { font-family: "Sora"; font-weight: 700; font-size: 1.02rem; flex: 1; }
.acc-head .acc-meta { font-size: 0.78rem; color: var(--muted); background: rgba(255,255,255,0.06); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.acc-head .acc-arrow { transition: transform 0.25s; color: var(--muted); }
.acc-item.open .acc-arrow { transform: rotate(90deg); }
.acc-body { display: none; padding: 0 20px 20px; color: #c7cdec; }
.acc-item.open .acc-body { display: block; animation: fade 0.3s var(--ease); }
.acc-body h4 { font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); margin: 16px 0 8px; }
.acc-body p { margin: 0 0 10px; line-height: 1.6; font-size: 0.94rem; }
.acc-body ul { margin: 0; padding-left: 20px; line-height: 1.65; font-size: 0.93rem; }
.acc-body li { margin-bottom: 5px; }
.acc-body .print-btn { margin-top: 16px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.05); color: var(--text); font: inherit; font-weight: 600; font-size: 0.85rem; padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.acc-body .print-btn:hover { background: rgba(255,255,255,0.12); }

/* glossary */
.glossary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.gloss { background: var(--panel); border: 1px solid var(--stroke-soft); border-radius: 11px; padding: 13px 15px; }
.gloss dt { font-family: "Sora"; font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.gloss dd { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }

/* faq */
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: var(--panel); border: 1px solid var(--stroke); border-radius: 12px; overflow: hidden; }
.faq-q { width: 100%; text-align: left; background: transparent; border: 0; color: var(--text); font: inherit; font-weight: 600; font-size: 0.98rem; cursor: pointer; padding: 15px 18px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.faq-q:hover { background: rgba(255,255,255,0.03); }
.faq-q .fa-arrow { color: var(--muted); transition: transform 0.25s; flex: none; }
.faq-item.open .fa-arrow { transform: rotate(45deg); }
.faq-a { display: none; padding: 0 18px 16px; color: var(--muted); line-height: 1.6; font-size: 0.93rem; }
.faq-item.open .faq-a { display: block; animation: fade 0.3s var(--ease); }

/* ============ charts modal ============ */
.charts-wrap { padding: 26px 30px 30px; }
.charts-wrap h2 { font-family: "Sora"; margin: 0 0 4px; font-size: 1.4rem; }
.charts-wrap .sub { color: var(--muted); margin: 0 0 16px; font-size: 0.92rem; }
.chart-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chart-tab { border: 1px solid var(--stroke); background: var(--panel); color: var(--muted); font: inherit; font-size: 0.84rem; font-weight: 600; padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: background 0.2s, color 0.2s; }
.chart-tab.on { background: linear-gradient(180deg, #cfe0ff, #a9c4ff); color: #0a0c18; border-color: transparent; }
.chart-svg { width: 100%; height: auto; background: rgba(255,255,255,0.02); border: 1px solid var(--stroke-soft); border-radius: 12px; }
.chart-svg .axis-line { stroke: var(--stroke); stroke-width: 1; }
.chart-svg .grid-line { stroke: var(--stroke-soft); stroke-width: 1; }
.chart-svg .data-line { fill: none; stroke: url(#chartGrad); stroke-width: 2.5; }
.chart-svg .dot { cursor: pointer; transition: r 0.15s; }
.chart-svg text { fill: var(--muted-2); font-size: 11px; }
.chart-note { margin-top: 12px; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.chart-tip { fill: var(--text); font-weight: 700; }

/* ============ flashcards ============ */
.study { padding: 28px 30px 30px; text-align: center; }
.study-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 0.85rem; color: var(--muted); padding-right: 36px; }
.study-mode { display: inline-flex; gap: 4px; padding: 3px; background: rgba(255,255,255,0.05); border-radius: 999px; border: 1px solid var(--stroke-soft); margin: 0 auto 16px; }
.study-mode button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.78rem; font-weight: 700; padding: 6px 13px; border-radius: 999px; cursor: pointer; }
.study-mode button.on { background: var(--text); color: #0a0c18; }
.flashcard { perspective: 1200px; max-width: 340px; margin: 0 auto; aspect-ratio: 3/2; cursor: pointer; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform 0.5s var(--ease); transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 16px; border: 1px solid var(--stroke); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px; background: var(--panel-solid); }
.flash-front { background: linear-gradient(160deg, color-mix(in srgb, var(--c) 28%, #0d1124), color-mix(in srgb, var(--c) 8%, #0b0e1d)); }
.flash-front .big { font-family: "Sora"; font-weight: 800; font-size: 4rem; line-height: 1; }
.flash-front .small { color: var(--muted); font-size: 0.85rem; }
.flash-back { transform: rotateY(180deg); }
.flash-back .bname { font-family: "Sora"; font-weight: 800; font-size: 1.6rem; }
.flash-back .brow { color: var(--muted); font-size: 0.9rem; }
.flash-hint { margin-top: 12px; color: var(--muted-2); font-size: 0.8rem; }
.study-nav { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.study-nav button { border: 1px solid var(--stroke); background: var(--panel); color: var(--text); font: inherit; font-weight: 700; font-size: 0.9rem; padding: 11px 20px; border-radius: 999px; cursor: pointer; }
.study-nav button.primary { background: linear-gradient(180deg, #cfe0ff, #a9c4ff); color: #0a0c18; border-color: transparent; }
.study-nav button:hover { transform: translateY(-2px); }

/* info modal (help / family / trend) */
.info-pad { padding: 30px; }
.info-pad h2 { font-family: "Sora"; margin: 0 0 6px; font-size: 1.5rem; display: flex; align-items: center; gap: 10px; }
.info-pad .swatch { width: 18px; height: 18px; border-radius: 6px; background: var(--c); box-shadow: 0 0 12px var(--c); }
.info-pad h4 { font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); margin: 20px 0 10px; }
.info-pad p { color: #c7cdec; line-height: 1.65; margin: 0 0 10px; }
.info-pad ul { margin: 0; padding-left: 20px; color: #c7cdec; line-height: 1.65; }
.info-pad li { margin-bottom: 6px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.help-feat { background: rgba(255,255,255,0.04); border: 1px solid var(--stroke-soft); border-radius: 11px; padding: 13px 15px; }
.help-feat .hf-ico { font-size: 1.3rem; }
.help-feat b { display: block; margin: 4px 0 3px; font-size: 0.95rem; }
.help-feat span { color: var(--muted); font-size: 0.85rem; line-height: 1.45; }

/* ============ light theme ============ */
body[data-theme="light"] {
  --bg: #eef1fb; --bg-2: #f7f9ff; --panel: rgba(255,255,255,0.78); --panel-solid: #ffffff;
  --stroke: rgba(20,30,70,0.12); --stroke-soft: rgba(20,30,70,0.07);
  --text: #141a33; --muted: #5a6488; --muted-2: #8088a8;
  background:
    radial-gradient(1200px 700px at 15% -10%, #dfe6ff 0%, transparent 55%),
    radial-gradient(1000px 600px at 95% 0%, #f0e2ff 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 60%);
}
body[data-theme="light"] .stars, body[data-theme="light"] .bg-glow { opacity: 0; }
body[data-theme="light"] .grad { background: linear-gradient(100deg, #3b6fe0, #8a5cf0 45%, #e85aa8); -webkit-background-clip: text; background-clip: text; }
body[data-theme="light"] .modal-overlay { background: rgba(40,50,90,0.4); }
body[data-theme="light"] .theme-btn { box-shadow: 0 2px 10px rgba(20,30,70,0.08); }
body[data-theme="light"] .vt-btn.is-active, body[data-theme="light"] .ct-go, body[data-theme="light"] .quiz-next,
body[data-theme="light"] .chart-tab.on, body[data-theme="light"] .study-nav button.primary { color: #fff; background: linear-gradient(180deg, #5b8def, #3b6fe0); }
/* tiles stay dark in both themes -> keep light text on them */
body[data-theme="light"] .el { color: #eef1ff; }
body[data-theme="light"] .el .nm { color: #b9c0e0; }
body[data-theme="light"] .el .ms { color: #8b93b8; }
body[data-theme="light"] .series-link { color: #5a6488; }
/* body text that was hardcoded light -> darken for light bg */
body[data-theme="light"] .fact-text,
body[data-theme="light"] .intro p,
body[data-theme="light"] .trend-card p,
body[data-theme="light"] .acc-body,
body[data-theme="light"] .acc-body p,
body[data-theme="light"] .info-pad p,
body[data-theme="light"] .info-pad ul,
body[data-theme="light"] .m-summary p,
body[data-theme="light"] .m-didyouknow { color: #29314f; }
body[data-theme="light"] .m-didyouknow b { color: #a86b00; }
body[data-theme="light"] .m-didyouknow { background: rgba(20,30,70,0.05); }
body[data-theme="light"] .cmp-bar .bv { color: #fff; }
body[data-theme="light"] .modal-close, body[data-theme="light"] .theme-btn { background: rgba(20,30,70,0.06); }

@media (max-width: 760px) {
  .topnav-links a:not(:last-child) { display: none; }
  .help-grid { grid-template-columns: 1fr; }
  .content { padding: 0 14px; }
}
