:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #171b23;
  --line: rgba(255,255,255,.09);
  --line-strong: rgba(255,255,255,.16);
  --text: #f5f2ea;
  --muted: #9a9da6;
  --gold: #d9b86d;
  --gold-bright: #f0d28b;
  --gold-soft: rgba(217,184,109,.12);
  --green: #79d8a0;
  --danger: #ff8b8b;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --shadow: 0 24px 70px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% -8%, rgba(203,168,93,.13), transparent 34rem),
    radial-gradient(circle at -15% 35%, rgba(87,96,119,.1), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }
.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 0 32px; }

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 760; letter-spacing: .25em; }
.brand-mark { width: 31px; height: 31px; color: var(--gold); }
.brand-mark svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; }
.market-state { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 5px var(--gold-soft); animation: pulse 1.5s infinite; }
.market-state.ready .status-dot { background: var(--green); box-shadow: 0 0 0 5px rgba(121,216,160,.1); animation: none; }
.market-state.stale .status-dot { background: var(--gold); animation: none; }
.market-state.error .status-dot { background: var(--danger); animation: none; }
@keyframes pulse { 50% { opacity: .45; } }

main { padding: 54px 0 74px; }
.intro { padding: 80px 0 54px; max-width: 760px; }
.eyebrow, .section-kicker { margin: 0 0 16px; color: var(--gold); font-size: 10px; font-weight: 750; letter-spacing: .24em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 24px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(44px, 6.4vw, 76px); line-height: .98; letter-spacing: -.04em; font-weight: 400; }
h1 em { color: var(--gold-bright); font-weight: 400; }
.lead { max-width: 620px; margin-bottom: 0; color: var(--muted); font-size: 17px; line-height: 1.7; }
h2 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: 31px; font-weight: 400; letter-spacing: -.02em; }

.calculator-card { padding: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-xl); background: linear-gradient(145deg, rgba(24,28,36,.96), rgba(15,18,24,.98)); box-shadow: var(--shadow); }
.card-heading, .section-heading-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.section-kicker { margin-bottom: 10px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); transition: .2s ease; }
.icon-button:hover { border-color: var(--gold); color: var(--gold); transform: rotate(25deg); }
.icon-button:disabled { opacity: .45; cursor: wait; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.metal-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 34px 0; padding: 7px; border: 1px solid var(--line); border-radius: 17px; background: rgba(0,0,0,.15); }
.metal-option { min-height: 74px; display: flex; align-items: center; gap: 14px; padding: 12px 18px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--muted); text-align: left; transition: .2s ease; }
.metal-option:hover { color: var(--text); background: rgba(255,255,255,.025); }
.metal-option.active { border-color: rgba(217,184,109,.28); background: var(--gold-soft); color: var(--text); box-shadow: inset 0 0 20px rgba(217,184,109,.025); }
.metal-option strong, .metal-option small { display: block; }
.metal-option strong { margin-bottom: 4px; font-size: 14px; }
.metal-option small { font-size: 10px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.metal-gem { display: block; width: 23px; height: 23px; flex: 0 0 23px; clip-path: polygon(50% 0, 91% 25%, 100% 70%, 50% 100%, 0 70%, 9% 25%); }
.gold-gem { background: linear-gradient(135deg, #f1d98d 8%, #8c6825 52%, #f5dfa1 100%); }
.silver-gem { background: linear-gradient(135deg, #f3f6f8 5%, #78808a 50%, #dce2e7 100%); }
.platinum-gem { background: linear-gradient(135deg, #e7eff0 5%, #758c8e 48%, #c6d6d6 100%); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: block; }
.field-label { display: block; margin: 0 0 10px 3px; color: #c8c8c9; font-size: 12px; font-weight: 650; }
.input-wrap, .select-wrap { min-height: 62px; display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(255,255,255,.025); transition: .18s ease; }
.input-wrap:focus-within, .select-wrap:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input, select { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
input { padding: 0 6px 0 18px; font-size: 21px; font-weight: 600; }
.input-unit { padding-right: 18px; color: var(--muted); font-size: 14px; }
select { height: 60px; appearance: none; padding: 0 50px 0 18px; font-size: 15px; font-weight: 570; }
select option { background: #171a20; color: var(--text); }
.select-wrap { position: relative; }
.select-wrap svg { position: absolute; right: 17px; width: 18px; pointer-events: none; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.field > small { display: block; min-height: 17px; margin: 8px 0 0 3px; color: #747780; font-size: 10px; }

.result-panel { margin-top: 30px; padding: 29px 30px 0; border: 1px solid rgba(217,184,109,.22); border-radius: var(--radius-lg); background: linear-gradient(135deg, rgba(217,184,109,.105), rgba(217,184,109,.025)); overflow: hidden; }
.result-topline { display: flex; justify-content: space-between; align-items: center; color: #d0c7b4; font-size: 11px; letter-spacing: .04em; }
.live-badge { display: flex; align-items: center; gap: 6px; color: var(--green); font-size: 9px; font-weight: 750; letter-spacing: .12em; }
.live-badge i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.result-main { min-height: 122px; display: flex; align-items: baseline; gap: 12px; padding: 18px 0 24px; }
.result-main strong { font-family: Georgia, "Times New Roman", serif; font-size: clamp(50px, 7vw, 74px); font-weight: 400; letter-spacing: -.035em; color: var(--gold-bright); }
.result-main > span { color: var(--gold); font-size: 14px; font-weight: 700; letter-spacing: .12em; }
.result-currencies { display: grid; grid-template-columns: 1fr 1fr; margin: 0 -30px; border-top: 1px solid rgba(217,184,109,.14); }
.result-currencies > div { padding: 17px 30px 18px; }
.result-currencies > div + div { border-left: 1px solid rgba(217,184,109,.14); }
.result-currencies span, .result-currencies strong { display: block; }
.result-currencies span { margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.result-currencies strong { color: #ddd7c9; font-size: 17px; font-weight: 650; }
.result-breakdown { display: grid; grid-template-columns: 1fr 1fr; margin: 0 -30px; border-top: 1px solid rgba(217,184,109,.14); }
.result-breakdown > div { padding: 20px 30px 22px; }
.result-breakdown > div + div { border-left: 1px solid rgba(217,184,109,.14); }
.result-breakdown span, .result-breakdown strong { display: block; }
.result-breakdown span { margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.result-breakdown strong { font-size: 16px; }
.quotes-section { padding-top: 72px; }
.updated-at { color: #c4c5ca; font-size: 14px; font-weight: 600; }
.update-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; text-align: right; }
.refresh-schedule { color: #686b73; font-size: 9px; }
.quotes-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 27px; }
.quote-card { min-height: 152px; padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.02); transition: transform .2s ease, border-color .2s ease; }
.quote-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.quote-icon { height: 34px; display: flex; align-items: center; }
.quote-card span, .quote-card strong, .quote-card small { display: block; }
.quote-card #fxPairLabel { white-space: nowrap; }
.quote-card > div:last-child > span { margin-top: 13px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.quote-card strong { margin: 7px 0 2px; font-size: 20px; font-weight: 600; }
.quote-card .quote-local { margin-bottom: 7px; color: #c9cbd0; font-size: 13px; font-weight: 600; }
.quote-card small { color: #6f727a; font-size: 9px; }
.usd-icon { color: #afc9a8; font-family: Georgia, serif; font-size: 27px; }

footer { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 45px; padding: 36px 0 calc(40px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: #6e7178; font-size: 9px; line-height: 1.6; }
.footer-brand span, .footer-brand small { display: block; }
.footer-brand span { color: #bdb9ae; font-weight: 750; letter-spacing: .2em; }
.footer-brand small { margin-top: 4px; }
footer p { margin: 0; max-width: 540px; }
.source-links { white-space: nowrap; }
.source-links a { text-underline-offset: 3px; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); transform: translate(-50%, 20px); padding: 12px 18px; border: 1px solid var(--line-strong); border-radius: 12px; background: #20242c; color: var(--text); box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .quotes-grid { grid-template-columns: 1fr 1fr; }
  footer { grid-template-columns: 1fr 1fr; }
  footer p { grid-column: 1 / -1; grid-row: 2; }
  .source-links { justify-self: end; }
}
@media (max-width: 620px) {
  .app-shell { padding-left: calc(18px + env(safe-area-inset-left)); padding-right: calc(18px + env(safe-area-inset-right)); }
  main { padding-top: 32px; }
  .topbar { min-height: 72px; }
  .market-state #statusText { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  h1 { font-size: clamp(40px, 12vw, 57px); }
  .lead { font-size: 15px; line-height: 1.65; }
  .calculator-card { padding: 24px 17px; border-radius: 22px; }
  .metal-switch { gap: 4px; margin: 27px 0; padding: 5px; }
  .metal-option { min-height: 69px; justify-content: center; gap: 8px; padding: 10px 7px; }
  .metal-option .metal-gem { width: 18px; height: 18px; flex-basis: 18px; }
  .metal-option strong { font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 16px; }
  .result-panel { padding: 24px 21px 0; }
  .result-main { min-height: 105px; }
  .result-main strong { font-size: clamp(46px, 14vw, 64px); }
  .result-currencies { margin: 0 -21px; }
  .result-currencies > div { padding: 16px 21px 17px; }
  .result-currencies strong { font-size: 15px; white-space: nowrap; }
  .result-breakdown { margin: 0 -21px; }
  .result-breakdown > div { padding: 18px 21px 20px; }
  .quotes-section { padding-top: 56px; }
  .quotes-section .section-heading-row { flex-direction: column; align-items: flex-start; gap: 13px; }
  .update-meta { max-width: none; align-items: flex-start; text-align: left; }
  .updated-at { font-size: 11px; font-weight: 500; line-height: 1.35; }
  .quotes-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 20px; }
  .quote-card { min-height: 0; display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 14px; padding: 17px 18px; border-radius: 15px; }
  .quote-icon { width: 30px; height: auto; justify-content: center; }
  .quote-card > div:last-child { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 12px; }
  .quote-card > div:last-child > span { grid-column: 1 / -1; margin-top: 0; margin-bottom: 7px; }
  .quote-card > div:last-child > span:first-child { white-space: nowrap; }
  .quote-card strong { grid-column: 1; margin: 0; font-size: 17px; white-space: nowrap; }
  .quote-card .quote-local { grid-column: 2; margin: 0; font-size: 12px; white-space: nowrap; text-align: right; }
  .quote-card small:last-child { grid-column: 1 / -1; margin-top: 5px; }
  .quote-usd strong { grid-column: 1 / -1; }
  footer { gap: 22px; }
}
@media (max-width: 390px) {
  .metal-option { flex-direction: column; }
  .metal-option small { display: none; }
  footer { grid-template-columns: 1fr; }
  footer p, .source-links { grid-column: 1; grid-row: auto; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
