:root {
  --bg: #f1f4f8;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #66708a;
  --line: #d6dce6;
  --accent: #1e4fd8;
  --accent-ink: #0f2a7a;
  --accent-soft: #e9efff;
  --tab-hover: #e2e8f2;
  --focus: #7a9bff;
  --note-bg: #f7f9fc;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161f;
    --surface: #1b2130;
    --ink: #e6eaf3;
    --muted: #98a2b8;
    --line: #2c3548;
    --accent: #8aa8ff;
    --accent-ink: #dbe4ff;
    --accent-soft: #1f2a4c;
    --tab-hover: #232b3d;
    --focus: #a7bcff;
    --note-bg: #161c29;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 400px;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

body {
  display: flex;
  flex-direction: column;
  max-height: 600px;
}

[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 16px 6px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-by {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}
.brand-by:hover { color: var(--accent); text-decoration: underline; }

.tabs {
  display: flex;
  padding: 0 8px;
}

.tab {
  flex: 1 1 0;
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 4px 9px;
  transition: color .12s, background .12s;
}
.tab:hover { color: var(--ink); background: var(--tab-hover); }
.tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- content ---------- */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px 6px;
}

.intro {
  margin: 0 0 12px;
  color: var(--muted);
}

.sub {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.field > span {
  font-size: 12px;
  color: var(--muted);
}
.field-wide { grid-column: 1 / -1; }

.field-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  padding-bottom: 7px;
}
.field-check > span { color: var(--ink); font-size: 13px; }

input[type="number"],
select {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input[type="number"]:focus-visible,
select:focus-visible,
.tab:focus-visible,
.reset:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

/* ---------- result block ---------- */
.result {
  margin: 14px 0 0;
  padding: 12px 14px 10px;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

.result-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}
.result-label {
  font-size: 12px;
  color: var(--accent-ink);
}
.result-value {
  font-size: 15px;
  color: var(--accent-ink);
}
.result-value b {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.rows {
  margin: 0;
  display: grid;
  gap: 4px;
}
.rows > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 600; text-align: right; }
.rows-flat { margin-top: 10px; }
.rows-flat dt { color: var(--muted); }

.note {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.note:empty { display: none; }

/* ---------- method + links ---------- */
.method {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.method summary {
  cursor: pointer;
  color: var(--muted);
}
.method summary:hover { color: var(--ink); }
.method p { margin: 6px 0 0; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 12px 0 8px;
}
.links a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.links a:hover { text-decoration: underline; }

/* ---------- footer ---------- */
.bottom {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.bottom a {
  color: var(--muted);
  text-decoration: none;
}
.bottom a:hover { color: var(--accent); text-decoration: underline; }

.reset {
  appearance: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
}
.reset:hover { color: var(--ink); border-color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
