/* ==========================================================================
   AI Cost Desk — shared stylesheet
   Plain CSS, no build step, no external fonts or CDN dependencies.
   Works from a static host (Cloudflare Pages / Vercel) and from the local disk.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg: #f7f8fb;
  --bg-soft: #ffffff;
  --bg-elevated: #ffffff;
  --bg-sunken: #eef1f7;
  --text: #14161c;
  --text-soft: #4d5566;
  --text-faint: #6b7385;
  --border: #e2e6ef;
  --border-strong: #c9d0e0;
  --accent: #2f5cf0;
  --accent-soft: #e8edfe;
  --accent-text: #1f3fb0;
  --teal: #0f9d8a;
  --teal-soft: #e2f6f2;
  --amber: #b26a00;
  --amber-soft: #fff3dd;
  --rose: #c02b4b;
  --rose-soft: #ffe9ee;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-lg: 0 18px 40px rgba(16, 24, 40, .10);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", "Apple SD Gothic Neo", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1017;
    --bg-soft: #12161f;
    --bg-elevated: #161b26;
    --bg-sunken: #0a0d13;
    --text: #eef1f8;
    --text-soft: #b8c0d1;
    --text-faint: #8d97ab;
    --border: #232936;
    --border-strong: #333b4d;
    --accent: #7d9bff;
    --accent-soft: #1a2542;
    --accent-text: #a9bcff;
    --teal: #4fd1bb;
    --teal-soft: #10312d;
    --amber: #f0b45c;
    --amber-soft: #33260f;
    --rose: #ff8098;
    --rose-soft: #35141d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
    --shadow-lg: 0 22px 48px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  --bg: #0d1017;
  --bg-soft: #12161f;
  --bg-elevated: #161b26;
  --bg-sunken: #0a0d13;
  --text: #eef1f8;
  --text-soft: #b8c0d1;
  --text-faint: #8d97ab;
  --border: #232936;
  --border-strong: #333b4d;
  --accent: #7d9bff;
  --accent-soft: #1a2542;
  --accent-text: #a9bcff;
  --teal: #4fd1bb;
  --teal-soft: #10312d;
  --amber: #f0b45c;
  --amber-soft: #33260f;
  --rose: #ff8098;
  --rose-soft: #35141d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 22px 48px rgba(0, 0, 0, .55);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.22; letter-spacing: -.018em; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.85rem, 1.2rem + 2.4vw, 2.9rem); }
h2 { font-size: clamp(1.35rem, 1.05rem + 1.2vw, 1.85rem); margin-top: 2.2em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }
ul, ol { padding-left: 1.25em; }
li { margin-bottom: .35em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
strong { font-weight: 650; }
code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: .1em .35em;
  border-radius: 5px;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff;
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }
.section { padding: 3.2rem 0; }
.section--tight { padding: 2rem 0; }
.prose { max-width: 760px; }
.prose h2 { margin-top: 2em; }
.prose h3 { margin-top: 1.6em; }
.lede { font-size: 1.09rem; color: var(--text-soft); }
.muted { color: var(--text-faint); }
.small { font-size: .875rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .site-header { background: var(--bg); }
}
.nav {
  display: flex; align-items: center; gap: 1rem;
  min-height: 62px;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 750; font-size: 1.02rem; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; margin-right: auto;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  display: grid; place-items: center; color: #fff; font-size: .82rem; font-weight: 800;
  letter-spacing: -.03em;
}
.nav-links { display: flex; align-items: center; gap: .25rem; }
.nav-links a {
  color: var(--text-soft); text-decoration: none; font-size: .9rem; font-weight: 550;
  padding: .45rem .6rem; border-radius: 8px; white-space: nowrap;
}
.nav-links a:hover { background: var(--bg-sunken); color: var(--text); }
.nav-links a[aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--text-soft); cursor: pointer; font-size: 1rem; line-height: 1;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .nav { flex-wrap: wrap; padding-block: .55rem; }
  .nav-toggle { display: inline-grid; }
  .nav-links {
    display: none; width: 100%; flex-direction: column; align-items: stretch;
    gap: 2px; padding-bottom: .6rem;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: .6rem .7rem; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 4.2rem 0 3.4rem;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(1100px 420px at 12% -10%, var(--accent-soft), transparent 70%),
    radial-gradient(900px 380px at 90% 0%, var(--teal-soft), transparent 65%),
    var(--bg);
}
.hero__inner { max-width: 820px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-text); background: var(--accent-soft);
  padding: .32rem .7rem; border-radius: 999px; margin-bottom: 1.1rem;
}
.hero h1 { margin-bottom: .6rem; }
.hero .lede { font-size: clamp(1rem, .95rem + .35vw, 1.2rem); max-width: 640px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.6rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .68rem 1.15rem; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-size: .93rem; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent); filter: brightness(1.06); color: #fff; }
.btn--ghost { background: var(--bg-soft); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-text); }
.btn--sm { padding: .42rem .8rem; font-size: .84rem; border-radius: 8px; }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 1.15rem; }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid--3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid--2 { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}
.card--link {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.card--link:hover {
  border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px);
  color: inherit;
}
.card__icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-size: 1.2rem; margin-bottom: .9rem;
}
.card h3 { margin-bottom: .35rem; }
.card p { color: var(--text-soft); font-size: .93rem; margin-bottom: .8rem; }
.card__meta { margin-top: auto; font-size: .82rem; color: var(--text-faint); font-weight: 600; }

/* ---------- Calculator shell ---------- */
.tool-head { padding: 2.6rem 0 1.4rem; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.tool-head h1 { margin-bottom: .5rem; }
.tool-head .lede { max-width: 700px; }
.breadcrumb { font-size: .82rem; color: var(--text-faint); margin-bottom: .9rem; }
.breadcrumb a { color: var(--text-faint); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-text); text-decoration: underline; }
.updated-badge {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600;
  color: var(--teal); background: var(--teal-soft); padding: .25rem .6rem; border-radius: 999px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

.calc {
  display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 1.4rem; align-items: start;
  margin-top: 1.8rem;
}
@media (max-width: 980px) { .calc { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow-sm);
}
.panel--sticky { position: sticky; top: 80px; }
@media (max-width: 980px) { .panel--sticky { position: static; } }
.panel h2, .panel h3 { margin-top: 0; }
.panel__title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.panel__title h2 { font-size: 1.02rem; margin: 0; letter-spacing: -.01em; }

.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label {
  display: block; font-size: .85rem; font-weight: 620; color: var(--text-soft); margin-bottom: .32rem;
}
.field .hint { display: block; font-size: .78rem; color: var(--text-faint); margin-top: .28rem; font-weight: 400; }
.input, .select {
  width: 100%; padding: .58rem .7rem; font: inherit; font-size: .95rem;
  color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border-strong); border-radius: 9px;
  appearance: none;
}
.select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
                    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 2.2rem;
}
.input:focus, .select:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); outline-offset: 0; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.preset-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.chip {
  font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
  padding: .28rem .6rem; border-radius: 999px; color: var(--text-soft);
  background: var(--bg-sunken); border: 1px solid var(--border);
}
.chip:hover { border-color: var(--accent); color: var(--accent-text); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }

/* ---------- Results ---------- */
.results-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: .5rem; margin-bottom: .9rem;
}
.results-head h2 { font-size: 1.05rem; margin: 0; letter-spacing: -.01em; }
.total {
  display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem;
  background: linear-gradient(135deg, var(--accent-soft), var(--teal-soft));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem;
  margin-bottom: 1.1rem;
}
.total__label { font-size: .82rem; font-weight: 650; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; }
.total__value { font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.3rem); font-weight: 750; letter-spacing: -.03em; line-height: 1.1; }
.total__sub { font-size: .85rem; color: var(--text-soft); grid-column: 1 / -1; }

.kpi-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
@media (max-width: 620px) { .kpi-row { grid-template-columns: 1fr 1fr; } }
.kpi {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .7rem .8rem;
}
.kpi__label { font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.kpi__value { font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.kpi__sub { font-size: .76rem; color: var(--text-faint); }

/* ---------- Tables ---------- */
.table-wrap {
  width: 100%; overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-elevated); box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 560px; }
caption { text-align: left; font-size: .82rem; color: var(--text-faint); padding: .7rem .9rem; }
th, td { padding: .58rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th {
  background: var(--bg-sunken); font-size: .76rem; font-weight: 680; letter-spacing: .035em;
  text-transform: uppercase; color: var(--text-soft); white-space: nowrap; position: sticky; top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-sunken); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .85em; }
tr.is-best { background: var(--teal-soft); }
tr.is-best:hover { background: var(--teal-soft); }
tr.is-best td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
tr.is-ref { background: var(--accent-soft); }
tr.is-ref:hover { background: var(--accent-soft); }
.row-sub { display: block; font-size: .76rem; color: var(--text-faint); font-weight: 400; }

.badge {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .02em;
  padding: .12rem .45rem; border-radius: 5px; background: var(--bg-sunken); color: var(--text-soft);
  border: 1px solid var(--border); white-space: nowrap;
}
.badge--flag { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge--budget { background: var(--teal-soft); color: var(--teal); border-color: transparent; }
.badge--warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge--best { background: var(--teal); color: #fff; border-color: transparent; }

/* ---------- Recommendation ---------- */
.rec {
  display: grid; gap: .9rem; grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1.2rem;
}
@media (max-width: 680px) { .rec { grid-template-columns: 1fr; } }
.rec__card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem;
  background: var(--bg-elevated);
}
.rec__card--best { border-color: var(--teal); background: var(--teal-soft); }
.rec__card--flag { border-color: var(--accent); background: var(--accent-soft); }
.rec__label { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); }
.rec__name { font-size: 1.06rem; font-weight: 700; margin: .15rem 0 .1rem; }
.rec__price { font-size: 1.45rem; font-weight: 750; letter-spacing: -.03em; }
.rec__note { font-size: .82rem; color: var(--text-soft); }

.notice {
  border-left: 3px solid var(--amber); background: var(--amber-soft);
  padding: .75rem .95rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .87rem; color: var(--text); margin: 1rem 0;
}
.notice--info { border-color: var(--accent); background: var(--accent-soft); }
.notice strong { font-weight: 700; }

/* ---------- Bars ---------- */
.bars { display: grid; gap: .45rem; }
.bar-row { display: grid; grid-template-columns: 150px 1fr auto; gap: .6rem; align-items: center; font-size: .84rem; }
@media (max-width: 520px) { .bar-row { grid-template-columns: 110px 1fr auto; font-size: .8rem; } }
.bar-track { height: 9px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--teal)); border-radius: 999px; }
.bar-row--best .bar-fill { background: var(--teal); }

/* ---------- Content blocks ---------- */
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { position: relative; padding-left: 2.2rem; margin-bottom: .85rem; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: .1rem; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text); font-size: .78rem; font-weight: 700;
  display: grid; place-items: center;
}
.formula {
  font-family: var(--mono); font-size: .85rem; line-height: 1.7;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem 1.1rem; overflow-x: auto;
  white-space: pre; margin: 1rem 0;
}
.example {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elevated); padding: 1.1rem 1.25rem; margin: 1.2rem 0;
}
.example h3 { margin-top: 0; font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }

/* ---------- FAQ ---------- */
.faq { max-width: 820px; }
.faq details {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elevated); padding: .85rem 1rem; margin-bottom: .6rem;
}
.faq details[open] { border-color: var(--border-strong); }
.faq summary {
  cursor: pointer; font-weight: 620; font-size: .96rem; list-style: none;
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--text-faint); font-weight: 400; font-size: 1.15rem; flex: none; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: .65rem 0 0; color: var(--text-soft); font-size: .91rem; }
.faq details p:last-child { margin-bottom: 0; }

/* ---------- Ad slots (AdSense placeholders) ---------- */
.ad-slot {
  display: block; margin: 2rem auto; padding: .8rem;
  min-height: 100px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: repeating-linear-gradient(45deg, var(--bg-sunken), var(--bg-sunken) 10px, var(--bg-soft) 10px, var(--bg-soft) 20px);
  color: var(--text-faint); font-size: .76rem; text-align: center;
  display: grid; place-items: center;
}
.ad-slot::after { content: "Advertisement"; letter-spacing: .12em; text-transform: uppercase; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 3rem; border-top: 1px solid var(--border); background: var(--bg-soft);
  padding: 2.6rem 0 2rem; font-size: .88rem; color: var(--text-soft);
}
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 1.6rem; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-grid h4 {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint);
  margin-bottom: .7rem;
}
.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links li { margin-bottom: .4rem; }
.footer-links a { color: var(--text-soft); text-decoration: none; }
.footer-links a:hover { color: var(--accent-text); text-decoration: underline; }
.footer-bottom {
  margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; justify-content: space-between;
  font-size: .8rem; color: var(--text-faint);
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.taglist { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; list-style: none; }
.taglist li { margin: 0; }

@media print {
  .site-header, .site-footer, .ad-slot, .hero-actions { display: none; }
  body { background: #fff; }
}
