@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jbmono-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jbmono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============ темы ============
   Каждая тема задаёт только переменные (и пару точечных правил внизу).
   Селектор [data-theme] без привязки к html позволяет рисовать превью темы внутри шторки. */

/* Графит: минимализм, тёмная (по умолчанию) */
:root, [data-theme="graphite"] {
  --bg: #0d0f0e;
  --bg-image: none;
  --surface: #151917;
  --surface-2: #1d221f;
  --surface-3: #262c28;
  --line: rgba(236, 239, 236, .07);
  --text: #ecefec;
  --muted: #7d8681;
  --accent: #6fcf9f;
  --accent-rgb: 111, 207, 159;
  --accent-ink: #07130d;
  --warn: #d6a652;
  --bad: #e2806a;
  --bad-rgb: 226, 128, 106;
  --r: 20px;
  --r-sm: 10px;
  --font: "Onest", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --vt-weight: 500;
  --vt-track: -.025em;
  --backdrop: rgba(4, 6, 5, .62);
  --sheet-bg: var(--surface);
  --blur: none;
  --edge: 0 0 0 0 transparent;
  --key-shadow: 0 0 0 0 transparent;
  --glow: 0 10px 28px -14px rgba(var(--accent-rgb), .45);
  --flag-ring: rgba(255, 255, 255, .1);
  --grain: .05;
  --name-case: none;
  --name-track: 0;
}

/* Светлая: воздушная */
[data-theme="light"] {
  --bg: #f2f4f2;
  --surface: #ffffff;
  --surface-2: #e9ece9;
  --surface-3: #dde1dd;
  --line: rgba(18, 20, 19, .09);
  --text: #121413;
  --muted: #6d7671;
  --accent: #17804f;
  --accent-rgb: 23, 128, 79;
  --accent-ink: #ffffff;
  --warn: #a8731a;
  --bad: #c4472f;
  --bad-rgb: 196, 71, 47;
  --r: 22px;
  --backdrop: rgba(20, 28, 24, .35);
  --key-shadow: 0 1px 0 rgba(18, 20, 19, .04), 0 8px 16px -12px rgba(18, 20, 19, .35);
  --glow: 0 12px 28px -16px rgba(var(--accent-rgb), .5);
  --flag-ring: rgba(0, 0, 0, .12);
  --grain: 0;
}

/* Терминал: технический, моноширинный, острые углы */
[data-theme="tech"] {
  --bg: #0e0e0c;
  --surface: transparent;
  --surface-2: rgba(235, 232, 223, .06);
  --surface-3: rgba(235, 232, 223, .14);
  --line: rgba(235, 232, 223, .26);
  --text: #ebe8df;
  --muted: #8c8a80;
  --accent: #f0b429;
  --accent-rgb: 240, 180, 41;
  --accent-ink: #141000;
  --warn: #d9772b;
  --bad: #e5533d;
  --bad-rgb: 229, 83, 61;
  --r: 0px;
  --r-sm: 0px;
  --font: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --vt-weight: 500;
  --vt-track: -.04em;
  --backdrop: rgba(0, 0, 0, .7);
  --sheet-bg: #151512;
  --toast-bg: #24241f;
  --glow: 0 0 0 0 transparent;
  --flag-ring: rgba(235, 232, 223, .35);
  --grain: .07;
  --name-case: uppercase;
  --name-track: .02em;
}

/* Стекло: тёмный градиент и полупрозрачные панели */
[data-theme="glass"] {
  --bg: #071014;
  --bg-image:
    radial-gradient(120% 70% at 88% -6%, rgba(56, 189, 205, .38), transparent 60%),
    radial-gradient(90% 60% at -12% 55%, rgba(52, 110, 230, .3), transparent 62%),
    radial-gradient(80% 50% at 60% 112%, rgba(40, 200, 170, .22), transparent 60%);
  --surface: rgba(255, 255, 255, .06);
  --surface-2: rgba(255, 255, 255, .09);
  --surface-3: rgba(255, 255, 255, .16);
  --line: rgba(255, 255, 255, .12);
  --text: #eef6f8;
  --muted: #8fa6ad;
  --accent: #7fd8e8;
  --accent-rgb: 127, 216, 232;
  --accent-ink: #04161a;
  --warn: #e0b45c;
  --bad: #f0907a;
  --bad-rgb: 240, 144, 122;
  --r: 26px;
  --r-sm: 12px;
  --backdrop: rgba(2, 8, 10, .55);
  --sheet-bg: rgba(14, 30, 36, .72);
  --blur: blur(22px) saturate(1.5);
  --edge: inset 0 1px 0 rgba(255, 255, 255, .18);
  --glow: 0 14px 34px -16px rgba(var(--accent-rgb), .55);
  --flag-ring: rgba(255, 255, 255, .22);
  --grain: .04;
}

@media (prefers-reduced-transparency: reduce) {
  [data-theme="glass"] {
    --blur: none;
    --surface: #15262c;
    --surface-2: #1b323a;
    --surface-3: #24414b;
    --sheet-bg: #12242a;
  }
}

/* ============ база ============ */
:root {
  --accent-soft: rgba(var(--accent-rgb), .1);
  --accent-line: rgba(var(--accent-rgb), .26);
  --ease: cubic-bezier(.2, .8, .2, 1);
  /* Нижний отступ под индикатор «домой». JS уменьшает его, если iOS уже отдал странице окно короче экрана */
  --inset-b: env(safe-area-inset-bottom);
}
[data-theme] {
  --accent-soft: rgba(var(--accent-rgb), .1);
  --accent-line: rgba(var(--accent-rgb), .26);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
body { background-image: var(--bg-image); background-attachment: fixed; }
html { transition: background-color .3s; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ic { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* лёгкое зерно, чтобы фон не был стерильно плоским */
.grain {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: 0;
  pointer-events: none;
  opacity: var(--grain);
  z-index: 100;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

html.short .grain { display: none; }

/* Статус-бар в PWA всегда с белым текстом, поэтому под ним на светлой теме нужна тёмная полоса */
[data-theme="light"] body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top);
  background: #121413;
  z-index: 101;
}

#app {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--inset-b) + 12px);
}

/* ---------- шапка ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 0 6px;
  margin-bottom: 8px;
}
.title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
  font-size: 13.5px;
  line-height: 1.2;
  color: var(--accent);
  transition: color .2s;
}
.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px 1px currentColor;
}
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }
.status.busy { color: var(--muted); }
.status.busy::before { box-shadow: none; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.actions { display: flex; gap: 0; }
.icon-btn {
  width: 42px; height: 44px;
  display: grid; place-items: center;
  color: var(--muted);
  border-radius: 14px;
  transition: color .2s, background .2s, transform .15s var(--ease);
}
.icon-btn:active { background: var(--surface-2); color: var(--text); transform: scale(.94); }
#btn-refresh.spin .ic { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ошибка / нет курсов ---------- */
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 10px 12px 10px 14px;
  border-radius: calc(var(--r) * .7);
  background: rgba(var(--bad-rgb), .09);
  border: 1px solid rgba(var(--bad-rgb), .24);
  color: var(--bad);
  font-size: 14px;
  line-height: 1.3;
}
.notice[hidden] { display: none; }
.notice span { flex: 1; min-width: 0; }
.notice button {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: rgba(var(--bad-rgb), .16);
  font-weight: 500;
  font-size: 14px;
}
.notice button:active { background: rgba(var(--bad-rgb), .3); }

/* ---------- строки валют ---------- */
#rows {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row {
  flex: 1 1 0;
  min-height: 50px;
  max-height: 84px;
  display: grid;
  grid-template-columns: minmax(150px, 50%) 1fr;
  border-radius: var(--r);
  border: 1px solid transparent;
  position: relative;
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.row::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -2px;
  height: 1px;
  background: var(--line);
  transition: opacity .2s;
}
.row:last-child::after, .row.active::after { opacity: 0; }
.row.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: var(--glow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.row.enter { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.cur {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 0 12px;
  text-align: left;
  min-width: 0;
  border-radius: var(--r) 0 0 var(--r);
  transition: background .15s;
}
.cur:active { background: var(--surface-2); }
.cur .meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cur .code { font-size: 18px; font-weight: 600; letter-spacing: .01em; line-height: 1.15; }
.cur .name {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: var(--name-case);
  letter-spacing: var(--name-track);
}
.flag {
  flex: none;
  width: 34px; height: 25px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-3);
  box-shadow: 0 0 0 1px var(--flag-ring);
}

.val {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  padding: 0 16px 0 4px;
  overflow: hidden;
  border-radius: 0 var(--r) var(--r) 0;
}
.val .vt {
  font-size: 34px;
  font-weight: var(--vt-weight);
  letter-spacing: var(--vt-track);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.row.active .val .vt { color: var(--accent); }
.row.empty .val .vt { color: var(--muted); }
.row.loading .val .vt {
  width: 96px; height: 22px;
  border-radius: 8px;
  color: transparent;
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%) 0 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- клавиатура: цифры, запятая, стереть, очистить ---------- */
#keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: clamp(46px, 7.6dvh, 66px);
  gap: 8px;
  margin-top: 12px;
}
.key {
  border-radius: var(--r);
  font-size: 32px;
  font-weight: 400;
  display: grid;
  place-items: center;
  box-shadow: var(--key-shadow), var(--edge);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  transition: background .12s, transform .12s var(--ease), box-shadow .2s;
}
.key:active { transform: scale(.96); }
.key .ic { width: 28px; height: 28px; }
.key.num { background: var(--surface); }
.key.num:active { background: var(--surface-3); }
.key.fn { background: var(--surface-2); color: var(--muted); font-size: 24px; font-weight: 500; }
.key.fn:active { background: var(--surface-3); color: var(--text); }
.key.clear {
  grid-column: span 3;
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line), var(--edge);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .01em;
}
.key.clear:active { background: rgba(var(--accent-rgb), .22); }

/* ---------- выбор валюты ---------- */
.screen {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: var(--bg-image);
  background-attachment: fixed;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .3s var(--ease), visibility 0s .3s;
  padding-top: calc(env(safe-area-inset-top) + 6px);
  z-index: 10;
}
.screen.open { transform: none; visibility: visible; transition: transform .3s var(--ease); }
.screen-head { position: relative; display: grid; place-items: center; height: 48px; flex: none; }
.screen-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.icon-btn.back { position: absolute; left: 8px; top: 2px; color: var(--text); }

.search-wrap { position: relative; padding: 8px 16px 10px; flex: none; }
.search-wrap .ic { position: absolute; left: 32px; top: 50%; transform: translateY(-50%); margin-top: -1px; color: var(--muted); width: 22px; height: 22px; pointer-events: none; }
#search {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line);
  outline: 0;
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  padding: 0 16px 0 46px;
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  appearance: none;
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  transition: border-color .2s;
}
#search:focus-visible { outline: 0; border-color: var(--accent-line); }
#search::placeholder { color: var(--muted); }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

.list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px calc(var(--inset-b) + 16px);
}
.item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 62px;
  padding: 0 12px;
  text-align: left;
  border-radius: calc(var(--r) * .8);
  transition: background .15s;
}
.item:active { background: var(--surface-2); }
.item .flag { width: 44px; height: 32px; border-radius: 8px; }
.item .nm { flex: 1; min-width: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .cd { font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: .04em; }
.item .ck { width: 20px; height: 20px; color: var(--accent); display: none; }
.item.sel { background: var(--accent-soft); }
.item.sel .nm { color: var(--accent); }
.item.sel .cd { display: none; }
.item.sel .ck { display: block; }
.list .none { text-align: center; color: var(--muted); padding: 40px 0; font-size: 16px; }

/* ---------- шторки ---------- */
.backdrop {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: 0;
  background: var(--backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 20;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  max-width: 520px;
  margin: 0 auto;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-top: 1px solid var(--line);
  border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(var(--inset-b) + 22px);
  transform: translateY(105%);
  visibility: hidden;
  transition: transform .32s var(--ease), visibility 0s .32s;
  z-index: 30;
}
.sheet.open { transform: none; visibility: visible; transition: transform .32s var(--ease); }
.grabber { width: 36px; height: 4px; border-radius: 2px; background: var(--surface-3); margin: 0 auto 16px; }
.sheet h3 { margin: 0 0 16px; font-size: 20px; font-weight: 600; letter-spacing: -.015em; }

.source, .theme-opt {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border-radius: var(--r);
  border: 1px solid transparent;
  transition: background .15s, border-color .2s;
}
.source:active, .theme-opt:active { background: var(--surface-3); }
.source.sel, .theme-opt.sel { background: var(--accent-soft); border-color: var(--accent-line); }
.source .tx, .theme-opt .tx { flex: 1; min-width: 0; }
.source .nm, .theme-opt .nm { font-size: 17px; font-weight: 600; }
.source .ds, .theme-opt .ds { font-size: 14px; color: var(--muted); margin-top: 3px; line-height: 1.35; text-wrap: pretty; }
.source .up { font-size: 13.5px; color: var(--accent); margin-top: 6px; }
.source .ck, .theme-opt .ck { width: 22px; height: 22px; color: var(--accent); opacity: 0; }
.source.sel .ck, .theme-opt.sel .ck { opacity: 1; }

/* превью темы: рисуется её же переменными */
.theme-opt { padding: 12px 16px 12px 12px; }
.sw {
  flex: none;
  position: relative;
  width: 58px; height: 58px;
  border-radius: calc(var(--r) * .55);
  background-color: var(--bg);
  background-image: var(--bg-image);
  box-shadow: 0 0 0 1px rgba(128, 128, 128, .3);
  overflow: hidden;
}
.sw i { position: absolute; left: 9px; right: 9px; height: 9px; border-radius: calc(var(--r-sm) * .5); }
.sw i:nth-child(1) { top: 9px; background: var(--accent); }
.sw i:nth-child(2) { top: 24px; background: var(--surface-3); }
.sw i:nth-child(3) { top: 39px; background: var(--surface-3); right: 24px; }

.setting { margin-bottom: 16px; }
.setting-label { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface-2); border-radius: calc(var(--r) * .7); padding: 3px; gap: 3px; }
.seg.two { grid-template-columns: repeat(2, 1fr); }
.seg button { height: 42px; border-radius: calc(var(--r) * .55); font-size: 16px; font-weight: 500; color: var(--muted); transition: background .2s, color .2s; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.sheet-btn {
  width: 100%;
  height: 50px;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--bad);
  font-size: 16px;
  font-weight: 500;
}
.sheet-btn:active { background: var(--surface-3); }
.about { color: var(--muted); font-size: 13.5px; line-height: 1.45; margin: 18px 2px 0; text-wrap: pretty; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--inset-b) + 90px);
  transform: translate(-50%, 16px);
  background: var(--toast-bg, var(--surface-3));
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  padding: 11px 18px;
  border-radius: calc(var(--r) * .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease);
  z-index: 40;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (hover: hover) {
  .cur:hover, .item:hover, .source:hover, .theme-opt:hover { background: var(--surface-2); }
  .row.active .cur:hover { background: transparent; }
  .key.num:hover { background: var(--surface-2); }
  .icon-btn:hover { color: var(--text); }
}

/* ============ точечные правила тем ============ */

/* Светлая: карточки-клавиши с мягкой тенью, фон сидит на белом */
[data-theme="light"] .key.fn { background: var(--surface-2); }
[data-theme="light"] .row.active { background: rgba(var(--accent-rgb), .08); }

/* Терминал: рамки вместо заливок, активная строка инвертируется */
[data-theme="tech"] h1 { font-size: 18px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
[data-theme="tech"] .status { text-transform: uppercase; letter-spacing: .06em; font-size: 12px; }
[data-theme="tech"] .status::before { border-radius: 0; box-shadow: none; }
[data-theme="tech"] .icon-btn, [data-theme="tech"] .notice, [data-theme="tech"] .toast, [data-theme="tech"] .grabber { border-radius: 0; }
[data-theme="tech"] .key { border: 1px solid var(--line); font-weight: 500; }
[data-theme="tech"] .key.num:active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
[data-theme="tech"] .key.fn { background: transparent; color: var(--accent); }
[data-theme="tech"] .key.clear { background: transparent; border-color: var(--accent); box-shadow: none; text-transform: uppercase; letter-spacing: .12em; font-size: 16px; }
[data-theme="tech"] .key.clear:active { background: var(--accent); color: var(--accent-ink); }
[data-theme="tech"] .row::after { left: 0; right: 0; background: var(--line); }
[data-theme="tech"] .row.active { background: var(--accent); border-color: var(--accent); }
[data-theme="tech"] .row.active .code,
[data-theme="tech"] .row.active .val .vt { color: var(--accent-ink); }
[data-theme="tech"] .row.active .name { color: rgba(20, 16, 0, .7); }
[data-theme="tech"] .row.active .flag { box-shadow: 0 0 0 1px var(--accent-ink); }
[data-theme="tech"] .row.active .cur:active { background: rgba(0, 0, 0, .12); }
[data-theme="tech"] .flag, [data-theme="tech"] .item .flag { border-radius: 0; }
[data-theme="tech"] .cur .name { font-size: 10.5px; }
[data-theme="tech"] .cur .code { font-size: 17px; font-weight: 700; }
[data-theme="tech"] #search, [data-theme="tech"] .item, [data-theme="tech"] .item.sel { border-radius: 0; }
[data-theme="tech"] .item.sel { background: var(--accent); }
[data-theme="tech"] .item.sel .nm, [data-theme="tech"] .item.sel .ck { color: var(--accent-ink); }
[data-theme="tech"] .item .nm { text-transform: uppercase; letter-spacing: .03em; font-size: 15px; }
[data-theme="tech"] .sheet { border-radius: 0; border-top: 2px solid var(--accent); }
[data-theme="tech"] .source.sel, [data-theme="tech"] .theme-opt.sel { background: transparent; border-color: var(--accent); }
[data-theme="tech"] .seg { border: 1px solid var(--line); background: transparent; }
[data-theme="tech"] .sheet-btn { border: 1px solid var(--line); background: transparent; }

/* Стекло: чуть больше воздуха между клавишами */
[data-theme="glass"] #keypad { gap: 10px; }
[data-theme="glass"] .row.active { border-color: rgba(var(--accent-rgb), .4); }

#debug {
  position: fixed;
  left: 8px; right: 8px; top: calc(env(safe-area-inset-top) + 60px);
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .88);
  color: #9fe7b8;
  font: 12px/1.5 ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  z-index: 200;
  -webkit-user-select: text;
  user-select: text;
}
#debug[hidden] { display: none; }

@media (max-height: 700px) {
  .row { min-height: 42px; }
  .cur .code { font-size: 16px; }
  .val .vt { font-size: 28px; }
  #keypad { gap: 6px; margin-top: 8px; grid-auto-rows: clamp(40px, 7dvh, 56px); }
  .key { font-size: 26px; }
  .key.clear { font-size: 17px; }
}

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