:root {
  color-scheme: dark;
  --bg: #101719;
  --surface: #171f22;
  --surface-2: #1d292b;
  --line: #2d3c3d;
  --text: #f0f6f3;
  --muted: #a7b9b5;
  --accent: #9ef6c8;
  --accent-deep: #173d30;
  --warn: #f9ce8a;
  --radius: 24px;
  --font: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font: 1rem/1.5 var(--font); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:not(:disabled), a { touch-action: manipulation; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, h1, h2, h3, p, ol { margin: 0; }
[hidden] { display: none !important; }
.shell { width: min(100% - 64px, 1112px); margin-inline: auto; }
.top { border-bottom: 1px solid var(--line); }
.bar { min-height: 74px; display: flex; gap: 24px; align-items: center; justify-content: space-between; padding-top: env(safe-area-inset-top); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 750; letter-spacing: -.04em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 35px; aspect-ratio: 1; border-radius: 11px; color: #122c23; background: var(--accent); font-size: 1.48rem; line-height: 1; }
.brand-accent { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { border-radius: 11px; min-height: 42px; display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; font-size: .9rem; font-weight: 650; color: var(--muted); }
.nav a[aria-current], .nav a:hover { background: #223430; color: var(--accent); }
.nav-icon { font-size: 1.12rem; font-weight: 600; line-height: 1; }
.header-actions { display: flex; gap: 8px; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--line); font-size: 1.4rem; line-height: 1; }
.icon-button:hover { border-color: #638377; }
#refresh:disabled { color: var(--accent); }
.main { padding-top: 37px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 20px; }
.dateline { margin-bottom: 4px; color: var(--muted); font-size: .9rem; }
h1 { font-size: clamp(2.18rem, 5.4vw, 3.6rem); line-height: 1.04; letter-spacing: -.065em; font-weight: 770; }
h2 { font-size: 1.3rem; letter-spacing: -.035em; line-height: 1.2; }
.connection { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: .85rem; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.connection[data-state="live"] .status-dot { background: var(--accent); }
#today-view, .rates-details, .footer { width: min(100%, 720px); margin-inline: auto; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 22px; }
.panel-heading { min-height: 37px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.converter { background: radial-gradient(ellipse at 91% -14%, #26413a 0%, transparent 60%), var(--surface); }
.button { min-height: 37px; padding: 5px 13px; border-radius: 10px; border: 1px solid var(--line); font-size: .86rem; font-weight: 690; }
.subtle { background: #23322f; color: var(--text); }
.subtle:hover:not(:disabled) { background: #2c4037; }
.primary { background: var(--accent); color: #142c24; border-color: var(--accent); }
.quick-rates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.quick-rates button { min-height: 44px; padding: 5px 4px; border: 1px solid var(--line); border-radius: 9px; background: #202d2b; font-size: .88rem; font-weight: 700; }
.quick-rates button:hover, .quick-rates button[aria-pressed="true"] { color: var(--accent); border-color: #679d81; background: #2a483b; }
.quote-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: center; margin: 9px 0 10px; }
.next-rate { background: #203631; color: var(--accent); border-color: #416353; min-height: 40px; }
.next-rate:hover { background: #2a483b; }
.quote-controls > div { grid-column: 1 / -1; }
.quote-controls > div:empty { display: none; }
.amount-row { display: flex; justify-content: space-between; align-items: center; gap: 11px; background: #111b1c; padding: 10px 11px 10px 15px; border: 1px solid #354545; border-radius: 15px; min-height: 79px; }
.amount-row:focus-within { border-color: #80cba9; }
.amount-output { background: #182c25; border-color: #365344; }
.amount-label { display: grid; align-content: center; flex: 1; min-width: 0; font-size: .88rem; color: var(--muted); }
.amount-label input { width: 100%; padding: 0; color: var(--text); background: transparent; border: 0; font-family: var(--mono); font-size: clamp(1.32rem, 4vw, 2.05rem); font-weight: 670; letter-spacing: -.065em; line-height: 1.18; outline-offset: 1px; border-radius: 3px; }
.amount-output input { color: var(--accent); }
.amount-label input::placeholder { color: #9ab3a8; }
.currency-option { display: flex; align-items: center; gap: 7px; padding: 6px 8px; min-height: 44px; border-radius: 12px; border: 1px solid #3b504c; background: #23342f; }
.currency-option:hover { border-color: var(--accent); }
.currency-option strong { font-size: .86rem; }
.chevron { width: 6px; height: 6px; transform: rotate(45deg); border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); margin: -3px 4px 0 0; }
.currency-icon { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 12px; background: #283d38; color: var(--accent); font-weight: 780; font-size: 1.05rem; line-height: 1; }
.currency-option .currency-icon { width: 27px; height: 27px; border-radius: 8px; font-size: .94rem; }
.currency-icon[data-coin="usd"] { background: #244440; color: #b3f7d6; }
.currency-icon[data-coin="eur"] { background: #313d63; color: #d6dfff; }
.currency-icon[data-coin="binance"] { background: #403720; color: #ffde75; }
.currency-icon[data-coin="okx"] { background: #36383d; color: #f2f5fc; }
.currency-icon[data-coin="airtm"] { background: #253c58; color: #a3d1ff; }
.switch-row { display: flex; align-items: center; justify-content: center; gap: 10px; height: 36px; }
.switch-row div { height: 1px; background: var(--line); flex: 1; }
.switch { border: 1px solid #4f7463; background: #26463a; color: var(--accent); border-radius: 10px; width: 38px; height: 34px; font-size: 1.2rem; line-height: 1; z-index: 1; }
.switch:hover { background: #315747; }
.presets { display: grid; gap: 7px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 11px; }
.presets button { display: grid; gap: 2px; text-align: left; background: #212f2d; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; min-height: 47px; font-size: .86rem; font-variant-numeric: tabular-nums; }
.presets button span { color: var(--muted); }
.presets button strong { overflow-wrap: anywhere; font-weight: 680; }
.presets button:hover, .presets button[aria-pressed="true"] { color: var(--accent); border-color: #5d9278; background: #253e34; }
.rate-note { text-align: right; overflow-wrap: anywhere; color: var(--muted); font-size: .86rem; }
.rates-details { padding: 0; margin-top: 13px; }
.rates-details summary { list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 50px; cursor: pointer; padding: 8px 17px; border-radius: var(--radius); font-weight: 720; }
.rates-details summary::-webkit-details-marker { display: none; }
.rates-details summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); margin: -4px 3px 0 0; }
.rates-details[open] summary::after { transform: rotate(225deg); margin-top: 4px; }
.rates-details[open] summary { border-bottom: 1px solid var(--line); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.rates-content { padding: 12px; display: grid; gap: 14px; }
.rates-content h2 { margin-bottom: 8px; font-size: 1.03rem; }
.tag { display: inline-flex; align-items: center; color: var(--accent); font-size: .77rem; font-weight: 730; border-radius: 7px; padding: 3px 7px; background: #253e34; letter-spacing: .025em; white-space: nowrap; }
.official-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.official-item { background: #141d1f; border: 1px solid #293b3a; border-radius: 14px; overflow: hidden; }
.official-tap { width: 100%; border: 0; display: flex; align-items: center; text-align: left; gap: 11px; background: transparent; padding: 12px; }
.official-tap:hover { background: #22312e; }
.quote-name { flex: 1; min-width: 0; font-weight: 700; line-height: 1.2; }
.quote-name small { display: block; font-size: .83rem; color: var(--muted); margin-top: 5px; font-weight: 450; }
.quote-value { font: 700 clamp(1.12rem, 3.3vw, 1.49rem)/1.15 var(--mono); letter-spacing: -.065em; white-space: nowrap; text-align: right; }
.upcoming { border-top: 1px solid #293b3a; padding: 7px 12px; color: #bbc9c2; font-size: .82rem; display: flex; justify-content: space-between; gap: 8px; }
.upcoming strong { color: var(--accent); font-weight: 650; }
.market-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.market-card { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 14px; min-width: 0; }
.market-heading { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.market-heading .quote-name { font-size: .95rem; }
.market-heading .quote-name small { margin-top: 3px; }
.market-heading > .quote-name > a:hover { color: var(--accent); }
.market-card .currency-icon { width: 31px; height: 31px; border-radius: 9px; font-size: .94rem; }
.market-values { display: flex; gap: 7px; }
.market-values button { min-width: 0; flex: 1; min-height: 53px; text-align: left; border-radius: 9px; background: #202b2b; border: 1px solid #33423e; padding: 5px 8px; }
.market-values button:hover:not(:disabled), .market-values button[aria-pressed="true"] { background: #253f34; border-color: #639879; }
.market-values button span, .market-meta { color: var(--muted); font-size: .79rem; display: block; }
.market-values button strong { font: 690 1rem/1.2 var(--mono); letter-spacing: -.05em; }
.market-meta { margin-top: 7px; line-height: 1.35; }
.market-meta a, .market-meta button { color: var(--accent); font-size: inherit; text-decoration: underline; background: none; border: 0; padding: 6px 0; }
.market-meta a:hover, .market-meta button:hover { color: white; }
.side-picker { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .82rem; }
.side-picker + .side-picker { margin-top: 5px; }
.side-picker div { display: inline-flex; gap: 4px; }
.side-picker button { border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; background: #23302d; }
.side-picker button[aria-pressed="true"] { color: var(--accent); border-color: #639879; }
.footer { font-size: .82rem; color: var(--muted); display: flex; justify-content: space-between; gap: 16px; margin-block: 21px 20px; padding: 12px 0 0; border-top: 1px solid var(--line); }
.history select { max-width: 53%; background: #23302d; color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; }
.empty { padding: 22px 0; color: var(--muted); }
#history-chart { width: 100%; height: 210px; display: block; }
.history-rows { padding: 0; list-style: none; }
.history-rows li { padding: 8px 3px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.history-rows li span { color: var(--muted); font-size: .88rem; }
dialog { width: min(100% - 28px, 460px); max-height: min(90dvh, 630px); padding: 18px; color: var(--text); border: 1px solid #425553; border-radius: 20px; background: #1b2827; box-shadow: 0 28px 100px #000a; }
dialog::backdrop { background: #0a1514bc; backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
dialog p { margin: 12px 0; color: var(--muted); }
.currency-list { display: grid; gap: 6px; }
.currency-list button { display: flex; align-items: center; gap: 10px; padding: 7px 10px; min-height: 49px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; text-align: left; }
.currency-list button[aria-pressed="true"], .currency-list button:hover { border-color: #639879; background: #263d33; }
.currency-list button span:last-child { margin-left: auto; color: var(--muted); font-size: .82rem; }
.choice-list { display: grid; gap: 7px; }
.choice-rate { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 11px; min-height: 48px; background: #23302d; border: 1px solid #3b504c; border-radius: 11px; text-align: left; }
.choice-rate:hover:not(:disabled) { border-color: #639879; background: #263d33; }
.choice-rate strong { color: var(--accent); text-align: right; white-space: nowrap; }
.choice-rate small { color: var(--muted); display: block; font-size: .81rem; }
.manual-input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px; }
.dialog-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
.error { color: var(--warn); }
.toast { position: fixed; bottom: calc(17px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 5; padding: 9px 16px; max-width: calc(100% - 30px); border-radius: 12px; background: var(--accent); color: #142c24; font-weight: 690; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 720px) {
  .shell { width: min(100% - 28px, 540px); }
  .bar { min-height: 59px; }
  .nav { position: fixed; z-index: 4; inset: auto 0 0; justify-content: space-around; border-top: 1px solid var(--line); background: #111c1df7; padding: 5px 8px calc(5px + env(safe-area-inset-bottom)); }
  .nav a { flex: 1; flex-direction: column; justify-content: center; gap: 3px; padding: 4px 3px; font-size: .8rem; min-height: 47px; }
  .nav-icon { font-size: 1.12rem; }
  .main { padding-top: 15px; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .page-heading { flex-wrap: wrap; margin-bottom: 14px; gap: 9px; }
  .connection { font-size: .76rem; padding: 5px 8px; }
  .market-grid, .official-list { grid-template-columns: 1fr; gap: 9px; }
  .panel { padding: 15px; border-radius: 18px; }
  .amount-row { min-height: 69px; }
  .rates-details { padding: 0; }
  .footer { margin-top: 16px; font-size: .76rem; }
  .toast { bottom: calc(69px + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .shell { width: calc(100% - 22px); }
  .panel { padding: 12px; }
  .rates-details { padding: 0; }
  .quote-name { font-size: .94rem; }
  .quote-name small { font-size: .79rem; }
}
