:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  --background: #101116;
  --surface: #171922;
  --raised: #20232f;
  --ink: #f6f5f9;
  --muted: #b9b9c8;
  --line: #343548;
  --orange: #ff8a1f;
  --accent: #ffb06a;
  --danger: #ffb6b2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at 84% -35%, #33202f 0, transparent 43%), var(--background);
}

a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: #ffd0af; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 4px; }

.wrapper { width: min(72rem, calc(100% - 2rem)); margin-inline: auto; }
.top { border-bottom: 1px solid var(--line); background: #101116c9; }
.top > .wrapper { display: flex; align-items: center; gap: 1.6rem; min-height: 3.75rem; }
.brand { color: var(--ink); font-size: 1.05rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.brand strong { color: var(--orange); }
.top nav { display: flex; flex-wrap: wrap; gap: .2rem .7rem; }
.top nav a {
  padding: .5rem .65rem;
  border-radius: .5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .84rem;
  font-weight: 600;
}
.top nav a[aria-current], .top nav a:hover { color: var(--ink); background: var(--raised); }

main { padding-block: clamp(1.75rem, 5vw, 4.5rem); }
h1 {
  max-width: 20ch;
  margin: 0;
  font-size: clamp(2.25rem, 6.8vw, 4.5rem);
  line-height: 1.04;
  letter-spacing: -.045em;
  text-wrap: balance;
}
h2 { margin: 0 0 .75rem; font-size: 1.2rem; }
p { line-height: 1.6; }
.intro { max-width: 58ch; margin: .85rem 0 1.65rem; color: var(--muted); font-size: clamp(1rem, 2vw, 1.13rem); }
.tool-layout { display: grid; grid-template-columns: minmax(16rem, 2fr) minmax(21rem, 3fr); gap: 1rem; align-items: start; }

.panel {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(125deg, #1c1f2c 0%, var(--surface) 62%);
}

label, legend { font-weight: 650; }
.field { display: grid; gap: .45rem; margin-bottom: 1rem; }
.field small, .muted { color: var(--muted); }
input:not([type=radio]), select {
  min-width: 0;
  min-height: 3rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: #10121a;
  color: var(--ink);
  padding: .65rem .85rem;
  font-size: 1rem;
}
input::placeholder { color: #a6a7b6; }

.actions, .examples, .secondary { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.examples { margin: .8rem 0 1.15rem; }
button, .link-button {
  min-height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: var(--raised);
  color: var(--ink);
  padding: .48rem .75rem;
  text-decoration: none;
}
button:hover, .link-button:hover { border-color: var(--orange); color: var(--ink); }
button.primary {
  min-height: 3rem;
  background: var(--orange);
  border-color: var(--orange);
  color: #17100a;
  padding-inline: 1.05rem;
  font-weight: 800;
}
button.primary:hover { background: #ffa757; }

.result-value {
  margin: .25rem 0 .6rem;
  font-size: clamp(1.95rem, 5vw, 3.25rem);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -.035em;
  color: var(--accent);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.result-value span { color: var(--ink); font-size: .48em; letter-spacing: 0; }
.result-note { margin: .25rem 0 .9rem; color: var(--muted); }
.formula-answer { margin: .1rem 0; font-weight: 700; font-size: 1.1rem; }
.how { padding-top: 1.05rem; margin-top: 1.2rem; border-top: 1px solid var(--line); }
.how p { margin: .5rem 0; }

table { width: 100%; border-collapse: collapse; margin: .55rem 0; text-align: left; font-variant-numeric: tabular-nums; }
th, td { padding: .65rem .3rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .76rem; }
td:not(:first-child), th:not(:first-child) { text-align: right; }
.legend { font-size: .86rem; color: var(--muted); }
.error { margin: .8rem 0 0; color: var(--danger); font-size: .92rem; }

fieldset { margin: 0 0 1rem; padding: 0; border: 0; }
fieldset > div { display: flex; flex-wrap: wrap; gap: .4rem 1rem; padding: .45rem 0; }
fieldset label { padding-block: .25rem; font-size: .92rem; cursor: pointer; }
input[type=radio] { accent-color: var(--orange); margin-inline: 0 .35rem; }

.reference { max-width: 72ch; margin-top: 1.35rem; color: var(--muted); font-size: .84rem; }
.code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
.orbitals { padding: 0; margin: .75rem 0 1rem; display: grid; list-style: none; gap: .6rem; }
.orbitals li { display: flex; align-items: center; gap: .6rem; }
.orbital-label { width: 2.5rem; color: var(--muted); }
.boxes { display: flex; flex-wrap: wrap; gap: .23rem; }
.boxes span {
  width: clamp(1.45rem, 3.9vw, 1.8rem);
  height: 1.8rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: .22rem;
  color: var(--accent);
  font-weight: 750;
}

.tool-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; list-style: none; padding: 0; }
.tool-list a { font-weight: 750; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 710px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr); }
  .top > .wrapper { align-items: flex-start; flex-direction: column; gap: .35rem; padding-block: .7rem; }
  .top nav a { padding: .5rem .38rem; }
  .action button { width: 100%; }
}
