/* Вспомогательный текст не бледнее 4.5:1 к фону, значки — 3:1 (WCAG AA;
   проверка — tools/check-contrast.py). Раньше строка курса была 2.4:1. */
:root{
  --bg:#F2F3F5; --card:#FFFFFF; --blue:#1565C0; --ink:#1A1A1A;
  --gray:#6E6E6E; --gray2:#6F6F6F; --line:#EEE;
  --badge:#E8EEF9; --green:#2E7D32; --green2:#43A047;
  --faint:#8C8C8C; --faint2:#6E6E6E; --muted:#687074; --dim:#6E6E6E;
  --gray3:#666; --gray4:#6F6F6F; --gray5:#555; --gray6:#333;
  --press:#0000000d; --hover:#f2f2f2; --chip-border:#ddd; --chip-on:#455A64;
  --on-accent:#fff;
  /* «с поправкой»: один цвет — одно значение. Оранжевый и коричневый заняты
     статусами, синий — активной строкой, зелёный — логотипом. */
  --adjusted:#6A1B9A; --adjusted-bg:#EBD9F0; --on-adjusted:#FFFFFF;
  --stale:#C93E14; --offline:#86685E;
}

/* Тёмная тема. Фон не чёрный, а тёмно-серый: на OLED чистый чёрный даёт резкие
   границы карточек. Синий и зелёный осветлены — исходные на тёмном не проходят
   по контрасту. Применяется по настройке системы, а data-theme на <html>
   позволяет пользователю выбрать режим принудительно. */
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#121212; --card:#1E1E1E; --blue:#64B5F6; --ink:#ECECEC;
    --gray:#B4B4B4; --gray2:#8C8C8C; --line:#2C2C2C;
    --badge:#1B2A3A; --green:#81C784; --green2:#81C784;
    --faint:#696969; --faint2:#858585; --muted:#78909C; --dim:#858585;
    --gray3:#B4B4B4; --gray4:#9A9A9A; --gray5:#B4B4B4; --gray6:#D0D0D0;
    --press:#ffffff14; --hover:#2A2A2A; --chip-border:#3A3A3A; --chip-on:#37474F;
    --on-accent:#0B0B0B;
    --adjusted:#CE93D8; --adjusted-bg:#3A2348; --on-adjusted:#0B0B0B;
    --stale:#FF8A65; --offline:#BCAAA4;
  }
}
:root[data-theme="dark"]{
  --bg:#121212; --card:#1E1E1E; --blue:#64B5F6; --ink:#ECECEC;
  --gray:#B4B4B4; --gray2:#8C8C8C; --line:#2C2C2C;
  --badge:#1B2A3A; --green:#81C784; --green2:#81C784;
  --faint:#696969; --faint2:#858585; --muted:#78909C; --dim:#858585;
  --gray3:#B4B4B4; --gray4:#9A9A9A; --gray5:#B4B4B4; --gray6:#D0D0D0;
  --press:#ffffff14; --hover:#2A2A2A; --chip-border:#3A3A3A; --chip-on:#37474F;
  --on-accent:#0B0B0B;
  --adjusted:#CE93D8; --adjusted-bg:#3A2348; --on-adjusted:#0B0B0B;
  --stale:#FF8A65; --offline:#BCAAA4;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  background:var(--bg); color:var(--ink);
  overscroll-behavior:none;
  position:fixed; inset:0;   /* блокируем прокрутку страницы целиком */
}
/* Контейнер жёстко = видимый вьюпорт (не зависит от dvh/vh, надёжно в standalone) */
#app{
  position:fixed; top:0; bottom:0; left:0; right:0;
  display:flex; flex-direction:column;
  max-width:640px; margin:0 auto; background:var(--bg);
  overflow:hidden;
}

/* Header */
.header{
  display:flex; align-items:center; gap:8px;
  background:var(--card); min-height:48px; padding:6px 14px 6px 9px;
  box-shadow:0 1px 3px rgba(0,0,0,.08);
  padding-top:calc(6px + env(safe-area-inset-top));
}
/* «Рыночный курс · 13:11 · источник ⓘ» — кнопка: открывает пояснение о курсах */
.status{flex:1; min-width:0; margin-left:14px; min-height:44px; border:0; background:transparent; border-radius:6px; padding:2px 4px;
  font:inherit; font-size:12px; color:var(--gray3); text-align:start; cursor:pointer;
  white-space:normal; line-height:1.25; overflow-wrap:break-word}
.status:active{background:var(--press)}
.status.adj{color:var(--adjusted); font-weight:600}
/* Значки — один стиль: контур линией 1.8, цвет от текста */
svg.line{fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; flex:none}
svg.info{width:1.15em; height:1.15em; vertical-align:-.22em}
.icon-btn{
  border:0; background:transparent; color:var(--gray3);
  font-size:22px; width:44px; height:44px; border-radius:50%;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.icon-btn:active{background:var(--press)}
/* идёт запрос — крутим сам значок, отдельного индикатора нет */
@keyframes fixxe-spin{to{transform:rotate(360deg)}}
#btnRefresh.loading svg{animation:fixxe-spin .9s linear infinite}
#btnSettings{margin-right:4px}

/* Clear */
.clear-row{background:var(--card); display:grid; grid-template-columns:1fr auto 1fr; align-items:center; padding:2px 14px 2px 16px}
.brand{color:var(--green); font-weight:800; font-size:15px; letter-spacing:.12em; justify-self:start; text-decoration:none}
.mini-logo-link{justify-self:center; display:flex}
.mini-logo{height:40px; width:auto; display:block}
.clear-btn{justify-self:end}
.clear-btn{
  border:0; background:transparent; color:var(--blue);
  font-size:14px; padding:6px 16px; cursor:pointer; border-radius:6px;
}
.clear-btn:active{background:var(--press)}

/* List */
.list{flex:1; min-height:0; overflow-y:auto; padding:6px 10px 8px; -webkit-overflow-scrolling:touch}
.card{
  background:var(--card); border-radius:10px; margin-bottom:6px;
  box-shadow:0 1px 2px rgba(0,0,0,.06); border:0 solid transparent;
  transition:border-color .12s;
}
.card.active{border:3px solid var(--blue)}
.card.dragging{opacity:.6; box-shadow:0 4px 14px rgba(0,0,0,.2)}
.row1{display:flex; align-items:center; padding:11px 6px 2px}
/* зона нажатия 44 px, место в строке прежнее (36) — лишнее съедают отрицательные отступы */
.del{
  width:44px; height:44px; margin:-4px; border:0; background:transparent; color:var(--faint);
  cursor:pointer; border-radius:50%; flex:none; display:flex; align-items:center; justify-content:center;
}
.del svg,.handle svg{width:15px; height:15px; fill:currentColor}
.del:active{background:var(--press)}
.flag{width:36px; text-align:center; font-size:22px; flex:none; margin-left:4px}
.code{font-weight:700; font-size:15px; margin-left:8px; letter-spacing:.02em; flex:none}
.spacer{flex:1}
.sym{font-size:14px; color:var(--gray); margin-right:3px; margin-left:6px; flex:none}
/* 130 px, когда место есть; на узком экране (320 px) поле уступает — иначе
   код слипался с символом, а ручка вылезала за карточку. Длинную сумму
   подгоняет fitAmount. */
.amount{
  flex:0 1 130px; width:130px; min-width:64px; border:0; background:transparent; text-align:right;
  font-size:22px; font-weight:700; color:var(--ink); outline:none;
  font-family:inherit; padding:0; font-variant-numeric:tabular-nums;
}
.amount::placeholder{color:var(--faint2)}
.handle{
  width:44px; height:44px; margin:-4px -6px -4px -2px; border:0; background:transparent; color:var(--faint);
  cursor:grab; touch-action:none; flex:none; display:flex; align-items:center; justify-content:center;
}
.handle svg{width:18px; height:18px}
.row2{display:flex; padding:0 12px 10px 90px}
@media (max-width:360px){
  .row1{padding-left:2px; padding-right:4px}
  .flag{width:30px; margin-left:0}
  .code{margin-left:6px}
  .row2{padding-left:74px}   /* название — под кодом: 2 + 36 + 30 + 6 */
}
.name{flex:1; font-size:11px; color:var(--gray2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.rate{font-size:10px; color:var(--gray2); text-align:right; white-space:nowrap; padding-left:8px}

/* Footer */
.footer{background:var(--card); box-shadow:0 -2px 8px rgba(0,0,0,.06); padding-bottom:env(safe-area-inset-bottom)}
.footer-top{display:flex; align-items:center; gap:8px; min-height:52px; padding:0 12px}
.add-btn{display:flex; align-items:center; gap:4px; border:0; background:transparent; color:var(--blue); font-size:14px; padding:6px; min-height:44px; cursor:pointer; border-radius:6px}
/* Значки магазинов — справа в строке «Добавить валюту». Высота — по видимой части
   значка; у PNG Google Play вокруг прозрачное поле (41 из 250 px с каждой стороны),
   его съедают отрицательные отступы, чтобы оба значка были одного роста. */
/* «Добавить валюту» и значки — всегда одна строка: длинная подпись сокращается
   многоточием. Подпись ExchangeRate-API, если не помещается, уходит строкой ниже. */
.footer-top{flex-wrap:wrap; column-gap:8px; row-gap:0}
.footer-main{flex:1 1 auto; min-width:0; display:flex; align-items:center; gap:8px}
.add-btn{min-width:0; flex:0 1 auto}
.add-btn span{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.stores{--bh:36px; margin-inline-start:auto; display:flex; align-items:center; gap:6px; flex:none}
.stores a{display:block; line-height:0; border-radius:7px}
.stores .badge-ios{height:var(--bh); width:auto; display:block}
.stores .play{overflow:hidden; height:var(--bh)}
.stores .play img{height:calc(var(--bh) * 250 / 168); width:auto; display:block; margin:calc(var(--bh) * -41 / 168)}
@media (max-width:420px){ .stores{--bh:30px; gap:5px} }
@media (max-width:360px){ .stores{--bh:26px; gap:4px} }
/* подпись ExchangeRate-API — в той же строке, мелко; зона нажатия по высоте строки */
.attribution{margin-inline-start:auto; display:flex; align-items:center; min-height:44px; padding:0 4px; font-size:10px; color:var(--muted);
  text-decoration:none; white-space:nowrap}
.attribution[hidden]{display:none}

/* Modal */
/* --vv-top/--vv-bottom — видимая область над клавиатурой (app.js), иначе окно уходит под неё */
.overlay{
  position:fixed; inset:0; top:var(--vv-top,0); bottom:var(--vv-bottom,0); background:rgba(0,0,0,.4);
  display:flex; align-items:center; justify-content:center; z-index:100; padding:20px;
}
.modal{
  background:var(--card); border-radius:14px; width:100%; max-width:400px;
  max-height:min(85vh, 100%); display:flex; flex-direction:column; overflow:hidden;
  box-shadow:0 10px 40px rgba(0,0,0,.3);
}
.modal h3{margin:0; padding:18px 20px 6px; font-size:18px; flex-shrink:0}
.modal .msg{padding:4px 20px 8px; font-size:14px; color:var(--gray6); white-space:pre-line; overflow-y:auto; line-height:1.45; flex:1; min-height:0}
.modal .list-choice{overflow-y:auto; padding:4px 0; flex:1; min-height:0}
.choice{
  display:flex; align-items:center; gap:12px; padding:13px 20px; cursor:pointer; font-size:15px;
  border:0; background:transparent; width:100%; text-align:left; font-family:inherit; color:var(--ink);
}
.choice:active{background:var(--hover)}
.choice.sel{color:var(--blue); font-weight:600}
.choice .radio{width:18px; text-align:center}
.modal .actions{display:flex; justify-content:flex-end; gap:8px; padding:10px 14px 14px; flex-shrink:0}
.modal .actions button{
  border:0; background:transparent; color:var(--blue); font-size:14px; font-weight:600;
  padding:8px 14px; cursor:pointer; border-radius:8px; font-family:inherit;
}
.modal .actions button:active{background:var(--press)}
.search-box{display:flex; align-items:center; gap:8px; padding:14px 16px; border-bottom:1px solid var(--line); flex-shrink:0}
.search-box input{flex:1; border:0; outline:none; font-size:16px; font-family:inherit; background:transparent; color:var(--ink)}
.search-box input::placeholder{color:var(--gray4)}
/* выбор валюты не сжимается при поиске — иначе поле ввода прыгает вслед за списком */
.pick-modal{height:min(85vh, 100%)}
.pick-row{display:flex; align-items:center; gap:10px; padding:12px 16px; cursor:pointer; border-bottom:1px solid var(--line)}
.pick-row:active{background:var(--hover)}
.pick-row .pf{font-size:20px; width:30px; text-align:center}
.pick-row .pc{font-weight:700; width:52px; font-size:14px}
.pick-row .pn{flex:1; font-size:13px; color:var(--gray4); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.pick-row.added{opacity:.4; cursor:default}
.pick-row .added-tag{color:var(--green2); font-weight:700; font-size:15px; margin-inline-start:6px}
.pick-row .src-dots{display:flex; gap:4px; align-items:center; margin-inline-start:8px}
.pick-row .src-dots .dot{width:9px; height:9px; border-radius:50%}
.pick-row.unavail{opacity:.72}
/* Фильтр по источнику */
.src-filter{display:flex; gap:6px; padding:8px 14px; border-bottom:1px solid var(--line); overflow-x:auto; -webkit-overflow-scrolling:touch; flex-shrink:0}
.chip{border:1px solid var(--chip-border); background:var(--card); border-radius:14px; padding:5px 11px; font-size:12px;
  white-space:nowrap; cursor:pointer; color:var(--gray5); display:flex; align-items:center; gap:5px; font-family:inherit; flex-shrink:0}
.chip .cdot{width:8px; height:8px; border-radius:50%}
.chip.on{color:var(--on-accent); border-color:transparent; background:var(--chip-on)}
.pick-list{overflow-y:auto; flex:1; min-height:0}
[dir="rtl"] .row1,[dir="rtl"] .row2{direction:rtl}
[dir="rtl"] .amount{text-align:left}

/* «Уменьшить движение» в системе: значок «обновить» не крутим, а приглушаем */
@media (prefers-reduced-motion: reduce){
  .icon-btn.loading, .icon-btn.loading *{animation:none !important}
  .icon-btn.loading{opacity:.4}
}

/* ---------- Поправка к курсу ---------- */
/* Значок «%» дублирует цвет: при дальтонизме фиолетовый близок к синему. */
.pct{display:inline-flex; align-items:center; justify-content:center; flex:none; width:18px; height:18px; border-radius:5px;
  background:var(--adjusted); color:var(--on-adjusted); font-size:12px; font-weight:800; line-height:1}
.adjust-banner{display:flex; align-items:center; gap:8px; width:100%; min-height:40px; padding:0 14px; border:0; flex-shrink:0;
  background:var(--adjusted-bg); color:var(--adjusted); font:inherit; font-size:13px; font-weight:700; text-align:start; cursor:pointer}
.adjust-banner #adjustBannerText{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.adjust-banner .chev{font-size:20px; line-height:1}
[dir="rtl"] .adjust-banner .chev{display:inline-block; transform:scaleX(-1)}
.adjust-notice{display:flex; align-items:center; gap:8px; min-height:40px; padding:0 14px; flex-shrink:0;
  background:var(--card); color:var(--ink); font-size:13px}
.adjust-notice span{flex:1; min-width:0}
.adjust-notice button{border:0; background:none; color:var(--blue); font:inherit; font-weight:700; min-height:40px; cursor:pointer}
.adjust-banner[hidden], .adjust-notice[hidden]{display:none}
/* Пересчитанные строки: сумма и курс другим цветом, перед курсом метка. Метка —
   отдельный блок, а не символ в тексте: иначе в арабском и иврите её
   переставил бы двунаправленный алгоритм. */
.card.adj .amount{color:var(--adjusted)}
.card.adj .rate{color:var(--adjusted); font-weight:600}
.card.adj .rate:not(:empty)::before{content:"%"; display:inline-block; width:12px; height:12px; line-height:12px; margin-inline-end:4px;
  border-radius:3px; background:var(--adjusted); color:var(--on-adjusted); font-size:9px; font-weight:800; text-align:center; vertical-align:1px}
/* Окно настроек: название слева, значение справа, шеврон; поправка — под линией */
.set-row{display:flex; align-items:center; gap:10px; width:100%; min-height:48px; border:0; background:transparent;
  padding:6px 14px 6px 20px; font:inherit; font-size:15px; color:var(--ink); text-align:start; cursor:pointer}
.set-row:active{background:var(--hover)}
.set-row .k{flex:1; min-width:0}
.set-row .v{max-width:50%; color:var(--gray3); font-size:13px; text-align:end}
.set-row .chev{width:16px; height:16px; color:var(--faint)}
[dir="rtl"] .set-row .chev{transform:scaleX(-1)}
.set-row.adj, .set-row.adj .v, .set-row.adj .chev{color:var(--adjusted)}
.set-sep{border:0; border-top:1px solid var(--divider, rgba(127,127,127,.25)); margin:6px 14px 6px 20px}
.set-foot{display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:0 14px; padding:8px 0 2px}
.set-ver, .set-apk{border:0; background:transparent; font:inherit; font-size:11px; color:var(--dim); min-height:36px; cursor:pointer; text-decoration:none; display:flex; align-items:center}
.choice.two{align-items:flex-start}
.choice.two small{display:block; font-size:12px; color:var(--gray3); font-weight:400; margin-top:2px}
.modal .hint{margin:6px 20px 4px; font-size:12.5px; color:var(--gray3); line-height:1.4}
.adjust-info{display:flex; gap:8px; margin:4px 20px 8px; padding:10px 12px; border-radius:10px; flex-shrink:0;
  background:var(--adjusted-bg); color:var(--adjusted); font-size:13px; line-height:1.4}
.adjust-info .link{border:0; background:none; padding:6px 0 0; color:inherit; font:inherit; font-weight:700; text-decoration:underline; cursor:pointer}
.adj-value{color:var(--adjusted)}
.adjust-modal .sign{display:flex; gap:6px; padding:4px 20px 8px; flex-shrink:0}
.adjust-modal .sign button{flex:1; min-height:40px; border:1px solid var(--chip-border); border-radius:8px;
  background:var(--card); color:var(--ink); font-size:18px; cursor:pointer}
.adjust-modal .sign button.on{background:var(--adjusted); color:var(--on-adjusted); border-color:transparent; font-weight:700}
.adjust-modal .custom input{width:72px; margin-inline-start:auto; padding:6px 8px; border:1px solid var(--chip-border); border-radius:8px;
  background:var(--card); color:var(--ink); font:inherit; text-align:end}
.adjust-modal .keep{display:flex; align-items:center; gap:10px; min-height:44px; padding:6px 20px 0; font-size:14px; color:var(--ink); flex-shrink:0}
.adjust-modal .keep input{width:20px; height:20px}
.adjust-modal .hint{padding:0 20px 4px; font-size:12px; color:var(--gray4); flex-shrink:0}
.adjust-modal .adjust-about{margin:-4px 0 10px; font-size:13px; color:var(--gray3)}
