:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #5b6b7f;
  --faint: #8a97a8;
  --border: #e3e8ef;
  --border-strong: #cfd8e3;
  --accent: #1d6fd8;
  --accent-hover: #175db4;
  --accent-soft: #e8f1fd;
  --ok: #0f7d5a;
  --ok-soft: #e1f5ee;
  --warn: #96650a;
  --warn-soft: #faeeda;
  --err: #b03027;
  --err-soft: #fbe9e7;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

[data-theme="dark"] {
  --bg: #0e1319;
  --surface: #161c24;
  --surface-2: #1d242e;
  --text: #e6edf3;
  --muted: #97a3b4;
  --faint: #6b7787;
  --border: #262e39;
  --border-strong: #35404e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-soft: #12283f;
  --ok: #3fb98c;
  --ok-soft: #0d2b22;
  --warn: #d9a13b;
  --warn-soft: #2e2314;
  --err: #e5534b;
  --err-soft: #2d1614;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.site-nav { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.site-nav a { color: var(--muted); font-size: 14px; }
.site-nav a:hover { color: var(--text); text-decoration: none; }

.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- hero ---------- */
.hero { padding: 44px 0 28px; }
.hero h1 {
  font-size: 30px;
  line-height: 1.3;
  margin: 0 0 10px;
  letter-spacing: -.5px;
}
.hero p { color: var(--muted); margin: 0 0 20px; max-width: 640px; }

.tool-search {
  display: flex;
  gap: 8px;
  max-width: 560px;
}
.tool-search input {
  flex: 1;
  padding: 11px 14px;
  font-size: 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

/* ---------- tool grid ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 30px 0 14px;
}
.section-head h2 { font-size: 18px; margin: 0; }
.section-head span { font-size: 13px; color: var(--faint); }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: block;
  color: var(--text);
  transition: border-color .15s, transform .15s;
}
.tool-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
}
.tool-card h3 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
.tool-card p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.55; }
.tool-card .tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
}
.tool-card.is-soon { opacity: .62; }
.tool-card.is-soon:hover { transform: none; border-color: var(--border); }
.tool-card .tag.soon { background: var(--surface-2); color: var(--faint); }

/* ---------- calculator layout ---------- */
.crumbs { font-size: 13px; color: var(--faint); padding: 16px 0 0; }
.crumbs a { color: var(--faint); }

.page-title { font-size: 27px; margin: 12px 0 8px; letter-spacing: -.4px; }
.lede { color: var(--muted); max-width: 760px; margin: 0 0 26px; }

.calc-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--faint);
  margin: 0 0 16px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 4px; }

.btn {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--accent-soft); }

/* ---------- results ---------- */
.result-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
}
.metric .k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.metric .v { font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.metric .u { font-size: 13px; color: var(--faint); font-weight: 400; }

.verdict {
  border-radius: var(--radius);
  padding: 13px 15px;
  font-size: 14px;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.verdict.pass { background: var(--ok-soft); color: var(--ok); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict.fail { background: var(--err-soft); color: var(--err); }
.verdict b { font-weight: 600; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th, table.data td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}
table.data th { color: var(--muted); font-weight: 500; font-size: 13px; }
table.data td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: none; }

.sizing-table td.min { color: var(--ok); font-weight: 600; }

/* ---------- content sections ---------- */
.prose { max-width: 760px; }
.prose h2 { font-size: 20px; margin: 34px 0 12px; letter-spacing: -.2px; }
.prose h3 { font-size: 16px; margin: 22px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.formula {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  margin: 0 0 16px;
  overflow-x: auto;
  line-height: 1.9;
}

.callout {
  background: var(--warn-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--warn);
  margin: 0 0 16px;
}

.faq { border-top: 1px solid var(--border); }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary {
  padding: 14px 0;
  cursor: pointer;
  font-weight: 500;
  font-size: 15px;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--faint); font-weight: 400; }
.faq details[open] summary::after { content: "\2212"; }
.faq .answer { padding: 0 0 16px; color: var(--muted); font-size: 14px; }

/* ---------- related ---------- */
.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 14px; }
.related a {
  display: block;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
}
.related a:hover { border-color: var(--accent); text-decoration: none; }
.related a span { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 60px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 28px 0;
}
.footer-inner { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.site-footer p { font-size: 13px; color: var(--faint); margin: 0 0 8px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px; }
.site-footer nav a { font-size: 13px; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .calc-shell { grid-template-columns: 1fr; }
  .hero h1 { font-size: 25px; }
  .page-title { font-size: 23px; }
}
@media (max-width: 560px) {
  .site-nav a { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .header-inner { gap: 12px; }
}

/* --- string configurator additions --- */
table.data td.pass { color: var(--ok); font-weight: 600; }
table.data td.fail { color: var(--err); font-weight: 600; }
table.data tr.is-current td { background: var(--accent-soft); }
#detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
#detail-grid .metric .v { font-size: 19px; }
