@font-face {
  font-family: "Tally Sans";
  src: local("Arial");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #171814;
  --muted: #62655b;
  --paper: #f5f1e8;
  --card: rgba(255, 253, 247, 0.88);
  --line: rgba(23, 24, 20, 0.14);
  --acid: #d9ff57;
  --purple: #6d5ce7;
  --purple-dark: #4a3cc1;
  --coral: #ff7d5f;
  --shadow: 0 18px 55px rgba(41, 38, 28, 0.1);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(23, 24, 20, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 24, 20, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: "Tally Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.5;
  pointer-events: none;
}

.ambient-one { width: 310px; height: 310px; right: -120px; top: 140px; background: rgba(217, 255, 87, 0.62); }
.ambient-two { width: 250px; height: 250px; left: -110px; top: 680px; background: rgba(109, 92, 231, 0.16); }

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.03em; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px 11px 11px 3px; display: grid; place-items: center; background: var(--ink); color: var(--acid); transform: rotate(-4deg); }
.header-link { color: var(--ink); text-decoration: none; font-size: 0.9rem; font-weight: 700; border-bottom: 1px solid var(--ink); }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.hero { padding: 80px 0 54px; max-width: 870px; }
.eyebrow, .step { margin: 0 0 14px; text-transform: uppercase; font-size: 0.72rem; font-weight: 850; letter-spacing: 0.16em; color: var(--muted); }
.eyebrow { display: flex; align-items: center; gap: 9px; }
.eyebrow-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 5px rgba(255, 125, 95, 0.16); }
.hero h1 { margin: 0; font-size: clamp(3.4rem, 8.5vw, 7.5rem); line-height: 0.88; letter-spacing: -0.075em; font-weight: 880; }
.hero h1 em { font-family: Georgia, "Times New Roman", serif; font-weight: 400; color: var(--purple); }
.hero-copy { max-width: 660px; margin: 34px 0 22px; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.3rem); }
.trust-row { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 0.82rem; font-weight: 700; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(330px, 0.9fr); gap: 22px; align-items: start; }
.card, .result-panel { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.card { background: var(--card); padding: clamp(22px, 3vw, 36px); }
.calculator-card { grid-row: span 2; }
.decipher-card { background: rgba(228, 222, 255, 0.72); }
.result-panel { background: var(--ink); color: white; padding: clamp(22px, 3vw, 34px); position: sticky; top: 20px; }
.card-heading, .result-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.card-heading h2, .section-heading h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: -0.045em; line-height: 1.05; }
.text-button, .details-button, .copy-button { border: 0; background: transparent; padding: 3px 0; color: var(--muted); font-size: 0.78rem; font-weight: 800; border-bottom: 1px solid currentColor; }
.copy-button { color: rgba(255, 255, 255, 0.7); }
.copy-button:disabled { opacity: 0.4; cursor: not-allowed; }
.field-label { display: block; margin-bottom: 8px; font-weight: 800; font-size: 0.84rem; }
.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; right: 18px; top: 50%; transform: translateY(-56%); pointer-events: none; font-size: 1.2rem; }
select, input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, 0.72); color: var(--ink); transition: border-color 150ms ease, background 150ms ease, transform 150ms ease; }
select:hover, input:hover, textarea:hover { border-color: rgba(23, 24, 20, 0.32); }
select { appearance: none; padding: 15px 44px 15px 15px; font-weight: 750; }
textarea { padding: 16px; resize: vertical; min-height: 176px; line-height: 1.55; }

.model-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px 0; font-size: 0.74rem; }
.model-strip > div { display: flex; align-items: center; min-width: 0; gap: 9px; }
.model-strip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.7rem; }
.status-badge { border-radius: 999px; padding: 4px 8px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 900; font-size: 0.6rem; background: var(--acid); }
.status-badge.reference { background: #eee6ff; color: var(--purple-dark); }
.status-badge.unpriced { background: #ffe1da; color: #9b321c; }
.rate-detail { margin: 14px 0 0; padding: 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 0.82rem; background: rgba(255,255,255,0.45); }
.rate-detail p { margin: 0 0 8px; }
.rate-detail p:last-child { margin-bottom: 0; }
.rate-detail a { color: var(--purple-dark); font-weight: 800; }
.tier-row { margin-top: 22px; }
.token-grid { margin: 28px 0 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.token-field { display: block; }
.token-field > span { display: flex; min-height: 35px; flex-direction: column; margin: 0 0 7px 2px; font-size: 0.82rem; font-weight: 800; }
.token-field small { color: var(--muted); font-weight: 600; }
.token-field input { padding: 15px; font-variant-numeric: tabular-nums; font-weight: 780; }
.token-field.is-unavailable { opacity: 0.48; }
.field-help { margin: 13px 0 24px; color: var(--muted); font-size: 0.75rem; }
.primary-button, .secondary-button { width: 100%; border: 0; border-radius: 14px; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; font-weight: 880; transition: transform 150ms ease, box-shadow 150ms ease; }
.primary-button { background: var(--ink); color: white; box-shadow: 0 8px 0 var(--acid); }
.secondary-button { background: var(--purple); color: white; box-shadow: 0 8px 0 rgba(74, 60, 193, 0.25); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); }
.primary-button:active, .secondary-button:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(23, 24, 20, 0.18); }
.secondary-button:disabled { cursor: wait; opacity: 0.72; }
.luna-chip { flex: none; border: 1px solid rgba(74, 60, 193, 0.25); border-radius: 999px; padding: 7px 10px; color: var(--purple-dark); background: rgba(255,255,255,0.46); font-size: 0.65rem; font-weight: 850; }
.textarea-meta { margin: 8px 2px 24px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.7rem; }
.button-icon.is-loading { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.parse-status { margin-top: 18px; padding: 14px 15px; border-radius: 12px; background: rgba(217, 255, 87, 0.55); font-size: 0.82rem; }
.parse-status.error { color: #7e2817; background: rgba(255, 125, 95, 0.18); }

.result-panel .step { color: rgba(255,255,255,0.5); }
.result-main { padding: 20px 0 28px; border-bottom: 1px solid rgba(255,255,255,0.16); }
.result-kicker { margin: 0 0 6px; color: rgba(255,255,255,0.6); font-size: 0.82rem; }
.result-total { display: block; font-size: clamp(3rem, 6vw, 5.3rem); line-height: 1; letter-spacing: -0.07em; font-weight: 880; color: var(--acid); overflow-wrap: anywhere; }
.result-caption { margin: 12px 0 0; color: rgba(255,255,255,0.56); font-size: 0.78rem; }
.breakdown { padding: 18px 0; }
.line-item { display: grid; grid-template-columns: 1fr auto; gap: 7px 16px; padding: 10px 0; }
.line-item + .line-item { border-top: 1px solid rgba(255,255,255,0.09); }
.line-item strong { font-size: 0.82rem; }
.line-item output { font-variant-numeric: tabular-nums; font-size: 0.82rem; font-weight: 800; }
.line-meta { grid-column: 1 / -1; color: rgba(255,255,255,0.48); font-size: 0.68rem; }
.assumption-note { padding: 14px; border-radius: 12px; background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.68); font-size: 0.72rem; }

.method-section { margin: 100px 0 70px; padding-top: 36px; border-top: 1px solid var(--line); }
.section-heading { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 40px; align-items: end; }
.section-heading .step { grid-column: 1 / -1; margin: 0; }
.section-heading p:last-child { margin: 0; color: var(--muted); max-width: 530px; }
.method-grid { margin-top: 42px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.method-grid article { padding: 25px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,0.38); }
.method-number { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--acid); font-weight: 900; }
.method-grid h3 { margin: 24px 0 8px; font-size: 1.15rem; }
.method-grid p { margin: 0; color: var(--muted); font-size: 0.86rem; }
.billing-note { margin: 22px 0 0; padding: 19px 22px; border-left: 4px solid var(--coral); background: rgba(255,255,255,0.46); color: var(--muted); font-size: 0.86rem; }

footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 22px 0 40px; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.75rem; }
footer strong { color: var(--ink); }
.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; }

@media (max-width: 860px) {
  .hero { padding-top: 56px; }
  .workspace { grid-template-columns: 1fr; }
  .calculator-card { grid-row: auto; }
  .result-panel { position: static; order: 3; }
  .section-heading { grid-template-columns: 1fr; }
  .method-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .site-header, main, footer { width: min(100% - 24px, 1180px); }
  .site-header { padding-top: 16px; }
  .hero { padding: 44px 0 38px; }
  .hero h1 { font-size: clamp(3.05rem, 17vw, 5rem); }
  .card, .result-panel { border-radius: 19px; }
  .token-grid { grid-template-columns: 1fr; }
  .token-field > span { min-height: 0; }
  .card-heading { align-items: flex-start; }
  .luna-chip { display: none; }
  .model-strip { align-items: flex-start; flex-direction: column; }
  .textarea-meta, footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
