@font-face {
  font-family: 'Nunito';
  src: url('assets/fonts/Nunito.ttf') format('truetype');
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('assets/fonts/Inter.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-canvas: #ffffff;
  --bg-bar: rgba(250, 250, 252, 0.96);
  --bg-grouped: #f2f1f7;
  --bg-card: #ffffff;
  --bg-subcard: #f6f7fb;
  --bg-seg: rgba(118, 118, 128, 0.12);
  --bg-seg-thumb: #ffffff;
  --bg-pill-btn: #ffffff;
  --bg-popover: rgba(255, 255, 255, 0.98);
  --bg-banner: rgba(255, 255, 255, 0.96);
  --bg-hud: rgba(255, 255, 255, 0.94);
  --bg-kbd: #f1f5f9;
  --border-hairline: rgba(15, 23, 42, 0.08);
  --border-soft: rgba(15, 23, 42, 0.05);
  --text-primary: #17171c;
  --text-secondary: #686b78;
  --text-muted: #989ca8;
  --accent-blue: #007aff;
  --sel-ring: #111827;
  --grid-label: #9ba0ad;
  --bohr-ring: #d7dce3;
  --bohr-electron: #0f85e9;
  --bohr-nucleus: #fc8d29;
  --bohr-glow: rgba(252, 141, 41, 0.16);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.045), 0 0 0 0.5px rgba(15, 23, 42, 0.04);
  --shadow-float: 0 12px 32px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.45, 0.64, 1);
  --titlebar-h: 48px;
}

html[data-theme="dark"] {
  --bg-canvas: #11131a;
  --bg-bar: rgba(24, 27, 36, 0.96);
  --bg-grouped: #171a23;
  --bg-card: #212533;
  --bg-subcard: #2a2f40;
  --bg-seg: rgba(255, 255, 255, 0.08);
  --bg-seg-thumb: #343a4f;
  --bg-pill-btn: #252a3a;
  --bg-popover: rgba(34, 38, 52, 0.98);
  --bg-banner: rgba(30, 34, 46, 0.96);
  --bg-hud: rgba(30, 34, 46, 0.94);
  --bg-kbd: #2d3347;
  --border-hairline: rgba(255, 255, 255, 0.085);
  --border-soft: rgba(255, 255, 255, 0.05);
  --text-primary: #f2f4fa;
  --text-secondary: #a1a8bc;
  --text-muted: #6e768b;
  --accent-blue: #4ea2ff;
  --sel-ring: #f8fafc;
  --grid-label: #788098;
  --bohr-ring: rgba(255, 255, 255, 0.22);
  --bohr-electron: #3ea6ff;
  --bohr-nucleus: #ff9838;
  --bohr-glow: rgba(255, 152, 56, 0.22);
  --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(255, 255, 255, 0.05);
  --shadow-float: 0 16px 36px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.25);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button,
a {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  overflow: hidden;
  transition: background-color 220ms ease, color 220ms ease;
}

/* -------------------------------------------------------------------------
   Top Titlebar
   ------------------------------------------------------------------------- */
.titlebar {
  height: var(--titlebar-h);
  min-height: var(--titlebar-h);
  padding: 0 14px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--border-hairline);
  -webkit-app-region: drag;
  position: relative;
  z-index: 30;
  transition: background-color 220ms ease, border-color 220ms ease;
}

.no-drag {
  -webkit-app-region: no-drag;
}

.titlebar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn.settings-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-pill-btn);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: transform 220ms var(--ease-bounce), background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.icon-btn.settings-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 360ms var(--ease-spring);
}

.icon-btn.settings-btn:hover {
  color: var(--text-primary);
}

.icon-btn.settings-btn:active {
  transform: scale(0.9);
}

.icon-btn.settings-btn.active {
  background: color-mix(in srgb, var(--accent-blue) 15%, var(--bg-pill-btn));
  border-color: color-mix(in srgb, var(--accent-blue) 45%, transparent);
  color: var(--accent-blue);
}

.icon-btn.settings-btn.active svg {
  transform: rotate(60deg);
}

/* 4-way Mode Segmented Control */
.mode-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--bg-seg);
  padding: 2.5px;
  border-radius: 9px;
  height: 29px;
}

.mode-thumb {
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  height: 24px;
  border-radius: 7px;
  background: var(--bg-seg-thumb);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
  transition: transform 280ms var(--ease-spring), width 280ms var(--ease-spring);
  pointer-events: none;
}

.mode-btn {
  position: relative;
  z-index: 1;
  height: 24px;
  padding: 0 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 7px;
  transition: color 180ms ease;
  white-space: nowrap;
}

.mode-btn:hover,
.mode-btn.active {
  color: var(--text-primary);
}

/* Category Filter Pills Strip */
.titlebar-center {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}

.category-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 4px 2px;
  width: 100%;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

.pills-fade {
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 24px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 180ms ease;
}

.pills-fade.visible {
  opacity: 1;
}

.pills-fade-left {
  left: 0;
  background: linear-gradient(to right, var(--bg-bar), transparent);
}

.pills-fade-right {
  right: 0;
  background: linear-gradient(to left, var(--bg-bar), transparent);
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
  height: 25px;
  padding: 0 8.5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--pill-tint, #f1f5f9);
  color: var(--pill-text, #1f2937);
  border: 1px solid rgba(15, 23, 42, 0.08);
  transition: transform 200ms var(--ease-bounce), background-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

html[data-theme="dark"] .cat-pill {
  background: color-mix(in srgb, var(--pill-color) 18%, #212533);
  color: color-mix(in srgb, var(--pill-color) 72%, #ffffff);
  border-color: color-mix(in srgb, var(--pill-color) 36%, transparent);
}

.cat-pill svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.cat-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.cat-pill:active {
  transform: scale(0.94);
}

.cat-pill.active,
html[data-theme="dark"] .cat-pill.active {
  background: var(--pill-color, #4f46e5);
  color: #101218;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* macOS Style Traffic Lights on the RIGHT + Web Download Button */
.titlebar-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 6px;
}

.mac-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mac-btn {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 160ms var(--ease-bounce), background-color 180ms ease;
}

.mac-btn svg {
  width: 8.5px;
  height: 8.5px;
  opacity: 0;
  color: rgba(25, 16, 12, 0.72);
  transition: opacity 140ms ease;
}

.mac-controls:hover .mac-btn svg {
  opacity: 1;
}

.mac-btn:active {
  transform: scale(0.84);
}

.mac-max { background: #28c840; box-shadow: inset 0 0 0 0.75px rgba(0, 0, 0, 0.14); }
.mac-min { background: #febc2e; box-shadow: inset 0 0 0 0.75px rgba(0, 0, 0, 0.14); }
.mac-close { background: #ff5f57; box-shadow: inset 0 0 0 0.75px rgba(0, 0, 0, 0.14); }

body:not(.app-focused) .mac-controls:not(:hover) .mac-btn {
  background: #d4d4d8;
  box-shadow: inset 0 0 0 0.75px rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"] body:not(.app-focused) .mac-controls:not(:hover) .mac-btn {
  background: #474d5f;
}

.web-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  background: #243553;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(36, 53, 83, 0.25);
  transition: transform 180ms var(--ease-bounce), background-color 180ms ease, box-shadow 180ms ease;
}

html[data-theme="dark"] .web-download-btn {
  background: #4ea2ff;
  color: #0b1220;
  box-shadow: 0 2px 10px rgba(78, 162, 255, 0.28);
}

.web-download-btn svg {
  width: 14px;
  height: 14px;
}

.web-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(36, 53, 83, 0.35);
}

.web-download-btn:active {
  transform: scale(0.95);
}

[hidden] {
  display: none !important;
}

/* -------------------------------------------------------------------------
   Workspace Layout & Dynamic Side Ordering
   ------------------------------------------------------------------------- */
.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
  background: var(--bg-canvas);
}

.table-viewport {
  order: 2;
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg-canvas);
  cursor: grab;
  transition: background-color 220ms ease;
}

.table-viewport.panning {
  cursor: grabbing;
}

.workspace[data-char-side="right"] .settings-panel {
  order: 1;
  border-right: 1px solid var(--border-hairline);
}

.workspace[data-char-side="right"] .char-panel {
  order: 3;
  border-left: 1px solid var(--border-hairline);
}

.workspace[data-char-side="left"] .char-panel {
  order: 1;
  border-right: 1px solid var(--border-hairline);
}

.workspace[data-char-side="left"] .settings-panel {
  order: 3;
  border-left: 1px solid var(--border-hairline);
}

/* -------------------------------------------------------------------------
   Side Panels
   ------------------------------------------------------------------------- */
.side-panel {
  width: 0;
  opacity: 0;
  flex-shrink: 0;
  background: var(--bg-grouped);
  overflow: hidden;
  pointer-events: none;
  transition: width 300ms var(--ease-spring), opacity 200ms ease, background-color 220ms ease;
}

.side-panel.open {
  opacity: 1;
  pointer-events: auto;
}

.char-panel.open {
  width: 412px;
}

.settings-panel.open {
  width: 304px;
}

.panel-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.char-inner {
  width: 412px;
  padding: clamp(7px, 1vh, 12px) 13px;
  overflow: hidden;
}

.settings-inner {
  width: 304px;
  padding: 12px 13px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: clamp(5px, 0.8vh, 9px);
  flex-shrink: 0;
}

.char-title-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.panel-title {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(18px, 2vh, 21px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-subtitle {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.close-pill-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-seg);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background-color 160ms ease, color 160ms ease, transform 180ms var(--ease-bounce);
}

.close-pill-btn svg {
  width: 13px;
  height: 13px;
}

.close-pill-btn:hover {
  color: var(--text-primary);
}

.close-pill-btn:active {
  transform: scale(0.88);
}

/* -------------------------------------------------------------------------
   Floating Category Explanation Banner
   ------------------------------------------------------------------------- */
.category-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, -14px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  max-width: min(820px, calc(100% - 36px));
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px 7px 13px;
  background: var(--bg-banner);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
  transition: opacity 220ms ease, transform 280ms var(--ease-spring);
}

.category-banner.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

.banner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.banner-text {
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-secondary);
}

.banner-text strong {
  color: var(--text-primary);
  font-weight: 700;
}

.banner-close {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.banner-close svg {
  width: 12px;
  height: 12px;
}

.banner-close:hover {
  background: var(--bg-seg);
  color: var(--text-primary);
}

/* -------------------------------------------------------------------------
   Periodic Table Grid — Crisp HD Native Scaling (--z) vs Weak PC GPU Scale
   ------------------------------------------------------------------------- */
.table-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.periodic-grid {
  --z: 1;
  position: relative;
  width: calc(1252px * var(--z));
  height: calc(664px * var(--z));
  padding: calc(4px * var(--z)) calc(10px * var(--z)) calc(10px * var(--z)) calc(4px * var(--z));
}

.col-header {
  position: absolute;
  left: calc(var(--bx) * 1px * var(--z));
  top: calc(var(--by) * 1px * var(--z));
  width: calc(var(--bw) * 1px * var(--z));
  height: calc(var(--bh) * 1px * var(--z));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: calc(11px * var(--z));
  font-weight: 500;
  color: var(--grid-label);
  padding-bottom: calc(4px * var(--z));
  pointer-events: none;
}

.row-header {
  position: absolute;
  left: calc(var(--bx) * 1px * var(--z));
  top: calc(var(--by) * 1px * var(--z));
  width: calc(var(--bw) * 1px * var(--z));
  height: calc(var(--bh) * 1px * var(--z));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-family: 'Inter', sans-serif;
  font-size: calc(11px * var(--z));
  font-weight: 500;
  color: var(--grid-label);
  padding-right: calc(6px * var(--z));
  pointer-events: none;
}

.el-tile {
  position: absolute;
  left: calc(var(--bx) * 1px * var(--z));
  top: calc(var(--by) * 1px * var(--z));
  width: calc(64px * var(--z));
  height: calc(64px * var(--z));
  border-radius: calc(8px * var(--z));
  background: var(--tile-bg, #8dce98);
  color: #14161e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(5px * var(--z)) calc(3px * var(--z)) calc(4px * var(--z));
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 0.75px rgba(15, 23, 42, 0.08);
  transition:
    transform 170ms var(--ease-bounce),
    opacity 220ms ease,
    filter 220ms ease,
    background-color 240ms ease,
    box-shadow 170ms ease;
}

html[data-theme="dark"] .el-tile {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 2px 6px rgba(0, 0, 0, 0.24);
}

.el-tile:hover {
  transform: translateY(-2px);
  z-index: 6;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18), inset 0 0 0 1.2px rgba(15, 23, 42, 0.22);
}

html[data-theme="dark"] .el-tile:hover {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45), inset 0 0 0 1.5px rgba(255, 255, 255, 0.45);
}

.el-tile:active {
  transform: translateY(0);
}

.el-tile.selected {
  z-index: 7;
  box-shadow: 0 0 0 2.5px var(--sel-ring), 0 8px 18px rgba(15, 23, 42, 0.26);
  transform: translateY(-1px);
}

.el-tile.dimmed {
  opacity: 0.22;
  filter: grayscale(0.58) brightness(1.08);
}

html[data-theme="dark"] .el-tile.dimmed {
  opacity: 0.19;
  filter: grayscale(0.65) brightness(0.62);
}

.el-tile.dimmed:hover {
  opacity: 0.76;
  filter: grayscale(0.12);
}

.tile-num {
  font-size: calc(9.5px * var(--z));
  font-weight: 600;
  line-height: 1;
  color: rgba(17, 24, 39, 0.78);
}

.tile-sym {
  font-family: 'Nunito', sans-serif;
  font-size: calc(20.5px * var(--z));
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #101218;
}

.tile-sub {
  width: 100%;
  font-size: calc(8px * var(--z));
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: rgba(17, 24, 39, 0.84);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-sub.long-name {
  font-size: calc(7px * var(--z));
  letter-spacing: -0.035em;
}

.el-tile.mode-both .tile-sym {
  font-size: calc(18.5px * var(--z));
}

.el-tile.mode-both .tile-sub {
  font-size: calc(7.2px * var(--z));
  line-height: 1.04;
}

.el-tile.mode-both .tile-sub.long-name {
  font-size: calc(6.4px * var(--z));
}

.tile-mass-line {
  display: block;
  font-size: calc(7px * var(--z));
  opacity: 0.85;
  font-weight: 600;
}

/* Weak PC Mode (GPU transform zoom + disables backdrop-filter blurs) */
body.weak-pc .table-stage {
  will-change: transform;
}

body.weak-pc .category-banner,
body.weak-pc .zoom-hud,
body.weak-pc .tip-popover,
body.weak-pc .lightbox {
  backdrop-filter: none !important;
}

body.weak-pc .el-tile,
body.weak-pc .side-panel {
  transition-duration: 90ms;
}

/* Zoom HUD */
.zoom-hud {
  position: absolute;
  right: 16px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  background: var(--bg-hud);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  z-index: 15;
}

.zoom-hud-btn,
.zoom-hud-readout {
  height: 28px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background-color 140ms ease, color 140ms ease;
}

.zoom-hud-btn {
  width: 28px;
  font-size: 15px;
}

.zoom-hud-readout {
  padding: 0 8px;
  min-width: 48px;
  border-left: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
}

.zoom-hud-btn:hover,
.zoom-hud-readout:hover {
  background: var(--bg-seg);
  color: var(--text-primary);
}

/* -------------------------------------------------------------------------
   Characteristics Panel Cards (Zero-scroll adaptive vertical stack)
   ------------------------------------------------------------------------- */
.char-cards {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 0.78vh, 8px);
}

.ios-card {
  background: var(--bg-card);
  border-radius: 13px;
  box-shadow: var(--shadow-card);
  padding: clamp(6px, 0.9vh, 10px) 12px;
  flex-shrink: 0;
  transition: background-color 220ms ease, box-shadow 220ms ease;
}

.info-btn {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.25px solid color-mix(in srgb, var(--accent-blue) 56%, transparent);
  color: var(--accent-blue);
  font-family: 'Nunito', sans-serif;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-bounce);
}

.info-btn:hover {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
  transform: scale(1.08);
}

body.hide-tips .info-btn {
  display: none;
}

/* 1. Hero Card */
.hero-card {
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 0.75vh, 8px);
}

.hero-metrics {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  gap: 10px;
}

.hero-divider {
  width: 1px;
  height: 26px;
  background: var(--border-hairline);
}

.hero-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-metric-right {
  align-items: flex-end;
  text-align: right;
}

.metric-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.8px;
  font-weight: 500;
  color: var(--text-secondary);
}

.metric-value {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(16px, 1.75vh, 19px);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.hero-badge-wrap {
  display: flex;
  justify-content: center;
}

.hero-symbol-badge {
  width: clamp(52px, 6.2vh, 64px);
  height: clamp(52px, 6.2vh, 64px);
  border-radius: 15px;
  background: var(--badge-tint, #d9ecfb);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
  transition: background-color 280ms ease;
}

html[data-theme="dark"] .hero-symbol-badge {
  background: color-mix(in srgb, var(--badge-color, #87ace0) 24%, #2a2f40);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--badge-color, #87ace0) 40%, transparent);
}

.hero-symbol-badge span {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(25px, 3vh, 31px);
  font-weight: 800;
  color: #111318;
  letter-spacing: -0.03em;
  line-height: 1;
}

html[data-theme="dark"] .hero-symbol-badge span {
  color: #f8fafc;
}

.badge-pop {
  animation: badgePop 300ms var(--ease-bounce);
}

@keyframes badgePop {
  0% { transform: scale(0.84); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

/* 2. Atomic Structure + Bohr Card */
.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-section-label {
  font-size: 11.3px;
  font-weight: 600;
  color: var(--text-secondary);
}

.shells-pill {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subcard);
  padding: 2px 7px;
  border-radius: 999px;
}

.bohr-wrap {
  width: 100%;
  height: clamp(96px, 12.6vh, 128px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  margin: 2px 0;
}

.bohr-svg {
  width: clamp(96px, 12.6vh, 128px);
  height: clamp(96px, 12.6vh, 128px);
  display: block;
  flex-shrink: 0;
}

.bohr-bloom {
  animation: bohrBloom 320ms var(--ease-spring);
}

@keyframes bohrBloom {
  0% { transform: scale(0.88); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

.card-list {
  position: relative;
  z-index: 2;
  background: var(--bg-card);
  border-top: 1px solid var(--border-hairline);
  margin-top: 2px;
  padding-top: 2px;
  transition: background-color 220ms ease;
}

.prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: clamp(21px, 2.5vh, 26px);
  font-size: 11.8px;
}

.prop-row + .prop-row {
  border-top: 1px solid var(--border-soft);
}

.prop-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
}

.prop-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.prop-val {
  color: var(--text-secondary);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 215px;
  padding-right: 3px;
}

.ox-list.compact {
  font-size: 10.8px;
}

.ox-list strong {
  color: var(--text-primary);
  font-weight: 700;
}

.ox-list em {
  color: var(--text-secondary);
  font-style: italic;
  font-weight: 500;
}

/* 3. Place in the Table Card */
.place-grid {
  margin-top: clamp(4px, 0.65vh, 7px);
  display: grid;
  grid-template-columns: 1.38fr 0.82fr;
  gap: clamp(4px, 0.7vh, 7px) 9px;
}

.place-cell {
  background: var(--bg-subcard);
  border-radius: 9px;
  padding: clamp(4px, 0.6vh, 6px) 9px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: background-color 220ms ease;
}

.place-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 10.3px;
  font-weight: 500;
  color: var(--text-secondary);
}

.place-val {
  font-size: 12.2px;
  font-weight: 700;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 4. Redesigned Divided Temperature & Pressure Phase Diagram */
.state-title-left {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.state-badges {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pressure-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-subcard);
  color: var(--text-secondary);
}

.state-pill {
  font-size: 10.3px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.state-pill.solid { background: #e1edfa; color: #164e87; }
.state-pill.liquid { background: #fcf0d9; color: #7a4f06; }
.state-pill.gas { background: #fae2e2; color: #8c2020; }
.state-pill.unknown_state { background: var(--bg-subcard); color: var(--text-secondary); }

html[data-theme="dark"] .state-pill.solid { background: rgba(59, 151, 240, 0.22); color: #86c5ff; }
html[data-theme="dark"] .state-pill.liquid { background: rgba(242, 191, 44, 0.22); color: #fbd76b; }
html[data-theme="dark"] .state-pill.gas { background: rgba(232, 90, 80, 0.24); color: #ff9c94; }

.phase-diagram {
  margin-top: 5px;
  position: relative;
  user-select: none;
}

.phase-top-row {
  position: relative;
  height: 17px;
  margin-bottom: 3px;
}

.phase-stick-val {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-subcard);
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-hairline);
  white-space: nowrap;
  z-index: 3;
}

.phase-stick-val.align-left { transform: translateX(0); }
.phase-stick-val.align-right { transform: translateX(-100%); }

.phase-track-wrap {
  position: relative;
  height: 22px;
  cursor: crosshair;
}

.phase-track {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 2px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-subcard);
}

.phase-seg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow: hidden;
  white-space: nowrap;
  padding: 0 4px;
  position: relative;
  transition: filter 150ms ease;
}

.phase-seg.solid {
  background: #3b97f0;
  color: #ffffff;
}

.phase-seg.liquid {
  background: #f2bf2c;
  color: #2c1e03;
}

.phase-seg.gas {
  background: #e85a50;
  color: #ffffff;
}

.phase-seg.unknown {
  background: repeating-linear-gradient(
    -45deg,
    rgba(148, 163, 184, 0.25),
    rgba(148, 163, 184, 0.25) 4px,
    rgba(148, 163, 184, 0.1) 4px,
    rgba(148, 163, 184, 0.1) 8px
  );
  color: var(--text-secondary);
}

.phase-stick-line {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2.5px;
  background: var(--text-primary);
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 0 1.5px var(--bg-card);
  z-index: 4;
  pointer-events: none;
}

.phase-room-dot {
  position: absolute;
  bottom: -4px;
  width: 8px;
  height: 8px;
  background: #ffffff;
  border: 2px solid #111827;
  border-radius: 50%;
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.phase-bottom-row {
  position: relative;
  height: 15px;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.8px;
  font-weight: 600;
  color: var(--text-secondary);
}

.phase-sub-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.phase-sub-label.align-left { transform: translateX(0); }
.phase-sub-label.align-right { transform: translateX(-100%); }

.phase-unknown-note {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 5. Photo + Everyday Uses Card */
.photo-uses-card {
  flex: 1;
  min-height: 98px;
  display: flex;
  align-items: stretch;
  gap: 11px;
  overflow: hidden;
}

.photo-box {
  width: clamp(92px, 11vh, 114px);
  height: clamp(92px, 11vh, 114px);
  align-self: center;
  border-radius: 11px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  background: var(--bg-subcard);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--border-hairline);
}

.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 280ms var(--ease-spring);
}

.photo-box:hover img {
  transform: scale(1.06);
}

.photo-zoom-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(17, 24, 39, 0.65);
  color: #ffffff;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 180ms ease;
}

.photo-zoom-badge svg {
  width: 12px;
  height: 12px;
}

.photo-box:hover .photo-zoom-badge {
  opacity: 1;
}

.synthetic-badge {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #1c1f2b;
}

.syn-sym {
  font-family: 'Nunito', sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.syn-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.75;
}

.uses-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.uses-heading {
  font-size: 10.8px;
  font-weight: 700;
  color: var(--text-secondary);
}

.uses-text {
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-primary);
}

.fact-divider {
  height: 1px;
  background: var(--border-hairline);
  margin: 2px 0;
}

.fact-text {
  font-size: 10.3px;
  line-height: 1.28;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------------------
   Settings Side Panel
   ------------------------------------------------------------------------- */
.settings-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-bottom: 8px;
  padding-right: 2px;
}

.settings-scroll::-webkit-scrollbar {
  width: 5px;
}

.settings-scroll::-webkit-scrollbar-thumb {
  background: var(--border-hairline);
  border-radius: 999px;
}

.settings-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 4px 4px 0;
}

.settings-card {
  padding: 9px 11px;
}

.setting-item.stacked {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.setting-name {
  font-size: 12.2px;
  font-weight: 600;
  color: var(--text-primary);
}

.setting-hint {
  font-size: 10.3px;
  color: var(--text-secondary);
}

.setting-divider {
  height: 1px;
  background: var(--border-hairline);
  margin: 7px 0;
}

.ios-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--bg-seg);
  padding: 2.5px;
  border-radius: 8px;
  gap: 2px;
}

.ios-seg button {
  height: 25px;
  font-size: 11.3px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.ios-seg button.active {
  background: var(--bg-seg-thumb);
  color: var(--text-primary);
  box-shadow: 0 1px 2.5px rgba(15, 23, 42, 0.16);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.setting-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ios-switch {
  appearance: none;
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: #9ca3af;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 220ms ease;
}

html[data-theme="dark"] .ios-switch:not(:checked) {
  background: #43495d;
}

.ios-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 240ms var(--ease-bounce);
}

.ios-switch:checked {
  background: #34c759;
}

.ios-switch:checked::after {
  transform: translateX(17px);
}

/* Updater Card */
.updater-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.updater-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-blue) 14%, var(--bg-card));
  color: var(--accent-blue);
  transition: background-color 160ms ease, transform 150ms ease;
}

.updater-btn:hover {
  background: color-mix(in srgb, var(--accent-blue) 22%, var(--bg-card));
}

.updater-btn:active {
  transform: scale(0.95);
}

.updater-status {
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.updater-progress {
  margin-top: 6px;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-seg);
  overflow: hidden;
}

.updater-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-blue);
  transition: width 200ms ease;
}

.updater-cta {
  margin-top: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--accent-blue);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
}

.setting-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.2px;
  font-weight: 600;
  color: var(--accent-blue);
  padding: 2px 0;
}

.kbd-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-kbd);
  padding: 2px 7px;
  border-radius: 5px;
}

.controls-mini-guide {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.controls-mini-guide strong {
  color: var(--text-primary);
}

.about-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.about-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.about-name {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 800;
}

.about-ver {
  font-size: 10.8px;
  color: var(--text-secondary);
}

.about-note {
  font-size: 10.6px;
  line-height: 1.4;
  color: var(--text-secondary);
}

body.web-mode .desktop-only {
  display: none !important;
}

/* -------------------------------------------------------------------------
   Info Tip Popover & Photo Lightbox
   ------------------------------------------------------------------------- */
.tip-popover {
  position: fixed;
  z-index: 60;
  width: 316px;
  background: var(--bg-popover);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
  padding: 13px 14px;
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: scale(0.93) translateY(4px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms var(--ease-spring);
}

.tip-popover.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.tip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.tip-head strong {
  font-family: 'Nunito', sans-serif;
  font-size: 14.5px;
  font-weight: 800;
}

.tip-close {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-seg);
  font-size: 15px;
  line-height: 1;
  color: var(--text-secondary);
}

.tip-body,
.tip-extra {
  font-size: 12px;
  line-height: 1.48;
  color: var(--text-primary);
  opacity: 0.92;
}

.tip-extra {
  margin-top: 7px;
}

.tip-examples {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  color: var(--text-primary);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-card {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 12px;
  max-width: 440px;
  width: calc(100% - 40px);
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  transform: scale(0.92);
  transition: transform 260ms var(--ease-spring);
}

.lightbox.open .lightbox-card {
  transform: scale(1);
}

.lightbox-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.72);
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.lightbox-meta {
  padding: 10px 4px 2px;
}

.lightbox-title {
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 800;
}

.lightbox-credit {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}
