/* ==========================================================================
   TaskPulsee — дизайн-система Mini App
   Принципы: один акцент, одна серая шкала, тонированные тени, SVG-иконки,
   быстрые сдержанные анимации (transform/opacity), уважение к reduced-motion.
   ========================================================================== */

@font-face {
  font-family: "Onest";
  src: url("fonts/Onest.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Токены: тёмная тема (графит) ---------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --page: #0b0d11;
  --surface: #12151b;
  --surface-2: #181c24;
  --surface-3: #20252f;
  --shell: rgba(255, 255, 255, 0.025);

  --hairline: rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.12);

  --text: #eceef2;
  --text-2: #a3a9b6;
  --text-3: #6b7280;

  --accent: #5b8cff;
  --accent-rgb: 91, 140, 255;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --on-accent: #ffffff;

  --success: #34c77b;
  --success-soft: rgba(52, 199, 123, 0.14);
  --warning: #e5a93b;
  --warning-soft: rgba(229, 169, 59, 0.14);
  --danger: #f0645a;
  --danger-soft: rgba(240, 100, 90, 0.13);

  --note-surface: #1b1a15;
  --note-hairline: rgba(229, 169, 59, 0.16);

  --inverse-bg: #eceef2;
  --inverse-text: #0b0d11;

  --overlay: rgba(4, 6, 10, 0.62);

  --shadow-sm: 0 1px 2px rgba(2, 4, 10, 0.45);
  --shadow-md: 0 8px 22px -8px rgba(2, 4, 10, 0.65);
  --shadow-lg: 0 20px 44px -14px rgba(2, 4, 10, 0.75);
  --inner-hl: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

/* ---------- Токены: светлая тема (бумага) ---------- */
:root[data-theme="light"] {
  color-scheme: light;

  --page: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceff3;
  --shell: rgba(15, 23, 42, 0.03);

  --hairline: rgba(15, 23, 42, 0.08);
  --hairline-strong: rgba(15, 23, 42, 0.14);

  --text: #111726;
  --text-2: #525b6b;
  --text-3: #8a92a1;

  --accent: #2f64e6;
  --accent-rgb: 47, 100, 230;
  --accent-soft: rgba(47, 100, 230, 0.1);
  --on-accent: #ffffff;

  --success: #1e9e5a;
  --success-soft: rgba(30, 158, 90, 0.11);
  --warning: #b7791f;
  --warning-soft: rgba(183, 121, 31, 0.12);
  --danger: #d6453b;
  --danger-soft: rgba(214, 69, 59, 0.1);

  --note-surface: #fffaeb;
  --note-hairline: rgba(183, 121, 31, 0.2);

  --inverse-bg: #111726;
  --inverse-text: #ffffff;

  --overlay: rgba(17, 23, 38, 0.36);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 22px -10px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 22px 44px -16px rgba(15, 23, 42, 0.28);
  --inner-hl: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* ---------- Общие токены ---------- */
:root {
  --font: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --r-xl: 22px;
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 12px;
  --r-xs: 9px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.75, 0);
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --dur-sheet: 420ms;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==================== База ==================== */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(128px + var(--safe-bottom));
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
h1, h2, p { margin: 0; }

.num { font-variant-numeric: tabular-nums; }

.ico {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hidden { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
:focus:not(:focus-visible) { outline: none; }

/* ==================== Шапка ==================== */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 20px 20px 4px;
}

.eyebrow {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.005em;
  margin-bottom: 2px;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }

/* ==================== Общий дедлайн ==================== */
.global-deadline {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 32px);
  margin: 14px 16px 0;
  padding: 10px 12px 10px 10px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: transform var(--dur-fast) var(--ease-out);
}
.global-deadline:active { transform: scale(0.985); }

.global-deadline > .ico {
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.gd-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.gd-label { font-size: 12px; font-weight: 500; color: var(--text-3); }
.gd-date { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }

.gd-days {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.global-deadline.warn > .ico, .global-deadline.warn .gd-days { background: var(--warning-soft); color: var(--warning); }
.global-deadline.overdue > .ico, .global-deadline.overdue .gd-days { background: var(--danger-soft); color: var(--danger); }

/* ==================== Вкладки-«папки» ==================== */
.tabs-wrap {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 14px 16px 0;
  background: color-mix(in srgb, var(--page) 86%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
}

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: flex-end;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  top: 1px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r-md) var(--r-md) 0 0;
  border: 1px solid transparent;
  border-bottom: 0;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}

.tab.active {
  z-index: 2;
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  border-color: var(--hairline);
}

/* Акцентная полоска сверху активной «папки» */
.tab::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 22px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
  transform: translateX(-50%) scaleX(0);
  transition: transform var(--dur-base) var(--ease-out);
}
.tab.active::before { transform: translateX(-50%) scaleX(1); }

.tab-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  color: var(--text-2);
}
.tab.active .tab-count { background: var(--accent-soft); color: var(--accent); }

.tab-add {
  color: var(--accent);
  padding: 0 12px;
}
.tab-add .ico { width: 20px; height: 20px; stroke-width: 2; }

/* ==================== Тело «папки» ==================== */
.folder-body {
  position: relative;
  margin: 0 16px;
  padding: 14px 14px 20px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
}
.folder-body.first-active { border-top-left-radius: 6px; }

.folder-body.switching > * { animation: fadeSwap 260ms var(--ease-out) both; }
@keyframes fadeSwap {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ==================== Hero (двойная рамка) ==================== */
.hero-shell {
  padding: 5px;
  border-radius: var(--r-xl);
  background: var(--shell);
  border: 1px solid var(--hairline);
}

.hero {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px 18px 16px;
  border-radius: calc(var(--r-xl) - 5px);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(var(--accent-rgb), 0.10), transparent 55%),
    var(--surface-2);
  border: 1px solid var(--hairline);
  box-shadow: var(--inner-hl), var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out);
}
.hero:active { transform: scale(0.99); }

.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.hero-eyebrow {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-edit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  flex: 0 0 auto;
}
.hero-edit .ico { width: 15px; height: 15px; }

.hero-main {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}
.hero-days {
  font-size: 54px;
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 0;
}
.hero.warn .hero-days { color: var(--warning); }
.hero.overdue .hero-days { color: var(--danger); }

.hero-days-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hero-days-unit { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.hero-date { font-size: 13px; color: var(--text-3); }

/* Состояние «дедлайн не задан» */
.hero.no-deadline .hero-days {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
}
.hero.no-deadline .hero-days .ico { width: 24px; height: 24px; }
.hero.no-deadline .hero-date { color: var(--accent); font-weight: 500; }

.hero-progress {
  height: 6px;
  margin-top: 16px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.hero-progress-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 600ms var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.hero-progress-fill.complete { background: var(--success); }

.hero-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--text-3);
}
.hero-pct { font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hero-counts { font-variant-numeric: tabular-nums; text-align: right; }

/* ==================== Секции ==================== */
.section { margin-top: 22px; }
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 10px;
}
.section-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.section-count {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  background: var(--surface-3);
}
.section-count:empty { display: none; }

/* ==================== Примечания ==================== */
.notes-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  margin: 0 -2px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.notes-row::-webkit-scrollbar { display: none; }

.note-card {
  position: relative;
  flex: 0 0 auto;
  width: 214px;
  min-height: 92px;
  padding: 13px 34px 13px 14px;
  border-radius: var(--r-md);
  background: var(--note-surface);
  border: 1px solid var(--note-hairline);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  cursor: pointer;
  scroll-snap-align: start;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
  transition: transform var(--dur-fast) var(--ease-out);
}
.note-card:active { transform: scale(0.97); }
.note-card .note-pin {
  position: absolute;
  top: 11px;
  right: 10px;
  width: 16px;
  height: 16px;
  color: var(--warning);
}

.note-add {
  flex: 0 0 auto;
  width: 104px;
  min-height: 92px;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--hairline-strong);
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.note-add:active { transform: scale(0.96); }

/* ==================== Задачи ==================== */
.task-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 14px 14px 12px;
  margin-bottom: 10px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.task-card:active { transform: scale(0.985); }
.task-card.done { opacity: 0.6; }

.task-card.enter {
  animation: rise 380ms var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 8) * 38ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

.check {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin-top: 0;
  border-radius: 50%;
  border: 1.6px solid var(--hairline-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.check .ico { width: 15px; height: 15px; stroke-width: 2.4; }
.check:active { transform: scale(0.88); }
.check.checked { background: var(--success); border-color: var(--success); color: #fff; }
.check.pop { animation: pop 320ms var(--ease-out); }
@keyframes pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-wrap: pretty;
  word-break: break-word;
}
.task-card.done .task-title { text-decoration: line-through; text-decoration-color: var(--text-3); color: var(--text-3); }

.task-desc {
  margin-top: 4px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
}
.meta-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.meta-item .ico { width: 14px; height: 14px; stroke-width: 1.8; }
.meta-item.warn { color: var(--warning); }
.meta-item.overdue { color: var(--danger); }
.meta-pct { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status-dot.in_progress { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.status-dot.done { background: var(--success); }

.task-progress {
  height: 3px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.task-progress-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left center;
  transition: transform 500ms var(--ease-out);
}
.task-card.done .task-progress-fill { background: var(--success); }

/* ==================== Пустые состояния / скелетоны ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 12px 18px;
}
.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 14px;
}
.empty-icon .ico { width: 26px; height: 26px; }
.empty-title { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.empty-text { margin-top: 4px; font-size: 13.5px; color: var(--text-2); max-width: 30ch; text-wrap: balance; }
.empty-state .btn { margin-top: 16px; flex: 0 0 auto; padding: 0 18px; height: 44px; }

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: var(--r-md);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.3s infinite;
}
:root[data-theme="light"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-card { height: 84px; margin-bottom: 10px; }

.error-state { color: var(--text-2); font-size: 14px; text-align: center; padding: 26px 10px; line-height: 1.55; }

/* ==================== FAB ==================== */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(22px + var(--safe-bottom));
  display: flex;
  gap: 12px;
  z-index: 40;
}
.fab-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.fab-btn .ico { width: 28px; height: 28px; stroke-width: 1.9; }
.fab-btn:active { transform: scale(0.93); }

.fab-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 14px 28px -10px rgba(var(--accent-rgb), 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.fab-primary .ico { stroke-width: 2.2; }

.fab-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-md);
}
.fab-secondary.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: ring 1.4s var(--ease-out) infinite;
}
.fab-secondary.busy { color: var(--text-3); pointer-events: none; }
.fab-secondary.busy .ico { animation: breathe 1s ease-in-out infinite; }
@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(240, 100, 90, 0.55); }
  100% { box-shadow: 0 0 0 16px rgba(240, 100, 90, 0); }
}
@keyframes breathe { 50% { opacity: 0.35; } }

/* ==================== Индикатор записи ==================== */
.rec-pill {
  position: fixed;
  right: 18px;
  bottom: calc(102px + var(--safe-bottom));
  z-index: 41;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  animation: rise 240ms var(--ease-out) both;
}
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: breathe 1.1s ease-in-out infinite; }

/* ==================== Тост ==================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(104px + var(--safe-bottom));
  z-index: 200;
  max-width: calc(100% - 40px);
  padding: 11px 16px;
  border-radius: var(--r-sm);
  background: var(--inverse-bg);
  color: var(--inverse-text);
  font-size: 14px;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 8px);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ==================== Шторки (bottom sheet) ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: overlayIn var(--dur-base) var(--ease-out) both;
}
.modal-overlay.closing { animation: overlayOut 240ms var(--ease-in) both; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayOut { from { opacity: 1; } to { opacity: 0; } }

.modal-sheet {
  position: relative;
  width: 100%;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -12px 40px -12px rgba(0, 0, 0, 0.4);
  animation: sheetIn var(--dur-sheet) var(--ease-ios) both;
}
.modal-overlay.closing .modal-sheet { animation: sheetOut 260ms var(--ease-in) both; }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetOut { from { transform: none; } to { transform: translateY(100%); } }

.modal-sheet::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 999px;
  background: var(--hairline-strong);
}

.sheet-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 16px 12px 8px;
  flex: 0 0 auto;
}
.sheet-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 0 12px 0 6px;
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: 15.5px;
  font-weight: 550;
  transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.sheet-back .ico { width: 22px; height: 22px; stroke-width: 2; }
.sheet-back:active { background: var(--accent-soft); transform: scale(0.96); }
.sheet-title { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; text-align: center; }
.sheet-header-spacer { justify-self: end; }

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 18px 22px;
}

.sheet-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--hairline);
  background: var(--surface);
}

/* ==================== Поля формы ==================== */
.field-label {
  display: block;
  margin: 20px 2px 8px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  letter-spacing: -0.005em;
}
.sheet-body > .field-label:first-child { margin-top: 6px; }
.field-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.field-label-row b { font-weight: 650; color: var(--text); }

.helper { margin: 8px 2px 0; font-size: 12.5px; line-height: 1.45; color: var(--text-3); }

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); animation: shake 320ms var(--ease-out); }
@keyframes shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}
.input-lg { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
textarea.input { min-height: 104px; resize: vertical; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 17px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -6px;
  border-right: 1.7px solid var(--text-3);
  border-bottom: 1.7px solid var(--text-3);
  transform: rotate(45deg);
  pointer-events: none;
}
.select-wrap .input { padding-right: 40px; cursor: pointer; }

.date-row, .subtask-add-row { display: flex; gap: 8px; }
.date-row .input, .subtask-add-row .input { flex: 1; min-width: 0; }

.square-btn {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--text-2);
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.square-btn:active { transform: scale(0.94); }
.square-btn:disabled { opacity: 0.4; pointer-events: none; }
#addSubtaskBtn { color: var(--accent); }

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin-top: 10px;
  padding: 0 15px 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  font-size: 13.5px;
  font-weight: 550;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.chip-btn .ico { width: 18px; height: 18px; color: var(--accent); }
.chip-btn:active { transform: scale(0.96); }
.chip-btn.active { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.chip-btn.active .ico { color: var(--danger); animation: breathe 1s ease-in-out infinite; }

.rec-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.transcribing { margin-top: 10px; font-size: 12.5px; font-weight: 500; color: var(--text-3); }

/* Сегментированный переключатель статуса */
.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
}
.status-btn {
  flex: 1;
  height: 38px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.status-btn.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm), 0 0 0 1px var(--hairline); }
.status-row.disabled { opacity: 0.5; pointer-events: none; }

/* Слайдер прогресса */
.slider-row { padding: 6px 2px 2px; }
input[type="range"] {
  --val: 0%;
  width: 100%;
  height: 6px;
  margin: 10px 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0 var(--val), var(--surface-3) var(--val) 100%);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: transform var(--dur-fast) var(--ease-out);
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
input[type="range"]:disabled { opacity: 0.5; cursor: default; }
.progress-auto-note { margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--success); }

/* Шаги */
.subtask-list { margin-top: 10px; }
.subtask-list:empty { margin-top: 0; }
.subtask-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  animation: rise 260ms var(--ease-out) both;
}
.subtask-check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.6px solid var(--hairline-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  cursor: pointer;
  transition: background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.subtask-check .ico { width: 13px; height: 13px; stroke-width: 2.6; }
.subtask-check.checked { background: var(--success); border-color: var(--success); color: #fff; }
.subtask-text { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.4; word-break: break-word; }
.subtask-text.done { color: var(--text-3); text-decoration: line-through; }
.subtask-del {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.subtask-del .ico { width: 17px; height: 17px; }
.subtask-del:active { color: var(--danger); background: var(--danger-soft); }

/* Файлы */
.file-list:empty { display: none; }
.file-list { margin-bottom: 2px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: 14px;
}
.file-item > .ico { color: var(--text-3); width: 18px; height: 18px; }
.file-item a { flex: 1; min-width: 0; color: var(--accent); text-decoration: none; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .del {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.file-item .del .ico { width: 17px; height: 17px; }
.attach-input { display: none; }

.divider { height: 1px; background: var(--hairline); margin: 24px 0 4px; }

/* ==================== Кнопки ==================== */
.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 16px;
  border-radius: var(--r-md);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.btn .ico { width: 18px; height: 18px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 10px 22px -12px rgba(var(--accent-rgb), 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--hairline-strong); }
.btn-danger-ghost { flex: 0 0 auto; color: var(--danger); padding: 0 14px; }
.btn-danger-ghost:active { background: var(--danger-soft); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== Наведение (десктоп) ==================== */
@media (hover: hover) {
  .tab:not(.active):hover { color: var(--text-2); }
  .task-card:hover { border-color: var(--hairline-strong); }
  .note-add:hover { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.45); }
  .btn-primary:hover, .fab-primary:hover { filter: brightness(1.06); }
  .icon-btn:hover, .square-btn:hover, .chip-btn:hover { border-color: var(--hairline-strong); background: var(--surface-3); }
  .sheet-back:hover { background: var(--accent-soft); }
  .subtask-del:hover, .file-item .del:hover { color: var(--danger); background: var(--danger-soft); }
}

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