/* RhythmCalc — clean light theme, mobile first, no build step required */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --ink: #0f1b2d;
  --ink-2: #33445c;
  --muted: #66788f;
  --line: #e4eaf2;
  --line-strong: #cfd9e6;
  --brand: #0f766e;
  --brand-dark: #0b5d57;
  --brand-2: #14b8a6;
  --brand-soft: #ecfdf7;
  --accent: #b45309;
  --accent-soft: #fff8ed;
  --danger: #b91c1c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06);
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 10px 28px rgba(15, 27, 45, .07);
  --max: 1120px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Liberation Sans", "Noto Sans", FreeSans, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; }

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

h1, h2, h3, h4 { line-height: 1.22; letter-spacing: -0.015em; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(1.75rem, 4.2vw, 2.5rem); }
h2 { font-size: clamp(1.28rem, 2.6vw, 1.6rem); margin-top: 0; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }

:focus-visible { outline: 3px solid rgba(20, 184, 166, .5); outline-offset: 2px; border-radius: 6px; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 18px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--brand); color: #fff;
  padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; gap: 14px;
  min-height: 62px; flex-wrap: wrap;
  padding-top: 8px; padding-bottom: 8px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.12rem; color: var(--ink); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--brand-2), var(--brand));
  display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 800;
  box-shadow: 0 3px 10px rgba(15, 118, 110, .28);
}
.brand span b { color: var(--brand); }

.site-nav { order: 3; width: 100%; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  white-space: nowrap; padding: 6px 10px; border-radius: 999px; color: var(--ink-2);
  font-size: .88rem; font-weight: 600;
}
.site-nav a:hover { background: var(--brand-soft); color: var(--brand-dark); text-decoration: none; }
.site-nav a[aria-current="page"] { background: var(--brand); color: #fff; }

.header-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.unit-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; }
.unit-toggle button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: .8rem; font-weight: 700; color: var(--muted);
  padding: 5px 11px; border-radius: 999px; letter-spacing: .01em;
}
.unit-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }

@media (min-width: 900px) {
  .header-inner { flex-wrap: nowrap; }
  .site-nav { order: 2; width: auto; margin-left: 8px; }
  .header-tools { margin-left: auto; }
}

/* ---------- Hero / sections ---------- */
.page-header { padding: 30px 0 8px; }
.page-header .kicker {
  display: inline-block; font-size: .78rem; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--brand-dark); background: var(--brand-soft);
  border: 1px solid #c8f0e4; border-radius: 999px; padding: 4px 10px; margin-bottom: 12px;
}
.page-header p.lead { font-size: 1.06rem; color: var(--ink-2); max-width: 68ch; margin-bottom: 0; }

.breadcrumb { font-size: .84rem; color: var(--muted); margin: 14px 0 0; }
.breadcrumb a { color: var(--muted); }
.breadcrumb span { opacity: .55; padding: 0 5px; }

main { display: block; padding-bottom: 56px; }

.section { margin: 34px 0 0; }
.section > h2 { margin-bottom: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.pad { padding: 20px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); }
.grid.tight { gap: 10px; }

/* ---------- Calculator ---------- */
.calc-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-top: 22px;
}
@media (min-width: 700px) { .calc-card { padding: 26px; } }

.calc-form { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .calc-form { grid-template-columns: 1fr 1fr; } }
.calc-form .field-wide, .calc-form .calc-actions, .calc-form .field-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: .86rem; font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: .78rem; color: var(--muted); }

input[type="number"], input[type="time"], input[type="text"], select {
  width: 100%; min-width: 0; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 11px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input[type="number"]:focus, input[type="time"]:focus, input[type="text"]:focus, select:focus {
  outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20, 184, 166, .18); background: #fff;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input { padding-right: 62px; }
.input-unit .unit-tag {
  position: absolute; right: 11px; font-size: .82rem; font-weight: 700; color: var(--muted);
  pointer-events: none;
}

.fieldset-reset { border: 0; padding: 0; margin: 0; min-width: 0; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: .92rem; color: var(--ink-2); }
.checkline input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); flex: 0 0 auto; }

.calc-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 1rem;
  background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff;
  padding: 12px 22px; border-radius: 12px; box-shadow: 0 4px 14px rgba(15, 118, 110, .25);
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: .94rem;
  background: transparent; color: var(--muted); border: 1px solid var(--line-strong);
  padding: 11px 16px; border-radius: 12px;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }

/* ---------- Results ---------- */
.result { margin-top: 20px; border-top: 1px dashed var(--line-strong); padding-top: 20px; }
.result[hidden] { display: none; }
.result-hero {
  background: linear-gradient(145deg, #ecfdf7, #f4fbf8);
  border: 1px solid #cdeee2; border-radius: var(--radius);
  padding: 18px 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.result-hero .big {
  font-size: clamp(1.75rem, 6vw, 2.5rem); font-weight: 800; letter-spacing: -.03em;
  color: var(--brand-dark); font-variant-numeric: tabular-nums; line-height: 1.05;
}
.result-hero .big small { font-size: .42em; font-weight: 700; color: var(--brand); margin-left: 4px; letter-spacing: 0; }
.result-hero .meta { min-width: 0; }
.result-hero .meta .label { font-size: .82rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--brand); }
.result-hero .meta .sub { font-size: .95rem; color: var(--ink-2); }

.result-rows { display: grid; gap: 8px; margin-top: 16px; }
.result-row {
  display: flex; justify-content: space-between; gap: 14px; align-items: baseline;
  padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; font-size: .95rem;
}
.result-row .k { color: var(--ink-2); min-width: 0; flex: 1 1 auto; }
.result-row .v { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.result-row.is-best { background: var(--brand-soft); border-color: #bfe9dc; }
.result-row.is-best .v { color: var(--brand-dark); }
.result-row.is-warn { background: var(--accent-soft); border-color: #f3dfc2; }
.result-note { margin-top: 14px; font-size: .88rem; color: var(--muted); }
.result-note strong { color: var(--ink-2); }
.badge { display: inline-block; font-size: .74rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #bfe9dc; }
.badge.warn { background: var(--accent-soft); color: var(--accent); border-color: #f3dfc2; }

.mini-bars { display: grid; gap: 7px; margin-top: 14px; }
.mini-bar { display: grid; grid-template-columns: 56px 1fr 78px; align-items: center; gap: 10px; font-size: .86rem; color: var(--muted); }
.mini-bar .track { display: block; height: 8px; border-radius: 999px; background: #edf1f6; overflow: hidden; }
.mini-bar .fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); }
.mini-bar .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }

/* ---------- Prose / content ---------- */
.prose { max-width: 78ch; }
.prose h2 { margin-top: 30px; }
.prose h3 { margin-top: 22px; }
.prose ul, .prose ol { padding-left: 1.15em; margin: 0 0 1em; }
.prose li { margin-bottom: .4em; }
.prose p, .prose li { color: var(--ink-2); }
.prose strong { color: var(--ink); }

.two-col { display: grid; gap: 26px; }
@media (min-width: 860px) { .two-col { grid-template-columns: 1.55fr 1fr; align-items: start; } }

.formula-list { display: grid; gap: 12px; }
.formula {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 14px 16px;
}
.formula .name { font-weight: 700; font-size: .95rem; margin-bottom: 4px; }
.formula code, .formula .expr {
  display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88rem; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; margin: 6px 0 8px; color: #0b3b36;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.formula p { margin: 0; font-size: .9rem; color: var(--muted); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: .92rem; }
caption { text-align: left; padding: 12px 14px 0; font-size: .82rem; color: var(--muted); font-weight: 600; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: #fcfdfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.faq { display: grid; gap: 10px; }
details {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0;
  box-shadow: var(--shadow-sm);
}
details[open] { border-color: #c9e9df; }
summary {
  cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 700; font-size: .97rem;
  display: flex; gap: 10px; align-items: flex-start; color: var(--ink);
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; color: var(--brand); font-weight: 800; font-size: 1.05rem; line-height: 1.35; flex: 0 0 auto; }
details[open] summary::before { content: "–"; }
details .answer { padding: 0 16px 15px; color: var(--ink-2); font-size: .94rem; }
details .answer p:last-child { margin-bottom: 0; }

.sources { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.sources li { font-size: .89rem; color: var(--muted); padding-left: 16px; position: relative; }
.sources li::before { content: "•"; position: absolute; left: 0; color: var(--brand-2); }
.sources a { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-strong); }
.sources a:hover { color: var(--brand); }

.update-note { font-size: .84rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 18px; }

.tool-links { display: grid; gap: 8px; }
.tool-link {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; color: var(--ink); font-weight: 600; font-size: .93rem; box-shadow: var(--shadow-sm);
}
.tool-link:hover { border-color: var(--brand-2); text-decoration: none; color: var(--brand-dark); }
.tool-link .arrow { color: var(--brand-2); font-weight: 800; }

.callout {
  border: 1px solid #f1e0c4; background: var(--accent-soft); color: #7c4a06;
  border-radius: var(--radius-sm); padding: 13px 15px; font-size: .9rem;
}
.callout strong { color: #63390a; }
.callout.info { border-color: #cfe2f7; background: #f2f8ff; color: #1e4b7a; }
.callout.info strong { color: #12365a; }

/* ---------- Home ---------- */
.hero { padding: 34px 0 10px; }
.hero h1 { max-width: 22ch; }
.hero .lead { font-size: clamp(1rem, 2.4vw, 1.16rem); color: var(--ink-2); max-width: 62ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 16px 20px; margin-top: 24px; max-width: 640px; }
.hero-stats div { font-size: .84rem; color: var(--muted); }
.hero-stats b { display: block; font-size: 1.24rem; color: var(--ink); letter-spacing: -.02em; line-height: 1.2; }

.cat-card { display: flex; flex-direction: column; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.cat-card h3 { margin: 0; font-size: 1.06rem; }
.cat-card .cat-desc { font-size: .88rem; color: var(--muted); margin: 0; }
.cat-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cat-card li a { display: block; padding: 5px 0; font-size: .92rem; color: var(--ink-2); border-bottom: 1px dotted #eef2f7; }
.cat-card li:last-child a { border-bottom: 0; }
.cat-card li a:hover { color: var(--brand-dark); }
.cat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: var(--brand-soft); border: 1px solid #d6f2e8; }

.pop-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); }
.pop-card { padding: 15px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 5px; }
.pop-card h3 { font-size: .98rem; margin: 0; }
.pop-card p { font-size: .85rem; color: var(--muted); margin: 0; }
.pop-card a.stretch { margin-top: auto; font-size: .86rem; font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: #fff; margin-top: 50px; padding: 34px 0 26px; }
.footer-cols { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
.footer-cols h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-cols a { font-size: .88rem; color: var(--ink-2); }
.footer-bottom { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; }
.footer-disclaimer { font-size: .78rem; color: var(--muted); margin-top: 10px; max-width: 90ch; }

/* ---------- Utility ---------- */
.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; }
.muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.small { font-size: .86rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

@media (max-width: 480px) {
  .site-nav { gap: 2px; }
  .site-nav a { font-size: .84rem; padding: 6px 8px; }
  .brand { font-size: 1.02rem; }
  .calc-card { padding: 15px; }
  .result-hero { padding: 15px 16px; }
}

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