@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/manrope-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2191, U+2193, U+2212;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/manrope-700-cyrillic.woff2") format("woff2");
  unicode-range: U+0400-045F, U+0490-0491, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/manrope-800-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2191, U+2193, U+2212;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/manrope-800-cyrillic.woff2") format("woff2");
  unicode-range: U+0400-045F, U+0490-0491, U+2116;
}

:root {
  --bg: #FAF6F4;
  --surface: #FFFFFF;
  --surface-2: #F3EBE8;
  --surface-3: #ECE1DC;
  --text: #241B19;
  --text-dim: #8E7E78;
  --border: #E8DCD7;
  --accent: #D7263D;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE3E5;
  --warn: #C96A12;
  --warn-soft: #FBE6CC;
  --shadow: rgba(36, 24, 20, 0.10);
  --check-ring: #CFC2BC;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120F; --surface: #221B18; --surface-2: #2B2320; --surface-3: #352C27;
    --text: #F4EBE7; --text-dim: #A8978E; --border: #3C322C;
    --accent: #FF5A6E; --accent-ink: #1C1110; --accent-soft: #3B1E22;
    --warn: #FFA94D; --warn-soft: #3E2C17; --shadow: rgba(0,0,0,.45); --check-ring: #4A3F38;
  }
}
:root[data-theme="dark"] {
  --bg: #17120F; --surface: #221B18; --surface-2: #2B2320; --surface-3: #352C27;
  --text: #F4EBE7; --text-dim: #A8978E; --border: #3C322C;
  --accent: #FF5A6E; --accent-ink: #1C1110; --accent-soft: #3B1E22;
  --warn: #FFA94D; --warn-soft: #3E2C17; --shadow: rgba(0,0,0,.45); --check-ring: #4A3F38;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button { font-family: inherit; }
.num { font-family: "Manrope", -apple-system, Roboto, sans-serif; font-variant-numeric: tabular-nums; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }

/* ---- липкая шапка: topbar+tabs+stats ОДНИМ блоком, чтобы высота баннера
   (п.8: при показе «сегодня понедельник» высота topbar меняется) не
   рассинхронивала фиксированные отступы между частями ---- */
.app-header { position: sticky; top: 0; z-index: 30; background: var(--bg); }

.topbar { padding: 10px 14px 0; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar-row h1 { font-family: "Manrope", sans-serif; font-weight: 800; font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 16px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn:active { filter: brightness(.95); }

.search-wrap { margin-top: 10px; display: none; }
.search-wrap.open { display: block; }
.search-input {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 11px 14px; font-size: 15px; outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-dim); }

.weekly-banner {
  margin-top: 10px; background: var(--accent-soft); color: var(--accent);
  border-radius: 12px; padding: 9px 13px; font-size: 13px; font-weight: 700;
}

/* ---- category tabs ---- */
.tabs {
  display: flex; gap: 6px; padding: 12px 14px 10px; overflow-x: auto;
  scrollbar-width: none; border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  padding: 8px 13px; border-radius: 20px; font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---- stats bar ---- */
.stats-bar { display: flex; align-items: center; gap: 14px; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.stat { display: flex; flex-direction: column; align-items: flex-start; flex-shrink: 0; }
.stat-value { font-family: "Manrope", sans-serif; font-weight: 800; font-size: 17px; color: var(--accent); }
.stat-label { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.progress-wrap { flex: 1; min-width: 0; }
.progress-label { font-size: 11.5px; color: var(--text-dim); display: block; margin-bottom: 4px; }
.progress-track { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s ease; width: 0%; }

/* ---- list ---- */
.list { flex: 1; padding: 4px 14px 24px; }
.loading { text-align: center; color: var(--text-dim); padding: 40px 0; font-size: 14px; }
.category { margin-top: 18px; }
.category:first-of-type { margin-top: 14px; }
.category-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 8px; }
.category-title {
  font-family: "Manrope", sans-serif; font-size: 13px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em; margin: 0;
}
.category-confirm {
  border: none; background: none; color: var(--accent); font-size: 12px; font-weight: 700;
  padding: 4px 2px; cursor: pointer; flex-shrink: 0; white-space: nowrap;
}
.category-confirm:disabled { color: var(--text-dim); opacity: .5; cursor: default; }

.row[hidden] { display: none; }
.row {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 11px 12px; margin-bottom: 8px; transition: background .2s, border-color .2s;
}
.row.changed { background: var(--accent-soft); border-color: var(--accent); }

.row-top { min-width: 0; }
.row-name { font-size: 14.5px; font-weight: 600; margin-bottom: 3px; word-break: break-word; }
.row-meta { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meta-chip {
  display: inline-flex; align-items: center; gap: 3px; background: var(--warn-soft); color: var(--warn);
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px; white-space: nowrap;
}

.row-bottom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper-block { display: flex; align-items: center; gap: 6px; }
.stepper-cap { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; margin-right: 1px; }
.stepper {
  width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; touch-action: manipulation; flex-shrink: 0;
}
.stepper.full { width: 48px; height: 48px; font-size: 22px; border-radius: 13px; }
.stepper:active { transform: scale(.93); background: var(--surface-3); }
.stepper:disabled { opacity: .35; cursor: default; transform: none; }
.count-num { min-width: 28px; text-align: center; font-weight: 800; font-size: 19px; display: inline-block; }
.count-num.full-num { min-width: 34px; font-size: 21px; }
.row-bottom .spacer { flex: 1; }

.check-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--check-ring);
  display: flex; align-items: center; justify-content: center; color: transparent; font-size: 15px; font-weight: 800;
  cursor: pointer; flex-shrink: 0; transition: background .15s, border-color .15s, color .15s; margin-left: auto;
}
.check-dot.checked { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---- bottom bar ---- */
.bottom-bar {
  position: sticky; bottom: 0; display: flex; gap: 10px;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border);
}
.btn-undo {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 13px;
  padding: 0 16px; font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.btn-undo:disabled { opacity: .4; cursor: default; }
.btn-send {
  flex: 1; border: none; background: var(--accent); color: var(--accent-ink); border-radius: 13px;
  font-size: 16px; font-weight: 800; letter-spacing: .01em; cursor: pointer; min-height: 48px;
}
.btn-send:active { filter: brightness(.92); }
.btn-send:disabled { opacity: .5; }

/* ---- success overlay / toast ---- */
.success-overlay {
  position: fixed; inset: 0; background: rgba(23,18,15,.55); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 100;
}
.success-overlay.show { opacity: 1; pointer-events: auto; }
.success-card {
  background: var(--surface); border-radius: 20px; padding: 30px 40px; display: flex; flex-direction: column;
  align-items: center; gap: 10px; transform: scale(.85); transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.success-overlay.show .success-card { transform: scale(1); }
.success-check {
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800;
}
.success-text { font-family: "Manrope", sans-serif; font-weight: 700; font-size: 15px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90; max-width: 85%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .success-card, .stepper, .progress-fill, .toast { transition: none !important; }
}

/* ---- узкие экраны (проверено на 360px) ---- */
@media (max-width: 380px) {
  .row-name { font-size: 14px; }
  .stepper.full { width: 44px; height: 44px; }
  .stepper { width: 34px; height: 34px; }
}
