/* ─── Comfortaa (self-hosted, variable 300–700) ─── */
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/comfortaa-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/comfortaa-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+2020, U+20A0-20C0, U+2113;
}
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/comfortaa-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+FFFD;
}

/* ─── Ночное озеро: палитра со скриншота ─── */
:root {
  --ink: #03040c;
  --deep: #060c26;
  --navy: #0b1746;
  --cobalt: #14277e;
  --royal: #2242d6;
  --electric: #4a6bff;
  --moon: #cfd8ff;
  --text: #eef1ff;
  --hint: #8fa0c8;
  --danger: #ff6b81;

  --glass-bg: linear-gradient(145deg, rgba(120, 150, 255, 0.12), rgba(40, 70, 180, 0.07));
  --glass-border: rgba(150, 175, 255, 0.20);
  --glass-shine: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--ink); }

body {
  font-family: 'Comfortaa', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button, input { font-family: inherit; }

/* ─── Анимации ─── */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes veil {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
  50%      { transform: translateX(-3px); }
}

@keyframes fall {
  to { opacity: 0; transform: translateX(40px) scale(0.9); height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
}

/* ─── Фон: ночное озеро ─── */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(120% 55% at 50% 118%, rgba(70, 110, 255, 0.34), transparent 60%),
    radial-gradient(45% 26% at 40% 86%, rgba(160, 185, 255, 0.16), transparent 70%),
    linear-gradient(180deg, #01020a 0%, #04081e 26%, #0a1748 62%, #0c1e63 84%, #081340 100%);
}

.bg::after {                 /* луна в воде */
  content: '';
  position: absolute;
  left: 38%;
  bottom: 9%;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 38%, rgba(230, 238, 255, 0.30), rgba(150, 175, 255, 0.10) 55%, transparent 72%);
  filter: blur(2px);
  animation: floaty 7s ease-in-out infinite;
}

.hidden { display: none !important; }

/* ─── Liquid glass: базовый рецепт ─── */
.login-card, .item, .summary, .tabs, .sheet-body, header, .nav-btn, .empty, .segmented {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shine), var(--glass-shadow);
}

/* Настоящий blur — только там, где под элементом проезжает контент.
   На карточках его нет: hover + backdrop-filter даёт полосы-артефакты на части GPU,
   а за карточками статичный градиент — размытие всё равно не видно. */
header, .tabs, .sheet-body, .login-card {
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

/* ─── Логин ─── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  border-radius: 28px;
  padding: 36px 26px 30px;
  text-align: center;
  animation: rise 0.5s var(--spring);
}

.login-logo {
  font-size: 44px;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 18px rgba(74, 107, 255, 0.65));
  animation: floaty 4.5s ease-in-out infinite;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-bottom: 26px;
  color: var(--moon);
  text-shadow: 0 0 24px rgba(74, 107, 255, 0.45);
}

input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(150, 175, 255, 0.22);
  border-radius: 14px;
  background: rgba(6, 12, 38, 0.55);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

input::placeholder { color: var(--hint); }

input:focus {
  border-color: var(--electric);
  background: rgba(10, 18, 52, 0.65);
  box-shadow: 0 0 0 3px rgba(74, 107, 255, 0.22), 0 0 22px rgba(74, 107, 255, 0.18);
}

.btn {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--glass-bg);
  box-shadow: var(--glass-shine);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s var(--spring), box-shadow 0.25s, border-color 0.25s, filter 0.25s;
}

.btn:active { transform: scale(0.96); }

.btn.primary {
  background: linear-gradient(160deg, #4a6bff 0%, #2242d6 60%, #1a34ad 100%);
  border-color: rgba(160, 185, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 24px rgba(50, 80, 255, 0.45);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 30, 0.35);
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
  min-height: 18px;
}

.error.shake { animation: shake 0.45s ease; }

/* ─── Шапка ─── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 12px 4px;
  padding: 10px 12px;
  border-radius: 22px;
  position: sticky;
  top: 10px;
  z-index: 10;
  animation: fadeSlide 0.4s ease;
}

header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--moon);
  text-shadow: 0 0 20px rgba(74, 107, 255, 0.4);
}

.nav-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--moon);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s var(--spring), opacity 0.2s, background 0.25s, box-shadow 0.25s;
}

.nav-btn:active { transform: scale(0.86); }
.nav-btn:disabled { opacity: 0.25; }

/* ─── Список ─── */
main {
  padding: 10px 12px 150px;
  animation: fadeSlide 0.3s ease;
}

.items { list-style: none; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: opacity 0.3s, transform 0.25s var(--spring), border-color 0.3s, box-shadow 0.3s;
}

.item.rise {
  animation: rise 0.45s var(--spring) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

.item.removing {
  animation: fall 0.3s ease forwards;
  overflow: hidden;
}

.item .check {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 1.5px solid rgba(160, 185, 255, 0.55);
  border-radius: 50%;
  background: rgba(10, 20, 60, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 15px;
  transition: all 0.25s var(--spring);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.item .check.pop { animation: pop 0.35s var(--spring); }

.item.done .check {
  background: linear-gradient(160deg, #4a6bff, #2242d6);
  border-color: rgba(170, 195, 255, 0.7);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 16px rgba(74, 107, 255, 0.55);
}

.item .info { flex: 1; min-width: 0; }

.item .title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.3s;
}

.item .sub { font-size: 12px; color: var(--hint); margin-top: 3px; }

.item.done { opacity: 0.75; }
.item.done .title { text-decoration: line-through; opacity: 0.5; }
.item.done .amount { opacity: 0.5; }

.item .amount {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--moon);
  transition: opacity 0.3s;
}

.item .warn { color: var(--danger); }

.item .del {
  border: none;
  background: none;
  color: var(--hint);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 2px;
  opacity: 0.6;
  transition: color 0.2s, opacity 0.2s, transform 0.15s var(--spring);
}

.item .del:active { transform: scale(0.8); }

.empty {
  text-align: center;
  color: var(--hint);
  padding: 40px 16px;
  border-radius: 20px;
  animation: rise 0.45s var(--spring);
}

.summary {
  border-radius: 20px;
  padding: 16px 18px;
  font-size: 14px;
  margin-top: 14px;
  color: var(--hint);
  animation: fadeSlide 0.4s ease;
}

.summary b { font-size: 17px; color: var(--moon); text-shadow: 0 0 16px rgba(74, 107, 255, 0.4); }

/* ─── FAB ─── */
.fab {
  position: fixed;
  right: 18px;
  bottom: 96px;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(160, 185, 255, 0.4);
  border-radius: 50%;
  background: linear-gradient(160deg, #4a6bff, #2242d6);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 28px rgba(40, 70, 230, 0.55);
  z-index: 20;
  transition: transform 0.2s var(--spring), box-shadow 0.3s;
}

.fab:active { transform: scale(0.9) rotate(90deg); }

/* ─── Плавающий стеклянный таб-бар ─── */
.tabs {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 6px;
  border-radius: 30px;
  z-index: 20;
}

.tabs-thumb {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: 0;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(74, 107, 255, 0.35), rgba(34, 66, 214, 0.25));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 0 18px rgba(74, 107, 255, 0.35);
  transition: left 0.4s var(--spring), width 0.4s var(--spring);
  pointer-events: none;
}

.tab {
  position: relative;
  z-index: 1;
  padding: 11px 22px;
  border: none;
  border-radius: 24px;
  background: none;
  color: var(--hint);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.3s;
}

.tab.active { color: var(--moon); }

/* ─── Шторка добавления ─── */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 14, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  z-index: 30;
  animation: veil 0.25s ease;
}

.sheet-body {
  width: 100%;
  border-radius: 26px 26px 0 0;
  border-bottom: none;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(90, 120, 230, 0.14), rgba(10, 22, 70, 0.30)),
    rgba(4, 8, 30, 0.55);
  animation: sheetUp 0.4s var(--spring);
}

.sheet-body h3 {
  margin-bottom: 18px;
  color: var(--moon);
  font-size: 17px;
  font-weight: 700;
}

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ─── Сегментный ползунок «Разово / Каждый месяц» ─── */
.segmented {
  position: relative;
  display: flex;
  padding: 4px;
  border-radius: 16px;
  margin: 4px 0 16px;
}

.seg-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(74, 107, 255, 0.55), rgba(34, 66, 214, 0.45));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 18px rgba(74, 107, 255, 0.4);
  transition: transform 0.35s var(--spring);
  pointer-events: none;
}

.segmented:has(input[value="recurring"]:checked) .seg-thumb { transform: translateX(100%); }

.segmented label {
  position: relative;
  flex: 1;
  text-align: center;
  padding: 11px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--hint);
  cursor: pointer;
  border-radius: 12px;
  transition: color 0.3s;
  z-index: 1;
  user-select: none;
}

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label:has(input:checked) { color: #fff; }

/* ─── Hover: только там, где есть мышь ─── */
@media (hover: hover) {
  /* без transform/filter на стеклянных элементах: backdrop-filter даёт артефакты при сдвиге */
  .item:hover {
    border-color: rgba(170, 195, 255, 0.38);
    box-shadow: var(--glass-shine), 0 0 22px rgba(74, 107, 255, 0.28), var(--glass-shadow);
  }

  .item .check:hover {
    border-color: var(--electric);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 14px rgba(74, 107, 255, 0.45);
  }

  .item .del:hover { color: var(--danger); opacity: 1; transform: scale(1.15); }

  .btn:hover { border-color: rgba(170, 195, 255, 0.45); box-shadow: var(--glass-shine), 0 0 18px rgba(74, 107, 255, 0.3); }
  .btn.primary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 8px 32px rgba(60, 95, 255, 0.65); }

  .nav-btn:hover:not(:disabled) {
    background: linear-gradient(160deg, rgba(74, 107, 255, 0.3), rgba(34, 66, 214, 0.2));
    box-shadow: var(--glass-shine), 0 0 16px rgba(74, 107, 255, 0.35);
  }

  .fab:hover {
    transform: scale(1.08) rotate(90deg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 10px 36px rgba(50, 85, 255, 0.75);
  }

  .tab:hover:not(.active) { color: var(--moon); }

  .segmented label:hover { color: var(--moon); }
  .segmented label:has(input:checked):hover { color: #fff; }
}

/* ─── Уважение к reduce-motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
