/* LabLife — calculator page: top bar, inputs, unit selectors, results and readouts. */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: border-color .2s, background-color .2s;
}
/* once the page scrolls, the bar turns into dark glass over the content */
.topbar.scrolled {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  backdrop-filter: saturate(1.3) blur(14px);
  border-bottom-color: var(--line);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 60px; }
/* the back button names where it goes; on a narrow phone a long name is cut short (…) rather than
 * pushing Share and Equations off the screen */
.topbar .wrap > .btn-ghost { min-width: 0; }
.topbar .wrap > .btn-ghost svg { flex: none; }
.topbar .wrap > .btn-ghost span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { flex: none; }
@media (max-width: 360px) { #eq-open { padding: 0 12px; } }
@media (max-width: 340px) { .topbar .wrap { gap: 6px; } .topbar .btn { font-size: 14px; } }

.calc-head { padding-block: 8px 20px; display: grid; gap: 8px; }
.calc-head h1 { font-size: 28px; font-weight: 600; letter-spacing: 0.005em; line-height: 1.2; }
.calc-head p { color: var(--ink-2); font-size: 15px; max-width: 60ch; }

.calc-body { display: grid; gap: 18px; padding-bottom: 40px; }
@media (min-width: 880px) {
  .calc-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 24px; }
  .results { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); }
}

.panel {
  border: 1px solid transparent; border-radius: var(--radius);
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--edge-soft) border-box;
  box-shadow: var(--shadow);
}
/* small violet titles in wide capitals ("Inputs", "More results") */
.panel-title {
  font-family: var(--font-display); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--accent); padding: 14px 16px 0;
}

/* inputs */
.fields { display: grid; }
.field { display: grid; gap: 8px; padding: 14px 16px; }
.field + .field { border-top: 1px solid var(--line); }
.field-label { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-size: 15px; font-weight: 500; }
.field-label .sym { color: var(--accent); min-width: 1.6em; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.field-row.no-unit { grid-template-columns: minmax(0, 1fr); }
.hint { font-size: 13px; color: var(--ink-2); }
.field.invalid .hint { color: var(--danger); }
.optional-tag { font-size: 12px; font-weight: 500; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }

.num {
  width: 100%; min-width: 0; height: 50px;
  padding: 0 14px;
  font-family: var(--font-num); font-size: 19px; font-variant-numeric: tabular-nums;
  background: var(--well); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  -webkit-appearance: none; appearance: none;
}
.num::placeholder { color: var(--ink-2); opacity: 0.7; font-family: var(--font-ui); font-size: 15px; }
.num:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 18px var(--glow); background: var(--well); }
.field.invalid .num { border-color: var(--danger); }
.num[readonly] { color: var(--ink-2); }

.triple { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.axis { position: relative; display: block; }
.axis .sym {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 15px; color: var(--ink-2); pointer-events: none;
}
.axis .num { padding-left: 34px; font-size: 16px; }

/* unit selector: native select (OS picker on phones), styled as a pill */
.unit-wrap { position: relative; display: inline-grid; }
.unit-wrap::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg); pointer-events: none; opacity: 0.7;
}
.unit {
  height: 50px; min-width: 84px; padding: 0 32px 0 14px;
  font-family: var(--font-num); font-size: 16px; font-weight: 500;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  -webkit-appearance: none; appearance: none;
}
.unit-wrap { color: var(--accent); }
.unit:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* a quantity with only one unit shows it as plain text */
.unit-static {
  display: inline-grid; align-items: center; height: 50px; min-width: 84px; padding: 0 14px;
  font-family: var(--font-num); font-size: 16px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.unit-static.sm { height: 36px; min-width: 70px; font-size: 14px; padding: 0 10px; }
.readout .unit-static { color: var(--readout-ink); }
.unit-wrap.sm .unit { height: 36px; min-width: 70px; font-size: 14px; padding: 0 28px 0 10px; border-radius: 8px; }
.unit-wrap.sm::after { right: 10px; width: 6px; height: 6px; margin-top: -4px; }

.species, .pick {
  width: 100%; height: 50px; padding: 0 36px 0 14px;
  font-size: 16px; font-weight: 500;
  background: var(--well); border: 1px solid var(--line); border-radius: var(--radius-sm);
  -webkit-appearance: none; appearance: none;
}
.species-wrap, .pick-wrap { display: grid; color: var(--ink-2); }
.stat-tag {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.stat-tag.boson { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.stat-tag.fermion { color: var(--info); background: var(--info-soft); border-color: transparent; }

.seg {
  display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 3px;
  background: var(--well); border: 1px solid var(--line); border-radius: 999px;
}
.seg button {
  min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px rgb(176 105 247 / 45%); }
/* full-width choice between methods */
.seg.block { display: grid; grid-auto-columns: minmax(0, 1fr); width: 100%; }
.seg.block button { min-height: 42px; padding: 0 8px; font-size: 14.5px; line-height: 1.2; }
.seg.block button[aria-pressed="true"] { background: var(--accent-strong); color: var(--accent-ink); box-shadow: 0 0 16px rgb(142 69 220 / 35%); }

/* results */
.val { background: none; border: 0; padding: 0; margin: 0; color: inherit; font-family: var(--font-num); cursor: copy; border-radius: 6px; }
.val:active { opacity: 0.6; }
.results { display: grid; gap: 12px; }
/* the main result: a glowing violet card with the same violet-to-amber edge as the menu cards */
.readout {
  color: var(--readout-ink);
  border: 1px solid transparent; border-radius: var(--radius); padding: 16px 16px 18px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgb(142 69 220 / 38%), transparent 60%) padding-box,
    radial-gradient(90% 120% at 100% 100%, rgb(233 152 79 / 12%), transparent 60%) padding-box,
    linear-gradient(var(--readout), var(--readout)) padding-box,
    var(--edge) border-box;
  display: grid; gap: 10px;
  box-shadow: var(--shadow), 0 0 36px rgb(142 69 220 / 18%);
}
.readout-label { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 15px; font-weight: 500; }
.readout-label .sym { color: var(--readout-ink); }
.readout-label { display: block; }
.readout-label .sym { margin-right: 8px; }
.readout-note { font-size: 13px; color: var(--readout-dim); }
.readout-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.readout .val {
  font-family: var(--font-num); font-weight: 500; font-size: clamp(32px, 10vw, 44px);
  letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums;
  color: var(--readout-ink); background: none; border: 0; padding: 0; text-align: left;
  min-width: 0; overflow-wrap: anywhere;
}
.readout .unit-wrap { color: var(--readout-ink); }
.readout .unit { background: var(--readout-2); color: var(--readout-ink); border-color: var(--readout-line); }

/* three-axis readout (σx, σy, σz) */
.readout-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; }
.readout-head .readout-label { flex: 1 1 12em; min-width: 0; }
.readout-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.readout-cells .cell {
  display: grid; gap: 2px; min-width: 0;
  background: var(--readout-2); border: 1px solid var(--readout-line); border-radius: var(--radius-sm);
  padding: 8px 10px 10px;
}
.readout-cells .cell .sym { font-size: 15px; color: var(--readout-dim); }
.readout .readout-cells .val { font-size: clamp(19px, 5.6vw, 27px); letter-spacing: -0.01em; }

.val sup { font-size: 0.6em; vertical-align: 0.75em; line-height: 0; }
.val .times { opacity: 0.75; margin: 0 0.12em; }

.out-list { display: grid; }
.out-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; padding: 12px 16px; }
.out-row + .out-row { border-top: 1px solid var(--line); }
.out-label { display: grid; gap: 1px; min-width: 0; }
.out-label .top { display: block; font-size: 14px; font-weight: 500; line-height: 1.35; }
.out-label .top .sym { color: var(--accent); margin-right: 6px; }
.out-note { font-size: 12.5px; color: var(--ink-2); }
.out-val { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.out-val .val {
  font-family: var(--font-num); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums;
  background: none; border: 0; padding: 4px 0; color: var(--ink); text-align: right; white-space: nowrap;
}
.out-row.triple-out { grid-template-columns: minmax(0, 1fr) auto; }
.out-row.triple-out .vals { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.out-row.triple-out .vals .cell { display: grid; gap: 0; background: var(--well); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 0; }
.out-row.triple-out .vals .cell .sym { font-size: 14px; color: var(--ink-2); }
.out-row.triple-out .vals .val { text-align: left; font-size: 16px; overflow-wrap: anywhere; white-space: normal; }

.chips { display: grid; gap: 8px; }
.chip {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; line-height: 1.4;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: currentColor; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip span { color: var(--ink); }
.chip a { color: inherit; font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }

.empty-note { font-size: 14px; color: var(--ink-2); padding: 0 2px; }
