:root {
  --bg: #0d0f14;
  --surface: #161922;
  --surface-2: #1d2130;
  --surface-3: #262b3d;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #eef0f6;
  --muted: #8b91a5;
  --faint: #5d6377;
  --accent: #7d8cff;
  --accent-strong: #6474ff;
  --accent-soft: rgba(125, 140, 255, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --hard: #f87171;
  --hard-soft: rgba(248, 113, 113, 0.14);
  --radius: 16px;
  --radius-sm: 11px;
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --tabbar-h: 62px;
  --vh: var(--tg-viewport-height, 100vh);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ───────── шапка ───────── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(13, 15, 20, 0.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.project-chip {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  text-align: left;
}
.project-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); flex: none; }
.project-name { flex: 1; min-width: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { width: 18px; height: 18px; color: var(--muted); }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.icon-btn:active, .project-chip:active { background: var(--surface-2); }

/* ───────── контент ───────── */
.view { padding: 14px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 90px); max-width: 680px; margin: 0 auto; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 22px 2px 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.center { text-align: center; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}

/* ───────── кнопки ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px; border-radius: 13px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  font-weight: 600; white-space: nowrap;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent-strong); border-color: transparent; color: #fff; }
.btn.primary:active { background: #5565f0; }
.btn.ok { background: var(--ok); border-color: transparent; color: #05261a; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--hard); background: transparent; border-color: rgba(248, 113, 113, 0.28); }
.btn.small { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 14px; }

/* ───────── карточка прогноза ───────── */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(140deg, #1d2238 0%, #161922 62%);
  border: 1px solid var(--border); border-radius: 20px; padding: 18px 18px 16px;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -60px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(125, 140, 255, 0.22), transparent 70%);
  pointer-events: none;
}
.hero-label { font-size: 13px; color: var(--muted); }
.hero-main { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 2px; }
.hero-num { font-size: 44px; line-height: 1; font-weight: 750; letter-spacing: -0.02em; }
.hero-unit { font-size: 17px; font-weight: 600; color: var(--muted); }
.hero-sub { font-size: 14px; color: var(--muted); }
.hero-sub b { color: var(--text); font-weight: 600; }
.progress { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin-top: 14px; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); }
.hero-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }

.banner {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--accent-soft); border: 1px solid rgba(125, 140, 255, 0.25); font-size: 14px;
}
.spinner {
  width: 18px; height: 18px; flex: none; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.btn.primary .spinner { border-color: rgba(255, 255, 255, 0.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── дни и задачи ───────── */
.day { margin-top: 22px; }
.sortbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; }
.sortbar-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sortbar-label svg { width: 16px; height: 16px; }
.sortbar-label { flex: none; }
.sortbar .select { flex: 1 1 0; min-width: 0; max-width: 230px; text-overflow: ellipsis; height: 36px; padding: 0 34px 0 12px; font-size: 14px; border-radius: 10px; background-position: right 10px center; }
.task.sorted { padding-right: 8px; }
.added-at { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--faint); }
.day-head { display: flex; align-items: center; gap: 10px; margin: 0 2px 9px; }
.day-name { font-size: 17px; font-weight: 700; }
.day-date { font-size: 13px; color: var(--muted); }
.day-load { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { width: 46px; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 5px; background: var(--ok); }
.meter.full > i { background: var(--warn); }
.meter.over > i { background: var(--hard); }
.day-list { display: flex; flex-direction: column; gap: 8px; min-height: 4px; }
.day-done { font-size: 13px; color: var(--muted); margin: 8px 2px 0; display: flex; align-items: center; gap: 6px; }
.day-done svg { width: 15px; height: 15px; color: var(--ok); }

.task {
  display: flex; align-items: center; gap: 12px;
  min-height: 62px; padding: 10px 6px 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.task:active:not(.dragging) { background: var(--surface-2); }
.task.doing { border-color: rgba(125, 140, 255, 0.45); background: linear-gradient(90deg, rgba(125, 140, 255, 0.1), var(--surface) 55%); }
.check {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 2px solid var(--border-strong); display: grid; place-items: center; color: transparent;
}
.check svg { width: 15px; height: 15px; stroke-width: 3; }
.check:active { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.task-meta svg { width: 13px; height: 13px; }
.tag { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; font-weight: 600; font-size: 11.5px; }
.badge.doing { background: var(--accent-soft); color: var(--accent); }
.badge.attach { background: var(--warn-soft); color: var(--warn); }
.diff {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 6px;
  font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums;
}
.diff::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.diff.easy { color: var(--ok); background: var(--ok-soft); }
.diff.mid { color: var(--warn); background: var(--warn-soft); }
.diff.hard { color: var(--hard); background: var(--hard-soft); }
.task-copy {
  width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; color: var(--muted);
}
.task-copy:active { background: var(--surface-3); color: var(--text); }
.task-copy svg { width: 18px; height: 18px; }
.handle {
  width: 28px; height: 44px; flex: none; display: grid; place-items: center; color: var(--faint);
  touch-action: none; cursor: grab;
}
.handle svg { width: 18px; height: 18px; }

.task.dragging {
  position: fixed; z-index: 60; margin: 0; pointer-events: none;
  background: var(--surface-3); border-color: rgba(125, 140, 255, 0.5);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55); transform: scale(1.02);
}
.task-ph { border: 1.5px dashed rgba(125, 140, 255, 0.5); border-radius: 14px; background: var(--accent-soft); flex: none; }
.drop-zone { display: none; }
body.is-dragging .drop-zone {
  display: flex; flex-direction: column; justify-content: center; min-height: 62px; padding: 0 12px;
  border: 1.5px dashed var(--border-strong); border-radius: 14px; color: var(--faint); font-size: 13px; text-align: center;
}
body.is-dragging .drop-zone:has(.task-ph) { border-color: transparent; padding: 0; }
body.is-dragging .drop-zone:has(.task-ph) > span { display: none; }
body.is-dragging { user-select: none; -webkit-user-select: none; }

.cleared { text-align: center; padding: 22px 16px; }
.cleared-emoji { font-size: 34px; }
.cleared h3 { margin: 6px 0 4px; font-size: 17px; }
.cleared p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

.plan-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 26px; }

.empty { text-align: center; padding: 34px 18px; }
.empty-icon {
  width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.empty-icon svg { width: 30px; height: 30px; }
.empty h2 { margin: 0 0 6px; font-size: 20px; }
.empty p { margin: 0 auto 18px; color: var(--muted); max-width: 330px; }

/* ───────── формы ───────── */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 2px 6px; }
.input, .textarea, .select {
  width: 100%; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface-2); padding: 12px 13px; outline: none;
  transition: border-color 0.15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { resize: none; line-height: 1.5; min-height: 96px; display: block; }
.textarea.clamp { max-height: 112px; min-height: 0; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b91a5' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.title-input { font-size: 19px; font-weight: 700; line-height: 1.3; background: transparent; border-color: transparent; padding: 6px 2px; resize: none; display: block; overflow: hidden; }
.title-input:focus { background: var(--surface-2); padding: 6px 10px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

.compose { position: relative; }
.compose .textarea {
  min-height: max(260px, calc(var(--vh) - 360px));
  font-size: 16px; padding: 16px; border-radius: 18px; background: var(--surface);
}
.compose-meta { display: flex; justify-content: space-between; align-items: center; margin: 10px 2px 14px; font-size: 13px; color: var(--muted); }
.compose-target b { color: var(--text); }
.result-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.result-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; background: var(--surface-2); }
.result-item .task-body { font-size: 14px; }
.check-btn { margin-top: 8px; height: 42px; font-size: 14.5px; color: var(--muted); border-color: var(--border); }
.check-card { margin-top: 12px; }
.check-card p { margin: 6px 0 0; }
.check-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--ok); }
.check-head svg { width: 18px; height: 18px; }
.check-head.warn { color: var(--warn); }
.check-item { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.check-item blockquote { margin: 0 0 6px; padding: 8px 12px; border-left: 3px solid var(--warn); border-radius: 8px; background: var(--warn-soft); font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.check-item .link-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13.5px; }
.check-item .link-btn svg { width: 15px; height: 15px; }
.check-card > .btn { margin-top: 14px; }

.range-wrap { padding: 4px 2px; }
.range-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.range-value { font-size: 15px; font-weight: 700; }
input[type="range"] { width: 100%; height: 34px; background: transparent; -webkit-appearance: none; appearance: none; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--ok), var(--warn) 55%, var(--hard)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--ok), var(--warn) 55%, var(--hard)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff; }
input[type="range"].plain::-webkit-slider-runnable-track { background: var(--surface-3); }
input[type="range"].plain::-moz-range-track { background: var(--surface-3); }
.range-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.wd-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.wd-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px 9px 13px; border-radius: 13px; background: var(--surface); border: 1px solid var(--border); }
.wd-row.manual { border-color: rgba(125, 140, 255, 0.4); }
.wd-name { font-weight: 600; font-size: 14.5px; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.wd-trend { font-size: 11.5px; font-weight: 500; }
.wd-trend.down { color: var(--warn); }
.wd-trend.up { color: var(--ok); }
.wd-ctl { display: flex; align-items: center; gap: 6px; flex: none; }
.wd-btn { width: 32px; height: 32px; border-radius: 10px; background: var(--surface-3); font-size: 18px; line-height: 1; display: grid; place-items: center; }
.wd-btn:active { background: var(--accent-soft); }
.wd-val { min-width: 76px; text-align: center; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.wd-row:not(.manual) .wd-val { color: var(--muted); }
.wd-reset { height: 26px; padding: 0 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.range-scale.mid { position: relative; }
.range-scale.mid .mid-label { position: absolute; left: 50%; transform: translateX(-50%); }

.rate-big { text-align: center; margin: 10px 0 2px; }
.rate-num { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.rate-label { font-size: 15px; color: var(--muted); margin-top: 6px; min-height: 21px; }

.segmented { display: flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { flex: 1; height: 36px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.segmented button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.segmented svg { width: 16px; height: 16px; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 28px; background: var(--surface-3); transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + i { background: var(--accent-strong); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ───────── нижняя шторка ───────── */
.backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.55); animation: fade 0.2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  max-width: 680px; margin: 0 auto;
  max-height: calc(var(--vh) - 28px - var(--safe-top));
  display: flex; flex-direction: column;
  background: #12141b; border: 1px solid var(--border-strong); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  animation: slide-up 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.closing { animation: slide-down 0.2s ease forwards; }
.sheet-grip { width: 38px; height: 5px; border-radius: 5px; background: var(--border-strong); margin: 9px auto 2px; flex: none; }
.sheet-body { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 10px 18px calc(18px + var(--safe-bottom)); }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 19px; flex: 1; }
.sheet-close { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.sheet-close svg { width: 17px; height: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); font-size: 12.5px; color: var(--muted); max-width: 100%; }
.chip svg { width: 13px; height: 13px; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.sheet-section { margin-top: 18px; }
.sheet-section > .label { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 0 2px 7px; }
.prompt-box .textarea { min-height: 170px; font-size: 14.5px; }
.attach-box { margin-bottom: 10px; padding: 10px 12px 8px; border-radius: 14px; background: var(--warn-soft); border: 1px solid rgba(251, 191, 36, 0.35); }
.attach-box[hidden] { display: none; }
.attach-box .attach-title { font-size: 13px; font-weight: 600; color: var(--warn); margin-bottom: 2px; }
.attach-box .textarea { min-height: 44px; padding: 4px 0; border: 0; background: transparent; font-size: 14px; line-height: 1.45; }
.prompt-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.prompt-actions .btn { padding: 0 10px; min-width: 0; }
.prompt-actions .btn.primary { grid-column: 1 / -1; }
.move-row { display: grid; grid-template-columns: 1fr 46px 46px; gap: 8px; }
.move-row .btn { padding: 0; }
.pin-note { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.pin-note svg { width: 15px; height: 15px; }
.sheet-footer { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

.project-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 13px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.project-item.on { border-color: rgba(125, 140, 255, 0.5); background: linear-gradient(90deg, rgba(125, 140, 255, 0.1), var(--surface)); }
.project-item .grow { flex: 1; min-width: 0; }
.project-item .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.project-item .tick { color: var(--accent); }
.new-project { display: flex; gap: 8px; margin-top: 6px; }
.new-project .input { flex: 1; }

/* ───────── архив ───────── */
.arch-day { font-size: 13px; color: var(--muted); font-weight: 600; margin: 20px 2px 8px; }
.arch-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.arch-item .done-ic { width: 24px; height: 24px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; flex: none; }
.arch-item .done-ic svg { width: 14px; height: 14px; stroke-width: 3; }

/* ───────── статистика ───────── */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.tile-num { font-size: 26px; font-weight: 750; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.bars { position: relative; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; height: 130px; margin-top: 18px; }
.bar { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bar-col { position: relative; flex: 1; }
.bar-col > i { position: absolute; left: 0; right: 0; bottom: 0; min-height: 3px; border-radius: 5px 5px 2px 2px; background: var(--accent-strong); }
.bar.zero .bar-col > i { background: var(--surface-3); }
.bar.today .bar-col > i { background: var(--accent); }
.bar > span { font-size: 10.5px; line-height: 13px; color: var(--faint); text-align: center; white-space: nowrap; }
.cap-line { position: absolute; left: 0; right: 0; border-top: 1.5px dashed rgba(251, 191, 36, 0.6); pointer-events: none; }
.cap-line span { position: absolute; right: 0; top: -18px; font-size: 11px; color: var(--warn); }
.legend { display: flex; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.explain { font-size: 14px; color: var(--muted); line-height: 1.5; }
.explain b { color: var(--text); font-weight: 600; }

/* ───────── таббар, fab, тост ───────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: rgba(13, 15, 20, 0.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--faint); font-size: 11.5px; font-weight: 600; }
.tabbar button svg { width: 23px; height: 23px; }
.tabbar button.active { color: var(--accent); }
.fab {
  position: fixed; z-index: 31; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: var(--accent-strong); color: #fff; box-shadow: 0 10px 28px rgba(100, 116, 255, 0.4);
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
.fab:active { transform: scale(0.96); }
.fab.fab-chat { right: 86px; background: var(--surface-2); color: var(--accent); border: 1px solid var(--border-strong); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); }
.fab.fab-chat svg { stroke-width: 2; }
.chat-ico { width: 46px; height: 46px; background-color: currentColor; -webkit-mask: url(chat-icon.png?v=3) center / contain no-repeat; mask: url(chat-icon.png?v=3) center / contain no-repeat; }
.fab svg { transition: transform 0.18s ease; }
.fab.open svg { transform: rotate(45deg); }
.confirm { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, 0.6); animation: fade-in 0.15s ease; }
.confirm-box { width: 100%; max-width: 340px; padding: 20px 18px 16px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55); animation: fab-pop 0.16s ease; }
.confirm-box p { margin: 0 0 18px; font-size: 16px; line-height: 1.45; text-align: center; }
.confirm-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.danger-fill { background: var(--hard); border-color: transparent; color: #2a0909; }
.fab-shade { position: fixed; inset: 0; z-index: 31; background: rgba(0, 0, 0, 0.45); animation: fade-in 0.15s ease; }
.fab-shade[hidden], .fab-menu[hidden] { display: none; }
.fab-menu {
  position: fixed; z-index: 32; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 84px);
  display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  animation: fab-pop 0.16s ease;
}
.fab-item {
  display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 10px 18px 10px 14px;
  border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border-strong);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4); text-align: left; font-weight: 600; font-size: 15px;
}
.fab-item:active { transform: scale(0.98); background: var(--surface-3); }
.fab-item svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
.fab-item-text { display: flex; flex-direction: column; gap: 2px; }
.fab-item small { font-size: 11.5px; font-weight: 600; color: var(--ok); }
.fab-item[data-fab="auto"] { border-color: rgba(125, 140, 255, 0.45); }
@keyframes fab-pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ───────── чат с помощником ───────── */
.chat {
  position: fixed; left: 0; right: 0; top: 0; z-index: 60;
  height: var(--vh); max-width: 680px; margin: 0 auto;
  display: flex; flex-direction: column; background: var(--bg);
  animation: chat-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.chat-top {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  border-bottom: 1px solid var(--border); background: rgba(13, 15, 20, 0.94);
}
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-strong), #a78bfa); color: #fff;
  box-shadow: 0 6px 16px rgba(100, 116, 255, 0.35);
}
.chat-avatar svg { width: 19px; height: 19px; }
.chat-title-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.chat-title-text b { font-size: 15.5px; }
.chat-title-text span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; max-width: 86%; animation: msg-in 0.2s ease; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.ai { align-self: flex-start; }
.bubble { padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent-strong); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.ai .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg.ai.error .bubble { border-color: rgba(248, 113, 113, 0.35); }
.msg.ai.note .bubble { background: transparent; border-style: dashed; color: var(--muted); font-size: 14px; }
.bubble p { margin: 0; }
.bubble p + p, .bubble p + ul, .bubble ul + p { margin-top: 6px; }
.bubble ul { margin: 0; padding-left: 18px; }
.bubble li + li { margin-top: 3px; }
.msg-time { font-size: 11px; color: var(--faint); margin: 3px 6px 0; }
.chat-changes { margin-top: 6px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.chat-changes.undone { opacity: 0.55; }
.chat-changes.undone ul { text-decoration: line-through; }
.cc-head { display: flex; align-items: center; gap: 6px; font-weight: 650; color: var(--text); margin-bottom: 5px; }
.cc-head svg { width: 15px; height: 15px; color: var(--accent); }
.chat-changes ul { margin: 0; padding-left: 16px; }
.chat-changes li + li { margin-top: 2px; }
.cc-undo { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 10px; background: var(--surface-3); color: var(--text); font-weight: 600; font-size: 13px; }
.cc-undo svg { width: 15px; height: 15px; }
.cc-undone { margin-top: 6px; font-size: 12.5px; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
.chat-hello { margin: auto 0; text-align: center; padding: 10px 6px 4px; }
.chat-hello .chat-avatar { width: 58px; height: 58px; border-radius: 19px; margin: 0 auto 12px; }
.chat-hello .chat-avatar svg { width: 28px; height: 28px; }
.chat-hello h3 { margin: 0 0 6px; font-size: 19px; }
.chat-hello p { margin: 0 auto; max-width: 330px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.chat-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.chat-suggest button { padding: 9px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border-strong); font-size: 13.5px; text-align: left; }
.chat-suggest button:active { background: var(--surface-2); }
.chat-input {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--border); background: rgba(13, 15, 20, 0.96);
}
.chat-input textarea {
  flex: 1; min-height: 44px; max-height: 160px; resize: none; outline: none;
  padding: 11px 15px; border-radius: 22px; border: 1px solid var(--border-strong);
  background: var(--surface-2); font-size: 15.5px; line-height: 1.4;
}
.chat-input textarea:focus { border-color: var(--accent); }
.chat-send { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--accent-strong); color: #fff; transition: opacity 0.15s, transform 0.1s; }
.chat-send:disabled { opacity: 0.35; }
.chat-send:active:not(:disabled) { transform: scale(0.94); }
.chat-send svg { width: 21px; height: 21px; stroke-width: 2.4; }
@keyframes chat-in { from { opacity: 0; transform: translateY(18px); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes typing { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.toast {
  position: fixed; z-index: 90; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 14px;
  background: #262b3d; border: 1px solid var(--border-strong); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  font-size: 14px; animation: toast-in 0.22s ease;
}
.toast .msg { flex: 1; }
.toast button { color: var(--accent); font-weight: 700; }
.toast.error { border-color: rgba(248, 113, 113, 0.4); }

@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }
@keyframes slide-down { to { transform: translateY(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

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