:root {
  color-scheme: dark;
  --bg: #080b1b;
  --border: #293148;
  --cyan: #35f2d7;
  --purple: #a890ff;
  --text: #f3f4ff;
  --muted: #a6b0ce;
  --error: #ffb3c4;
  font-family: 'Segoe UI Variable', 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, p, ul { margin: 0; }
input, select, button { font: inherit; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.cosmos {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse at 90% 0%, #6436ae2e, transparent 40%),
    radial-gradient(ellipse at 0% 24%, #144e8326, transparent 40%);
}

.cosmos::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: .23;
  background-image: radial-gradient(1px 1px at 15% 20%, #ddd 98%, transparent),
    radial-gradient(1px 1px at 80% 63%, #9d83ff 98%, transparent),
    radial-gradient(1px 1px at 55% 40%, #84e8ff 98%, transparent);
  background-size: 160px 210px, 193px 280px, 277px 153px;
}

.cosmos i {
  position: absolute;
  border: 1px solid #8e5fff38;
  border-radius: 50%;
  box-shadow: 0 0 80px #7955ff18, inset 0 0 80px #7955ff15;
}

.cosmos i:first-child { top: -420px; right: -200px; width: 740px; height: 740px; }
.cosmos i:last-child { bottom: -360px; left: -215px; width: 845px; height: 500px; transform: rotate(20deg); }

.shell { width: min(100% - 56px, 1120px); margin-inline: auto; }
.topbar { min-height: 94px; display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid #ffffff14; }
.topbar h1 { font-size: clamp(1.55rem, 4.5vw, 2.375rem); line-height: 1.13; font-weight: 700; letter-spacing: -.045em; }
.topbar h1 span { color: #b7c0df; font-weight: 400; }
.planet { position: relative; flex: 0 0 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 25% 20%, #44ffff, #6058e03b 64%); box-shadow: 0 0 15px #655dff70; }
.planet::before, .planet::after { content: ''; position: absolute; inset: 10px 5px; border: 1px solid #83f9ee; border-radius: 50%; transform: rotate(-36deg); }
.planet::after { transform: rotate(44deg); }
.planet i { position: absolute; inset: 17px; border-radius: 50%; background: #b4fff3; box-shadow: 0 0 8px #83f9ee; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 22px 0; }
.intro p { align-self: center; color: var(--muted); }
.date-controls { flex: 0 0 auto; }
.date-controls label, .field, .result label { color: #c4cce1; font-size: .875rem; }
.date-controls label { display: block; margin-bottom: 6px; }
.date-actions { display: flex; gap: 8px; }
.date-actions input { width: 148px; font-variant-numeric: tabular-nums; }

.panel { border: 1px solid var(--border); border-top-color: #414965; border-radius: 14px; background: linear-gradient(130deg, #171d35ed, #0e1428ed); box-shadow: 0 7px 30px #00000024; padding: 23px; }
.panel + .panel { margin-top: 18px; }
.section-head, .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h2 { font-size: 1.25rem; line-height: 1.25; font-weight: 650; letter-spacing: -.025em; }
.status-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; min-height: 22px; }
.status, .muted { color: var(--muted); font-size: .875rem; }
.status[data-state='error'], .input-error { color: var(--error); }
.text-button { border: 0; padding: 0; background: none; color: var(--cyan); cursor: pointer; font-size: .875rem; text-decoration: underline; }

.rate-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 0; list-style: none; }
.rate-card { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px; border: 1px solid #343d5b; border-radius: 10px; background: linear-gradient(130deg, #212844a1, #10172c 76%); }
.rate-identity { display: flex; align-items: center; gap: 10px; min-height: 35px; margin-bottom: 11px; }
.currency-mark { display: grid; place-items: center; min-width: 35px; height: 35px; border: 1px solid #a890ff45; border-radius: 8px; background: #a890ff16; color: #d0c2ff; font-size: 1.125rem; }
.currency-mark:empty { display: none; }
.rate-currency { min-width: 0; }
.rate-code, .rate-name { display: block; }
.rate-code { font-size: .875rem; font-weight: 700; letter-spacing: .055em; }
.rate-name { color: var(--muted); font-size: .8125rem; overflow-wrap: anywhere; }
.rate-value { display: block; margin-top: auto; color: var(--cyan); font-size: clamp(1.25rem, 2.6vw, 1.65rem); font-weight: 640; letter-spacing: -.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.rate-nominal { color: var(--muted); font-size: .8125rem; }
.missing { color: var(--muted); }

input:not([type='checkbox']), select {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  border: 1px solid #3b4766;
  border-radius: 8px;
  padding: 8px 11px;
  background: #0c1228;
  color: var(--text);
}

input#rate-date { width: 148px; }
input:hover:not([type='checkbox']), select:hover:not(:disabled) { border-color: #627197; }
select { appearance: none; padding-right: 31px; cursor: pointer; text-overflow: ellipsis; background-image: linear-gradient(45deg, transparent 50%, #afbad7 50%), linear-gradient(135deg, #afbad7 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px; background-repeat: no-repeat; }

.button { display: inline-grid; place-items: center; min-height: 39px; padding: 7px 13px; border: 1px solid #68518f; border-radius: 8px; background: #7252a223; color: #e0ccff; font-size: .875rem; white-space: nowrap; cursor: pointer; }
.button:hover:not(:disabled) { border-color: var(--purple); background-color: #7252a244; }
button:disabled, select:disabled { cursor: default; opacity: .62; }
.primary { background: var(--cyan); border-color: #77ffe6; color: #082522; font-weight: 700; }
.primary:hover:not(:disabled) { background: #86ffe9; border-color: #a9ffee; }

.converter-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; margin-top: 17px; }
.converter-controls { display: grid; align-content: start; gap: 12px; min-width: 0; }
.field { display: grid; gap: 6px; min-width: 0; }
input#amount { font-size: 1.125rem; font-weight: 550; font-variant-numeric: tabular-nums; }
input[aria-invalid='true'] { border-color: var(--error); }
.input-error { font-size: .875rem; }
.currency-pair { display: grid; grid-template-columns: minmax(0, 1fr) 43px minmax(0, 1fr); align-items: end; gap: 9px; }
.swap { width: 43px; height: 43px; padding: 0; font-size: 1.3rem; }
.result { display: flex; flex-direction: column; justify-content: center; min-height: 140px; min-width: 0; padding: 15px 20px; border-radius: 10px; border: 1px solid #35f2d766; background: radial-gradient(ellipse at 95% 10%, #35f2d721, transparent 68%), linear-gradient(110deg, #16333baf, #111b30); box-shadow: inset 0 1px 0 #35f2d72e, 0 0 22px #35f2d708; }
.result output { color: var(--cyan); font-size: clamp(1.875rem, 4.5vw, 2.65rem); font-weight: 700; line-height: 1.13; letter-spacing: -.04em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; margin: 6px 0; }
.result-rate { color: #b9c8e1; font-size: .875rem; overflow-wrap: anywhere; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; margin-top: 25px; padding: 14px 0 24px; border-top: 1px solid #ffffff14; color: var(--muted); font-size: .8125rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }

dialog { width: min(480px, calc(100% - 28px)); max-height: 90dvh; padding: 20px; border: 1px solid #665386; border-radius: 14px; background: #151b33; color: var(--text); box-shadow: 0 20px 90px #000b; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #030717c9; backdrop-filter: blur(5px); }
.close { width: 39px; padding: 0; font-size: 1.45rem; line-height: 1; }
.search { margin: 13px 0 9px; flex-shrink: 0; }
.currency-options { min-height: 0; max-height: 43vh; overflow-y: auto; overscroll-behavior: contain; padding: 4px; margin-inline: -4px; }
.currency-option { display: grid; grid-template-columns: 19px 40px minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px; border-radius: 7px; font-size: .875rem; cursor: pointer; }
.currency-option:hover, .currency-option:focus-within { background: #a890ff18; }
.currency-option input { margin: 0; width: 16px; height: 16px; accent-color: var(--cyan); }
.currency-option span { color: var(--muted); }
.dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--border); }

@media (max-width: 780px) {
  .shell { width: calc(100% - 40px); }
  .intro { align-items: start; flex-direction: column; gap: 13px; }
  .intro p { align-self: start; }
  .rate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .converter-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}

@media (max-width: 460px) {
  .shell { width: calc(100% - 28px); }
  .topbar { min-height: 70px; gap: 10px; }
  .planet { flex-basis: 34px; height: 34px; }
  .planet i { inset: 14px; }
  .planet::before, .planet::after { inset: 8px 4px; }
  .panel { padding: 15px; }
  .section-head { flex-wrap: wrap; }
  .rate-grid { gap: 8px; }
  .rate-card { padding: 10px; }
  .rate-identity { gap: 7px; }
  .currency-mark { min-width: 26px; height: 26px; }
  .result { min-height: 117px; }
}
