:root {
  --background: oklch(14.5% 0.01 240);
  --foreground: oklch(96% 0.01 240);
  --card: oklch(18% 0.012 240);
  --secondary: oklch(22% 0.012 240);
  --muted: oklch(65% 0.02 240);
  --border: oklch(28% 0.015 240);
  --grid: oklch(24% 0.012 240);
  --primary: oklch(78% 0.19 60);
  --primary-ink: oklch(12% 0.01 240);
  --danger: oklch(68% 0.2 25);
  --font-sans: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.shell { width: min(100% - 48px, 1280px); margin-inline: auto; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 88%, transparent);
  backdrop-filter: blur(12px);
}
.header-inner { height: 64px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font: 700 14px var(--font-mono); }
.brand > span:last-child span { color: var(--primary); }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--primary); color: var(--primary); }
.header-status, .footer-inner { color: var(--muted); font: 500 10px var(--font-mono); text-transform: uppercase; letter-spacing: .1em; }
.header-status, .footer-inner span:last-child { display: flex; align-items: center; gap: 8px; }
.status-dot { display: inline-block; width: 6px; height: 6px; background: var(--primary); animation: blink 1.4s step-end infinite; }

.intro { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr); gap: 72px; align-items: end; padding-block: 76px; }
.intro::before, .rates-section::before {
  content: ""; position: fixed; inset: 64px 0 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px; opacity: .16;
}
.eyebrow { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; color: var(--primary); font: 500 11px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
.eyebrow span { width: 28px; height: 1px; background: var(--primary); }
.eyebrow b { font-weight: 400; animation: blink 1s step-end infinite; }
h1, h2 { margin: 0; font-family: var(--font-mono); text-transform: uppercase; }
h1 { max-width: 760px; font-size: clamp(46px, 7vw, 86px); line-height: .98; }
h1 em { color: var(--primary); font-style: normal; }
h2 { font-size: clamp(28px, 4vw, 46px); line-height: 1.05; }
.intro-copy { max-width: 650px; margin: 26px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }

.date-panel, .result-panel { position: relative; border: 1px solid var(--border); background: var(--card); padding: 26px; }
.frame-corners::before, .frame-corners::after { content: ""; position: absolute; width: 14px; height: 14px; border-color: var(--primary); }
.frame-corners::before { top: 7px; left: 7px; border-top: 2px solid var(--primary); border-left: 2px solid var(--primary); }
.frame-corners::after { right: 7px; bottom: 7px; border-right: 2px solid var(--primary); border-bottom: 2px solid var(--primary); }
.panel-code { display: flex; justify-content: space-between; margin-bottom: 28px; color: var(--muted); font: 500 10px var(--font-mono); letter-spacing: .08em; }
.connection { display: flex; align-items: center; gap: 7px; }
.connection i { width: 6px; height: 6px; background: var(--primary); }
.connection.error i { background: var(--danger); }
.date-panel label, .field label { display: block; margin-bottom: 9px; color: var(--muted); font: 500 10px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
.date-control { display: grid; grid-template-columns: 1fr auto; }
input, select { width: 100%; min-width: 0; height: 52px; border: 1px solid var(--border); background: var(--background); color: var(--foreground); outline: none; font-family: var(--font-mono); border-radius: 0; }
input { padding: 0 15px; }
select { padding: 0 42px 0 15px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--primary) 50%), linear-gradient(135deg, var(--primary) 50%, transparent 50%); background-position: calc(100% - 18px) 22px, calc(100% - 12px) 22px; background-size: 6px 6px; background-repeat: no-repeat; }
input:focus, select:focus { border-color: var(--primary); }
input[type="date"] { color-scheme: dark; }
.date-control button { border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); padding: 0 16px; font: 700 11px var(--font-mono); text-transform: uppercase; }
.date-note { min-height: 20px; margin: 14px 0 0; color: var(--muted); font-size: 12px; }

.section-band { border-block: 1px solid var(--border); background: color-mix(in oklab, var(--background) 94%, transparent); padding-block: 68px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.section-heading .eyebrow { margin-bottom: 12px; }
.outline-button, .text-button, .primary-button { min-height: 42px; padding: 0 16px; border: 1px solid var(--border); background: transparent; color: var(--foreground); font: 700 11px var(--font-mono); text-transform: uppercase; letter-spacing: .05em; }
.outline-button:hover, .text-button:hover { border-color: var(--primary); color: var(--primary); }
.primary-button { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.rates-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); }
.rate-card { min-width: 0; min-height: 210px; padding: 24px; background: var(--background); border-right: 1px solid var(--border); }
.rate-card:nth-child(4n) { border-right: 0; }
.rate-card:nth-child(n + 5) { border-top: 1px solid var(--border); }
.rate-top { display: flex; justify-content: space-between; gap: 16px; }
.currency-code { color: var(--primary); font: 700 28px var(--font-mono); }
.rate-change { height: fit-content; padding: 5px 7px; border: 1px solid var(--border); color: var(--muted); font: 600 10px var(--font-mono); }
.rate-change.up { color: var(--primary); border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); }
.rate-change.down { color: oklch(72% .15 210); }
.currency-name { min-height: 42px; margin: 10px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.rate-value { margin: 0; font: 700 25px var(--font-mono); }
.rate-unit { margin: 7px 0 0; color: var(--muted); font: 400 10px var(--font-mono); text-transform: uppercase; }
.skeleton { height: 210px; background: linear-gradient(90deg, var(--background), var(--card), var(--background)); background-size: 220% 100%; border-right: 1px solid var(--border); animation: loading 1.3s linear infinite; }

.converter-section { padding-block: 76px 90px; }
.section-aside { margin: 0 0 5px; color: var(--muted); font: 400 11px var(--font-mono); text-transform: uppercase; }
.converter-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(330px, .75fr); border: 1px solid var(--border); }
.converter-form { display: grid; grid-template-columns: 1.15fr 1fr 52px 1fr; align-items: end; gap: 16px; padding: 30px; border-right: 1px solid var(--border); background: var(--background); }
.swap-button { width: 52px; height: 52px; border: 1px solid var(--border); background: var(--secondary); color: var(--primary); font: 24px var(--font-mono); }
.swap-button:hover { border-color: var(--primary); }
.result-panel { display: flex; min-height: 184px; flex-direction: column; justify-content: center; border: 0; }
.result-label { margin: 0 0 12px; color: var(--muted); font: 500 10px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
.result-value { overflow-wrap: anywhere; color: var(--primary); font: 700 clamp(28px, 4vw, 50px) var(--font-mono); line-height: 1.1; }
.result-formula { margin: 13px 0 0; color: var(--muted); font: 400 11px var(--font-mono); line-height: 1.5; }

footer { border-top: 1px solid var(--border); }
.footer-inner { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }

dialog { width: min(720px, calc(100% - 32px)); max-height: min(760px, calc(100vh - 32px)); padding: 0; border: 1px solid var(--border); background: var(--card); color: var(--foreground); }
dialog::backdrop { background: rgb(0 0 0 / .72); backdrop-filter: blur(4px); }
.dialog-panel { padding: 28px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-head h2 { font-size: 28px; }
.icon-button { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border: 1px solid var(--border); background: transparent; color: var(--foreground); font: 24px var(--font-mono); }
.icon-button:hover { border-color: var(--primary); color: var(--primary); }
.dialog-copy { margin: 18px 0 22px; color: var(--muted); font-size: 13px; }
.currency-checklist { display: grid; max-height: 390px; grid-template-columns: repeat(3, 1fr); overflow: auto; border: 1px solid var(--border); }
.currency-option { display: flex; min-width: 0; align-items: center; gap: 10px; padding: 13px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; }
.currency-option:nth-child(3n) { border-right: 0; }
.currency-option:hover { background: var(--secondary); }
.currency-option input { width: 15px; height: 15px; padding: 0; accent-color: var(--primary); }
.currency-option b { color: var(--primary); font: 600 12px var(--font-mono); }
.currency-option small { min-width: 0; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.dialog-actions { display: flex; justify-content: space-between; gap: 16px; margin-top: 22px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 380px; padding: 14px 16px; border: 1px solid var(--primary); background: var(--card); color: var(--foreground); font: 500 12px/1.5 var(--font-mono); transform: translateY(18px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
.error-state { grid-column: 1 / -1; padding: 34px; border-left: 3px solid var(--danger); background: var(--card); }
.error-state strong { display: block; margin-bottom: 8px; font-family: var(--font-mono); color: var(--danger); }
.error-state p { margin: 0; color: var(--muted); line-height: 1.55; }

@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .2; } }
@keyframes loading { to { background-position: -220% 0; } }

@media (max-width: 980px) {
  .intro { grid-template-columns: 1fr; gap: 42px; }
  .rates-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rate-card:nth-child(2n) { border-right: 0; }
  .rate-card:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .converter-grid { grid-template-columns: 1fr; }
  .converter-form { border-right: 0; border-bottom: 1px solid var(--border); }
  .currency-checklist { grid-template-columns: repeat(2, 1fr); }
  .currency-option:nth-child(3n) { border-right: 1px solid var(--border); }
  .currency-option:nth-child(2n) { border-right: 0; }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 30px, 1280px); }
  .header-status { display: none; }
  .intro { padding-block: 52px; }
  h1 { font-size: clamp(38px, 12vw, 56px); }
  .date-panel { padding: 22px; }
  .section-band, .converter-section { padding-block: 52px; }
  .section-heading { align-items: start; }
  .section-aside { display: none; }
  .rates-grid { grid-template-columns: 1fr; }
  .rate-card, .rate-card:nth-child(2n), .rate-card:nth-child(4n) { min-height: 184px; border-right: 0; border-top: 1px solid var(--border); }
  .rate-card:first-child { border-top: 0; }
  .converter-form { grid-template-columns: 1fr 52px; gap: 14px; }
  .amount-field { grid-column: 1 / -1; }
  .field:nth-of-type(2) { grid-column: 1; }
  .swap-button { grid-column: 2; grid-row: 2; }
  .field:nth-of-type(3) { grid-column: 1; grid-row: 3; }
  .result-panel { min-height: 160px; }
  .currency-checklist { grid-template-columns: 1fr; }
  .currency-option, .currency-option:nth-child(2n), .currency-option:nth-child(3n) { border-right: 0; }
  .footer-inner { align-items: start; flex-direction: column; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
