/* вСрок — стиль Filamento + иконки ДокПоток. Темы: peach, fog (светлые), ash, graphite (тёмные) */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(../fonts/manrope-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(../fonts/manrope-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/* ---------- Темы ---------- */
:root,
[data-theme="peach"] {
  color-scheme: light;
  --bg: #F6F1EC; --card: #FFFFFF; --line: #EADFD6; --text: #2B211C; --dim: #76665C; --faint: #A3958C;
  --accent: #E76F3C; --deep: #B9501F; --on-accent: #FFFFFF; --tint: #FBE3D7;
  --gray-t: #F1ECE7; --field: #FBF8F5; --shadow: 0 1px 2px rgba(60, 35, 20, .06); --scrim: rgba(43, 33, 28, .38);
  --red: #C2362B; --red-t: #FBE0DC; --amber: #9A6200; --amber-t: #FBEFD2; --blue: #2765B5; --blue-t: #E2ECFA;
}
[data-theme="fog"] {
  color-scheme: light;
  --bg: #EDF0F3; --card: #FFFFFF; --line: #DAE0E6; --text: #1E252D; --dim: #5B6773; --faint: #8C97A2;
  --accent: #E76F3C; --deep: #B9501F; --on-accent: #FFFFFF; --tint: #FBE6DC;
  --gray-t: #EDF0F3; --field: #F6F8FA; --shadow: 0 1px 2px rgba(20, 35, 50, .06); --scrim: rgba(30, 37, 45, .38);
  --red: #C2362B; --red-t: #FBE0DC; --amber: #9A6200; --amber-t: #FBEFD2; --blue: #2765B5; --blue-t: #E2ECFA;
}
[data-theme="ash"] {
  color-scheme: dark;
  --bg: #2B2D31; --card: #36383D; --line: #46494F; --text: #EBEBED; --dim: #B4B7BD; --faint: #8C9097;
  --accent: #F08A5D; --deep: #F6A882; --on-accent: #231812; --tint: #4D3B33;
  --gray-t: #42454B; --field: #303236; --shadow: none; --scrim: rgba(0, 0, 0, .5);
  --red: #FF9488; --red-t: #553634; --amber: #F5BE5A; --amber-t: #4E4128; --blue: #93C3FF; --blue-t: #2F3F55;
}
[data-theme="graphite"] {
  color-scheme: dark;
  --bg: #131417; --card: #1D1F23; --line: #2B2E33; --text: #ECEDEF; --dim: #9EA4AC; --faint: #757B84;
  --accent: #F08A5D; --deep: #F6A882; --on-accent: #1A120D; --tint: #3A2A22;
  --gray-t: #272A2F; --field: #17181B; --shadow: none; --scrim: rgba(0, 0, 0, .6);
  --red: #FF8A7E; --red-t: #43272A; --amber: #F5B94F; --amber-t: #3D3320; --blue: #8CC0FF; --blue-t: #22324A;
}

/* Цвета групп: светлые темы */
:root, [data-theme="peach"], [data-theme="fog"] {
  --c-violet: #5B3FC4; --c-violet-t: #ECE6FD;
  --c-green: #21744A;  --c-green-t: #DFF3E8;
  --c-blue: #2765B5;   --c-blue-t: #E0ECFB;
  --c-amber: #8A5A00;  --c-amber-t: #F8EDD3;
  --c-red: #B3332A;    --c-red-t: #FBE2DE;
  --c-teal: #0F7178;   --c-teal-t: #DAF1F1;
  --c-pink: #A8306E;   --c-pink-t: #FAE2EE;
  --c-gray: #5E6670;   --c-gray-t: #E9ECEF;
}
[data-theme="ash"] {
  --c-violet: #C7B6FF; --c-violet-t: #443F5C;
  --c-green: #86DCAB;  --c-green-t: #2E473A;
  --c-blue: #93C3FF;   --c-blue-t: #2F405A;
  --c-amber: #EBC866;  --c-amber-t: #4C4330;
  --c-red: #FF9C90;    --c-red-t: #563836;
  --c-teal: #7DD9DE;   --c-teal-t: #2B4749;
  --c-pink: #F5A3CB;   --c-pink-t: #533A48;
  --c-gray: #C4C7CC;   --c-gray-t: #45484D;
}
[data-theme="graphite"] {
  --c-violet: #C3B2FF; --c-violet-t: #302B45;
  --c-green: #7FD8A5;  --c-green-t: #20362A;
  --c-blue: #8CC0FF;   --c-blue-t: #22324A;
  --c-amber: #E8C25A;  --c-amber-t: #3A321F;
  --c-red: #FF968A;    --c-red-t: #44292A;
  --c-teal: #72D3D8;   --c-teal-t: #1C3638;
  --c-pink: #F29CC6;   --c-pink-t: #40293A;
  --c-gray: #B9BDC3;   --c-gray-t: #2C2F34;
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: Manrope, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.4; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--deep); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.view { flex: 1; padding: env(safe-area-inset-top, 0px) 0 calc(96px + env(safe-area-inset-bottom, 0px)); outline: none; }

/* ---------- Шапка ---------- */
.top { display: flex; align-items: flex-end; gap: 8px; padding: 22px 20px 10px; }
.top-text { flex: 1; min-width: 0; }
.top-date { font-size: 13.5px; font-weight: 600; color: var(--dim); }
.top h1 { margin: 2px 0 0; font-size: 32px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.top h1 .dim { color: var(--dim); font-weight: 600; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  color: var(--text); display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.round-btn svg { width: 18px; height: 18px; }
.round-btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.search { margin: 4px 16px 0; }
.search input {
  width: 100%; height: 46px; padding: 0 16px; border-radius: 23px; border: 1px solid var(--line);
  background: var(--card); outline: none;
}
.search input:focus { border-color: var(--accent); }

/* ---------- Сводка ---------- */
.hero { margin: 6px 16px 0; padding: 18px; border-radius: 22px; background: var(--tint); display: flex; align-items: center; gap: 16px; }
.hero-num { font-size: 56px; font-weight: 800; line-height: 1; color: var(--deep); font-variant-numeric: tabular-nums; }
.hero-title { font-size: 16px; font-weight: 700; }
.hero-sub { font-size: 13.5px; color: var(--dim); margin-top: 2px; }
.hero.calm { background: var(--card); box-shadow: var(--shadow); }
.hero.calm .hero-num { color: var(--text); }

/* ---------- Фильтры групп ---------- */
.chips { display: flex; gap: 8px; padding: 16px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  height: 40px; flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--card); font-size: 14.5px; font-weight: 700; white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; stroke-width: 1.8; }
.chip .n { color: var(--faint); font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }

/* ---------- Секции и карточки ---------- */
.list { display: flex; flex-direction: column; gap: 18px; padding: 12px 16px 16px; }
.sec { display: flex; flex-direction: column; gap: 8px; }
.sec-head { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.sec-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--card); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 700; color: var(--dim); display: inline-flex; align-items: center; justify-content: center;
}

.item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px; background: var(--card);
  box-shadow: var(--shadow); color: var(--text); text-decoration: none; border: 0; width: 100%; text-align: left;
}
.item:active { transform: scale(.99); }
.dateblk {
  width: 52px; height: 52px; flex: none; border-radius: 15px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1.05;
}
.dateblk b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dateblk small { font-size: 11.5px; font-weight: 700; }
.item-main { flex: 1; min-width: 0; }
.item-title { display: block; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { display: block; font-size: 13.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-side { flex: none; align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 6px; }
.gicon { width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.gicon svg { width: 16px; height: 16px; stroke-width: 1.8; }

.badge { padding: 3px 9px; border-radius: 10px; font-size: 13px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t-red { background: var(--red-t); color: var(--red); }
.t-amber { background: var(--amber-t); color: var(--amber); }
.t-blue { background: var(--blue-t); color: var(--blue); }
.t-gray { background: var(--gray-t); color: var(--dim); }

/* цвета групп */
.g-violet { background: var(--c-violet-t); color: var(--c-violet); }
.g-green { background: var(--c-green-t); color: var(--c-green); }
.g-blue { background: var(--c-blue-t); color: var(--c-blue); }
.g-amber { background: var(--c-amber-t); color: var(--c-amber); }
.g-red { background: var(--c-red-t); color: var(--c-red); }
.g-teal { background: var(--c-teal-t); color: var(--c-teal); }
.g-pink { background: var(--c-pink-t); color: var(--c-pink); }
.g-gray { background: var(--c-gray-t); color: var(--c-gray); }
.dot-violet { background: var(--c-violet); } .dot-green { background: var(--c-green); } .dot-blue { background: var(--c-blue); }
.dot-amber { background: var(--c-amber); } .dot-red { background: var(--c-red); } .dot-teal { background: var(--c-teal); }
.dot-pink { background: var(--c-pink); } .dot-gray { background: var(--c-gray); }

.empty { margin: 24px 16px; padding: 28px 20px; border-radius: 22px; background: var(--card); text-align: center; box-shadow: var(--shadow); }
.empty h2 { margin: 0 0 6px; font-size: 18px; font-weight: 800; }
.empty p { margin: 0 0 16px; color: var(--dim); }

/* ---------- Календарь ---------- */
.cal { margin: 0 16px; padding: 14px 10px 12px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.cal-wd, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wd { text-align: center; font-size: 12.5px; font-weight: 700; color: var(--dim); padding-bottom: 8px; }
.cal-grid { row-gap: 4px; }
.day {
  height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: transparent; padding: 0; color: var(--text);
}
.day .num {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.day.past .num { color: var(--faint); }
.day.has .num { font-weight: 800; }
.day.today .num { background: var(--deep); color: var(--bg); font-weight: 800; }
.day.over .num { background: var(--red-t); color: var(--red); font-weight: 800; }
.day.sel .num { box-shadow: inset 0 0 0 2px var(--accent); }
.day .dots { display: flex; gap: 3px; height: 5px; }
.day .dots i { width: 5px; height: 5px; border-radius: 50%; }

.seg { display: flex; gap: 4px; margin: 16px 16px 0; padding: 4px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.seg button { flex: 1; height: 38px; border: 0; border-radius: 12px; background: transparent; color: var(--dim); font-weight: 700; font-size: 14.5px; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

/* ---------- Настройки ---------- */
.group-box { margin: 0 16px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; width: 100%;
  border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; color: var(--text);
}
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; }
.row-sub { font-size: 13.5px; color: var(--dim); }
.row > svg.chev { width: 16px; height: 16px; color: var(--faint); }
.set-title { margin: 22px 20px 8px; font-size: 18px; font-weight: 800; }
.set-hint { margin: 8px 20px 0; font-size: 13.5px; color: var(--dim); }

.themes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0 16px; }
.theme-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--card); font-size: 12.5px; font-weight: 700; color: var(--text);
}
.theme-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.swatch { width: 36px; height: 36px; border-radius: 50%; position: relative; overflow: hidden; border: 1px solid rgba(128, 128, 128, .35); }
.swatch i { position: absolute; right: 5px; bottom: 5px; width: 12px; height: 12px; border-radius: 50%; }

.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--field); font-size: 20px; font-weight: 700; line-height: 1; }
.stepper output { min-width: 34px; text-align: center; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }

/* ---------- Кнопки ---------- */
.btn {
  height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  font-weight: 800; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--text);
}
.btn svg { width: 18px; height: 18px; stroke-width: 1.8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-soft { background: var(--tint); border-color: transparent; color: var(--deep); }
.btn-danger { color: var(--red); background: transparent; border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Нижняя панель ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-width: 560px; margin: 0 auto;
  height: calc(72px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center;
  background: var(--card); border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; color: var(--dim); text-decoration: none; padding: 6px 0; }
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a[aria-current="page"] { color: var(--deep); font-weight: 800; }
.fab {
  justify-self: center; width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(231, 111, 60, .32);
}
.fab svg { width: 24px; height: 24px; stroke-width: 2; }

/* ---------- Нижний лист (редактор) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 560px; margin: 0 auto;
  max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .item:active { transform: none; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 22px; font-weight: 800; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field legend { font-size: 13.5px; font-weight: 700; color: var(--dim); padding: 0 2px; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.input, .field select, .field textarea {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); outline: none; font-size: 16px;
}
.field textarea { height: auto; min-height: 76px; padding: 12px 14px; resize: vertical; }
.input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.input.invalid { border-color: var(--red); }
.field-row { display: flex; gap: 8px; }
.field-row > * { flex: 1; min-width: 0; }
.hint { font-size: 13px; color: var(--dim); padding: 0 2px; }
.err { font-size: 13px; color: var(--red); font-weight: 700; padding: 0 2px; }

.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick .chip { height: 38px; }
.icon-grid, .color-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.icon-opt, .color-opt {
  height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.icon-opt svg { width: 20px; height: 20px; }
.icon-opt[aria-pressed="true"], .color-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.color-opt i { width: 22px; height: 22px; border-radius: 50%; }
.color-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }

.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.sheet-actions .btn { width: 100%; }

.history { margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--dim); }
.history li { padding: 4px 2px; }

/* ---------- Уведомление ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 30;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--bg);
  font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 12px;
}
.toast button { border: 0; background: transparent; color: inherit; font-weight: 800; text-decoration: underline; padding: 4px; }

@media (min-width: 600px) {
  .tabbar { border: 1px solid var(--line); border-bottom: 0; }
}
