/* ---- Tokens ------------------------------------------------------------ */

:root {
  --bg: #fcfcfc;
  --surface: #ffffff;
  --text: #16181d;
  --text-muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1f5fd0;
  --focus: #1f5fd0;
  --space: 1rem;
  --measure: 34rem;
  --radius: 6px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #161a20;
    --text: #e8eaed;
    --text-muted: #9aa1ac;
    --line: #2a2f38;
    --accent: #7aa5f0;
    --focus: #7aa5f0;
  }
}

/* ---- Base -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: calc(var(--space) * 2) var(--space) calc(var(--space) * 4);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: calc(var(--space) * 2.5);
}

h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 600; margin: calc(var(--space) * 2) 0 0.4rem; }
p { margin: 0.6rem 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.page-head { display: flex; flex-direction: column; gap: 0.25rem; align-items: center; text-align: center; }
.sub, .hint, .muted { color: var(--text-muted); font-size: 0.875rem; }
.hint { margin: 0.5rem 0; }

.page-foot {
  border-top: 1px solid var(--line);
  padding-top: var(--space);
  font-size: 0.875rem;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Keyboard-first: a clearly visible focus ring on every interactive element. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---- Inputs ------------------------------------------------------------ */

.inputs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space);
}

@media (max-width: 30rem) {
  .inputs { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }

.field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.input-wrap { position: relative; display: flex; align-items: center; }

.prefix {
  position: absolute;
  left: 0.7rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  pointer-events: none;
}

.input-wrap:has(.prefix) input { padding-left: 1.5rem; }

input[type="number"], input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

input:focus { border-color: var(--focus); }

/* Spinners add visual noise and steal clicks — the fields are keyboard-first. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- Freelance --------------------------------------------------------- */

.freelance {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: var(--space);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
}

.toggle input { width: 1rem; height: 1rem; accent-color: var(--accent); }

.slider-row { display: flex; align-items: center; gap: 0.75rem; }
.slider-row label { font-size: 0.8125rem; color: var(--text-muted); }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }

#multiplier-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
  min-width: 3.5rem;
  text-align: right;
}

/* ---- Tables ------------------------------------------------------------ */

table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

thead th {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

tbody th { font-weight: 400; }

.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.results tbody td { font-size: 1rem; }
.results tbody tr:last-child th, .results tbody tr:last-child td { border-bottom: 0; }

.note-mark {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-family: var(--sans);
}

.ccy { font-size: 0.6875rem; color: var(--text-muted); }

.table-scroll { overflow-x: auto; }

/* ---- Disclosure -------------------------------------------------------- */

.disclosure button, .share-row button {
  padding: 0.45rem 0.8rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.disclosure button:hover, .share-row button:hover { border-color: var(--focus); }

.work-lines {
  margin: 0.75rem 0 0;
  padding: var(--space);
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.9;
  overflow-x: auto;
}

.work-lines li { white-space: nowrap; }

/* ---- Share ------------------------------------------------------------- */

.share { display: flex; flex-direction: column; gap: 0.3rem; }
.share > label { font-size: 0.8125rem; font-weight: 500; color: var(--text-muted); }
.share-row { display: flex; gap: 0.5rem; }
.share-row input { font-size: 0.8125rem; }
.share-row button { flex-shrink: 0; }

/* ---- Wage reference ---------------------------------------------------- */

.wage-ref {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 var(--space);
}

.wage-ref summary {
  padding: 0.7rem 0;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  list-style-position: inside;
}

.wage-ref[open] summary { border-bottom: 1px solid var(--line); margin-bottom: var(--space); }
.wage-ref > *:last-child { margin-bottom: var(--space); }

.wage-table th, .wage-table td { font-size: 0.8125rem; }

.sources { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.8125rem; }
.sources li { margin: 0.2rem 0; }

/* ---- About page -------------------------------------------------------- */

.prose { display: block; }
.prose h2:first-of-type { margin-top: var(--space); }
.prose ul { padding-left: 1.1rem; }
.prose li { margin: 0.35rem 0; }
.prose .page-foot { margin-top: calc(var(--space) * 2); }
