/* LRA Tools design system: Drafting.
   Light first, like a clean engineering drawing marked up in signal red, with a matching dark theme.
   Type follows the Tailwind scale, spacing uses 0 2 4 8 12 16 24 32 40 48 64 80 96 px only,
   and every transition uses one easing curve.
   Greys run in three text tiers (--text, --muted, --soft) and depth comes from one shadow scale
   (--shadow-sm, --shadow-md, --shadow-lg) rather than extra borders. */
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  color-scheme: light;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --line: #dce0e5;
  --text: #0d0f12;
  --muted: #4b5260;
  --soft: #656c78;
  --accent: #d92d20;
  --accent-strong: #b42318;
  --accent-soft: rgba(217, 45, 32, 0.08);
  --grad-a: #e5483b;
  --grad-b: #b42318;
  --glow: rgba(217, 45, 32, 0.24);
  --brand: #d92d20;
  --gold: var(--accent);
  --mint: #13795b;
  --button-text: #ffffff;
  --warn: var(--gold);
  --nav-bg: rgba(255, 255, 255, 0.72);
  --scrim: 244, 245, 247;
  --head-a: #000000;
  --head-b: #666666;
  --shadow: 0 16px 48px rgba(13, 15, 18, 0.08);
  --shadow-sm: 0 0 0 1px rgba(13, 15, 18, 0.05), 0 1px 2px rgba(13, 15, 18, 0.05), 0 2px 6px -2px rgba(13, 15, 18, 0.08);
  --shadow-md: 0 2px 4px -2px rgba(13, 15, 18, 0.06), 0 6px 12px -4px rgba(13, 15, 18, 0.1);
  --shadow-lg: 0 4px 8px -4px rgba(13, 15, 18, 0.08), 0 16px 32px -8px rgba(13, 15, 18, 0.16);
  --card-border: transparent;
  --primary-shadow: 0 1px 2px rgba(180, 35, 24, 0.24), 0 4px 12px -4px var(--glow);
  font-family: var(--sans);
  font-synthesis: none;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #181818;
  --surface: #1f1f1f;
  --surface-2: #272727;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f1f2f4;
  --muted: #b4b9c2;
  --soft: #8c929c;
  --accent: #f0564a;
  --accent-strong: #e5483b;
  --accent-soft: rgba(240, 86, 74, 0.12);
  --grad-a: #ee5a4d;
  --grad-b: #c42519;
  --glow: rgba(229, 72, 59, 0.3);
  --brand: #e5483b;
  --gold: var(--accent);
  --mint: #3ccb8f;
  --button-text: #ffffff;
  --nav-bg: rgba(31, 31, 31, 0.72);
  --scrim: 24, 24, 24;
  --head-a: #ffffff;
  --head-b: #9b9b9b;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 4px -2px rgba(0, 0, 0, 0.3), 0 6px 12px -4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 8px -4px rgba(0, 0, 0, 0.4), 0 16px 32px -8px rgba(0, 0, 0, 0.5);
  --card-border: var(--line);
  --primary-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px -4px var(--glow);
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  color: inherit;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input {
  min-width: 0;
  font-size: 16px;
}
button svg,
a svg {
  pointer-events: none;
}
.icon-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.04em;
}
p {
  color: var(--muted);
}
.mono,
.eyebrow {
  font-family: var(--mono);
}
.eyebrow {
  font-size: 12px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.5;
}
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint) 10%, transparent);
  flex-shrink: 0;
}

nav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 12px;
}

main {
  max-width: 1220px;
  margin: auto;
}
.page {
  padding: 0 32px;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  transition:
    background 0.2s,
    transform 0.2s;
}
.button:hover {
  transform: translateY(-1px);
}
.primary {
  background: var(--accent);
  color: var(--button-text);
  border-color: var(--accent);
}
.primary:hover {
  background: var(--accent-strong);
  color: #fff;
}
.secondary {
  background: var(--surface);
  color: var(--text);
}
.secondary:hover {
  background: var(--surface-2);
}

.accent {
  color: var(--accent);
}

.featured {
  border-color: var(--accent);
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--accent) 10%, var(--surface)),
    var(--surface)
  );
}
.plan-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.saving {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 9%, transparent);
  padding: 4px 4px;
  border: 1px solid color-mix(in srgb, var(--gold) 25%, transparent);
  border-radius: 4px;
  white-space: nowrap;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--soft);
}
.narrow-page {
  max-width: 470px;
  margin: 48px auto 96px;
}
.back-link {
  font-size: 12px;
  color: var(--muted);
  display: inline-block;
  min-height: 44px;
  padding: 8px 0;
}
.auth-card {
  padding: 32px 0;
}
.auth-card h1 {
  font-size: 36px;
  margin: 16px 0;
}
.auth-card > p:not(.eyebrow) {
  font-size: 12px;
}
.auth-card form {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}
label {
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
label input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  width: 100%;
  min-height: 48px;
}
input::placeholder {
  color: var(--soft);
  opacity: 0.7;
}
.password-field {
  position: relative;
}
.password-field input {
  padding-right: 64px;
}
.password-field button {
  position: absolute;
  right: 5px;
  top: 4px;
  background: none;
  border: none;
  color: var(--muted);
  padding: 12px;
  font-size: 12px;
}
.full-width {
  width: 100%;
}
.auth-options {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  gap: 8px;
}
.text-button {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 8px 0;
  font-size: 12px;
  min-height: 44px;
}
.auth-trial-note {
  border-top: 1px solid var(--line);
  padding-top: 24px;
  margin-top: 24px;
  font-size: 14px !important;
}
.connection-banner {
  background: color-mix(in srgb, var(--warn) 12%, var(--bg));
  color: var(--warn);
  padding: 8px 16px;
  font-size: 12px;
  text-align: center;
}
.toast {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  max-width: calc(100% - 32px);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 12px;
  padding: 12px 16px;
}
.toast.error {
  border-color: var(--warn);
}
.calculator-page {
  max-width: 1060px;
  margin: auto;
  padding-top: 24px;
  padding-bottom: 96px;
}
.calc-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 24px;
}
.calc-heading h1 {
  font-size: 30px;
  margin-top: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 24px;
  flex-shrink: 0;
}
.icon-button:hover {
  color: var(--accent);
  background: var(--surface-2);
}
.calc-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.setting-button {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}
.setting-button.active,
.setting-button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  color: var(--accent);
}
.setting-symbol {
  font-family: var(--mono);
  font-size: 18px;
  line-height: 20px;
}
.calc-toolbar > .icon-button {
  margin-left: auto;
}
.file-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
  margin-bottom: 16px;
}
.file-menu button {
  border: 0;
  background: none;
  font-size: 12px;
  padding: 12px;
  color: var(--muted);
  border-radius: 4px;
}
.file-menu button:hover {
  background: var(--surface-2);
}
.input-guide {
  display: flex;
  justify-content: space-between;
  padding: 0 12px;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.input-guide .mono {
  font-size: 12px;
  color: var(--soft);
  margin-left: 4px;
}
.bend-rows {
  display: grid;
  gap: 8px;
}
.bend-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.bend-row.final-row {
  border-style: dashed;
  background: color-mix(in srgb, var(--surface) 65%, var(--bg));
}
.row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.row-step {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text);
}
.row-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.row-controls button {
  width: 34px;
  height: 34px;
  min-width: 34px;
}
.row-controls .icon {
  width: 17px;
  height: 17px;
}
.comp-toggle {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--soft);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.comp-toggle.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.trash-button {
  background: none;
  border: 0;
  color: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.trash-button:hover {
  color: var(--warn);
}
.row-fields {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}
.machine-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.error-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.field {
  min-width: 0;
}
.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  height: 26px;
}
.field-label small {
  font-size: 12px;
  color: var(--soft);
  font-family: var(--sans);
}
.entry-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  display: flex;
  align-items: center;
  min-height: 47px;
}
.entry-wrap:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.entry-wrap.locked {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
}
.entry-wrap input {
  width: 100%;
  border: 0;
  background: none;
  color: var(--text);
  padding: 12px 4px 12px 8px;
  outline: none !important;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  min-height: 45px;
  font-size: 16px;
  letter-spacing: -0.035em;
}
.lock-button {
  width: 29px;
  min-width: 29px;
  height: 44px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.lock-button .icon {
  width: 14px;
  height: 14px;
}
.locked .lock-button {
  color: var(--accent);
}
.lock-button:disabled {
  opacity: 1;
  cursor: default;
}
.sign-button {
  border: 0;
  background: none;
  color: var(--soft);
  font-size: 12px;
  width: 28px;
  min-width: 28px;
  height: 40px;
  padding: 0;
}
.no-value {
  color: var(--soft);
  font-size: 14px;
  padding: 8px;
  min-height: 45px;
  display: flex;
  align-items: center;
}
.error-fields .entry-wrap {
  background: color-mix(in srgb, var(--surface-2) 35%, var(--bg));
}
.field-group-title {
  display: none;
}
.clr-linked {
  color: var(--accent) !important;
}
.add-bend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 16px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}
.add-bend:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.calculate-dock {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0 calc(14px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.calculate-dock .mono {
  font-size: 12px;
  color: var(--text);
}
.calculate-dock small {
  display: block;
  font-size: 12px;
  color: var(--soft);
  margin-top: 2px;
}
.calculate-dock .button {
  min-width: 160px;
}
.mapping-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  margin-bottom: 16px;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-heading h2 {
  font-size: 16px;
}
.mapping-panel p {
  font-size: 12px;
  margin: 8px 0;
}
.mapping-table {
  max-height: 320px;
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  text-align: right;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
td {
  text-align: right;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
th:first-child,
td:first-child {
  text-align: left;
}
.mapping-table select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
  font-size: 16px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  min-height: 44px;
}
.check-label input {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}
.results {
  margin-top: 32px;
  scroll-margin-top: 25px;
}
.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.results-heading h2 {
  font-size: 24px;
  margin-top: 4px;
}
.result-status {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.result-status span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 8px;
  font-size: 12px;
  color: var(--muted);
}
.result-status .good {
  color: var(--mint);
  border-color: color-mix(in srgb, var(--mint) 30%, var(--line));
}
.result-status .attention {
  color: var(--warn);
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}
.result-card h3 {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.result-card h3 span {
  font-size: 12px;
  color: var(--soft);
}
.result-card td:last-child {
  color: var(--text);
  font-weight: 600;
}
.result-card td {
  font-family: var(--mono);
  font-size: 12px;
}
.result-card tr:last-child td {
  border-bottom: 0;
}
.result-card .final-result {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.final-note {
  font-size: 12px;
  margin: 12px 0;
  color: var(--soft);
}
.residual-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
  font-size: 12px;
  background: var(--surface);
}
summary {
  cursor: pointer;
  min-height: 24px;
  font-size: 12px;
  color: var(--muted);
}
summary span {
  float: right;
}
.residual-table {
  overflow: auto;
  margin-top: 16px;
}
.residual-details p {
  font-size: 12px;
  line-height: 1.7;
  margin-top: 16px;
}
.inline-notice {
  font-size: 12px;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 8%, var(--surface));
  padding: 8px 12px;
  margin: 8px 0;
}
.results.stale .result-card {
  border-style: dashed;
  border-color: var(--warn);
}
.results.stale #copy {
  opacity: 0.5;
}
.account-page {
  max-width: 760px;
  margin: 24px auto 80px;
}
.account-page > h1 {
  font-size: 36px;
  margin-top: 8px;
}
.account-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
}
.avatar {
  width: 45px;
  height: 45px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.account-summary h2 {
  font-size: 18px;
  letter-spacing: -0.02em;
}
.account-summary p {
  font-size: 12px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}
.settings-card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.setting-row h2 {
  font-size: 14px;
  letter-spacing: -0.015em;
}
.setting-row p {
  font-size: 12px;
  line-height: 1.8;
  margin-top: 4px;
}
.small-tag {
  font-size: 12px;
  font-family: var(--mono);
  padding: 4px 8px;
  border: 1px solid var(--line);
  color: var(--accent);
  border-radius: 4px;
  white-space: nowrap;
}
.settings-card > .button {
  margin-top: 16px;
}
.account-plans {
  margin-bottom: 24px;
}
.account-plan {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.account-plan h3 {
  font-size: 12px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.account-plan p {
  font-size: 12px;
  margin-top: 8px;
}
.account-plan strong {
  font-size: 20px;
  color: var(--text);
}
.account-plan small {
  display: block;
  font-size: 12px;
  margin-top: 4px;
}
.account-plan-note {
  font-size: 12px;
  line-height: 1.6;
  padding: 4px 4px 0;
}
.theme-control {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 4px;
}
.theme-control button {
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--soft);
  width: 40px;
  height: 38px;
}
.theme-control button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--surface-2);
}
.signout-button {
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding: 16px 0;
}
.legend-dialog,
.confirm-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: calc(100% - 28px);
  max-width: 570px;
  padding: 24px;
  max-height: calc(100dvh - 50px);
  overflow: auto;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: #070a13b0;
  backdrop-filter: blur(5px);
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dialog-heading h2 {
  font-size: 24px;
  margin-top: 8px;
}
.legend-visual {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 24px 0;
  font-size: 12px;
  color: var(--muted);
}
.legend-field {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px;
  color: var(--accent);
  font-family: var(--mono);
}
.legend-field strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
}
.legend-list {
  margin: 0;
}
.legend-list > div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.legend-list dt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}
.legend-list dt svg,
.legend-list dt .setting-symbol {
  color: var(--accent);
  width: 20px;
}
.legend-list dd {
  margin: 8px 0 0 32px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}
.legend-tip {
  padding: 16px 0;
}
.legend-tip .mono {
  font-size: 12px;
  color: var(--accent);
}
.legend-tip p {
  font-size: 12px;
  line-height: 1.8;
  margin-top: 8px;
}
.confirm-dialog {
  max-width: 400px;
}
.confirm-dialog h2 {
  font-size: 20px;
}
.confirm-dialog p {
  font-size: 12px;
  margin: 16px 0;
}
.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
[hidden] {
  display: none !important;
}
@keyframes flow {
  to {
    stroke-dashoffset: -415;
  }
}
@keyframes rotation-glow {
  50% {
    opacity: 0.3;
  }
}
@media (min-width: 900px) {
  .row-top {
    margin-bottom: 4px;
  }
  .bend-row {
    padding: 12px 16px;
  }
  .row-fields {
    gap: 24px;
  }
  .calc-heading {
    margin-bottom: 16px;
  }
}
@media (max-width: 760px) {
  .page {
    padding-left: 16px;
    padding-right: 16px;
  }

  nav {
    gap: 12px;
    font-size: 12px;
  }

  footer {
    font-size: 12px;
    gap: 12px;
  }
  .narrow-page {
    margin: 16px auto 64px;
  }
  .calculator-page {
    padding-top: 16px;
  }
  .calc-heading {
    margin: 8px 0 16px;
  }
  .calc-heading h1 {
    font-size: 24px;
  }
  .calc-toolbar {
    gap: 4px;
    margin-bottom: 16px;
  }
  .setting-button {
    gap: 4px;
    padding: 8px 8px;
    font-size: 12px;
    min-height: 44px;
  }
  .setting-button .icon {
    width: 17px;
  }
  .calc-toolbar > .icon-button {
    width: 36px;
    min-width: 36px;
    border: 0;
    background: none;
  }
  .input-guide {
    display: none;
  }
  .row-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .bend-row {
    padding: 12px;
  }
  .machine-fields,
  .error-fields {
    gap: 8px;
  }
  .field-group-title {
    display: block;
    font-size: 12px;
    color: var(--soft);
    margin-bottom: 4px;
  }
  .field-label {
    font-size: 12px;
  }
  .entry-wrap input {
    padding-left: 8px;
    letter-spacing: -0.045em;
  }
  .lock-button {
    width: 27px;
    min-width: 27px;
  }
  .sign-button {
    min-width: 19px;
    width: 19px;
  }
  .machine-fields .sign-button {
    position: absolute;
    top: -27px;
    right: 0;
    height: 24px;
    font-size: 12px;
  }
  .row-name {
    font-size: 12px;
  }
  .row-top {
    margin-bottom: 8px;
  }
  .row-controls {
    gap: 8px;
  }
  .row-controls button {
    min-height: 38px;
    width: 38px;
  }
  .calculate-dock {
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  }
  .calculate-dock .button {
    min-width: 145px;
  }
  .calculate-dock small {
    font-size: 12px;
  }
  .result-grid {
    gap: 8px;
  }
  .result-card {
    padding: 12px 8px;
  }
  .result-card h3 {
    font-size: 14px;
    padding: 0 2px;
  }
  .result-card th {
    font-size: 12px;
    padding: 8px 2px;
  }
  .result-card td {
    font-size: 12px;
    padding: 8px 2px;
  }
  .result-card th:first-child,
  .result-card td:first-child {
    display: none;
  }
  .result-status span {
    font-size: 12px;
    padding: 8px;
  }
  .results-heading h2 {
    font-size: 24px;
  }
  .account-page {
    margin-top: 16px;
  }
  .account-page > h1 {
    font-size: 30px;
  }
  .settings-card {
    padding: 16px;
  }
  .setting-row {
    gap: 12px;
  }
  .setting-row p {
    font-size: 12px;
  }
  .setting-row .text-button {
    font-size: 12px;
    white-space: nowrap;
  }
  .account-plan {
    padding: 16px;
  }
  .account-plan .button {
    padding: 12px 12px;
    font-size: 12px;
  }
  .account-plan h3 {
    gap: 8px;
  }
  .account-plan .saving {
    font-size: 12px;
  }
  .legend-dialog {
    padding: 16px;
    border-radius: 12px;
  }
  .dialog-heading h2 {
    font-size: 20px;
  }
  .legend-visual {
    gap: 12px;
    padding: 12px;
  }
  .legend-field {
    gap: 8px;
    padding: 8px;
  }
  .legend-list dd {
    font-size: 12px;
  }
  .legend-list dt {
    font-size: 12px;
  }
  .legend-tip p {
    font-size: 12px;
  }
  .toast {
    bottom: calc(85px + env(safe-area-inset-bottom));
    font-size: 12px;
  }
}
@media (max-width: 370px) {
  .page {
    padding-left: 12px;
    padding-right: 12px;
  }
  .calc-toolbar {
    gap: 4px;
  }
  .setting-button {
    padding: 8px 8px;
    font-size: 12px;
  }

  .calculate-dock small {
    max-width: 120px;
  }
  .entry-wrap input {
    font-size: 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -0px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 760px) {
  .field-group-title {
    grid-column: 1/-1;
  }
  .machine-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .machine-fields .field {
    min-width: 0;
  }
  .entry-wrap input {
    font-size: 16px;
  }
  .field-group-title {
    margin-bottom: 0;
  }
  .row-fields {
    gap: 12px;
  }
}
.result-status {
  font-size: 12px;
  color: var(--mint);
}

.result-status.attention {
  color: var(--warn);
}

/* Compact spreadsheet workspace */
.table-scroll-hint {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px;
}
.table-scroll-hint span {
  color: var(--accent);
}
.input-table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) var(--surface);
}
.input-table {
  width: 100%;
  min-width: 780px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}
.input-table .step-col {
  width: 38px;
}
.input-table .machine-col {
  width: 100px;
}
.input-table .error-col {
  width: 90px;
}
.input-table .actions-col {
  width: 72px;
}
.input-table th,
.input-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 4px;
  text-align: center;
}
.input-table thead th {
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  padding: 8px 4px;
}
.input-table thead small {
  color: var(--soft);
  font-size: 12px;
}
.input-table .group-head th {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 4px;
}
.input-table .bend-row {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface);
}
.input-table tbody th,
.input-table .group-head th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-2);
}
.input-table tbody th small {
  display: block;
  font-size: 12px;
  color: var(--gold);
  margin-top: 2px;
}
.input-table .row-step {
  background: none;
  border: 0;
  padding: 0;
  font-size: 12px;
  color: var(--muted);
}
.input-table tr:last-child td,
.input-table tr:last-child th {
  border-bottom: 0;
}
.input-table td:last-child,
.input-table thead tr:first-child th:last-child {
  border-right: 0;
}
.input-table .table-field {
  display: block;
  position: relative;
  margin: 0;
}
.input-table .entry-wrap {
  min-height: 40px;
  border: 0;
  border-radius: 4px;
  background: var(--bg);
}
.input-table .entry-wrap input {
  padding: 8px 2px 8px 4px;
  min-height: 40px;
  height: 40px;
  font-size: 16px;
  letter-spacing: -0.055em;
}
.input-table .lock-button {
  width: 28px;
  min-width: 28px;
  height: 40px;
  padding: 2px;
}
.input-table .lock-button .icon {
  width: 12px;
  height: 12px;
}
.input-table .entry-wrap.locked {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, var(--line));
}
.input-table .sign-button {
  position: static;
  width: 20px;
  min-width: 20px;
  height: 40px;
  font-size: 12px;
}
.rotation-sign {
  position: absolute;
  right: 0;
  top: -3px;
  width: 16px;
  height: 17px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  z-index: 1;
}
.input-table .row-controls {
  display: flex;
  gap: 2px;
  justify-content: center;
  margin: 0;
}
.input-table .row-controls button {
  width: 29px;
  min-height: 38px;
  height: 38px;
  padding: 2px;
}
.input-table .row-controls .icon {
  width: 15px;
}
.unused-cell {
  color: var(--soft);
}
.calculator-page {
  padding-bottom: 96px;
}
.calculator-page .add-bend {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 12;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
  color: var(--button-text);
  box-shadow: 0 5px 20px #0005;
}
.add-bend .icon {
  width: 24px;
  height: 24px;
}
.calculator-page .calculate-dock {
  padding-left: 64px;
}
.calculate-dock > div {
  font-size: 12px;
}
.calculate-dock .button {
  min-width: 135px;
}
@media (max-width: 760px) {
  .calculator-page {
    padding-left: 12px;
    padding-right: 12px;
  }
  .table-scroll-hint {
    font-size: 12px;
  }
  .input-table .bend-row {
    padding: 0;
  }
  .calculate-dock > div {
    display: none;
  }
  .calculator-page .calculate-dock {
    justify-content: flex-end;
  }
  .input-table .row-controls {
    gap: 2px;
  }
  .input-table .row-controls button {
    min-height: 38px;
    width: 29px;
  }
  .input-table .entry-wrap input {
    font-size: 16px;
  }
}
@media (min-width: 900px) {
  .table-scroll-hint span {
    display: none;
  }
}
.input-table .bend-rows {
  display: table-row-group;
}
.input-table .bend-row {
  display: table-row;
}
.input-table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  contain: inline-size;
}
#calculator-form {
  min-width: 0;
  max-width: 100%;
}
.input-table .table-field {
  overflow: hidden;
}
.input-table-scroll {
  contain: inline-size layout paint;
}
/* Fixed-size paired states and anchored workspace menu */
.calc-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) 40px;
  gap: 4px;
  max-width: 470px;
  position: relative;
  overflow: visible;
}
.calc-toolbar .setting-button {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 8px 4px;
  gap: 4px;
  justify-content: center;
  font-size: 12px;
  white-space: nowrap;
  transition:
    background-color 200ms,
    border-color 200ms;
  color: var(--state-color);
  border-color: color-mix(in srgb, var(--state-color) 45%, var(--line));
  background: color-mix(in srgb, var(--state-color) 12%, var(--surface));
}
#polarity[aria-pressed="false"],
#direction[aria-pressed="false"],
#wrap[aria-pressed="false"],
#final-display[aria-pressed="true"] {
  --state-color: var(--accent);
}
#polarity[aria-pressed="true"],
#direction[aria-pressed="true"],
#wrap[aria-pressed="true"],
#final-display[aria-pressed="false"] {
  --state-color: var(--gold);
}
html[data-theme="light"] #polarity[aria-pressed="false"],
html[data-theme="light"] #direction[aria-pressed="false"],
html[data-theme="light"] #wrap[aria-pressed="false"],
html[data-theme="light"] #final-display[aria-pressed="true"] {
  --state-color: var(--accent);
}
html[data-theme="light"] #polarity[aria-pressed="true"],
html[data-theme="light"] #direction[aria-pressed="true"],
html[data-theme="light"] #wrap[aria-pressed="true"],
html[data-theme="light"] #final-display[aria-pressed="false"] {
  --state-color: var(--gold);
}
.calc-toolbar #clear {
  --state-color: var(--accent);
}
.calc-toolbar .setting-button .icon {
  width: 15px;
}
.menu-anchor {
  position: relative;
  width: 40px;
  height: 44px;
}
#file-menu-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  width: 40px;
  height: 44px;
  font-size: 24px;
  color: var(--text);
  border-radius: 8px;
}
.menu-anchor .file-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: min(225px, calc(100vw - 32px));
  max-height: min(360px, 60dvh);
  overflow-y: auto;
  display: grid;
  gap: 4px;
  padding: 8px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 12px;
}
.menu-anchor .file-menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 8px 12px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 12px;
  text-align: left;
}
.file-menu button:hover,
.file-menu button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}
.file-menu button span {
  font-size: 18px;
  color: var(--accent);
}
.input-panels {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.input-panel {
  min-width: 0;
}
.input-panel h2 {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin: 0 0 8px;
  color: var(--text);
}
.input-panel h2 span {
  font-size: 12px;
  color: var(--soft);
  font-weight: 400;
}
.input-table.machine-table {
  min-width: 480px;
}
.input-table.errors-table {
  min-width: 290px;
}
.input-table.errors-table .error-col {
  width: auto;
}
.input-table .entry-wrap input {
  letter-spacing: -0.035em;
}
.part-name-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 16px;
  max-width: 350px;
}
.part-name-label small {
  font-size: 12px;
  color: var(--soft);
  margin-left: 4px;
}
.part-name-label input {
  display: block;
  width: 100%;
  height: 42px;
  padding: 8px 12px;
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.workspace-links {
  display: flex;
  align-items: center;
  gap: 12px;
}
.history-link {
  font-size: 12px;
  color: var(--accent);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
  height: 44px;
  min-width: 70px;
  text-align: center;
}
.button {
  width: 190px;
  min-width: 0;
  height: 48px;
  min-height: 48px;
  white-space: nowrap;
}
.button.full-width,
#auth-submit {
  width: 100%;
}
.calculate-dock #calculate {
  width: 145px;
  min-width: 145px;
}
.account-plan .button {
  width: 130px;
}
.confirm-actions .button {
  width: 140px;
}

.settings-card .button {
  width: 190px;
}
.result-card th:first-child,
.result-card td:first-child {
  display: table-cell !important;
  width: 32px;
  font-size: 12px;
  color: var(--soft);
}
.result-card th:last-child {
  font-size: 12px;
}
.result-card td:last-child {
  font-size: 16px;
  padding: 12px 4px;
}
.residual-details summary {
  font-size: 12px;
}
.history-page {
  max-width: 850px;
  margin: 32px auto 80px;
}
.history-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 24px 0;
}
.history-heading h1 {
  font-size: 36px;
}
.history-heading span {
  font-size: 12px;
  color: var(--muted);
}
.history-search-label input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 12px;
}
.history-group h2 {
  font-size: 12px;
  color: var(--muted);
  margin: 32px 0 12px;
}
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  height: 76px;
  padding: 12px;
  margin-bottom: 8px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}
.history-item > span:first-child {
  min-width: 0;
}
.history-item strong {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}
.history-open {
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}
#history-status {
  font-size: 12px;
  margin-top: 12px;
}
#history-more {
  margin-top: 16px;
}
.history-note {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 0;
}
.history-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.history-actions .button {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
}
@media (max-width: 760px) {
  .input-panels {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .input-table.machine-table {
    min-width: 480px;
  }
  .input-table.errors-table {
    min-width: 0;
  }
  .errors-table .error-col {
    width: auto;
  }
  .history-page {
    margin-top: 16px;
  }
  .result-card td:last-child {
    font-size: 14px;
  }
  .calc-heading .workspace-links {
    gap: 8px;
  }
  .history-link {
    min-width: 62px;
    padding: 12px 8px;
  }
  .menu-anchor {
    width: 40px;
  }
  .account-plan .button {
    width: 110px;
  }
  .residual-details summary {
    font-size: 12px;
  }
  .history-heading h1 {
    font-size: 30px;
  }
}
@media (max-width: 360px) {
  .calc-toolbar .setting-button .icon,
  .calc-toolbar .setting-symbol {
    display: none;
  }
}

.input-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface-2);
}

/* Account and interaction audit */

.back-link,
.text-button,
.signout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  text-align: center;
  text-decoration: none;
}
.back-link:hover,
.text-button:hover,
.signout-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.auth-options {
  gap: 8px;
}
.auth-options .text-button {
  width: 50%;
  font-size: 12px;
}
/* The Show button sits beside the password box, not over it, so the
   fill icons password managers place inside the box stay clear. */
.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}
.password-field input {
  padding-right: 12px;
}
.password-field button {
  position: static;
  height: 48px;
  min-width: 64px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
}
.icon-button,
.lock-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 6px;
}
.input-table .lock-button {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 4px 4px 0;
  background: var(--surface-2);
}
.theme-control button {
  border: 1px solid var(--line);
  background: var(--bg);
}
.theme-control button[aria-pressed="true"] {
  border-color: var(--accent);
}
.residual-details summary {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
}
.check-label {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}
.history-item:hover {
  border-color: var(--accent);
}
.account-page {
  max-width: 880px;
}
.account-profile {
  padding: 24px;
  background: linear-gradient(
    120deg,
    color-mix(in srgb, var(--accent) 10%, var(--surface)),
    var(--surface)
  );
  border: 1px solid var(--line);
  border-radius: 12px;
}
.account-profile .avatar {
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  background: var(--surface-2);
}
.settings-card {
  border-radius: 12px;
}
.subscription-indicator {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}
.subscription-time {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}
#access-badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  min-width: 78px;
  text-align: center;
  padding: 8px 12px;
}
#access-badge[data-tier="lifetime"] #tier-text {
  background-image: linear-gradient(
    90deg,
    #f2769e,
    #eeac6c,
    #e5d477,
    #72dbb1,
    #6fbdf5,
    #b6a0fa,
    #f2769e
  );
  background-size: 200% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  animation: rainbow-text 5s linear infinite;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}
#access-badge[data-tier="premium"] {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 50%, var(--line));
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
}
#access-badge[data-tier="standard"] {
  color: #ced4df;
  border-color: #8f99aa;
  background: #8f99aa15;
}
html[data-theme="light"] #access-badge[data-tier="premium"] {
  color: var(--gold);
}
html[data-theme="light"] #access-badge[data-tier="standard"] {
  color: #5e687a;
}
html[data-theme="light"] #access-badge[data-tier="lifetime"] #tier-text {
  background-image: linear-gradient(
    90deg,
    #ad1a59,
    #a24a0b,
    #876000,
    #087454,
    #166bae,
    #7041b1,
    #ad1a59
  );
}
#account-reset {
  width: 150px !important;
  flex-shrink: 0;
}
.signout-button {
  margin-top: 8px;
  width: 150px;
  color: var(--warn);
}
@keyframes rainbow-text {
  to {
    background-position: 200% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  #access-badge[data-tier="lifetime"] #tier-text {
    animation: none;
  }
}
@media (max-width: 760px) {
  .account-profile {
    padding: 16px;
  }
  .account-page .settings-card .setting-row {
    flex-wrap: wrap;
  }
  .subscription-indicator {
    width: 100%;
    justify-content: flex-end;
  }
  .account-page .setting-row .button {
    max-width: 190px;
  }
  .auth-options .text-button {
    font-size: 12px;
    padding: 8px 8px;
  }

  .back-link {
    font-size: 12px;
  }
}

.button {
  transition: transform 0.2s;
}
.account-profile {
  margin-bottom: 16px;
}
.account-profile > div:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.text-button {
  height: 44px;
  min-height: 44px;
}
.auth-options .text-button {
  white-space: nowrap;
}

/* Audit: accessible focus, legible compact controls, and narrow-table discovery. */
h1[tabindex="-1"]:focus {
  outline: none;
}
.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 1000;
  padding: 12px 16px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
}
.skip-link:focus {
  top: 12px;
}
.table-scroll-hint {
  display: none;
}
@media (max-width: 620px) {
  .table-scroll-hint {
    display: inline;
    color: var(--muted);
  }
}

/* Email-only account identity and subscription overview. */
.email-profile {
  gap: 16px;
  padding: 16px;
}
.account-profile.email-profile #account-email {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  overflow-wrap: anywhere;
  min-width: 0;
}
.email-profile .avatar {
  flex-shrink: 0;
}
.subscription-indicator {
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
}
.subscription-indicator .subscription-time {
  border: 0;
  border-radius: 0;
  padding: 12px;
  min-width: 132px;
  text-align: center;
  font-size: 14px;
}
.subscription-indicator .subscription-time.unlimited {
  min-width: 60px;
  font-size: 24px;
  line-height: 20px;
  color: var(--accent);
}
.subscription-indicator #access-badge {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 12px;
  min-width: 90px;
  font-size: 14px;
  background: var(--surface-2);
}
#access-badge[data-tier="lifetime"] #tier-text {
  display: inline-block;
  -webkit-text-fill-color: transparent;
}
.install-heading {
  display: flex;
  gap: 12px;
  align-items: center;
}
.install-heading img {
  border-radius: 12px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.install-heading h2 {
  font-size: 18px;
  margin: 0 0 4px;
}
.install-heading p {
  font-size: 12px;
  margin: 0;
  color: var(--muted);
}
.install-card .install-button {
  margin-top: 16px;
  width: 100%;
}
.install-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.install-guide > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.install-guide h3 {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--text);
}
.install-guide p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.install-guide strong {
  color: var(--text);
  font-weight: 600;
}
.install-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin: 16px 0 0;
}
@media (max-width: 600px) {
  .install-guide {
    grid-template-columns: 1fr;
  }
  .email-profile {
    padding: 16px;
  }
}

.subscription-indicator {
  width: max-content;
  max-width: 100%;
  margin-left: auto;
}

.calc-toolbar {
  grid-template-columns: repeat(4, minmax(0, 1fr)) 48px 36px;
  max-width: 620px;
  gap: 4px;
}
.calc-toolbar .menu-anchor,
.calc-toolbar #file-menu-button {
  width: 36px;
  min-width: 36px;
}
@media (max-width: 600px) {
  .calc-toolbar .setting-button .icon,
  .calc-toolbar .setting-symbol {
    display: none;
  }
  .calc-toolbar .setting-button {
    padding: 8px 2px;
    font-size: 12px;
  }
}

/* Compact icon controls, with destructive actions beside history. */
.calc-toolbar {
  grid-template-columns: repeat(4, minmax(0, 1fr)) 36px;
}
.calc-toolbar .setting-button .icon {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.calc-toolbar .setting-symbol {
  display: inline-block;
  font-size: 18px;
  line-height: 18px;
}
.workspace-links .history-link,
.workspace-links .clear-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 88px;
  min-width: 88px;
  height: 44px;
  padding: 8px;
  font-size: 12px;
  border-radius: 8px;
}
.workspace-links .clear-button {
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.workspace-links .icon {
  width: 16px;
  height: 16px;
}
.table-units {
  white-space: nowrap;
}
@media (max-width: 620px) {
  .table-scroll-hint {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    margin-right: 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--accent);
    background: var(--surface-2);
    font-size: 12px;
    white-space: nowrap;
  }
  .calc-heading {
    flex-wrap: wrap;
    gap: 12px;
  }
  .calc-heading .workspace-links {
    width: 100%;
    justify-content: flex-end;
  }
  .calc-toolbar .setting-button {
    flex-direction: column;
    gap: 2px;
    height: 54px;
    padding: 4px 2px;
  }
  .calc-toolbar .menu-anchor,
  .calc-toolbar #file-menu-button {
    height: 54px;
  }
}

/* Keep the calculator title and compact workspace actions together. */
@media (max-width: 620px) {
  .calc-heading {
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
  }
  .calc-heading > div:first-child {
    min-width: 0;
  }
  .calc-heading h1 {
    font-size: 20px;
    white-space: nowrap;
  }
  .calc-heading .eyebrow {
    font-size: 12px;
  }
  .calc-heading .workspace-links {
    width: auto;
    gap: 4px;
    flex-shrink: 0;
  }
  .workspace-links .history-link {
    width: 60px;
    min-width: 60px;
  }
  .workspace-links .clear-button {
    width: 52px;
    min-width: 52px;
  }
  .workspace-links .history-link,
  .workspace-links .clear-button {
    padding: 4px 2px;
    font-size: 12px;
    gap: 2px;
    height: 36px;
  }
  .workspace-links .icon {
    width: 12px;
    height: 12px;
  }
  .workspace-links #help {
    width: 30px;
    min-width: 30px;
    height: 36px;
    padding: 4px;
  }
}
@media (max-width: 360px) {
  .calc-heading h1 {
    font-size: 16px;
  }
}

/* Unified workspace actions and continuous input-state borders. */
.calc-heading {
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.calc-heading .workspace-links {
  gap: 4px;
}
.workspace-links .history-link,
.workspace-links .clear-button,
.workspace-links #help {
  height: 44px;
  border-radius: 8px;
}
.calc-toolbar {
  gap: 4px;
  margin-bottom: 16px;
}
.calc-toolbar .setting-button,
.calc-toolbar #file-menu-button,
.calc-toolbar .menu-anchor {
  height: 54px;
  border-radius: 8px;
}
.input-table .entry-wrap,
.input-table .entry-wrap.locked {
  outline: none;
  box-shadow: none;
  border-radius: 6px;
  overflow: hidden;
}
.input-table .entry-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
}
.input-table .entry-wrap.locked::after {
  border-color: color-mix(in srgb, var(--gold) 60%, var(--line));
}
.input-table .entry-wrap:focus-within::after {
  border: 2px solid var(--accent);
}
.input-table .entry-wrap.locked:focus-within::after {
  border: 2px solid color-mix(in srgb, var(--gold) 70%, var(--line));
}
.input-table .entry-wrap.locked .lock-button {
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
}
.input-table .entry-wrap input {
  border-radius: 0;
  box-shadow: none;
}
.input-table .entry-wrap .lock-button:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px currentColor;
}
html[data-theme="light"] .input-table .entry-wrap.locked::after {
  border-color: color-mix(in srgb, var(--gold) 60%, var(--line));
}
html[data-theme="light"] .input-table .entry-wrap.locked .lock-button {
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
}
@media (max-width: 620px) {
  .calc-heading {
    gap: 8px;
  }
  .calc-heading h1 {
    font-size: 20px;
    line-height: 1.2;
  }
  .calc-heading .eyebrow {
    margin-bottom: 4px;
  }
  .workspace-links .history-link,
  .workspace-links .clear-button,
  .workspace-links #help {
    width: 36px;
    min-width: 36px;
    height: 44px;
    padding: 8px;
  }
  .workspace-links .history-link span,
  .workspace-links .clear-button span {
    display: none;
  }
  .workspace-links .icon {
    width: 17px;
    height: 17px;
  }
}
@media (max-width: 360px) {
  .calc-heading h1 {
    font-size: 20px;
  }
}

/* Photo import: source selection, bounded review, and reversible application. */
.photo-anchor {
  position: fixed;
  left: max(80px, calc(env(safe-area-inset-left) + 80px));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 13;
}
#photo-button {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--surface);
  box-shadow: 0 5px 20px #0005;
}
#photo-menu {
  position: absolute;
  bottom: 66px;
  left: -48px;
  width: 200px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
#photo-menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 4px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  text-align: left;
}
.calculator-page .calculate-dock {
  padding-left: 96px;
}
#photo-undo {
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface);
  margin: 12px 0;
}
.photo-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: calc(100% - 24px);
  max-width: 850px;
  padding: 16px;
  max-height: calc(100dvh - 24px);
  overflow: auto;
}
.photo-dialog .dialog-heading h2 {
  font-size: 20px;
}
.photo-dialog p {
  margin: 12px 0;
  line-height: 1.5;
}
.photo-caption {
  font-size: 12px;
  color: var(--muted);
}
.photo-actions {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}
.photo-dialog .button {
  max-width: 100%;
}
#photo-previews img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
  background: var(--bg);
}
.photo-review-scroll {
  overflow-x: auto;
  margin: 16px 0;
}
#photo-review table {
  width: 100%;
  min-width: 430px;
  border-collapse: collapse;
}
#photo-review th,
#photo-review td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}
#photo-review small {
  display: block;
  font-size: 12px;
  margin: 4px 0;
}
#photo-review input[data-photo-field] {
  width: 90px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--bg);
  color: var(--text);
}
.photo-uncertain {
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
}
.photo-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
}
.photo-check input {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.photo-confirm {
  margin: 16px 0;
}
@media (max-width: 600px) {
  .photo-dialog {
    padding: 12px;
  }
  .calculate-dock .button {
    width: 145px;
    min-width: 135px;
  }
  .photo-actions .button {
    width: 50%;
    font-size: 12px;
  }
}

.photo-dialog .dialog-heading {
  position: sticky;
  top: -20px;
  z-index: 4;
  background: var(--surface);
  padding: 12px 0;
}
@media (max-width: 600px) {
  .photo-dialog .dialog-heading {
    top: -14px;
  }
}

/* Beta information and uncluttered floating controls. */

.calculator-page .calculate-dock {
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  pointer-events: none;
}
.calculator-page .calculate-dock button {
  pointer-events: auto;
}
.photo-review-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.photo-review-heading .button {
  padding: 8px 8px;
  min-height: 40px;
  font-size: 12px;
}
.photo-dialog.reviewing #photo-usage,
.photo-dialog.reviewing > .photo-caption {
  display: none;
}
.photo-dialog.reviewing #photo-status {
  font-size: 12px;
  margin: 4px 0;
}
.photo-dialog #photo-review-count {
  font-size: 12px;
  margin: 8px 0;
  color: var(--accent);
}
/* Compact review grid: one short row per point so the whole table can be skimmed. */
.photo-review-scroll {
  margin: 8px 0;
}
#photo-review table {
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0 5px;
}
#photo-review th,
#photo-review td {
  border: 0;
  padding: 0 2px;
  font-size: 12px;
  vertical-align: middle;
}
#photo-review thead th {
  padding-bottom: 2px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}
#photo-review th:first-child {
  width: 34px;
  padding-left: 0;
  text-align: left;
}
#photo-review tbody th {
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
#photo-review tbody td:first-of-type {
  padding-left: 0;
}
#photo-review small {
  margin: 0px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.photo-cell {
  position: relative;
}
#photo-review input[data-photo-field],
.photo-blank {
  display: block;
  width: 100%;
  min-width: 0;
  height: 36px;
  min-height: 0;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
#photo-review input[data-photo-field]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
/* Cells with no value show a dash, matching the calculator tables. */
.photo-blank {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--soft);
}
#photo-review .photo-uncertain {
  background: none;
}
#photo-review .photo-uncertain input[data-photo-field] {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, var(--bg));
}
/* The confirm box sits on the cell's top-right corner so the value keeps the full width. */
.photo-final-row th,
.photo-final-row td {
  padding-top: 4px !important;
}
.photo-review-footer {
  position: sticky;
  bottom: -14px;
  background: var(--surface);
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.photo-review-footer .photo-confirm {
  margin: 0 0 8px;
  font-size: 12px;
}
.photo-review-footer #photo-apply {
  width: 100%;
}
#photo-review-error {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--warn);
}
.photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.photo-list[hidden] {
  display: none;
}
.photo-thumb {
  position: relative;
}
.photo-thumb > button:first-child {
  display: block;
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
}
.photo-thumb.selected > button:first-child {
  border: 2px solid var(--accent);
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb span {
  position: absolute;
  left: 3px;
  bottom: 3px;
  min-width: 18px;
  padding: 0px 4px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
}
.photo-thumb-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
#photo-previews[hidden] {
  display: none;
}

.photo-review-heading .button {
  flex: 0 0 auto;
  width: auto;
}

/* Shared workshop utilities */

.utility-page {
  max-width: 1060px;
  padding-bottom: 48px;
}
.tool-intro {
  color: var(--muted);
  margin: -8px 0 24px;
  font-size: 14px;
}
.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.tool-card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.tool-card h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 24px;
  font-size: 16px;
}
.tool-card h2 span {
  color: var(--muted);
  font: 12px monospace;
}
.tool-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 16px;
  margin-bottom: 16px;
}
.tool-card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.tool-card label small {
  font-size: 12px;
}
.tool-card input,
.tool-card select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
}
.tool-card input:focus,
.tool-card select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tool-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  margin: 16px 0;
}
.tool-output {
  min-height: 240px;
}
.tool-empty {
  color: var(--muted);
  font-size: 14px;
  padding: 24px 0;
}
.tool-number {
  font-variant-numeric: tabular-nums;
  font-size: clamp(24px, 4vw, 36px);
  letter-spacing: -1px;
  line-height: 1.2;
  margin: 8px 0 24px;
  overflow-wrap: anywhere;
  color: var(--accent);
}
.tool-number small {
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 0;
}
.tool-result-label {
  color: var(--text);
  font-size: 12px;
  margin-bottom: 0;
}
.tool-copy {
  margin-top: 24px;
}
.tool-grip {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--warn);
}
.tool-error {
  color: var(--warn);
  font-size: 14px;
}
.tool-details {
  margin-top: 24px;
  padding: 16px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
}
.tool-details summary {
  cursor: pointer;
  color: var(--text);
}
.tool-details a {
  color: var(--accent);
  text-decoration: underline;
}
.conversion-direction {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}
.conversion-direction label {
  flex: 1;
  min-width: 0;
}
@media (max-width: 700px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
  .tool-card {
    padding: 16px;
  }
  .utility-page .calc-heading h1 {
    font-size: 24px;
  }
}
@media (max-width: 380px) {
  .tool-fields {
    grid-template-columns: 1fr;
  }
}

/* Keep page alignment stable and notifications clear of floating actions. */
html {
  scrollbar-gutter: stable;
}
@supports not (scrollbar-gutter: stable) {
  html {
    overflow-y: scroll;
  }
}
.toast {
  top: calc(88px + env(safe-area-inset-top));
  bottom: auto;
  pointer-events: none;
}
.polarity-choice {
  display: flex;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9999px;
  overflow: hidden;
  margin: 16px 0 12px;
}
.polarity-choice[hidden] {
  display: none;
}
.polarity-choice button {
  flex: 1;
  min-height: 48px;
  border: 0;
  border-radius: 0;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.polarity-choice button + button {
  border-left: 1px solid var(--line);
}
.polarity-choice button[aria-pressed="true"][data-confirm-polarity="same"] {
  background: var(--accent);
  color: var(--button-text);
}
.polarity-choice button[aria-pressed="true"][data-confirm-polarity="opposite"] {
  background: var(--gold);
  color: var(--button-text);
}
.polarity-choice button[aria-pressed="true"]::before {
  content: "✓ ";
}
.polarity-choice button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -4px;
}

.account-tier-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 16px;
  margin: 16px 0;
}
.account-tier-card.featured {
  border-color: var(--accent);
}
.account-tier-card h3 {
  margin: 0 0 8px;
}
.account-tier-card > p {
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}
.account-tier-card .account-plan {
  border: 0;
  border-radius: 0;
  padding: 16px 0;
  gap: 12px;
}
.account-tier-card .account-plan + .account-plan {
  border-top: 1px solid var(--line);
}
.account-tier-card .saving {
  display: inline-block;
  margin-top: 4px;
}
@media (max-width: 480px) {
  .account-tier-card .account-plan {
    flex-direction: column;
    align-items: stretch;
  }
  .account-tier-card .button {
    width: 100%;
  }
}

/* Public policies share the app typography and remain accessible when signed in. */
.policy-page {
  max-width: 900px;
  margin-inline: auto;
  padding-top: 40px;
  padding-bottom: 40px;
}
.policy-heading h1 {
  font-size: clamp(30px, 5vw, 48px);
  margin: 12px 0;
}
.policy-heading > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.6;
}
.policy-date {
  font-size: 12px;
}
.policy-nav,
.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0;
}
.policy-nav .button,
.support-actions .button {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 12px;
  width: auto;
}
.policy-nav .nav-current {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-2);
}
.policy-content {
  font-size: 14px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.policy-content h2 {
  font-size: 20px;
  line-height: 1.35;
  margin: 32px 0 12px;
}
.policy-content p {
  color: var(--muted);
  margin: 12px 0;
}
.policy-content li {
  color: var(--muted);
  margin-bottom: 8px;
}
.policy-content strong {
  color: var(--text);
}
.policy-content a:not(.button),
.signup-consent a,
.account-plan-note a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.policy-summary {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 12px;
  background: var(--surface);
  padding: 24px;
}
.policy-summary > strong {
  font-size: 18px;
}
.policy-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.policy-table-wrap table {
  border-collapse: collapse;
  width: 100%;
  min-width: 360px;
  text-align: left;
}
.policy-table-wrap th,
.policy-table-wrap td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.policy-table-wrap caption {
  text-align: left;
  padding: 12px;
  color: var(--muted);
}
.support-faq {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin: 12px 0;
  padding: 0 16px;
}
.support-faq summary {
  cursor: pointer;
  padding: 16px 0;
  font-weight: 600;
}
.support-faq p {
  margin: 0 0 16px;
}

.signup-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.6;
  margin: 12px 0 16px;
}
.signup-consent[hidden] {
  display: none;
}
.signup-consent input {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin-top: 2px;
}

/* Crop controls use image-relative coordinates and touch-friendly handles. */
.crop-workspace {
  padding: 16px;
  margin: 12px 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
.crop-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
  user-select: none;
}
#photo-crop-source {
  display: block;
  max-width: 100%;
  max-height: 360px;
  max-height: min(45dvh, 360px);
  width: auto;
  height: auto;
  pointer-events: none;
}
.crop-shade {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.crop-shade-box {
  position: absolute;
  box-shadow: 0 0 0 1000px #0009;
}
.crop-selection {
  position: absolute;
  border: 2px solid #fff;
  box-sizing: border-box;
}
.crop-move {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: move;
  touch-action: none;
  padding: 0;
}
.crop-move::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
      to right,
      transparent 33%,
      #ffffff70 33%,
      #ffffff70 33.5%,
      transparent 33.5%,
      transparent 66%,
      #ffffff70 66%,
      #ffffff70 66.5%,
      transparent 66.5%
    ),
    linear-gradient(
      to bottom,
      transparent 33%,
      #ffffff70 33%,
      #ffffff70 33.5%,
      transparent 33.5%,
      transparent 66%,
      #ffffff70 66%,
      #ffffff70 66.5%,
      transparent 66.5%
    );
  pointer-events: none;
}
.crop-handle {
  position: absolute;
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  touch-action: none;
  transform: translate(-50%, -50%);
  z-index: 2;
}
.crop-handle::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 2px;
  background: #fff;
  border: 1px solid #171c2a;
  box-shadow: 0 1px 4px #0009;
}
.crop-n {
  left: 50%;
  top: 0;
  cursor: ns-resize;
}
.crop-s {
  left: 50%;
  top: 100%;
  cursor: ns-resize;
}
.crop-w {
  left: 0;
  top: 50%;
  cursor: ew-resize;
}
.crop-e {
  left: 100%;
  top: 50%;
  cursor: ew-resize;
}
.crop-nw {
  left: 0;
  top: 0;
  cursor: nwse-resize;
}
.crop-ne {
  left: 100%;
  top: 0;
  cursor: nesw-resize;
}
.crop-sw {
  left: 0;
  top: 100%;
  cursor: nesw-resize;
}
.crop-se {
  left: 100%;
  top: 100%;
  cursor: nwse-resize;
}
.crop-handle:focus-visible,
.crop-move:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.crop-toolbar {
  display: flex;
  gap: 8px;
}
.crop-toolbar .button {
  flex: 1;
  min-width: 0;
  width: auto;
  padding-inline: 8px;
}

/* Desktop spacing is scoped so the established mobile layout is unchanged. */
@media (min-width: 761px) {
  #page-calculator {
    padding-top: 32px;
  }
  #page-calculator .calc-heading {
    margin: 0 0 24px;
    gap: 24px;
  }
  #page-calculator .calc-heading .eyebrow {
    margin: 0 0 8px;
  }
  #page-calculator .calc-heading h1 {
    margin: 0;
    line-height: 1.2;
  }
  #page-calculator .workspace-links {
    gap: 8px;
  }
  #page-calculator .workspace-links > * {
    height: 48px;
  }
  #page-calculator .calc-toolbar {
    max-width: none;
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr)) 48px;
    gap: 8px;
    margin: 0 0 24px;
  }
  #page-calculator .calc-toolbar .setting-button {
    font-size: 12px;
    gap: 8px;
  }
  #page-calculator .calc-toolbar .setting-button,
  #page-calculator .calc-toolbar .menu-anchor,
  #page-calculator #file-menu-button {
    height: 48px;
  }
  #page-calculator .calc-toolbar .menu-anchor,
  #page-calculator #file-menu-button {
    width: 48px;
    min-width: 48px;
  }
  #page-calculator .part-name-label {
    max-width: none;
    margin: 0 0 24px;
    font-size: 12px;
  }
  #page-calculator .part-name-label input {
    height: 48px;
    margin-top: 8px;
  }
  #page-calculator .mapping-panel {
    margin: 0 0 24px;
  }
}
.device-card {
  display: block;
  padding: 24px;
}
.device-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 8px 0 0;
}
.device-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.device-heading h2 {
  margin: 0;
  font-size: 20px;
}
.device-count {
  flex-shrink: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 14px monospace;
  color: var(--accent);
}
.device-card .device-status {
  padding: 12px 12px;
  margin: 16px 0 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--mint) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--mint) 35%, var(--line));
}
.device-status[data-allowed="false"] {
  background: color-mix(in srgb, var(--gold) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--gold) 40%, var(--line));
}
.device-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.device-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}
.device-icon svg {
  width: 24px;
  height: 24px;
}
.device-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.device-info strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.device-badge {
  font-size: 12px;
  color: var(--muted);
}
.device-badge[data-current="true"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 2px 8px;
  border-radius: 16px;
}
.device-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.device-card .button {
  min-height: 44px;
  width: auto;
  padding: 8px 12px;
  font-size: 12px;
}
.device-card .device-remove {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
}
.device-policy {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
}
.device-policy strong {
  font-size: 12px;
}
.device-policy .button,
.device-card .device-add {
  margin-top: 12px;
}
.device-card .device-empty {
  padding: 16px 0;
}
@media (max-width: 480px) {
  .device-card {
    padding: 16px;
  }
  .device-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .device-actions {
    width: 100%;
  }
  .device-actions .button {
    flex: 1;
  }
  .device-heading h2 {
    font-size: 18px;
  }
}

/* Paired control states share the brand palette across every page. */

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}
/* Checkboxes inside labels must not inherit text-field sizing; otherwise the focus ring wraps a tall empty box. */
label input:is([type="checkbox"], [type="radio"]) {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  flex: 0 0 auto;
}
input:is([type="checkbox"], [type="radio"]):focus {
  outline: none;
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 50%;
}

.subscription-indicator .subscription-time.unlimited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 64px;
  min-height: 48px;
  font-family: var(--sans);
  font-size: 30px;
  line-height: 1;
}
/* Setting captions and result change notes */
.setting-button .setting-caption {
  display: block;
  font-size: 12px;
  line-height: 1.1;
  opacity: 0.72;
}
.result-card td .result-value {
  display: block;
}
.result-card td .result-note {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--soft);
  white-space: normal;
  overflow-wrap: anywhere;
}
.result-card tr.changed td:last-child .result-value {
  color: var(--accent);
}
.result-card td .result-note.intentional {
  color: var(--gold);
}
.result-card tr.predicted-final td:last-child .result-value {
  font-style: italic;
}
#result-status {
  white-space: pre-line;
}

/* Subscription card: tier pill beside the heading, billing period and portal link in one footer row. */
.account-page .subscription-card .setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title pill" "status pill";
  align-items: center;
  column-gap: 16px;
  row-gap: 0;
  flex-wrap: nowrap;
}
.subscription-card .subscription-copy {
  display: contents;
}
.subscription-card .subscription-copy h2 {
  grid-area: title;
}
.subscription-card #account-status {
  grid-area: status;
  font-size: 12px;
  line-height: 1.55;
  margin-top: 4px;
}
.account-page .subscription-card .subscription-indicator {
  grid-area: pill;
  display: inline-flex;
  align-items: stretch;
  width: auto;
  max-width: none;
  margin: 0;
  height: 44px;
  gap: 0;
  border: 0;
  border-radius: 0;
  background: none;
  overflow: visible;
}
.subscription-card .lifetime-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  font-family: var(--sans);
  font-size: 24px;
  line-height: 1;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-right: 0;
  border-radius: 12px 0 0 12px;
}
.subscription-card .lifetime-mark[hidden] {
  display: none;
}
.account-page .subscription-card #access-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 96px;
  margin: 0;
  padding: 0 16px;
  font-size: 14px;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.account-page .subscription-card #access-badge[data-tier="lifetime"] {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}
.account-page .subscription-card .lifetime-mark:not([hidden]) + #access-badge {
  border-radius: 0 12px 12px 0;
}
.account-page .subscription-card #access-badge[data-tier="premium"] {
  border-color: color-mix(in srgb, var(--gold) 50%, var(--line));
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
}
.account-page .subscription-card #access-badge[data-tier="standard"] {
  border-color: #8f99aa;
  background: #8f99aa15;
}
.subscription-card #tier-text {
  padding: 2px 0;
}
.subscription-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.subscription-footer[hidden] {
  display: none;
}
.subscription-remaining {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.subscription-remaining-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.subscription-card .subscription-remaining .subscription-time {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1.2;
  text-align: left;
  color: var(--text);
}
.account-page .subscription-card .subscription-footer #manage-billing {
  width: auto;
  min-width: 170px;
  max-width: none;
  margin: 0;
  margin-left: auto;
}
@media (max-width: 600px) {
  .account-page .subscription-card .setting-row {
    grid-template-areas: "title pill" "status status";
  }
  .subscription-card #account-status {
    margin-top: 12px;
  }
  .subscription-footer {
    flex-wrap: nowrap;
  }
  .subscription-card .subscription-remaining .subscription-time {
    font-size: 16px;
  }
  .account-page .subscription-card .subscription-footer #manage-billing {
    min-width: 0;
    flex-shrink: 0;
    padding: 0 12px;
  }
}
.result-card .unused-result .result-value {
  color: var(--soft);
  font-weight: 400;
}

/* Account cards share one heading and description scale, and keep their controls beside the text. */
.account-page .settings-card .setting-row {
  flex-wrap: nowrap;
}
.account-page .setting-row > div:first-child {
  min-width: 0;
}
.account-page .setting-row h2,
.account-page .install-heading h2,
.account-page .device-heading h2 {
  font-size: 16px;
  letter-spacing: -0.015em;
}
.account-page .setting-row p,
.account-page .install-heading p,
.account-page .device-heading p {
  font-size: 12px;
  line-height: 1.55;
  margin-top: 4px;
}
.account-page .setting-row > .button,
.account-page .setting-row > .theme-switch,
.account-page .setting-row > div:last-child:not(:first-child) {
  flex-shrink: 0;
}
@media (min-width: 1280px) {
  .calculator-page .calculate-dock {
    padding-left: 0;
  }
}

/* Shared page gutter so the header, page content and footer line up at every width. */
:root {
  --gutter: 32px;
}
@media (max-width: 760px) {
  :root {
    --gutter: 16px;
  }
}

.page,
.page.calculator-page {
  padding-inline: var(--gutter);
}

.calculator-page {
  padding-bottom: 48px;
}

/* Polarity choice: a segmented control whose selected pill sits inside the track. */
.polarity-choice {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  overflow: visible;
}
.polarity-choice button {
  min-height: 44px;
  border-radius: 9999px;
  background: transparent;
}
.polarity-choice button + button {
  border-left: 0;
}
.polarity-choice button:focus-visible {
  outline-offset: 2px;
}
.confirm-actions .button {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}
.confirm-dialog .button:hover {
  transform: none;
}
/* Notes under result values wrap between words, never mid-word. */
.result-card td .result-note {
  overflow-wrap: normal;
  word-break: normal;
}
/* Footer links form an even two-column grid on phones instead of ragged rows. */

/* The plan card uses the same inner spacing as the other account cards. */
.account-tier-card {
  padding: 24px;
}
.account-tier-card .account-plan:last-child {
  padding-bottom: 0;
}
@media (max-width: 760px) {
  .account-tier-card {
    padding: 16px;
  }
}

/* ===== Drafting design layer: shared elements ===== */
[hidden] {
  display: none !important;
}
body {
  overflow-x: clip;
  font-feature-settings: "ss01" 0;
}
h1,
h2,
h3 {
  letter-spacing: -0.02em;
  font-weight: 600;
  text-wrap: balance;
}
p {
  text-wrap: pretty;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input,
select,
textarea {
  font-variant-numeric: tabular-nums;
}
::selection {
  background: var(--accent-soft);
}
.eyebrow {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--accent);
}
main {
  max-width: 1220px;
  margin: 0 auto;
  padding-top: calc(96px + env(safe-area-inset-top));
}
.button {
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  padding: 8px 12px;
  gap: 8px;
  border-radius: 8px;
  transition:
    background-color 300ms var(--ease),
    border-color 300ms var(--ease),
    box-shadow 300ms var(--ease),
    transform 300ms var(--ease);
}
.button:active {
  transform: scale(0.98);
}
.button.primary,
button.primary {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  border-color: transparent;
  color: var(--button-text);
  box-shadow: 0 8px 24px var(--glow);
}
.button.primary:hover,
button.primary:hover {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  box-shadow: 0 12px 32px var(--glow);
  transform: translateY(-1px);
  color: var(--button-text);
}
.button.secondary,
button.secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.button.secondary:hover,
button.secondary:hover {
  background: var(--surface-2);
}
.btn-sm,
.button.btn-sm {
  font-size: 14px;
  line-height: 20px;
  padding: 8px 12px;
  min-height: 36px;
  height: auto;
  width: auto;
  border-radius: 9999px;
}
.icon {
  fill: currentColor;
  stroke: none;
}

/* ===== Floating pill navigation ===== */
.site-header {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  padding-inline: var(--gutter);
  pointer-events: none;
}
.nav-pill {
  pointer-events: auto;
  width: 100%;
  max-width: 1148px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 8px 8px 16px;
  border-radius: 9999px;
  background: var(--nav-bg);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 8px 24px rgba(13, 15, 18, 0.06);
}
.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand[aria-disabled="true"] {
  cursor: default;
}
.brand-mark {
  width: 24px;
  height: 24px;
  color: var(--brand);
  flex-shrink: 0;
}
.beta-anchor {
  position: relative;
  display: flex;
  align-items: center;
}
#beta-badge {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}
#beta-info {
  position: absolute;
  top: calc(100% + 16px);
  left: 0;
  width: 256px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  z-index: 60;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: 14px;
}
.nav-links > a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 9999px;
  border: 0;
  background: transparent;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--muted);
  min-height: 0;
  height: auto;
  width: auto;
  transition:
    background-color 300ms var(--ease),
    color 300ms var(--ease);
}
.nav-links > a:hover {
  color: var(--text);
  background: var(--surface-2);
}
.nav-links > a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.nav-actions .icon {
  width: 16px;
  height: 16px;
}
.account-link[aria-current="page"] {
  border-color: var(--accent);
}
.menu-toggle {
  display: none;
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  background: var(--surface);
  align-items: center;
  justify-content: center;
}
.menu-toggle span {
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 500ms var(--ease);
}
.menu-toggle span:first-child {
  transform: translateY(-4px);
}
.menu-toggle span:last-child {
  transform: translateY(4px);
}
.menu-toggle[aria-expanded="true"] span:first-child {
  transform: rotate(45deg);
}
.menu-toggle[aria-expanded="true"] span:last-child {
  transform: rotate(-45deg);
}
.site-menu {
  position: fixed;
  inset: 0;
  z-index: 45;
  padding: calc(96px + env(safe-area-inset-top)) var(--gutter)
    calc(32px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  overflow-y: auto;
}
.site-menu nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  font-size: 30px;
}
.site-menu a {
  display: block;
  padding-block: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 30px;
  line-height: 36px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  opacity: 0;
  transform: translateY(24px);
  animation: menu-in 500ms var(--ease) forwards;
}
.site-menu a[aria-current="page"] {
  color: var(--accent);
}
.site-menu a:nth-child(2) {
  animation-delay: 60ms;
}
.site-menu a:nth-child(3) {
  animation-delay: 120ms;
}
.site-menu a:nth-child(4) {
  animation-delay: 180ms;
}
.site-menu a:nth-child(5) {
  animation-delay: 240ms;
}
.site-menu a:nth-child(6) {
  animation-delay: 300ms;
}
.site-menu a:nth-child(n + 7) {
  animation-delay: 360ms;
}
@keyframes menu-in {
  to {
    opacity: 1;
    transform: none;
  }
}
html.menu-open body {
  overflow: hidden;
}
@media (max-width: 860px) {
  .nav-links {
    display: none;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .nav-actions {
    margin-left: auto;
  }
}
@media (max-width: 400px) {
  .nav-pill {
    gap: 8px;
    padding-left: 12px;
  }
  .account-link #username {
    display: none;
  }
}

/* ===== Media slots ===== */
.media-slot {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(135deg, var(--surface-2), var(--bg));
}
.media-slot > img,
.media-slot > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 800ms var(--ease);
}
.media-slot.is-loaded > img,
.media-slot.is-loaded > video {
  opacity: 1;
}
html:not(.js) .media-slot > * {
  opacity: 1;
}
.closing .closing-scrim {
  background:
    linear-gradient(90deg, rgba(var(--scrim), 0.97) 0%, rgba(var(--scrim), 0.92) 45%, rgba(var(--scrim), 0.35) 85%),
    linear-gradient(0deg, rgba(var(--scrim), 0.6) 0%, rgba(var(--scrim), 0) 40%);
}
.hero-scrim,
.closing-scrim,
.not-found-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
      90deg,
      rgba(var(--scrim), 0.96) 0%,
      rgba(var(--scrim), 0.88) 32%,
      rgba(var(--scrim), 0) 68%
    ),
    linear-gradient(0deg, rgba(var(--scrim), 0.8) 0%, rgba(var(--scrim), 0) 32%);
}

/* ===== Home ===== */
.home-page {
  display: grid;
}
.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: min(720px, calc(100svh - 128px));
  border-radius: 24px;
  border: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
}
.hero-copy {
  position: relative;
  display: grid;
  gap: 24px;
  padding: 64px;
  max-width: 744px;
}
.hero h1,
.not-found-copy h1 {
  max-width: 680px;
  font-size: 60px;
  line-height: 1;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, var(--head-a), var(--head-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-description {
  max-width: 560px;
  font-size: 18px;
  line-height: 28px;
  color: var(--muted);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.hero-actions .button {
  width: auto;
  height: auto;
  min-height: 44px;
}
.hero .microcopy {
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
}
.home-section {
  padding-block: 96px 0;
}
.section-heading {
  display: grid;
  gap: 12px;
  max-width: 680px;
  margin-bottom: 40px;
}
.section-heading h2 {
  font-size: 36px;
  line-height: 40px;
}
.section-heading p {
  font-size: 18px;
  line-height: 28px;
}
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.step-card,
.feature-card,
.price-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.step-number {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--accent);
}
.step-card h3,
.feature-card h3 {
  font-size: 20px;
  line-height: 28px;
}
.step-card p,
.feature-card p {
  font-size: 16px;
  line-height: 24px;
}
.step-sample {
  margin-top: auto;
  padding-top: 16px;
  display: grid;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}
.sample-row {
  display: grid;
  grid-template-columns: 40px repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-block: 8px;
  border-top: 1px solid var(--line);
  text-align: right;
}
.sample-row > :first-child {
  text-align: left;
  color: var(--muted);
}
.sample-head {
  font-family: var(--sans);
  color: var(--muted);
  border-top: 0;
  font-size: 12px;
  line-height: 16px;
}
.sample-row .hit {
  color: var(--accent);
  font-weight: 500;
}
.tagline-section {
  padding-block: 96px 0;
}
.tagline {
  max-width: 880px;
  font-size: 48px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
  text-wrap: balance;
}
.js .tagline .word {
  color: color-mix(in srgb, var(--text) 28%, transparent);
  transition: color 600ms var(--ease);
}
.js .tagline .word.is-lit {
  color: var(--text);
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.feature-card,
.price-card.featured {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.feature-card > .icon {
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 880px;
}
.price-card {
  padding: 32px;
  gap: 16px;
}
.price-card.featured {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow);
}
.plan-label {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--muted);
}
.price-card.featured .plan-label {
  color: var(--accent);
}
.price-card h3 {
  display: grid;
  gap: 4px;
  font-size: 48px;
  line-height: 1;
  letter-spacing: -0.03em;
}
.price-card h3 span {
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}
.plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.plan-list li {
  display: flex;
  gap: 8px;
  font-size: 16px;
  line-height: 24px;
  color: var(--text);
}
.plan-list .icon {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--mint);
}
.price-card .button {
  width: 100%;
  height: auto;
  min-height: 44px;
}
.price-card > .button:first-of-type {
  margin-top: auto;
}
.annual-price {
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
}
.annual-price strong {
  color: var(--text);
  font-weight: 600;
}
.saving {
  display: inline-block;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 0;
  font-family: var(--sans);
}
.faq-list {
  max-width: 800px;
  border-top: 1px solid var(--line);
}
.faq-list details {
  border-bottom: 1px solid var(--line);
}
.faq-list summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-block: 16px;
  font-size: 18px;
  line-height: 28px;
  font-weight: 600;
  color: var(--text);
}
.faq-list summary::-webkit-details-marker {
  display: none;
}
.faq-list summary::after {
  content: "+";
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  font-weight: 400;
  font-size: 24px;
  color: var(--muted);
  transition: transform 300ms var(--ease);
}
.faq-list details[open] summary::after {
  transform: rotate(45deg);
}
.faq-list details p {
  padding-bottom: 16px;
  max-width: 680px;
  font-size: 16px;
  line-height: 24px;
}
.closing {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  margin-top: 96px;
  padding: 0;
  min-height: 420px;
  border-radius: 24px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  text-align: left;
}
.closing-copy {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 64px;
  max-width: 680px;
}
.closing-copy h2 {
  font-size: 48px;
  line-height: 1;
  letter-spacing: -0.03em;
}
.closing-copy p {
  font-size: 18px;
  line-height: 28px;
}

/* ===== Not found ===== */
.not-found-page {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  margin-inline: var(--gutter);
  padding: 0;
  min-height: min(640px, calc(100svh - 160px));
  border-radius: 24px;
  border: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
}
.page.not-found-page {
  padding-inline: 0;
}
.not-found-copy {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 64px;
  max-width: 680px;
}
.not-found-copy h1 {
  font-size: 48px;
}
.not-found-copy p:not(.eyebrow) {
  font-size: 18px;
  line-height: 28px;
}

/* ===== Reveals ===== */
.js .reveal {
  opacity: 0;
  transform: translateY(32px);
  transition:
    opacity 700ms var(--ease),
    transform 700ms var(--ease);
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 0;
  justify-content: normal;
  font-size: 14px;
  color: var(--muted);
  max-width: 1220px;
  margin: 96px auto 0;
  padding: 48px var(--gutter) calc(32px + env(safe-area-inset-bottom));
  display: grid;
  gap: 40px;
}
.footer-top {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  padding-top: 48px;
  border-top: 1px solid var(--line);
}
.footer-brand {
  display: grid;
  gap: 12px;
  align-content: start;
  justify-items: start;
}
.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -0.02em;
}
.footer-brand p {
  font-size: 14px;
  line-height: 20px;
  max-width: 320px;
}
.footer-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
}
.footer-col h2 {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 4px;
}
.footer-col a {
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
  transition: color 300ms var(--ease);
}
.footer-col a:hover,
.footer-col a[aria-current="page"] {
  color: var(--text);
}
.footer-legal {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}
.theme-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  margin-top: 8px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.theme-switch button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
  transition:
    background-color 300ms var(--ease),
    color 300ms var(--ease);
}
.theme-switch .icon {
  width: 16px;
  height: 16px;
}
.theme-switch button[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
}
.site-footer.with-floating-controls {
  padding-bottom: calc(144px + env(safe-area-inset-bottom));
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .steps,
  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  main {
    padding-top: calc(88px + env(safe-area-inset-top));
  }
  .hero {
    min-height: 640px;
    border-radius: 16px;
  }
  .hero-copy,
  .closing-copy,
  .not-found-copy {
    padding: 24px;
    gap: 16px;
  }
  .hero h1 {
    font-size: 36px;
    line-height: 40px;
  }
  .hero h1 br {
    display: none;
  }
  .closing .closing-scrim {
    background: linear-gradient(0deg, rgba(var(--scrim), 0.98) 0%, rgba(var(--scrim), 0.9) 55%, rgba(var(--scrim), 0.2) 100%);
  }
  .hero-description {
    font-size: 16px;
    line-height: 24px;
  }
  .hero-scrim,
  .closing-scrim,
  .not-found-scrim {
    background: linear-gradient(
      0deg,
      rgba(var(--scrim), 0.98) 0%,
      rgba(var(--scrim), 0.92) 48%,
      rgba(var(--scrim), 0) 80%
    );
  }
  .hero .media-slot > * {
    object-position: 70% 0% !important;
    height: 62%;
  }
  .not-found-media > * {
    object-position: 85% 50% !important;
    height: 60%;
  }
  .home-section,
  .tagline-section {
    padding-top: 64px;
  }
  .closing {
    margin-top: 64px;
    min-height: 480px;
    border-radius: 16px;
    align-items: flex-end;
  }
  .section-heading {
    margin-bottom: 24px;
  }
  .section-heading h2,
  .closing-copy h2,
  .not-found-copy h1 {
    font-size: 30px;
    line-height: 36px;
  }
  .section-heading p {
    font-size: 16px;
    line-height: 24px;
  }
  .tagline {
    font-size: 36px;
    line-height: 40px;
  }
  .steps,
  .feature-grid,
  .pricing-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .price-card {
    padding: 24px;
  }
  .not-found-page {
    border-radius: 16px;
    min-height: 600px;
  }
  .site-footer {
    margin-top: 64px;
  }
  .footer-top {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .footer-brand {
    grid-column: 1 / -1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal {
    transform: none;
    transition: opacity 300ms var(--ease);
  }
  .site-menu a {
    transform: none;
    animation-duration: 200ms;
  }
  .js .tagline .word {
    transition: color 300ms var(--ease);
  }
}

/* ===== Workspace controls on the Drafting palette =====
   Settings at their default read as neutral. A changed setting, a held value and every highlight use the
   site red (--gold now resolves to --accent). */
.calc-toolbar .setting-button {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}
.calc-toolbar .setting-button .icon,
.calc-toolbar .setting-button .setting-symbol {
  color: var(--muted);
}
.calc-toolbar .setting-button .setting-caption {
  color: var(--muted);
  opacity: 1;
}
#polarity[aria-pressed="true"],
#direction[aria-pressed="true"],
#wrap[aria-pressed="true"],
#final-display[aria-pressed="false"] {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
}
#polarity[aria-pressed="true"] .icon,
#direction[aria-pressed="true"] .icon,
#wrap[aria-pressed="true"] .icon,
#final-display[aria-pressed="false"] .icon,
#polarity[aria-pressed="true"] .setting-symbol {
  color: var(--gold);
}
.calc-toolbar .setting-button:hover {
  border-color: color-mix(in srgb, var(--text) 25%, var(--line));
}
.workspace-links .history-link {
  color: var(--text);
}

/* ===== Revisions: nav grid and tool pages ===== */
.nav-pill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.brand-group {
  grid-column: 1;
  justify-self: start;
}
.nav-links {
  grid-column: 2;
  margin-left: 0;
  gap: 8px;
}
.nav-actions {
  grid-column: 3;
  justify-self: end;
  margin-left: 0;
}
.tool-fields {
  align-items: end;
}
.tool-card label {
  font-size: 14px;
  line-height: 20px;
}
.tool-card input,
.tool-card select {
  height: 48px;
  min-height: 48px;
  padding: 0 12px;
  font: inherit;
  font-size: 16px;
  line-height: 24px;
}
.tool-card select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.conversion-direction {
  align-items: flex-end;
  gap: 8px;
}
.swap-button {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  transition: background-color 300ms var(--ease), transform 300ms var(--ease);
}
.swap-button .icon {
  width: 20px;
  height: 20px;
}
.swap-button:hover {
  background: var(--surface-2);
}
.convert-value {
  margin-bottom: 0;
}
#convert-hint {
  margin: 8px 0 16px;
}
.tool-output .tool-note {
  margin: 0;
}
.tool-code {
  margin: 16px 0 0;
  padding: 16px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 24px;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}
.tool-code .c {
  color: var(--muted);
}
.home-page .microcopy {
  margin-top: 16px;
}
.brand {
  white-space: nowrap;
}
@media (max-width: 860px) {
  .nav-pill {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}
.tool-output {
  min-height: 0;
}

/* The signed-in brand is not a link, so keep taps on it from starting a text selection. */
.brand,
.brand-group {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Phone account page: cards show only their heading and control. */
.account-label-short {
  display: none;
}
@media (max-width: 760px) {
  .account-page .setting-row h2 + p,
  .account-page .subscription-copy #account-status,
  .account-page .install-heading p,
  .account-page .device-heading p {
    display: none;
  }
  .account-page .account-label-full {
    display: none;
  }
  .account-page .account-label-short {
    display: inline;
  }
}

/* ===== Refactoring UI pass =====
   Hierarchy comes from weight, size and grey tier before colour; depth comes from the shadow scale
   before borders; and each action is styled by its importance: primary, secondary or tertiary. */

/* Cards: one radius and one elevation. Light mode drops the border for a soft shadow; dark mode keeps a
   hairline, since shadows barely read on a dark background. Featured cards keep their red outline. */
.settings-card,
.account-profile,
.account-tier-card,
.result-card,
.residual-details,
.tool-card,
.history-item,
.step-card,
.price-card {
  border-color: var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.account-tier-card.featured,
.price-card.featured {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--card-border));
}
.account-profile {
  background: var(--surface);
}

/* Buttons: 14px is the standard size; the main action of a form or page steps up to 16px. */
.button {
  font-size: 14px;
  line-height: 20px;
}
#auth-submit,
#calculate,
.narrow-page .auth-card .button.primary,
.tool-card .button.primary {
  font-size: 16px;
  line-height: 24px;
}
.button.primary,
button.primary {
  box-shadow: var(--primary-shadow);
}
.button.primary:hover,
button.primary:hover {
  box-shadow: var(--primary-shadow), var(--shadow-md);
}
.device-card .button {
  font-size: 14px;
}
/* A plan that cannot be bought yet reads as unavailable, not as a faded call to action. */
.button[data-plan]:disabled,
.button.primary[data-plan]:disabled {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--soft);
  box-shadow: none;
  opacity: 1;
  transform: none;
  cursor: not-allowed;
}

/* Tertiary actions are plain text: no box competing with the primary button. */
.auth-options {
  justify-content: space-between;
}
.auth-options .text-button,
.back-link,
.signout-button {
  width: auto;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 500;
  justify-content: flex-start;
}
.auth-options .text-button {
  color: var(--muted);
}
#auth-switch {
  color: var(--accent);
  font-weight: 600;
}
.back-link {
  color: var(--muted);
}
.signout-button {
  color: var(--accent);
  font-weight: 600;
}
.auth-options .text-button:hover,
.back-link:hover {
  color: var(--text);
  border-color: transparent;
}
.signout-button:hover,
#auth-switch:hover {
  color: var(--accent-strong);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.device-card .device-remove {
  background: none;
  border-color: transparent;
  color: var(--accent);
}
.device-card .device-remove:hover {
  background: var(--accent-soft);
}

/* Supporting text sits one grey tier below the heading and stays at a readable 14px or more. */
.narrow-page .auth-card > p:not(.eyebrow) {
  font-size: 16px;
  line-height: 24px;
  color: var(--muted);
}
.account-page .setting-row p,
.account-page .install-heading p,
.account-page .device-heading p,
.subscription-card #account-status,
.install-guide h3,
.install-guide p,
.device-policy p,
.device-policy strong,
.result-status,
#result-status {
  font-size: 14px;
  line-height: 20px;
}
.device-policy strong {
  color: var(--text);
}

/* Panels inside a card are set apart by a tint alone, never a second border. */
.install-guide > div,
.device-card .device-status {
  border-color: transparent;
}

/* Labels and status pills: small, quiet and clearly not buttons. */
.account-page .subscription-card .subscription-indicator {
  border: 0;
  background: none;
}
.account-page .subscription-card #access-badge,
.account-page .subscription-card #access-badge[data-tier] {
  min-width: 0;
  min-height: 28px;
  padding: 4px 12px;
  border: 0;
  border-radius: 9999px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}
.account-page .subscription-card #access-badge[data-tier="standard"] {
  background: var(--surface-2);
  color: var(--muted);
}
.account-page .subscription-card #access-badge[data-tier="premium"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.account-page .subscription-card #access-badge[data-tier="lifetime"] {
  background: var(--surface-2);
}
.device-count {
  padding: 4px 12px;
  border: 0;
  border-radius: 9999px;
  background: var(--surface-2);
  color: var(--muted);
  font: 600 12px/20px var(--sans);
  font-variant-numeric: tabular-nums;
}

/* Calculator settings: the caption is the label, the value is what matters. */
.calc-toolbar .setting-button .setting-caption {
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  color: var(--soft);
}
.calc-toolbar .setting-button > span:last-child {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}
#polarity[aria-pressed="true"] .setting-caption,
#direction[aria-pressed="true"] .setting-caption,
#wrap[aria-pressed="true"] .setting-caption,
#final-display[aria-pressed="false"] .setting-caption {
  color: inherit;
}

/* The residuals toggle sits inside its card without a second box around it. */
.residual-details summary {
  border: 0;
  background: none;
  padding: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

/* History rows: the part name leads, the time and size follow in a lighter tier, and the row lifts on hover. */
.history-item strong {
  font-size: 16px;
  line-height: 24px;
}
.history-item small {
  margin-top: 4px;
  font-size: 14px;
  color: var(--soft);
}
.history-open {
  font-size: 14px;
  font-weight: 500;
  color: var(--soft);
}
.history-item:hover {
  border-color: var(--card-border);
  box-shadow: var(--shadow-md);
}
.history-item:hover .history-open {
  color: var(--accent);
}
.history-note,
#history-status {
  font-size: 14px;
  line-height: 20px;
  color: var(--soft);
}
/* Deleting all history is a rare, confirmed action, so it stays a quiet text button like Remove. */
.history-actions .button {
  width: auto;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: 14px;
  color: var(--accent);
}
.history-actions .button:hover {
  background: none;
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ===== Stays on this device =====
   One shield badge marks where part data lives; it opens the same device / server picture shown on the
   landing page. The photo dialog carries the one honest exception. */
.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-top: 8px;
  padding: 4px 12px 4px 8px;
  border: 0;
  border-radius: 9999px;
  background: var(--surface-2);
  color: var(--muted);
  font: 600 12px/20px var(--sans);
  cursor: pointer;
  vertical-align: middle;
}
.local-badge .icon {
  width: 16px;
  height: 16px;
  color: var(--text);
}
.local-badge:hover {
  color: var(--text);
}
.history-note .local-badge {
  margin: 0 8px 0 0;
}
.history-note {
  font-size: 14px;
  line-height: 24px;
}
.local-diagram {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
}
.local-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.local-side-head {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
}
.local-side-head .icon {
  width: 24px;
  height: 24px;
}
.local-side ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 16px;
  line-height: 24px;
}
.local-side li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.local-side li .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.local-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin: auto 0 0;
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}
.local-tag .icon {
  width: 16px;
  height: 16px;
  color: var(--text);
}
.local-server {
  background: var(--surface-2);
  border: 1px dashed var(--soft);
  box-shadow: none;
}
/* The link between device and server: a thin line, labelled with the only thing that crosses it. */
.local-link {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 96px;
  padding: 0 8px;
}
.local-link::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px dashed var(--soft);
}
.local-link span {
  position: relative;
  padding: 4px 8px;
  border-radius: 9999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}
.local-photo {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 680px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}
.local-photo strong {
  color: var(--text);
}
.local-photo .icon {
  margin-top: 0;
}
.local-dialog {
  max-width: 640px;
}
.local-dialog .local-diagram {
  margin-top: 16px;
}
.local-dialog .local-side {
  padding: 16px;
  gap: 12px;
}
.local-dialog .local-side-head {
  font-size: 16px;
}
.local-dialog .local-side ul {
  font-size: 14px;
  line-height: 20px;
}
.local-dialog .local-link {
  min-width: 72px;
}
.local-dialog .local-link span {
  background: var(--surface);
}
.local-more {
  margin: 16px 0 0;
  font-size: 14px;
}
.send-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 4px 12px 4px 8px;
  border-radius: 9999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}
.send-badge .icon {
  width: 16px;
  height: 16px;
}
/* Phones stack the picture: device on top, the link runs down to the server. */
@media (max-width: 640px) {
  .local-diagram {
    grid-template-columns: 1fr;
  }
  .local-link {
    min-height: 48px;
  }
  .local-link::before {
    left: 50%;
    right: auto;
    top: 0;
    bottom: 0;
    border-top: 0;
    border-left: 1px dashed var(--soft);
  }
}
.local-server .local-tag {
  background: var(--surface);
}
