/* ============================================================
   Slon — спокойный трекер целей. Светлая «бумажная» тема,
   тёплая тёмная тема, крупная типографика и мягкие карточки.
   ============================================================ */

:root {
  --bg: #f6f3ec;
  --bg-deep: #eee9de;
  --surface: #fffdf8;
  --surface-2: #f8f5ee;
  --surface-3: #f0ebe1;
  --line: #e4ddd0;
  --line-strong: #d3c9b9;
  --ink: #20261f;
  --ink-soft: #3a4238;
  --muted: #5f675c;
  --faint: #697163;
  --primary: #075f3b;
  --primary-hover: #054b2f;
  --on-primary: #fffdf8;
  --primary-soft: #e3efe8;
  --success: #1c7a55;
  --success-soft: #e1f2e9;
  --gold: #b08a1f;
  --gold-ink: #765b07;
  --gold-soft: #faf0d2;
  --warning: #a8620b;
  --warning-ink: #794706;
  --warning-soft: #faedda;
  --danger: #b3443c;
  --danger-soft: #f8e7e4;
  --ring-track: #e8e1d4;
  --shadow-sm: 0 1px 2px rgba(36, 40, 32, .05);
  --shadow: 0 26px 50px -32px rgba(36, 40, 32, .42);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sidebar-w: 296px;
  --topbar-h: 68px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #141712;
  --bg-deep: #0f120e;
  --surface: #1c211b;
  --surface-2: #222820;
  --surface-3: #293027;
  --line: #30382e;
  --line-strong: #3d483b;
  --ink: #edf0e9;
  --ink-soft: #d2d8cf;
  --muted: #a2ab9e;
  --faint: #8f998b;
  --primary: #4e9b7d;
  --primary-hover: #5fae8e;
  --on-primary: #0b1712;
  --primary-soft: #223a30;
  --success: #63c79c;
  --success-soft: #1f3a2e;
  --gold: #d8b75e;
  --gold-ink: #efd991;
  --gold-soft: #342b17;
  --warning: #e0a75a;
  --warning-ink: #f1c47c;
  --warning-soft: #3a2f1d;
  --danger: #e0837c;
  --danger-soft: #3c2321;
  --ring-track: #2c332a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 28px 55px -30px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1000px 500px at 92% -12%, color-mix(in srgb, var(--primary) 8%, transparent), transparent 65%),
    radial-gradient(760px 420px at -8% 108%, color-mix(in srgb, var(--warning) 8%, transparent), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in srgb, var(--primary) 28%, transparent); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }

.icon { flex: 0 0 auto; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.skip-link {
  position: fixed; left: 16px; top: -80px; z-index: 200;
  padding: 10px 16px; border-radius: 999px;
  background: var(--primary); color: var(--on-primary); font-weight: 600;
  transition: top .15s;
}
.skip-link:focus { top: 16px; }

/* ---------- Оболочка ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.workspace { min-width: 0; display: flex; flex-direction: column; }

.view {
  width: 100%; max-width: 1240px; margin: 0 auto;
  padding: 34px 38px 90px; flex: 1;
}
.view:focus { outline: none; }

/* ---------- Вход и регистрация ---------- */
.shell[hidden], .auth-screen[hidden] { display: none; }
.auth-screen {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 24px;
  overflow-y: auto; background: var(--bg);
}
.auth-card {
  width: min(430px, 100%); padding: 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 20px; font-family: var(--font-display); font-size: 1.9rem; letter-spacing: -.02em; }
.auth-tabs {
  display: flex; gap: 3px; padding: 3px; margin-bottom: 20px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.auth-tabs[hidden] { display: none; }
.auth-tab {
  flex: 1; padding: 8px 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-size: .8rem; font-weight: 600;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-links { display: flex; justify-content: center; gap: 16px; }
.auth-link {
  padding: 4px; border: 0; background: transparent;
  color: var(--primary); font-size: .78rem; font-weight: 600;
}
.auth-link:hover { text-decoration: underline; }
.auth-link[hidden] { display: none; }
.auth-note { margin: 16px 0 0; color: var(--faint); font-size: .72rem; line-height: 1.45; }
.auth-note:empty { display: none; }
.account-email { margin: 0 0 4px; color: var(--muted); font-size: .84rem; }

/* ---------- Блок пользователя ---------- */
.side-user {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 8px 0; border-top: 1px solid var(--line);
}
.side-user-email {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0; border: 0; background: transparent; text-align: left;
  color: var(--muted); font: inherit; font-size: .7rem; cursor: pointer;
}
.side-user-email:hover { color: var(--ink); text-decoration: underline; }
.side-user .icon-btn { width: 28px; height: 28px; flex: 0 0 auto; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 10px 18px; font-size: .86rem; font-weight: 600; line-height: 1.2;
  transition: transform .12s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary {
  background: var(--primary); color: var(--on-primary);
  box-shadow: 0 10px 22px -14px color-mix(in srgb, var(--primary) 80%, transparent);
}
.btn.primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn.ghost {
  background: var(--surface); border-color: var(--line); color: var(--ink-soft);
}
.btn.ghost:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger:hover { filter: brightness(.94); }
.btn.danger-ghost { color: var(--danger); background: transparent; padding-left: 10px; padding-right: 10px; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn .icon { flex: 0 0 auto; }

.icon-btn {
  width: 38px; height: 38px; border: 1px solid transparent; border-radius: 50%;
  display: grid; place-items: center; background: transparent; color: var(--muted);
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn:disabled:hover { background: transparent; border-color: transparent; color: var(--muted); }

/* ---------- Сайдбар ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  padding: 22px 18px 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  backdrop-filter: blur(16px);
  scrollbar-width: thin;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 4px; }
.logo-mark { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px; }
.brand-name {
  font-family: var(--font-display); font-size: 1.45rem; font-weight: 700;
  line-height: 1; letter-spacing: -.015em;
}
.brand-tag {
  margin-top: 4px; color: var(--faint); font-size: .64rem;
  letter-spacing: .14em; text-transform: uppercase;
}

.auth-wordmark {
  display: block; width: min(250px, 82%); height: auto; margin-bottom: 26px;
}
html[data-theme="dark"] .auth-wordmark { filter: brightness(0) invert(1); opacity: .92; }

.overview-link {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm);
}
.overview-link:hover { border-color: var(--line-strong); }
.overview-link .icon { color: var(--primary); }
.overview-link.active {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 22%, var(--line));
}
.overview-link .label { font-size: .85rem; font-weight: 600; }
.overview-link .pct {
  font-size: .78rem; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.overview-link.active .pct { color: var(--primary); }

.nav-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 8px 0; color: var(--faint);
  font-size: .66rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
}
.nav-label b { font-weight: 700; color: var(--faint); }

.goal-nav { display: flex; flex-direction: column; gap: 2px; }
.goal-link {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 9px; align-items: center;
  padding: 9px 10px; border-radius: 12px; color: var(--muted);
}
.goal-link:hover { background: var(--surface); color: var(--ink); }
.goal-link.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.goal-ring {
  width: 26px; height: 26px; flex: 0 0 auto;
  transform: rotate(-90deg);
  overflow: visible;
}
.goal-ring-track { fill: none; stroke: color-mix(in srgb, var(--faint) 15%, transparent); stroke-width: 5; }
.goal-ring-fill {
  fill: none; stroke-width: 5; stroke-linecap: round;
  transition: stroke-dashoffset .45s ease;
}
.goal-link:hover .goal-ring-track,
.goal-link.active .goal-ring-track { stroke: color-mix(in srgb, var(--faint) 25%, transparent); }
.goal-link .label {
  min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: .8rem; line-height: 1.28;
}
.goal-link .pct {
  font-size: .73rem; color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums;
  align-self: center;
}
.goal-link.active .pct { color: var(--muted); }

.sidebar .new-goal {
  width: 100%; justify-content: center; border-style: dashed;
  background: transparent; color: var(--muted);
}
.sidebar .new-goal:hover { background: var(--surface); color: var(--ink); }

.sidebar .spacer { flex: 1 1 auto; min-height: 8px; }
.side-footer {
  display: flex; flex-direction: column; gap: 7px;
  padding: 13px 8px 2px; border-top: 1px solid var(--line);
  color: var(--faint); font-size: .72rem;
}
.app-version { color: var(--faint); font-size: .64rem; letter-spacing: .04em; }

/* ---------- Топбар ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h); padding: 0 28px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px);
}
.menu-btn { display: none; }
.crumb {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;
  color: var(--faint); font-size: .86rem;
}
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--ink); }
.crumb .current {
  color: var(--ink); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb .sep { color: var(--faint); }
.top-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.top-actions .btn { margin-left: 4px; }
.top-actions .btn-label { display: inline; }

/* ---------- Заголовки страниц ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 26px; margin-bottom: 26px;
}
.page-head .btn { margin-bottom: 5px; flex: 0 0 auto; }
.eyebrow {
  margin: 0 0 10px; color: var(--faint);
  font-size: .68rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase;
}
.display {
  margin: 0; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.9rem, 3.1vw, 2.85rem); line-height: 1.08; letter-spacing: -.025em;
}

.section-head {
  display: flex; align-items: center; gap: 10px; margin: 34px 0 14px;
}
.category-toggle {
  width: 24px; height: 24px; flex: 0 0 auto;
  display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--faint);
}
.category-toggle:hover { background: var(--surface-3); color: var(--ink); }
.category-toggle .icon { transition: transform .15s; }
.category-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }
.section-head h2 {
  margin: 0; font-family: var(--font-display); font-size: 1.35rem; letter-spacing: -.01em;
}
.section-head h2[data-action] { cursor: pointer; }
.section-head h2[data-action]:hover { color: var(--primary); }
.section-head p { margin: 0; color: var(--faint); font-size: .78rem; }

/* ---------- Панели и герой ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}

.hero-grid {
  display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); gap: 18px;
}

.progress-hero {
  padding: 26px; display: flex; align-items: center; gap: 28px;
}
.ring {
  --p: 0;
  width: 152px; height: 152px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--progress-color, var(--primary)) calc(var(--p) * 1%), var(--ring-track) 0);
  display: grid; place-items: center; position: relative;
  box-shadow: 0 0 32px -14px color-mix(in srgb, var(--progress-color, var(--primary)) 55%, transparent);
}
.ring::before {
  content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface);
}
.ring-inner { position: relative; text-align: center; display: flex; flex-direction: column; gap: 3px; }
.ring-inner strong {
  font-family: var(--font-display); font-size: 2.15rem; line-height: 1; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  color: var(--progress-color, var(--ink));
}
.ring-inner strong small { font-family: var(--font-ui); font-size: .85rem; font-weight: 600; color: var(--muted); }
.ring-inner span {
  color: var(--faint); font-size: .6rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}
.hero-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 13px; }
.hero-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-title h2 { margin: 0; font-size: 1.08rem; font-weight: 650; letter-spacing: -.01em; }
.hero-numbers {
  min-width: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px;
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat span {
  color: var(--faint); font-size: .66rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
}
.stat strong { font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; }

.chart-panel { padding: 23px 24px 17px; display: flex; flex-direction: column; min-width: 0; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.chart-head h2 { margin: 0; font-size: 1rem; font-weight: 650; letter-spacing: -.01em; }
.chart-head p { margin: 3px 0 0; color: var(--faint); font-size: .74rem; }
.chart-badge {
  display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
  padding: 5px 10px; border-radius: 999px;
  background: var(--warning-soft); color: var(--warning-ink);
  font-size: .69rem; font-weight: 700; white-space: nowrap;
}
.chart {
  display: flex; align-items: flex-end; gap: 5px;
  height: 108px; margin-top: auto; padding-top: 12px;
}
.chart-col {
  flex: 1 1 0; min-width: 10px; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px;
}
.chart-val { height: 10px; color: var(--faint); font-size: .58rem; line-height: 1; }
.chart-bar {
  width: 100%; max-width: 22px; min-height: 3px; border-radius: 6px 6px 3px 3px;
  background: var(--surface-3); transition: height .35s ease;
}
.chart-bar.has {
  background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary) 62%, transparent));
}
.chart-col.today .chart-bar { outline: 2px solid color-mix(in srgb, var(--primary) 28%, transparent); outline-offset: 2px; }
.chart-label { color: var(--faint); font-size: .58rem; text-transform: lowercase; white-space: nowrap; }
.chart-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-top: 10px; color: var(--faint); font-size: .7rem;
}

/* ---------- Карточки целей ---------- */
.goal-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
}
.goal-card {
  --accent-ink: color-mix(in srgb, var(--goal-accent, var(--primary)) 78%, #101410);
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  padding: 20px 20px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); color: var(--ink);
  transition: transform .15s, box-shadow .15s;
}
.goal-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent-ink); opacity: .9;
}
.goal-card:hover {
  transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow);
}
.goal-card.is-complete { background: color-mix(in srgb, var(--success-soft) 35%, var(--surface)); }
.goal-card header { display: flex; align-items: center; gap: 8px; min-height: 24px; margin-bottom: 10px; }
.goal-percent {
  margin-left: auto; font-size: 1rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.done-badge {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  color: var(--success); background: var(--success-soft);
  font-size: .63rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.goal-card h3 {
  margin: 0 0 12px; font-size: .96rem; font-weight: 650; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.7em;
}
.bar { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--progress-color, var(--goal-accent, var(--primary))) 55%, var(--surface)),
    var(--progress-color, var(--goal-accent, var(--primary))));
  transition: width .65s cubic-bezier(.22, 1, .36, 1);
}
.goal-card .bar { height: 8px; }
.goal-meta { margin: 8px 0 0; color: var(--faint); font-size: .73rem; font-variant-numeric: tabular-nums; }
.goal-next {
  display: flex; gap: 6px; margin: 10px 0 0; min-width: 0;
  color: var(--ink-soft); font-size: .78rem;
}
.goal-next span { flex: 0 0 auto; color: var(--faint); }
.goal-next em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-card footer {
  margin-top: auto; padding-top: 13px; display: flex; align-items: center; gap: 8px;
}
.open-hint {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  color: var(--faint); font-size: .7rem; transition: transform .15s;
}
.goal-card:hover .open-hint { color: var(--primary); transform: translateX(2px); }

/* ---------- Выполненные цели: карточки-награды ---------- */
.completed-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
}
.completed-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 26px 20px 18px;
  border: 1px solid color-mix(in srgb, var(--gold) 38%, var(--line));
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% -20%, color-mix(in srgb, var(--gold) 24%, transparent), transparent 58%),
    linear-gradient(155deg, color-mix(in srgb, var(--gold-soft) 45%, var(--surface)), var(--surface) 58%);
  box-shadow: var(--shadow-sm); color: var(--ink);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.completed-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--gold) 45%, transparent) 1px, transparent 1.6px);
  background-size: 18px 18px;
  opacity: .22;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 70%);
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}
.completed-card::after {
  content: ""; position: absolute; inset: 8px; z-index: -1;
  border: 1px solid color-mix(in srgb, var(--gold) 26%, transparent);
  border-radius: calc(var(--radius) - 8px);
  pointer-events: none;
}
.completed-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--gold) 58%, var(--line));
}
.completed-ribbon {
  position: absolute; top: 13px; right: 13px;
  padding: 3px 9px; border-radius: 999px;
  color: var(--gold-ink); background: color-mix(in srgb, var(--gold) 18%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  font-size: .64rem; font-weight: 800; letter-spacing: .04em;
}
.completed-medal {
  width: 88px; height: 88px; display: grid; place-items: center;
  margin: 1px 0 5px; color: var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--gold) 20%, transparent), transparent 68%);
  filter: drop-shadow(0 7px 14px color-mix(in srgb, var(--gold) 26%, transparent));
}
.medal-svg { width: 64px; height: 64px; flex: 0 0 auto; }
.completed-medal .medal-svg { width: 78px; height: 78px; }
.completed-kicker {
  color: var(--gold-ink); font-size: .61rem; font-weight: 800;
  letter-spacing: .15em; text-transform: uppercase;
}
.completed-card h3 {
  margin: 5px 0 0; font-size: 1rem; font-weight: 650; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  max-width: 26ch;
}
.completed-meta { margin: 6px 0 0; color: var(--muted); font-size: .73rem; }
.completed-open {
  margin-top: 13px; color: var(--faint); font-size: .7rem;
  display: inline-flex; align-items: center; gap: 4px;
}
.completed-card:hover .completed-open { color: var(--gold-ink); }

.completed-head h2,
.archive-head h2 { display: flex; align-items: center; gap: 7px; }
.completed-head h2 .medal-svg { width: 22px; height: 22px; color: var(--gold); }
.archive-head h2 .icon { color: var(--faint); }
.completed-head p { color: var(--gold-ink); }

/* ---------- Архив ---------- */
.archive-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
}
.archive-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 17px 14px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 65%, var(--surface));
  color: var(--muted);
}
.archive-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.archive-icon { display: inline-flex; color: var(--faint); }
.archive-icon .icon { width: 18px; height: 18px; }
.archive-percent { font-size: .88rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.archive-title {
  color: var(--ink-soft); font-size: .88rem; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.archive-title:hover { color: var(--ink); }
.archive-meta { margin: 0; color: var(--faint); font-size: .7rem; }
.archive-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.btn-sm { padding: 6px 11px; font-size: .73rem; }
.archive-actions .btn-sm { padding: 6px 10px; }

.category-empty {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 17px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  color: var(--muted);
}
.category-empty-icon {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--faint);
}
.category-empty-icon .icon { width: 18px; height: 18px; }
.category-empty-icon .medal-svg { width: 24px; height: 24px; color: var(--gold); }
.category-empty > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.category-empty strong { color: var(--ink-soft); font-size: .82rem; font-weight: 600; }
.category-empty span { color: var(--faint); font-size: .74rem; }
.completed-empty .category-empty-icon {
  background: color-mix(in srgb, var(--gold-soft) 55%, var(--surface));
  border-color: color-mix(in srgb, var(--gold) 30%, var(--line));
}

.empty.compact { padding: 28px 20px; border-style: dashed; background: transparent; }

/* ---------- Чипы ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  font-size: .67rem; font-weight: 500; white-space: nowrap;
}
.chip.warn { color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning) 28%, transparent); background: var(--warning-soft); }
.chip.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 28%, transparent); background: var(--success-soft); }
.chip.closed { color: var(--faint); background: transparent; }
.chip.note { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 22%, transparent); background: var(--primary-soft); }
.chip.next { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 24%, transparent); background: var(--primary-soft); max-width: 100%; }
.chip.next .chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .icon { width: 13px; height: 13px; }
.chip.section-ref { color: var(--faint); background: transparent; padding: 1px 7px; }
.chip.subtask-ref { max-width: min(100%, 320px); color: var(--muted); background: var(--surface); }
.chip.subtask-ref .chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.archive-chip { color: var(--faint); background: var(--surface-2); }
.chip.archive-chip .icon { width: 12px; height: 12px; }

/* ---------- Страница цели ---------- */
.goal-head { margin-bottom: 22px; }
.goal-title-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 22px;
}
.goal-title-main { min-width: 0; }
.goal-title-row h1 { overflow-wrap: anywhere; }
.goal-title-row .btn { flex: 0 0 auto; margin-top: 3px; }
.goal-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; flex: 0 0 auto; }
.goal-actions .btn { margin-top: 0; }
.archive-action { color: var(--faint); }
.archive-action:hover { color: var(--ink); }
.archived-banner {
  display: flex; align-items: center; gap: 11px;
  margin: 0 0 16px; padding: 11px 14px;
  border: 1px dashed var(--line-strong); border-radius: 14px;
  background: var(--surface-2); color: var(--muted);
}
.archived-banner > .icon { color: var(--faint); flex: 0 0 auto; }
.archived-banner > div { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.archived-banner strong { color: var(--ink-soft); font-size: .82rem; }
.archived-banner span { color: var(--faint); font-size: .72rem; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.goal-desc {
  margin: 14px 0 0; max-width: 82ch; color: var(--muted);
  font-size: .88rem; line-height: 1.62; white-space: pre-line;
}

/* ---------- Прогресс: закреплённая панель ---------- */
.dock-sentinel { height: 1px; }
.goal-dock {
  position: sticky; top: var(--topbar-h); z-index: 22;
  margin: 0 -10px 4px; padding: 0 10px;
  border-radius: 0 0 18px 18px;
  transition: box-shadow .18s ease;
}
.goal-dock.is-stuck {
  background: color-mix(in srgb, var(--bg) 91%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: 0 22px 34px -34px rgba(20, 24, 18, .55);
  padding-top: 8px;
  padding-bottom: 2px;
}
.goal-dock .progress-panel { margin-bottom: 0; }
.goal-dock .toolbar { position: static; top: auto; z-index: auto; background: transparent; backdrop-filter: none; padding: 10px 0 0; margin-bottom: 0; }

.progress-panel {
  padding: 22px 24px;
  border-color: color-mix(in srgb, var(--progress-color, var(--primary)) 22%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--progress-color, var(--primary)) 6%, var(--surface)), var(--surface) 55%);
  transition: padding .18s ease, border-radius .18s ease;
}
.progress-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.progress-value {
  font-family: var(--font-display); font-size: 2.25rem; line-height: 1;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  color: var(--progress-color, var(--ink));
}
.progress-value small { font-family: var(--font-ui); font-size: .9rem; font-weight: 600; color: var(--muted); }
.progress-value.is-updating { animation: progress-pop .55s ease-out; }
.progress-top .progress-meta { color: var(--muted); font-size: .83rem; }
.progress-state {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--progress-color, var(--primary)) 26%, var(--line));
  background: color-mix(in srgb, var(--progress-color, var(--primary)) 10%, var(--surface));
  color: var(--ink-soft); font-size: .68rem; font-weight: 600;
}
.progress-state::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--progress-color, var(--primary));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--progress-color, var(--primary)) 14%, transparent);
}
.progress-panel .bar {
  margin-top: 13px; height: 18px;
  background: var(--surface-3);
  box-shadow: inset 0 1px 3px rgba(25, 30, 22, .09);
}
.progress-panel .bar i {
  position: relative; overflow: hidden;
  border-radius: 99px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--progress-color, var(--primary)) 52%, var(--surface)),
    var(--progress-color, var(--primary)));
  box-shadow: 0 0 18px color-mix(in srgb, var(--progress-color, var(--primary)) 38%, transparent);
  transition: width .75s cubic-bezier(.22, 1, .36, 1);
}
.progress-panel .bar i.is-growing::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 20%, rgba(255, 255, 255, .45) 50%, transparent 80%);
  transform: translateX(-110%);
  animation: progress-shine .9s ease-out;
}
.progress-panel.is-complete { animation: complete-glow 1.4s ease-out; }
.progress-foot { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.goal-dock.is-stuck .progress-panel { padding: 10px 16px; }
.goal-dock.is-stuck .progress-value { font-size: 1.5rem; }
.goal-dock.is-stuck .progress-panel .bar { height: 12px; margin-top: 8px; }
.goal-dock.is-stuck .progress-foot { display: none; }
.goal-dock.is-stuck .toolbar { padding-top: 8px; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0 0;
}
.segmented {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 7px 11px;
  background: transparent; color: var(--muted); font-size: .76rem; font-weight: 600;
}
.seg-btn span { color: var(--faint); font-size: .66rem; font-variant-numeric: tabular-nums; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-btn.active span { color: var(--muted); }

.search { position: relative; display: flex; align-items: center; flex: 1 1 210px; min-width: 160px; }
.search .icon { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.search input {
  width: 100%; padding: 9px 38px 9px 38px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink); font-size: .8rem; outline: none;
  transition: box-shadow .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
.search kbd {
  position: absolute; right: 12px; padding: 1px 6px;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--surface-2); color: var(--faint);
  font-family: var(--font-ui); font-size: .65rem; line-height: 1.4;
}
.result-count { color: var(--faint); font-size: .71rem; white-space: nowrap; }

@keyframes progress-pop {
  0% { opacity: .35; transform: translateY(3px) scale(.97); }
  40% { opacity: 1; transform: translateY(0) scale(1.05); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes progress-shine {
  to { transform: translateX(110%); }
}
@keyframes complete-glow {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--progress-color, var(--success)) 34%, transparent); }
  100% { box-shadow: 0 0 0 22px transparent; }
}

/* ---------- Задачи ---------- */
.task-panel { padding: 4px 0; overflow: hidden; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row {
  --base-indent: 18px;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 18px 10px calc(var(--base-indent) + var(--indent-extra, 0px));
  border-top: 1px solid var(--line);
  transition: opacity .15s;
  scroll-margin-top: calc(var(--topbar-h) + 180px);
}
.task-row:first-child { border-top: 0; }
.task-row:hover { background: var(--surface-2); }
.task-row.in-section { --base-indent: 45px; }
.task-row.is-done { color: var(--muted); }
.task-row.is-overdue .task-title { color: var(--danger); }
.task-row.is-done .task-title {
  --strike-color: color-mix(in srgb, var(--faint) 65%, transparent);
  text-decoration: none;
  background-image: linear-gradient(
    transparent calc(50% + .18em - .5px),
    var(--strike-color) calc(50% + .18em - .5px),
    var(--strike-color) calc(50% + .18em + .5px),
    transparent calc(50% + .18em + .5px)
  );
  background-size: 100% 1.45em;
  background-position: 0 0;
  background-repeat: repeat-y;
}
.task-row.is-busy { opacity: .55; pointer-events: none; }
.task-row.is-flash { animation: flash 1.4s ease-out; }
.task-row.is-subtask { background: color-mix(in srgb, var(--surface-2) 52%, var(--surface)); }
.task-row.is-subtask:hover { background: var(--surface-2); }

.check {
  flex: 0 0 auto; width: 28px; height: 28px; margin-top: 1px; padding: 0;
  border: 1.7px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: transparent;
  display: grid; place-items: center; position: relative;
  transition: transform .1s;
}
.check:hover { border-color: var(--primary); }
.check:active { transform: scale(.9); }
.check svg { width: 17px; height: 17px; }
.check.checked { background: var(--success); border-color: var(--success); color: #fff; }
.check.checked:hover { background: color-mix(in srgb, var(--success) 88%, #000); }
.check.is-popping { animation: check-pop .36s cubic-bezier(.34, 1.56, .64, 1); }
.check.is-popping .icon { animation: check-mark .3s ease-out; }
.check.is-popping::after {
  content: ""; position: absolute; inset: -6px; border-radius: 13px;
  border: 2px solid color-mix(in srgb, var(--success) 48%, transparent);
  pointer-events: none; opacity: 0;
  animation: check-ripple .52s ease-out;
}

@keyframes check-pop {
  0% { transform: scale(.82); }
  55% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
@keyframes check-mark {
  0% { transform: scale(.3); opacity: .2; }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes check-ripple {
  0% { opacity: .65; transform: scale(.55); }
  100% { opacity: 0; transform: scale(1.3); }
}

.task-body { flex: 1 1 auto; min-width: 0; }
.task-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.subtask-mark { color: var(--faint); font-size: .82rem; line-height: 1.4; flex: 0 0 auto; }
.task-num {
  flex: 0 0 auto; min-width: 2.1em; color: var(--faint);
  font-size: .66rem; font-variant-numeric: tabular-nums;
}
.task-title-wrap {
  min-width: 0;
  font-size: .865rem; line-height: 1.45;
}
.task-title {
  padding: 0 2px; border-radius: 4px;
  font-size: .865rem; line-height: 1.45; word-break: break-word;
  cursor: text;
}
.task-title:hover { background-color: var(--surface-3); }
.task-title-input {
  flex: 1 1 260px; min-width: 0;
  padding: 3px 8px; border: 1px solid var(--primary); border-radius: 7px;
  background: var(--surface); color: var(--ink); font-size: .865rem; outline: none;
}
.task-note {
  margin: 5px 0 0; padding-left: 10px;
  border-left: 2px solid var(--line);
  color: var(--muted); font-size: .775rem; line-height: 1.55; white-space: pre-line;
}
.task-side { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.task-actions {
  display: flex; align-items: center; gap: 1px; flex: 0 0 auto;
  opacity: 0; transition: opacity .12s;
}
.task-row:hover .task-actions,
.task-row:focus-within .task-actions { opacity: 1; }
.task-actions .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.task-actions .icon-btn .icon { width: 16px; height: 16px; }
.subtask-btn {
  width: 28px; height: 28px; border-radius: 8px;
  color: var(--primary); background: transparent;
}
.subtask-btn:hover { background: var(--primary-soft); color: var(--primary-hover); }
.subtask-btn .icon { width: 15px; height: 15px; }
.icon-btn.is-note { color: var(--primary); }
.icon-btn.is-danger:hover { color: var(--danger); background: var(--danger-soft); }

.task-row.is-section {
  --base-indent: 18px;
  margin-top: 12px; padding-top: 12px; padding-bottom: 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}
.task-row.is-section:first-child { margin-top: 0; }
.task-row.is-section .task-title { font-weight: 700; font-size: .89rem; }
.task-row.is-section .task-title-wrap { font-size: .89rem; }
.task-row.is-section .task-num { color: var(--muted); }
.section-toggle { width: 22px; height: 24px; border: 0; background: transparent; color: var(--faint); display: grid; place-items: center; padding: 0; margin-top: 1px; border-radius: 5px; }
.section-toggle:hover { background: var(--surface-3); color: var(--ink); }
.section-toggle .icon { transition: transform .15s; }
.section-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }
.section-stat { color: var(--faint); font-size: .67rem; font-variant-numeric: tabular-nums; }

.note-editor { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.note-editor textarea {
  width: 100%; min-height: 66px; resize: vertical;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: .8rem; line-height: 1.5; outline: none;
}
.note-editor textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent); }
.note-editor .note-actions { display: flex; gap: 6px; }
.note-editor .note-actions .btn { padding: 6px 12px; font-size: .74rem; }

.subtask-form {
  margin-top: 9px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface-2);
}
.subtask-head {
  display: flex; align-items: center; gap: 5px; margin-bottom: 7px;
  color: var(--faint); font-size: .68rem;
}
.subtask-head .icon { color: var(--primary); }
.subtask-row { display: flex; align-items: center; gap: 6px; }
.subtask-row input {
  flex: 1 1 auto; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: .8rem; outline: none;
}
.subtask-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent);
}
.subtask-row .btn { padding: 7px 12px; font-size: .74rem; }

.add-hint {
  display: flex; align-items: center; gap: 6px;
  margin: 8px 2px 0; color: var(--faint); font-size: .72rem;
}
.add-hint .icon { color: var(--primary); }


.add-task { display: flex; gap: 9px; margin-top: 15px; }
.quick-add { margin: 9px 0 0; }
.add-task.quick-add input {
  padding: 9px 13px; border-style: solid; border-color: var(--line); border-radius: 12px;
}
.add-task.quick-add input:focus { border-color: var(--primary); }
.add-task.quick-add .btn { padding: 8px 14px; }
.add-task input {
  flex: 1 1 auto; min-width: 0; padding: 11px 15px;
  border: 1px dashed var(--line-strong); border-radius: 14px;
  background: var(--surface); color: var(--ink); font-size: .85rem; outline: none;
  transition: border-style .15s, box-shadow .15s;
}
.add-task input::placeholder { color: var(--faint); }
.add-task input:focus {
  border-style: solid; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent);
}
.add-task .btn { padding-left: 16px; padding-right: 18px; }

.empty {
  padding: 52px 22px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--muted);
}
.empty h2, .empty h3 { margin: 0 0 7px; font-family: var(--font-display); color: var(--ink); font-size: 1.2rem; }
.empty p { margin: 0 0 16px; font-size: .86rem; }
.empty .btn { margin-top: 2px; }
.empty-item { list-style: none; }
.task-panel .empty { border: 0; background: transparent; padding: 34px 18px; }

.loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 40vh; color: var(--faint); font-size: .86rem;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}

/* ---------- Диалоги ---------- */
.dialog {
  width: min(570px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--line); border-radius: 22px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.dialog::backdrop {
  background: rgba(18, 22, 16, .42);
  backdrop-filter: blur(4px);
}
.dialog form { display: flex; flex-direction: column; }
.dialog-head {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 24px 0;
}
.dialog-head h2 {
  margin: 0; flex: 1; font-family: var(--font-display);
  font-size: 1.35rem; letter-spacing: -.01em;
}
.dialog-head .icon-btn { font-size: 1.3rem; width: 34px; height: 34px; line-height: 1; }
.dialog-body { display: flex; flex-direction: column; gap: 14px; padding: 20px 24px 8px; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 18px 24px 22px; }
.spacer { flex: 1 1 auto; }
.dialog-small { width: min(440px, calc(100vw - 32px)); padding: 24px; }
.dialog-small h2 { margin: 0 0 8px; font-family: var(--font-display); font-size: 1.3rem; }
.dialog-small .dialog-foot { padding: 20px 0 0; }
.confirm-text { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field[hidden] { display: none; }
.field > span {
  color: var(--faint); font-size: .67rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface-2); color: var(--ink); font-size: .86rem; outline: none;
  transition: box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  background: var(--surface); border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent);
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field-row { display: flex; gap: 12px; }
.form-error {
  margin: 0; padding: 9px 12px; border-radius: 9px;
  background: var(--danger-soft); color: var(--danger); font-size: .78rem;
}
.form-error.is-info { background: var(--success-soft); color: var(--success); }

/* ---------- Тосты ---------- */
.toasts {
  position: fixed; right: 22px; bottom: 22px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  padding: 11px 14px; border: 1px solid var(--line); border-left: 3px solid var(--success);
  border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); font-size: .8rem; line-height: 1.4;
  animation: toast-in .2s ease-out;
}
.toast.err { border-left-color: var(--danger); }

/* ---------- Служебное ---------- */
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(18, 22, 16, .38); }
.noscript { padding: 30px; text-align: center; }
body.drawer-open { overflow: hidden; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flash {
  0% { background: color-mix(in srgb, var(--primary) 18%, var(--surface)); }
  100% { background: transparent; }
}

/* ---------- Адаптив ---------- */
@media (max-width: 1120px) {
  .goal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .completed-grid, .archive-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: 1fr; }
  .chart { height: 96px; }
}

@media (max-width: 920px) {
  :root { --sidebar-w: 0px; --topbar-h: 62px; }
  .shell { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    width: 304px; height: 100dvh; transform: translateX(-104%);
    transition: transform .22s ease-out;
    background: var(--bg); box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 14px; gap: 7px; }
  .view { padding: 24px 18px 72px; }
  .goal-title-row { flex-direction: column; gap: 12px; }
  .goal-title-row > .btn { align-self: flex-start; }
  .goal-actions { width: 100%; }
  .task-actions { opacity: 1; }
}

@media (max-width: 640px) {
  :root { --topbar-h: 58px; }
  .top-actions .btn-label { display: none; }
  .top-actions .btn { padding: 9px 11px; }
  .top-actions { gap: 1px; }
  .icon-btn { width: 34px; height: 34px; }
  .view { padding: 20px 14px 64px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
  .page-head .btn { margin-bottom: 0; }
  .display { font-size: 1.9rem; }
  .progress-hero { flex-direction: column; align-items: flex-start; gap: 22px; padding: 22px; }
  .hero-numbers { width: 100%; gap: 12px 18px; }
  .chart-panel { padding: 20px 18px 15px; }
  .goal-grid { grid-template-columns: 1fr; gap: 12px; }
  .completed-grid, .archive-grid { grid-template-columns: 1fr; gap: 12px; }
  .section-head { margin-top: 26px; }
  .archived-banner { flex-wrap: wrap; }
  .archived-banner > div { flex-basis: calc(100% - 32px); }
  .archived-banner .btn { width: 100%; justify-content: center; }
  .goal-dock { margin-left: -6px; margin-right: -6px; padding-left: 6px; padding-right: 6px; }
  .goal-dock .toolbar { gap: 8px; padding-top: 9px; }
  .goal-dock.is-stuck .progress-panel { padding: 9px 13px; }
  .goal-dock.is-stuck .progress-value { font-size: 1.35rem; }
  .progress-panel { padding: 18px 18px; }
  .progress-value { font-size: 2rem; }
  .progress-panel .bar { height: 16px; }
  .segmented { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .seg-btn { flex: 1 0 auto; justify-content: center; }
  .search { flex-basis: 100%; }
  .result-count { margin-left: 2px; }
  .task-row {
    --base-indent: 12px;
    padding: 10px 12px 10px calc(var(--base-indent) + var(--indent-extra, 0px));
    flex-wrap: wrap; gap: 9px;
    scroll-margin-top: calc(var(--topbar-h) + 220px);
  }
  .task-row.in-section { --base-indent: 32px; }
  .task-row.is-section .task-body { flex-basis: calc(100% - 70px); }
  .task-body { flex: 1 1 calc(100% - 38px); }
  .task-side { width: 100%; justify-content: flex-end; padding-left: 33px; margin-top: 1px; }
  .task-actions { width: auto; padding-left: 0; }
  .task-actions .icon-btn, .subtask-btn { width: 32px; height: 32px; }
  .subtask-row { flex-wrap: wrap; }
  .subtask-row input { flex-basis: 100%; }
  .subtask-row .btn { flex: 1 1 auto; justify-content: center; }
  .add-task { flex-direction: column; }
  .add-task .btn { width: 100%; }
  .quick-add { flex-direction: row; margin-top: 8px; }
  .quick-add .btn { width: auto; padding: 8px 10px; }
  .quick-add .btn-label { display: none; }
  .field-row { flex-direction: column; gap: 12px; }
  .dialog { width: calc(100vw - 20px); border-radius: 18px; }
  .dialog-head, .dialog-body, .dialog-foot { padding-left: 18px; padding-right: 18px; }
  .dialog-foot { flex-wrap: wrap; }
  .toasts { right: 12px; bottom: 12px; }
  .auth-screen { padding: 14px; }
  .auth-card { padding: 24px; border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (hover: none) {
  .task-actions { opacity: 1; }
}

/* В тёмной теме акцентные цвета целей осветляются, чтобы оставаться читаемыми. */
html[data-theme="dark"] .goal-card,
html[data-theme="dark"] .goal-link {
  --accent-ink: color-mix(in srgb, var(--goal-accent) 55%, #ffffff);
}
html[data-theme="dark"] .overview-link.active .pct { color: var(--ink-soft); }
html[data-theme="dark"] .chip.next,
html[data-theme="dark"] .chip.note { color: color-mix(in srgb, var(--primary) 45%, #ffffff); }

/* Переключение темы не анимируем: иначе фон и текст на миг расходятся по контрасту. */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}
