:root {
  --bg-0: #0d1217;
  --bg-1: #141b23;
  --panel: #151d25;
  --panel-strong: #19222b;
  --ink: #d9e1ea;
  --ink-soft: #95a4b4;
  --ink-faint: #728395;
  --line: #263341;
  --line-strong: #3a4b5c;
  --shadow: none;
  --accent-nuclear: #7f96ac;
  --accent-coulomb: #6a8dad;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Bahnschrift", "Aptos", "Segoe UI Variable", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(92, 125, 156, 0.08), transparent 28%),
    radial-gradient(circle at bottom right, rgba(71, 99, 125, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
}

.app-shell {
  width: min(1500px, calc(100vw - 30px));
  min-height: 100dvh;
  height: calc(100dvh - 36px);
  margin: 0 auto;
  padding: 18px 0;
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 26px;
  align-items: stretch;
}

.settings-panel {
  position: relative;
  padding: 22px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(rgba(84, 107, 130, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 107, 130, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, #141c24, #121920);
  background-size: 24px 24px, 24px 24px, auto;
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: auto;
}

.settings-panel__header {
  margin-bottom: 18px;
}

.settings-panel__eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

h1 {
  margin: 0;
  font-family: "Bahnschrift", "Aptos", "Segoe UI Variable", sans-serif;
  font-size: clamp(2.2rem, 3vw, 3.2rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

details {
  position: relative;
}

.accordion-card,
.sub-card {
  margin: 0 0 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  overflow: hidden;
}

.accordion-card summary,
.sub-card summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  cursor: pointer;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  background: #1a232d;
}

.sub-card summary {
  padding: 16px 18px;
  font-size: 1.3rem;
  background: #18212a;
}

.accordion-card summary::-webkit-details-marker,
.sub-card summary::-webkit-details-marker {
  display: none;
}

.accordion-card summary::before,
.sub-card summary::before {
  content: ">";
  display: inline-block;
  width: 22px;
  color: var(--ink);
  transform: rotate(0deg);
  transition: transform 150ms ease;
}

.accordion-card[open] > summary::before,
.sub-card[open] > summary::before {
  transform: rotate(90deg);
}

.accordion-card__body,
.sub-card__body {
  padding: 0 20px 20px;
}

.control-card {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.control-card__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--ink);
  font-weight: 700;
}

.control-card__label output {
  min-width: 64px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #111821;
  color: var(--accent-coulomb);
  text-align: center;
}

.control-card input[type="range"] {
  width: 100%;
  accent-color: var(--accent-coulomb);
}

.control-card__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-weight: 700;
}

.control-card__toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-coulomb);
}

.accordion-card__body--stacked {
  display: grid;
  gap: 18px;
}

.empty-note,
.mass-note {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #19222b;
  line-height: 1.6;
  color: var(--ink-soft);
}

.atom-info {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #19222b;
  min-height: 176px;
}

.atom-info--gas {
  border-color: #629ede;
  box-shadow: inset 0 0 0 1px rgba(98, 158, 222, 0.14);
}

.atom-info--noble-gas {
  border-color: #db6767;
  box-shadow: inset 0 0 0 1px rgba(219, 103, 103, 0.14);
}

.atom-info--metal {
  border-color: #e49c4c;
  box-shadow: inset 0 0 0 1px rgba(228, 156, 76, 0.14);
}

.atom-info--radioactive {
  border-color: #73c97a;
  box-shadow: inset 0 0 0 1px rgba(115, 201, 122, 0.14);
}

.atom-info--fictional {
  border-color: #ae71e7;
  box-shadow: inset 0 0 0 1px rgba(174, 113, 231, 0.14);
}

.atom-info--neutral {
  border-color: #7f8d9b;
  box-shadow: inset 0 0 0 1px rgba(127, 141, 155, 0.12);
}

.atom-info__title,
.atom-info__placeholder-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.atom-info__counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.atom-info__counts span,
.atom-info__badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #111821;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.atom-info__line,
.atom-info__placeholder-copy {
  margin: 0 0 8px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.atom-info__line:last-child,
.atom-info__placeholder-copy:last-child {
  margin-bottom: 0;
}

.atom-info__line--muted {
  color: var(--ink-faint);
}

.key-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.key-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #18212a;
}

.key-row--button {
  width: 100%;
  cursor: pointer;
  color: inherit;
  text-align: left;
  font: inherit;
  appearance: none;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.key-row--button:hover {
  border-color: var(--line-strong);
  background: #1b2630;
}

.key-row--button:focus-visible {
  outline: 2px solid rgba(122, 154, 188, 0.72);
  outline-offset: 2px;
}

.key-row--button:active {
  transform: translateY(1px);
  background: #1f2a35;
}

.key-row__key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #10161d;
  font-weight: 700;
  color: var(--accent-coulomb);
}

.key-row__label {
  font-size: 1.1rem;
  font-weight: 700;
}

.key-row__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #10161d;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.graph-canvas {
  display: block;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(rgba(92, 115, 139, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 115, 139, 0.1) 1px, transparent 1px),
    #111820;
  background-size: 22px 22px, 22px 22px, auto;
  touch-action: none;
}

.point-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.graph-scale {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.graph-scale__field {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.graph-scale__input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #111821;
  color: var(--ink);
  font: inherit;
}

.point-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #141c24;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.point-tag__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.simulation-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.simulation-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.toolbar-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #171f28;
  box-shadow: var(--shadow);
}

.toolbar-pill span {
  display: block;
  margin-bottom: 3px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.toolbar-pill strong {
  font-size: 0.98rem;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-left: auto;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 11px 16px;
  background: #18212a;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 160ms ease, border-color 160ms ease;
}

button:hover {
  background: #1d2832;
  border-color: #63778b;
}

button:active {
  background: #121920;
}

.button-secondary {
  background: #121a22;
}

.simulation-frame {
  position: relative;
  min-height: 0;
  height: 100%;
  border-radius: 34px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(rgba(92, 115, 139, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 115, 139, 0.08) 1px, transparent 1px),
    #10171f;
  background-size: 24px 24px, 24px 24px, auto;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#simulationCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
}

.simulation-hint {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(17, 24, 32, 0.92);
  color: var(--ink-soft);
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  pointer-events: none;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    height: auto;
  }

  .settings-panel {
    overflow: visible;
  }

  .simulation-column {
    min-height: 70dvh;
  }

  .simulation-frame {
    min-height: 70dvh;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 18px, 1500px);
    padding: 10px 0;
  }

  .settings-panel {
    padding: 16px;
  }

  .accordion-card summary,
  .sub-card summary {
    font-size: 1.12rem;
  }

  .toolbar-actions {
    margin-left: 0;
  }

  .simulation-column {
    min-height: 58dvh;
  }

  .simulation-frame {
    min-height: 58dvh;
  }
}
