:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --ink: #19202a;
  --muted: #69707d;
  --panel: rgba(255, 252, 246, 0.88);
  --line: rgba(25, 32, 42, 0.14);
  --shadow: 0 18px 45px rgba(47, 48, 55, 0.12);
  --accent: #147c72;
  --active: #19323c;
  --cell-bg: #ffffff;
  --heat-color: #9aa0a6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(73, 182, 168, 0.22), transparent 32rem),
    radial-gradient(circle at 88% 12%, rgba(242, 184, 75, 0.24), transparent 30rem),
    linear-gradient(135deg, #f6f2e9 0%, #eef3f1 54%, #f7efe5 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar,
.insight-panel,
.valence-panel,
.detail-panel,
.periodic-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2.8vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.search-box,
.select-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.search-box input,
.select-box select {
  min-width: 220px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  outline: none;
}

.search-box input:focus,
.select-box select:focus,
.trend-toggle input:focus-visible + .trend-switch,
.mode-button:focus-visible,
.element:focus-visible {
  outline: 3px solid rgba(20, 124, 114, 0.26);
  outline-offset: 2px;
}

.trend-toggle {
  position: relative;
  align-self: end;
  display: grid;
  grid-template-columns: auto 52px;
  align-items: center;
  justify-content: start;
  gap: 10px;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.trend-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.trend-switch {
  position: relative;
  width: 52px;
  height: 30px;
  border: 1px solid rgba(25, 32, 42, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 3px rgba(25, 32, 42, 0.08);
  transition: background 180ms ease, border-color 180ms ease;
}

.trend-switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fffdf8;
  box-shadow: 0 4px 10px rgba(25, 32, 42, 0.2);
  transition: transform 180ms ease;
}

.trend-toggle input:checked + .trend-switch {
  border-color: var(--active);
  background: var(--active);
}

.trend-toggle input:checked + .trend-switch::after {
  transform: translateX(22px);
}

.mode-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 2px;
}

.mode-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.mode-button:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 124, 114, 0.42);
}

.mode-button.active {
  color: #fffdf8 !important;
  background: var(--active) !important;
  border-color: var(--active) !important;
}

.mode-button[data-mode="electronegativity"],
.mode-button[data-mode="radius"],
.mode-button[data-mode="block"],
.mode-button[data-mode="valence"],
.mode-button[data-mode="melting"] {
  margin-left: 15px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}

.periodic-panel {
  position: relative;
  min-width: 0;
  overflow-x: auto;
  border-radius: 8px;
  padding: 36px 18px 18px 48px;
}

.table-grid,
.group-labels,
.period-labels {
  display: grid;
  grid-template-columns: repeat(18, minmax(48px, 1fr));
  grid-template-rows: repeat(9, 70px);
  gap: 6px;
  min-width: 1000px;
}

.table-grid {
  position: relative;
}

.group-labels {
  position: absolute;
  top: 10px;
  left: 48px;
  right: 18px;
  grid-template-rows: 18px;
  pointer-events: none;
}

.group-label {
  position: relative;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.group-label--span {
  display: grid;
  place-items: center;
}

.group-label--span::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: -4px;
  left: 14px;
  height: 5px;
  border: 2px solid rgba(105, 112, 125, 0.48);
  border-top: 0;
  border-radius: 0 0 6px 6px;
}

.period-labels {
  position: absolute;
  top: 36px;
  left: 10px;
  width: 30px;
  min-width: 30px;
  grid-template-columns: 30px;
  pointer-events: none;
}

.period-label {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.08;
  text-align: center;
}

.period-label--series {
  font-size: 0.68rem;
}

.element,
.placeholder {
  min-width: 0;
  border-radius: 8px;
}

.element {
  position: relative;
  display: grid;
  grid-template-rows: 10px 20px 16px 18px;
  border: 1px solid rgba(25, 32, 42, 0.12);
  padding: 3px 6px 2px;
  color: var(--cell-ink, var(--ink));
  background: var(--cell-bg);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease, opacity 160ms ease;
}

.element:hover,
.element.previewed,
.element.selected {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(25, 32, 42, 0.18);
  z-index: 3;
}

.element.previewed {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: -4px;
}

.element.selected {
  outline: 3px solid rgba(25, 50, 60, 0.7);
  outline-offset: -4px;
}

.element.dimmed {
  opacity: 0.23;
  filter: saturate(0.45);
}

.element.hidden-by-search {
  opacity: 0.12;
}

.number {
  grid-row: 1;
  grid-column: 1;
  justify-self: start;
  color: var(--cell-muted, rgba(25, 32, 42, 0.68));
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

.symbol {
  grid-row: 2;
  grid-column: 1;
  align-self: start;
  font-size: clamp(0.96rem, 1.3vw, 1.3rem);
  font-weight: 900;
  line-height: 0.9;
}

.name {
  grid-row: 3;
  grid-column: 1;
  align-self: start;
  overflow: hidden;
  color: var(--cell-muted, rgba(25, 32, 42, 0.74));
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.value-badge {
  grid-row: 4;
  grid-column: 1;
  justify-self: stretch;
  align-self: end;
  min-width: 0;
  overflow: hidden;
  border-radius: 999px;
  padding: 2px 4px 3px;
  color: var(--badge-ink, rgba(25, 32, 42, 0.72));
  background: var(--badge-bg, rgba(255, 255, 255, 0.5));
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed rgba(25, 32, 42, 0.22);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.38);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.block-guide {
  position: relative;
  z-index: 4;
  border: 2px solid var(--block-guide-color);
  border-radius: 8px;
  background: color-mix(in srgb, var(--block-guide-color) 8%, transparent);
  box-shadow: 0 0 0 3px rgba(255, 252, 246, 0.72);
  pointer-events: none;
}

.block-guide-label {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 34px;
  min-height: 26px;
  border: 2px solid var(--block-guide-color);
  border-radius: 8px;
  padding: 2px 8px 3px;
  color: var(--ink);
  background: rgba(255, 252, 246, 0.94);
  box-shadow: 0 8px 18px rgba(25, 32, 42, 0.14);
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1;
}

.block-guide--left .block-guide-label {
  top: 50%;
  left: 0;
  transform: translate(calc(-100% - 6px), -50%);
}

.block-guide--right .block-guide-label {
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
}

.block-guide--s .block-guide-label {
  top: 62px;
  right: 0;
  transform: translateX(calc(100% + 6px));
}

.block-guide--p .block-guide-label {
  top: 0;
  left: 50%;
  transform: translate(-50%, calc(-100% - 6px));
}

.block-guide--top .block-guide-label {
  top: 0;
  left: 50%;
  transform: translate(-50%, calc(-100% - 6px));
}

.trend-region {
  pointer-events: none;
}

.trend-guide-card {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--trend-color) 38%, rgba(25, 32, 42, 0.14));
  border-radius: 8px;
  padding: 8px 10px 10px;
  color: var(--ink);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--trend-color) 13%, transparent), rgba(255, 252, 246, 0.8)),
    rgba(255, 252, 246, 0.78);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    0 10px 28px rgba(25, 32, 42, 0.08);
  pointer-events: auto;
}

.trend-guide-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.trend-guide-title {
  color: color-mix(in srgb, var(--trend-color) 74%, #19202a);
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.trend-view-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--trend-color) 28%, rgba(25, 32, 42, 0.12));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.trend-view-toggle--placeholder {
  visibility: hidden;
  pointer-events: none;
}

.ionization-level-toggle {
  display: inline-flex;
  flex: 1 1 auto;
  justify-content: center;
  overflow: hidden;
  min-width: 240px;
  border: 1px solid color-mix(in srgb, var(--trend-color) 28%, rgba(25, 32, 42, 0.12));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
}

.trend-view-button {
  min-width: 40px;
  min-height: 24px;
  border: 0;
  padding: 0 8px;
  color: rgba(25, 32, 42, 0.68);
  background: transparent;
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1;
}

.ionization-level-button {
  min-width: 40px;
  min-height: 24px;
  border: 0;
  padding: 0 8px;
  color: rgba(25, 32, 42, 0.66);
  background: transparent;
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1;
}

.trend-view-button.active,
.ionization-level-button.active {
  color: #fffdf8;
  background: color-mix(in srgb, var(--trend-color) 72%, #19323c);
}

.ionization-level-button:focus-visible {
  outline: 3px solid rgba(20, 124, 114, 0.26);
  outline-offset: 2px;
}

.trend-map-view {
  position: relative;
  min-height: 0;
  height: 100%;
}

.trend-guide-lines {
  position: absolute;
  inset: 4px 22px 2px;
  width: calc(100% - 44px);
  height: calc(100% - 6px);
  overflow: visible;
}

.trend-guide-lines marker path {
  fill: var(--trend-color);
}

.trend-axis,
.trend-diagonal,
.trend-band {
  fill: none;
  stroke: var(--trend-color);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-axis {
  stroke-width: 5;
  opacity: 0.58;
}

.trend-diagonal {
  stroke-width: 7;
  opacity: 0.78;
}

.trend-band {
  stroke-width: 8;
  opacity: 0.72;
}

.trend-point {
  fill: color-mix(in srgb, var(--trend-color) 80%, #fffdf8);
  stroke: rgba(255, 252, 246, 0.92);
  stroke-width: 4;
}

.trend-guide-label,
.trend-guide-corner {
  position: absolute;
  z-index: 2;
  border-radius: 999px;
  padding: 4px 8px;
  color: rgba(25, 32, 42, 0.76);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.trend-guide-label--horizontal {
  bottom: 8px;
  left: 4px;
}

.trend-guide-label--vertical {
  top: 28px;
  left: 4px;
}

.trend-guide-label--exception {
  left: 4px;
  bottom: 38px;
  color: color-mix(in srgb, var(--trend-color) 70%, #19202a);
}

.trend-guide-corner {
  top: 4px;
  right: 4px;
  color: color-mix(in srgb, var(--trend-color) 76%, #19202a);
}

.trend-chart-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
}

.trend-chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
}

.trend-chart-gridline {
  stroke: rgba(25, 32, 42, 0.12);
  stroke-width: 1;
}

.trend-chart-axis {
  stroke: rgba(25, 32, 42, 0.36);
  stroke-width: 1.2;
}

.trend-chart-line {
  fill: none;
  stroke: var(--trend-color);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.trend-chart-point {
  fill: var(--trend-color);
  opacity: 0.62;
  transition: opacity 160ms ease, r 160ms ease;
}

.trend-chart-point:hover {
  opacity: 1;
}

.trend-chart-hit-area {
  fill: transparent;
  pointer-events: all;
}

.trend-chart-tick {
  fill: rgba(25, 32, 42, 0.58);
  font-size: 10px;
  font-weight: 800;
  text-anchor: end;
}

.trend-chart-marker-line {
  stroke: color-mix(in srgb, var(--trend-color) 78%, #19202a);
  stroke-dasharray: 3 3;
  stroke-width: 1.6;
}

.trend-chart-marker-dot {
  fill: #fffdf8;
  stroke: color-mix(in srgb, var(--trend-color) 78%, #19202a);
  stroke-width: 3;
}

.trend-chart-marker.hidden {
  display: none;
}

.trend-chart-note {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 120px);
  min-width: 0;
  border-radius: 8px;
  padding: 3px 6px 3px 4px;
  color: rgba(25, 32, 42, 0.72);
  background: rgba(255, 252, 246, 0.76);
  box-shadow: 0 6px 14px rgba(25, 32, 42, 0.08);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.trend-guide-card--ionization .trend-chart-note {
  top: 6px;
  max-width: calc(100% - 80px);
  background: rgba(255, 252, 246, 0.9);
}

.trend-chart-wrap.is-hovering .trend-chart-note {
  background: rgba(255, 252, 246, 0.94);
}

.trend-chart-active-symbol {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 18px;
  border-radius: 6px;
  color: #fffdf8;
  background: color-mix(in srgb, var(--trend-color) 78%, #19323c);
}

.trend-chart-active-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-factor-view {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  align-content: center;
}

.trend-factor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-self: center;
}

.trend-factor-grid span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid color-mix(in srgb, var(--trend-color) 34%, rgba(25, 32, 42, 0.12));
  border-radius: 8px;
  padding: 6px 8px;
  color: color-mix(in srgb, var(--trend-color) 72%, #19202a);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
}

.trend-factor-note {
  margin: 0;
  color: rgba(25, 32, 42, 0.68);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.45;
}

.valence-view-card {
  position: relative;
  z-index: 10;
  align-self: start;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(520px, 100%);
  border: 1px solid rgba(25, 32, 42, 0.14);
  border-radius: 8px;
  padding: 8px 10px 8px 12px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(65, 170, 160, 0.14), rgba(216, 95, 85, 0.13)),
    rgba(255, 252, 246, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 12px 26px rgba(25, 32, 42, 0.12);
}

.valence-view-card strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
}

.valence-view-card span {
  display: block;
  color: rgba(25, 32, 42, 0.66);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.16;
}

.valence-view-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(25, 32, 42, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.valence-view-button {
  min-width: 50px;
  min-height: 28px;
  border: 0;
  padding: 0 10px;
  color: rgba(25, 32, 42, 0.68);
  background: transparent;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
}

.valence-view-button.active {
  color: #fffdf8;
  background: var(--active);
}

.valence-view-button:focus-visible {
  outline: 3px solid rgba(20, 124, 114, 0.26);
  outline-offset: 2px;
}

.ion-exception-button {
  position: relative;
  z-index: 15;
  align-self: start;
  justify-self: center;
  display: grid;
  gap: 3px;
  min-width: 170px;
  border: 1px solid color-mix(in srgb, var(--trend-color) 28%, rgba(25, 32, 42, 0.12));
  border-radius: 8px;
  padding: 8px 12px;
  color: color-mix(in srgb, var(--trend-color) 68%, #19202a);
  background: rgba(255, 252, 246, 0.88);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.58),
    0 10px 22px rgba(25, 32, 42, 0.1);
  cursor: pointer;
  font: inherit;
  line-height: 1.1;
  text-align: center;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.ion-exception-button:hover,
.ion-exception-button.active {
  transform: translateY(-1px);
  color: #fffdf8;
  background: color-mix(in srgb, var(--trend-color, #301f67) 72%, #19323c);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.24),
    0 14px 28px rgba(25, 32, 42, 0.18);
}

.ion-exception-button strong {
  font-size: 0.78rem;
  font-weight: 900;
}

.ion-exception-button span {
  font-size: 0.68rem;
  font-weight: 900;
  opacity: 0.82;
}

.element.ion-exception-cell {
  z-index: 3;
}

.table-grid.ion-exception-focus .element.ion-exception-cell {
  z-index: 12;
  outline: 3px solid color-mix(in srgb, var(--trend-color, #4a3f91) 72%, #fffdf8);
  outline-offset: -3px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.82),
    0 0 0 2px color-mix(in srgb, var(--trend-color, #4a3f91) 20%, transparent),
    0 14px 30px rgba(25, 32, 42, 0.2);
}

.element.ion-exception-cell::after {
  content: attr(data-exception-role);
  position: absolute;
  right: 4px;
  top: 4px;
  display: none;
  place-items: center;
  min-width: 26px;
  height: 16px;
  border-radius: 999px;
  color: #fffdf8;
  background: color-mix(in srgb, var(--trend-color, #4a3f91) 78%, #19323c);
  box-shadow: 0 5px 12px rgba(25, 32, 42, 0.16);
  font-size: 0.54rem;
  font-weight: 900;
  line-height: 1;
}

.table-grid.ion-exception-focus .element.ion-exception-cell::after {
  display: grid;
}

.table-grid.ion-exception-focus .element.ion-exception-cell--lower {
  outline: 2px dashed color-mix(in srgb, var(--trend-color, #4a3f91) 54%, #fffdf8);
  outline-offset: -4px;
}

.table-grid.ion-exception-focus .element.ion-exception-cell--lower::after {
  color: color-mix(in srgb, var(--trend-color, #4a3f91) 76%, #19202a);
  background: rgba(255, 252, 246, 0.92);
}

.table-grid.ion-exception-focus .trend-guide-card,
.table-grid.ion-exception-focus .placeholder,
.table-grid.ion-exception-focus .element:not(.ion-exception-cell) {
  opacity: 0.16;
  filter: saturate(0.35);
}

.table-grid.ion-exception-focus .trend-guide-card {
  pointer-events: none;
}

.ion-exception-direction-cue {
  position: relative;
  z-index: 13;
  align-self: stretch;
  margin: 20px 6px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.table-grid.ion-exception-focus .ion-exception-direction-cue {
  opacity: 1;
}

.ion-exception-direction-cue svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ion-exception-direction-cue path {
  fill: none;
  stroke: color-mix(in srgb, var(--trend-color, #301f67) 72%, #19323c);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
  opacity: 0.82;
}

.ion-exception-direction-cue marker path {
  fill: color-mix(in srgb, var(--trend-color, #301f67) 72%, #19323c);
  stroke: none;
  opacity: 1;
}

.ion-exception-relation {
  position: relative;
  z-index: 11;
  align-self: center;
  display: grid;
  grid-template-columns: minmax(44px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  gap: 8px;
  margin: 6px 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.table-grid.ion-exception-focus .ion-exception-relation {
  opacity: 1;
  transform: translateY(0);
}

.ion-exception-relation::before {
  display: none;
}

.ion-exception-card {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 42px;
  min-height: 38px;
  border-radius: 8px;
  padding: 5px 7px 6px;
  box-shadow: 0 10px 22px rgba(25, 32, 42, 0.16);
  line-height: 1;
}

.ion-exception-card b {
  font-size: 1rem;
  font-weight: 900;
}

.ion-exception-card small {
  margin-top: 3px;
  font-size: 0.62rem;
  font-weight: 900;
}

.ion-exception-card--higher {
  color: #fffdf8;
  background: color-mix(in srgb, var(--trend-color, #301f67) 78%, #19323c);
}

.ion-exception-card--lower {
  color: color-mix(in srgb, var(--trend-color, #301f67) 76%, #19202a);
  background: rgba(255, 252, 246, 0.94);
  border: 2px dashed color-mix(in srgb, var(--trend-color, #301f67) 48%, rgba(25, 32, 42, 0.18));
}

.ion-exception-arrow {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  color: color-mix(in srgb, var(--trend-color, #301f67) 76%, #19202a);
  background: rgba(255, 252, 246, 0.96);
  box-shadow: 0 8px 18px rgba(25, 32, 42, 0.16);
  font-family: Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  text-indent: 1px;
  white-space: nowrap;
}

.ion-exception-relation--short {
  z-index: 14;
  justify-self: center;
  width: min(46px, 100%);
  grid-template-columns: 1fr;
  gap: 0;
  margin-inline: auto;
}

.ion-exception-relation--short::before,
.ion-exception-relation--short .ion-exception-card {
  display: none;
}

.ion-exception-relation--short .ion-exception-arrow {
  grid-column: 1;
  justify-self: center;
  width: 22px;
  height: 22px;
  min-width: 0;
  font-size: 0.72rem;
}

.trend-region {
  position: relative;
  z-index: 2;
  border: 2px solid var(--trend-color);
  border-radius: 8px;
  background: color-mix(in srgb, var(--trend-color) 9%, transparent);
  box-shadow:
    inset 0 0 0 2px rgba(255, 252, 246, 0.62),
    0 0 0 2px rgba(255, 252, 246, 0.58);
}

.trend-region span {
  position: absolute;
  top: 6px;
  left: 6px;
  border-radius: 999px;
  padding: 4px 7px;
  color: color-mix(in srgb, var(--trend-color) 76%, #19202a);
  background: rgba(255, 252, 246, 0.94);
  box-shadow: 0 6px 12px rgba(25, 32, 42, 0.1);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.trend-region--network span {
  top: auto;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
}

.detail-panel {
  border-radius: 8px;
  padding: 22px;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.atomic-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  flex: 0 0 auto;
  width: 76px;
  height: 88px;
  border-radius: 8px;
  border: 1px solid rgba(25, 32, 42, 0.12);
  padding: 7px 9px;
  color: var(--detail-card-ink, var(--ink));
  background: var(--detail-card-bg, var(--active));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    0 10px 24px rgba(25, 32, 42, 0.12);
}

.atomic-card-number {
  justify-self: start;
  color: var(--detail-card-muted, rgba(255, 255, 255, 0.78));
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.atomic-card-symbol {
  align-self: center;
  justify-self: center;
  font-size: 2.25rem;
  font-weight: 900;
  line-height: 0.95;
}

.atomic-card-name {
  overflow: hidden;
  color: var(--detail-card-muted, rgba(255, 255, 255, 0.78));
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-category {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.detail-main {
  min-width: 0;
}

.detail-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}

.detail-title-row h2 {
  margin: 0;
  font-size: 2.25rem;
  line-height: 1;
}

.detail-title-row h3 {
  margin: 0;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
}

.position-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.position-pills span {
  border: 1px solid rgba(20, 124, 114, 0.2);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--accent);
  background: rgba(20, 124, 114, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
}

.summary {
  color: var(--muted);
  line-height: 1.62;
}

.fact-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.fact-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.fact-list dt {
  color: var(--muted);
  font-weight: 700;
}

.fact-list dd {
  min-width: 0;
  margin: 0;
  font-weight: 900;
  text-align: right;
  overflow-wrap: anywhere;
}

.mini-chart {
  display: grid;
  grid-template-rows: auto 92px auto;
  gap: 8px;
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.58);
}

.mini-chart p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.mini-chart div {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 10px;
}

.mini-chart span {
  min-height: 8px;
  border-radius: 6px 6px 2px 2px;
  box-shadow: inset 0 -10px 18px rgba(255, 255, 255, 0.22);
}

.mini-chart span:nth-child(1) {
  background: linear-gradient(180deg, #dd5a67 0%, #f0b264 100%);
}

.mini-chart span:nth-child(2) {
  background: linear-gradient(180deg, #4c3f91 0%, #7ea3ee 100%);
}

.mini-chart span:nth-child(3) {
  background: linear-gradient(180deg, #2f9e8f 0%, #a8d8f0 100%);
}

.mini-chart ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  list-style: none;
  text-align: center;
}

.insight-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 520px);
  gap: 20px;
  margin-top: 16px;
  border-radius: 8px;
  padding: 20px 22px;
}

.insight-panel h2 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.insight-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.62;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: flex-end;
  gap: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--swatch);
}

.valence-panel {
  margin-top: 16px;
  border-radius: 8px;
  padding: 20px 22px 22px;
}

.valence-panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.valence-panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.valence-mode-button {
  min-height: 40px;
  border: 1px solid rgba(20, 124, 114, 0.34);
  border-radius: 8px;
  padding: 0 14px;
  color: #fffdf8;
  background: var(--active);
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.valence-mode-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(25, 32, 42, 0.14);
}

.valence-mode-button:focus-visible,
.valence-chip:focus-visible {
  outline: 3px solid rgba(20, 124, 114, 0.26);
  outline-offset: 2px;
}

.valence-board {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 16px;
}

.valence-section {
  min-width: 0;
}

.valence-section h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.valence-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.valence-chip {
  display: grid;
  grid-template-columns: minmax(42px, 0.55fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid color-mix(in srgb, var(--valence-chip) 38%, rgba(25, 32, 42, 0.14));
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--ink);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--valence-chip) 14%, transparent), rgba(255, 255, 255, 0.66)),
    rgba(255, 255, 255, 0.6);
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.valence-chip--static {
  cursor: default;
}

.valence-chip:not(.valence-chip--static):hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--valence-chip) 62%, rgba(25, 32, 42, 0.2));
  box-shadow: 0 10px 20px rgba(25, 32, 42, 0.1);
}

.valence-chip span {
  display: grid;
  place-items: center;
  min-height: 28px;
  border-radius: 7px;
  color: #fffdf8;
  background: color-mix(in srgb, var(--valence-chip) 76%, #19323c);
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1;
}

.valence-chip b {
  overflow-wrap: anywhere;
  color: color-mix(in srgb, var(--valence-chip) 62%, #19202a);
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.12;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) 1.2fr;
    gap: 18px;
  }

  .detail-panel h3,
  .summary,
  .fact-list,
  .mini-chart {
    grid-column: auto;
  }

  .valence-board {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    padding-top: 10px;
  }

  .topbar,
  .insight-panel,
  .valence-panel,
  .detail-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
    padding: 18px;
  }

  .controls,
  .search-box input,
  .select-box select,
  .trend-toggle {
    width: 100%;
    min-width: 0;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .search-box,
  .select-box {
    width: 100%;
  }

  .trend-toggle {
    justify-content: start;
  }

  .periodic-panel {
    padding-left: 42px;
  }

  .group-labels {
    left: 42px;
  }

  .table-grid,
  .group-labels,
  .period-labels {
    grid-template-columns: repeat(18, 48px);
    grid-template-rows: repeat(9, 64px);
    min-width: 966px;
  }

  .group-labels {
    grid-template-rows: 18px;
  }

  .period-labels {
    grid-template-columns: 30px;
    min-width: 30px;
  }

  .symbol {
    font-size: 1rem;
  }

  .trend-guide-head {
    flex-wrap: wrap;
  }

  .ionization-level-toggle {
    order: 3;
    flex-basis: 100%;
    min-width: 0;
  }

  .ionization-level-button {
    flex: 1 1 0;
    min-width: 0;
  }

  .value-badge {
    display: none;
  }

  .legend {
    justify-content: flex-start;
  }

  .valence-panel {
    padding: 18px;
  }

  .valence-panel-head {
    display: grid;
    align-items: start;
  }

  .valence-mode-button {
    width: 100%;
  }

  .valence-board,
  .valence-chip-grid {
    grid-template-columns: 1fr;
  }
}
