:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1b2232;
  --muted: #5a6377;
  --line: #e2e6ee;
  --brand: #1f5eff;
  --brand-soft: #e8efff;
  --accent: #f59e0b;
  --good: #0f9d74;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 12px rgba(16, 24, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e121a;
    --card: #161b26;
    --text: #e7eaf1;
    --muted: #9aa3b6;
    --line: #283041;
    --brand: #6b95ff;
    --brand-soft: #1c2742;
    --accent: #fbbf24;
    --good: #34c79a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* Header / footer */
header.site { background: var(--card); border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 12px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.logo span { color: var(--brand); }
nav.site a { color: var(--muted); text-decoration: none; margin-left: 18px; font-size: .95rem; }
nav.site a:hover { color: var(--text); }
footer.site { margin-top: 56px; padding: 28px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
footer.site .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
footer.site a { color: var(--muted); }

/* Page heading */
.crumbs { font-size: .85rem; color: var(--muted); margin: 22px 0 4px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
h1 { font-size: 1.9rem; line-height: 1.25; margin: 4px 0 8px; }
h2 { font-size: 1.35rem; margin: 36px 0 10px; }
h3 { font-size: 1.05rem; margin: 22px 0 6px; }
.lede { color: var(--muted); margin: 0 0 24px; max-width: 72ch; }

/* Tool layout */
.tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .tool { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card h2 { margin: 0 0 14px; font-size: 1.1rem; }

.field { margin-bottom: 18px; }
.field > label, .field .label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; font-size: .95rem; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
.row { display: flex; gap: 8px; align-items: center; }
input[type=number], input[type=text], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-variant-numeric: tabular-nums;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type=range] { width: 100%; accent-color: var(--brand); margin-top: 8px; }
select.unit { width: auto; flex: none; }
.check { display: flex; gap: 8px; align-items: center; font-size: .95rem; margin-bottom: 12px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
details.more { border-top: 1px solid var(--line); padding-top: 14px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: 12px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--brand); color: #fff; }

/* Results */
.result-main { text-align: center; padding: 4px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.result-main .label { color: var(--muted); font-size: .9rem; }
.result-main .value { font-size: 2.3rem; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; line-height: 1.2; }
.result-main .sub { color: var(--muted); font-size: .9rem; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv b { font-variant-numeric: tabular-nums; }
.kv.total { border-top: 1px solid var(--text); border-bottom: 0; font-weight: 700; margin-top: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.chart { display: flex; align-items: center; gap: 20px; justify-content: center; margin: 8px 0 16px; flex-wrap: wrap; }
.chart svg { width: 150px; height: 150px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.badge.good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
@media (max-width: 480px) {
  nav.site a { margin-left: 12px; }
  .card { padding: 16px; }
  th, td { padding: 8px 6px; }
}
thead th { color: var(--muted); font-weight: 600; background: var(--bg); position: sticky; top: 0; }
tr.strong td { font-weight: 700; }
.better { color: var(--good); font-weight: 700; }

/* CBSE marks table */
table.marks td { padding: 4px 4px; white-space: normal; }
table.marks input { padding: 8px 8px; }
table.marks td:nth-child(2), table.marks td:nth-child(3) { width: 84px; }
table.marks tr.picked td:first-child input { border-color: var(--good); box-shadow: inset 3px 0 0 var(--good); }
table.marks tr.bad .sub-marks { border-color: #dc2626; }

/* Article content */
.content { max-width: 76ch; }
.content p, .content li { color: var(--text); }
.formula { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand); padding: 12px 16px; border-radius: 8px; font-family: ui-monospace, Consolas, monospace; font-size: .95rem; overflow-x: auto; }
.note { font-size: .85rem; color: var(--muted); margin-top: 14px; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }

/* Home grid */
.hero { padding: 36px 0 12px; }
.hero h1 { font-size: 2.2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
a.tile, div.tile { display: block; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
a.tile:hover { border-color: var(--brand); transform: translateY(-2px); }
.tile .ico { font-size: 1.6rem; }
.tile h3 { margin: 8px 0 4px; }
.tile p { margin: 0; color: var(--muted); font-size: .92rem; }
div.tile { opacity: .7; }
.section-title { margin: 36px 0 14px; font-size: 1.2rem; }
.related { display: flex; flex-wrap: wrap; gap: 10px; }
.related a { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; text-decoration: none; font-size: .92rem; }
