/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ===== Theme tokens ===== */
:root {
  --bg: #fafaf7;
  --bg-surface: #ffffff;
  --bg-alt: #f3f2ed;
  --bg-muted: #eeece5;
  --text: #1a1a1a;
  --text-secondary: #595955;
  --text-tertiary: #8a8a85;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --accent: #c15f3c;
  --accent-soft: #f5e3db;
  --accent-text: #8a3e22;
  --success: #1d7a4f;
  --success-soft: #dff0e6;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --bg-surface: #1c1c1b;
    --bg-alt: #1f1f1e;
    --bg-muted: #262625;
    --text: #f5f5f0;
    --text-secondary: #b5b5ae;
    --text-tertiary: #807f78;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.2);
    --accent: #d97757;
    --accent-soft: #3d2419;
    --accent-text: #f2b199;
    --success: #4ade80;
    --success-soft: #1a3a28;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

/* ===== Layout ===== */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 64px 0;
}
.section-alt {
  background: var(--bg-alt);
}
.section-head {
  margin-bottom: 32px;
}
.section-head h3 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.section-head p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 16px;
}

.template-picker {
  margin-bottom: 28px;
}

.template-picker__head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 16px;
}

.template-picker__head h4 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.template-picker__head p {
  margin: 0;
  max-width: 640px;
  color: var(--text-secondary);
  font-size: 14px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.template-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-height: 208px;
  padding: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: left;
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.template-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.template-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.template-card__eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: 600;
}

.template-card__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.template-card__description {
  font-size: 14px;
  line-height: 1.5;
}

.template-card__practical {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.template-card__meta {
  font-size: 12px;
  color: var(--accent-text);
  font-weight: 600;
}

.template-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.template-card__chips span {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.logo-mark {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--accent);
  display: inline-block;
  position: relative;
}
.logo-mark::after {
  content: '';
  position: absolute;
  inset: 4px;
  background: var(--bg);
  border-radius: 2px;
}
.nav {
  display: flex;
  gap: 24px;
}
.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.15s;
}
.nav a:hover { color: var(--text); }

@media (max-width: 640px) {
  .nav { gap: 14px; }
  .nav a { font-size: 13px; }
  .logo { font-size: 14px; }
}

/* ===== Hero ===== */
.hero {
  padding: 72px 0 40px;
  text-align: center;
}
.hero h2 {
  font-size: 44px;
  font-weight: 600;
  margin: 0 0 16px;
  letter-spacing: -0.03em;
  line-height: 1.15;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}
.hero .lead {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto 16px;
  line-height: 1.55;
}
.pricing-note {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
}
@media (max-width: 640px) {
  .hero h2 { font-size: 32px; }
  .hero .lead { font-size: 16px; }
  .template-picker__head {
    align-items: start;
    flex-direction: column;
  }
  .template-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Panels & fields ===== */
.estimator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .estimator-grid { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .template-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.field {
  margin-bottom: 22px;
}
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}
.hint {
  font-size: 12.5px;
  color: var(--text-tertiary);
  margin: 6px 0 0;
  line-height: 1.45;
}
.hint a { color: var(--accent); text-decoration: none; }
.hint a:hover { text-decoration: underline; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.slider-head label { margin: 0; }
.slider-head output {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 6px;
}

/* ===== Form controls ===== */
select, input[type="number"], textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus, input[type="number"]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 160px; line-height: 1.5; }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  margin: 8px 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-muted);
  border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--bg-muted);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
  margin-top: -7px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-text); border-color: var(--accent-text); }
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-muted); }

/* ===== Results ===== */
.results-panel {
  background: var(--bg-alt);
}
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.model-pill {
  background: var(--bg-surface);
  color: var(--text);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--border);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}
@media (max-width: 560px) {
  .result-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.01em;
}
.stat-highlight {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.stat-highlight .stat-value { color: var(--accent-text); }

.breakdown {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.breakdown h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin: 0 0 12px;
  font-weight: 500;
}
.breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.breakdown-row span:first-child { color: var(--text-secondary); }
.breakdown-row span:last-child { color: var(--text); font-weight: 500; }

.share {
  display: flex;
  align-items: center;
  gap: 12px;
}
.share-status {
  font-size: 13px;
  color: var(--success);
  font-weight: 500;
}

/* ===== Compare table ===== */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.compare-table thead {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.compare-table th {
  padding: 12px 18px;
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.compare-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr.is-current {
  background: var(--accent-soft);
}
.compare-table .num { text-align: right; }
.compare-table .strong { font-weight: 600; color: var(--text); }
.compare-table .muted { color: var(--text-tertiary); font-size: 13px; }

.model-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.model-btn:hover { color: var(--accent); text-decoration: underline; }

.provider-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-muted);
  color: var(--text-secondary);
}
.provider-anthropic { background: #f5e3db; color: #8a3e22; }
.provider-openai { background: #dff0e6; color: #1d7a4f; }
.provider-google { background: #e0e7ff; color: #3730a3; }
.provider-xai { background: #e6e6e6; color: #1a1a1a; }

@media (prefers-color-scheme: dark) {
  .provider-anthropic { background: #3d2419; color: #f2b199; }
  .provider-openai { background: #1a3a28; color: #86efac; }
  .provider-google { background: #1e1b4b; color: #a5b4fc; }
  .provider-xai { background: #2a2a29; color: #e5e5e0; }
}

@media (max-width: 720px) {
  .compare-table th, .compare-table td {
    padding: 10px 12px;
    font-size: 13px;
  }
  .compare-table th:nth-child(2), .compare-table td:nth-child(2) { display: none; }
}

/* ===== Token counter ===== */
.counter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}
@media (max-width: 800px) {
  .counter-grid { grid-template-columns: 1fr; }
}
.counter-grid .field { margin: 0; }
.counter-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== FAQ ===== */
.faq {
  max-width: 800px;
}
.faq details {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.faq summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 500;
  font-size: 15px;
  list-style: none;
  position: relative;
  padding-right: 44px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--text-tertiary);
  font-weight: 300;
  transition: transform 0.2s;
}
.faq details[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.faq details[open] summary { border-bottom: 1px solid var(--border); }
.faq details p {
  padding: 14px 20px 18px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}
.faq details p a { color: var(--accent); }

/* ===== Footer ===== */
.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}
.site-footer p {
  color: var(--text-tertiary);
  font-size: 13px;
  margin: 0;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.6;
}
