@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&family=Libre+Caslon+Display&display=swap');

[hidden] {
  display: none !important;
}

:root {
  --bg: #151814;
  --ink: #f1efdf;
  --muted: #afb3a4;
  --line: #363b31;
  --accent: #d5bb77;
  --accent-strong: #e4cc8c;
  --panel: #1e221c;
  --soft: #272d22;
  --ok: #7ec495;
  --warn: #e5b869;
  --danger: #e2786a;
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 'DM Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-underline-offset: 4px;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  line-height: 1.08;
}

h1,
h2 {
  font-family: 'Libre Caslon Display', Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(50px, 7vw, 96px);
}

h2 {
  font-size: clamp(32px, 4.2vw, 50px);
}

h3 {
  font-family: 'Manrope', sans-serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

p {
  margin: 1em 0;
}

small,
.small {
  font-size: 13px;
  line-height: 1.5;
}

.muted {
  color: var(--muted);
}

.num-tabular {
  font-variant-numeric: tabular-nums;
}

.wrap {
  width: min(1240px, calc(100% - 72px));
  margin: auto;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: rgba(21, 24, 20, 0.88);
  backdrop-filter: blur(12px);
}

.nav {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font: 700 24px 'Manrope', sans-serif;
  text-decoration: none;
  letter-spacing: -0.06em;
  white-space: nowrap;
}

.brand em {
  font-style: normal;
  color: var(--accent);
}

nav {
  display: flex;
  gap: 28px;
  align-items: center;
}

nav a {
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.18s ease;
}

nav a:hover,
nav a[aria-current='page'] {
  color: var(--ink);
}

nav a[aria-current='page'] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

/* Hero */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  text-transform: uppercase;
  letter-spacing: 0.17em;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 22px;
}

.eyebrow::before {
  content: '';
  width: 26px;
  height: 2px;
  background: var(--accent);
}

.hero {
  padding: 58px 0 48px;
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  gap: 60px;
  align-items: center;
}

.hero-accent {
  color: var(--accent);
}

.intro {
  max-width: 495px;
  font-size: 18px;
  color: var(--muted);
  margin: 24px 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin: 28px 0;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #181b14;
  border: 1px solid transparent;
  padding: 14px 22px;
  border-radius: 7px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  min-height: 48px;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.btn:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.btn.secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--soft);
  border-color: var(--accent);
}

.textlink {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.quote-refresh {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.quote-refresh:hover:not(:disabled) {
  color: var(--accent-strong);
}

.hero-note {
  font-size: 12px;
  color: var(--muted);
}

.hero-art {
  min-height: 420px;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: radial-gradient(ellipse at center, #414332, #20251c 75%);
}

.hero-art svg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.art-top,
.art-label {
  position: absolute;
  left: 26px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
}

.art-top {
  top: 22px;
}

.art-label {
  bottom: 22px;
}

/* Jump links */
.jump-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: -10px 0 34px;
}

.jump-links a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  text-decoration: none;
  color: var(--muted);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.jump-links a:hover {
  background: var(--soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Price strip */
.price-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  border-block: 1px solid var(--line);
  padding: 20px 0;
  margin-bottom: 52px;
}

.price-strip strong {
  font: 600 30px/1.15 'Manrope', sans-serif;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.price-strip .status {
  font-size: 13px;
  line-height: 1.5;
  max-width: 440px;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.price-strip[data-quote-state='live'] .status-dot {
  background: var(--ok);
}

.price-strip[data-quote-state='cached'] .status-dot,
.price-strip[data-quote-state='stale'] .status-dot {
  background: var(--warn);
}

.price-strip[data-quote-state='error'] .status-dot {
  background: var(--danger);
}

/* Sections */
.section {
  padding: 22px 0 68px;
}

.section-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 25px;
  margin-bottom: 30px;
}

.section-top p {
  max-width: 440px;
  font-size: 15px;
  color: var(--muted);
  margin: 0;
}

.kicker {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.15em;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* Main Calculator */
.tool {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.04fr 0.96fr;
  background: var(--panel);
}

.form-panel {
  padding: 36px;
}

.result-panel {
  padding: 36px;
  background: var(--soft);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.field {
  margin: 0 0 20px;
  display: block;
}

.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

input[type='number'],
select {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink);
  padding: 10px 13px;
  font-variant-numeric: tabular-nums;
  scroll-margin-block: 80px;
  transition: border-color 0.15s ease;
}

input[type='number']:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
}

input[aria-invalid='true'] {
  border-color: var(--danger);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.quick-values {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: -6px 0 20px;
}

.quick-values > span {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}

.quick-values button {
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.quick-values button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(213, 187, 119, 0.14);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
  width: fit-content;
}

.result-big {
  font: 600 clamp(36px, 4.8vw, 60px)/1.08 'Manrope', sans-serif;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin: 16px 0 12px;
  overflow-wrap: anywhere;
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 22px 0;
}

.mini-stats > div {
  border: 1px solid var(--line);
  background: rgba(21, 24, 20, 0.35);
  border-radius: 9px;
  padding: 15px;
}

.mini-stats strong {
  display: block;
  font: 600 22px/1.2 'Manrope', sans-serif;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.mini-stats span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.notice {
  padding: 15px 18px;
  background: rgba(21, 24, 20, 0.55);
  border-left: 3px solid var(--accent);
  font-size: 13px;
  margin: 16px 0;
  border-radius: 0 7px 7px 0;
}

.offer-bar {
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
}

.offer-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

/* Batch Calculator */
.batch-tool {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 28px;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.batch-total {
  padding: 28px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  align-self: start;
  position: sticky;
  top: 96px;
  min-width: 0;
}

.piece-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) auto 40px;
  gap: 12px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.piece-row .field {
  margin: 0;
}

.piece-row .field > span {
  font-size: 11px;
  color: var(--muted);
}

.piece-number {
  font: 700 13px 'Manrope', sans-serif;
  color: var(--accent);
  padding-bottom: 14px;
}

.piece-subtotal {
  font: 600 14px 'Manrope', sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
  padding-bottom: 13px;
  min-width: 84px;
  text-align: right;
}

.remove-piece {
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin-bottom: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.remove-piece:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

/* Purity grid */
.purity-reference {
  padding: 32px 0 0;
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  gap: 32px;
  margin-top: 24px;
  border-top: 1px solid var(--line);
}

.purity-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.purity-grid > div {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  border-radius: 9px;
}

.purity-grid span,
.purity-grid small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.purity-grid strong {
  font: 600 22px/1.2 'Manrope', sans-serif;
  font-variant-numeric: tabular-nums;
  display: block;
  color: var(--accent);
  margin: 6px 0;
}

/* Offer comparison */
.offer-basis {
  max-width: 520px;
}

.offer-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.offer-card {
  min-width: 0;
  transition: border-color 0.2s ease;
}

.offer-card.is-best {
  border-color: var(--accent);
}

.offer-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.offer-card-head .kicker {
  margin-bottom: 0;
}

.offer-output {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.offer-output > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.offer-output > strong {
  display: block;
  font: 650 32px/1.15 'Manrope', sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: -0.04em;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.offer-output p {
  margin-bottom: 0;
}

/* Cards & Guides */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  background: var(--panel);
}

.card > p {
  font-size: 14px;
  color: var(--muted);
  margin: 14px 0 20px;
}

.card .num {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 28px;
  display: block;
}

.card a {
  text-decoration: none;
}

.card a:hover {
  text-decoration: underline;
}

.card h3 a {
  display: block;
}

/* FAQ Details */
.details {
  margin: 8px 0;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

summary {
  font-weight: 600;
  cursor: pointer;
  line-height: 1.5;
}

details p {
  font-size: 14px;
  color: var(--muted);
}

/* Articles */
.article {
  max-width: 780px;
  margin: 56px auto 80px;
}

.article h1 {
  font-size: clamp(38px, 5vw, 62px);
}

.article h2 {
  font-size: 30px;
  margin: 36px 0 14px;
}

.article h3 {
  margin: 24px 0 10px;
}

.article p,
.article li {
  color: var(--muted);
}

.article ul,
.article ol {
  padding-left: 22px;
}

.article .lead {
  font-size: 20px;
  line-height: 1.55;
  color: var(--ink);
}

.breadcrumb {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 26px;
}

.sources {
  word-break: break-word;
  font-size: 14px;
}

.article-toc {
  margin: 28px 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.article-toc strong {
  font-size: 13px;
}

.article-toc ol {
  margin: 14px 0 0;
  padding-left: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
}

.article-toc li,
.article-toc a {
  font-size: 13px;
}

.article-related {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 34px;
  background: var(--panel);
}

.article-related h2 {
  font-size: 24px;
  margin-top: 0;
}

.article-related a {
  display: block;
  margin: 12px 0;
  font-size: 14px;
}

.article-back {
  display: inline-block;
  margin-top: 26px;
}

/* Footer */
footer {
  border-top: 1px solid var(--line);
  padding: 36px 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  align-items: flex-start;
}

footer p {
  font-size: 12px;
  color: var(--muted);
  max-width: 420px;
}

.footer-links {
  display: flex;
  gap: 24px;
  font-size: 13px;
  flex-wrap: wrap;
}

/* Accessibility skip link */
.skip {
  position: absolute;
  left: 10px;
  top: -80px;
  padding: 12px 16px;
  background: var(--accent);
  color: #181b14;
  font-weight: 700;
  border-radius: 6px;
  z-index: 100;
}

.skip:focus {
  top: 10px;
}

/* Responsive */
@media (max-width: 960px) {
  .wrap {
    width: calc(100% - 40px);
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 40px 0 32px;
  }

  .hero-art {
    min-height: 320px;
  }

  .tool,
  .batch-tool,
  .purity-reference,
  .offer-cards,
  .cards {
    grid-template-columns: 1fr;
  }

  .result-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .batch-total {
    position: static;
  }

  .offer-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
  }

  .offer-card > .offer-card-head,
  .offer-card > .small,
  .offer-card > .offer-output {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .wrap {
    width: calc(100% - 32px);
  }

  .nav {
    min-height: 70px;
    gap: 12px;
  }

  .brand {
    font-size: 20px;
  }

  nav {
    gap: 16px;
  }

  nav a {
    font-size: 13px;
  }

  h1 {
    font-size: 48px;
  }

  .section-top {
    display: block;
  }

  .section-top p {
    margin-top: 14px;
  }

  .price-strip {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 36px;
  }

  .form-panel,
  .result-panel,
  .batch-tool,
  .batch-total,
  .card {
    padding: 22px;
  }

  .grid2,
  .article-toc ol,
  .offer-card {
    grid-template-columns: 1fr;
  }

  .piece-row {
    grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr) 38px;
    gap: 8px;
  }

  .piece-subtotal {
    grid-column: 2 / 4;
    text-align: left;
    padding: 0;
    font-size: 13px;
    color: var(--accent);
  }

  .purity-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-inner {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .btn,
  .offer-bar > span {
    transition: none;
  }
}

@media print {
  header,
  footer,
  .actions,
  .btn,
  nav,
  .hero-art,
  .jump-links,
  .quick-values,
  .result-actions,
  #add-piece,
  .remove-piece,
  #copy-batch,
  .article-toc {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    --muted: #444;
    --line: #ccc;
    --soft: #f3f3f3;
    --panel: #fff;
    --accent: #000;
  }

  .wrap {
    width: 100%;
  }

  .tool,
  .batch-tool,
  .purity-reference,
  .offer-cards {
    display: block;
  }

  .batch-total,
  .offer-card {
    break-inside: avoid;
    margin-bottom: 18px;
  }
}
