:root {
  --bg: #121316;
  --card: #1E2026;
  --raised: #2A2D34;
  --line: #2A2D34;
  --border: #34373F;
  --text: #F2F3F5;
  --text2: #C9CCD2;
  --hint: #9EA3AC;
  --dim: #6E737C;
  --accent: #F59E0B;
  --accent-text: #F7C04A;
  --accent-bg: #3A3020;
  --on-accent: #1B1D22;
  --danger: #FF8A5C;
  --danger-text: #FFB08F;
  --danger-bg: #3D2419;
  --radius: 14px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  min-height: 100vh;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex-shrink: 0; }

#app { padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 96px); max-width: 560px; margin: 0 auto; }
#app.no-nav { padding-bottom: calc(var(--safe-bottom) + 120px); }

/* ---------- заголовки и секции ---------- */
.eyebrow { font-size: 14px; color: var(--hint); }
h1 { margin: 2px 0 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.section-title {
  padding: 0 4px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text2);
}
.section-title .count { font-weight: 500; color: var(--hint); }
.section-title.accent { color: var(--accent-text); }
.section-title.danger { color: var(--danger); }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.muted { color: var(--hint); font-size: 14px; }
.small { font-size: 13px; }

/* ---------- прогресс ---------- */
.progress { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.progress-track { flex: 1; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s; }
.progress-label { font-size: 13px; font-weight: 600; color: var(--text2); }

/* ---------- строки ---------- */
.row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 8px 12px 14px; width: 100%; text-align: left; background: none; border: 0; }
.row + .row { border-top: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.row-meta { font-size: 13px; color: var(--hint); }
.row-meta.danger { color: var(--danger); }
.row.is-done .row-title { color: var(--dim); text-decoration: line-through; }
.row.is-done .row-meta { color: var(--dim); }
.note-chip { margin-top: 4px; align-self: flex-start; font-size: 13px; color: var(--text2); background: var(--raised); border-radius: 8px; padding: 5px 9px; overflow-wrap: anywhere; }
.chevron { display: flex; align-items: center; justify-content: center; width: 32px; min-height: 44px; margin: -10px 0; background: none; border: 0; padding: 0; }
.row-link { cursor: pointer; }

.check {
  flex-shrink: 0; width: 28px; height: 28px; margin-top: -1px; border-radius: 14px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 2px solid #5A5F69; position: relative;
}
.check::before { content: ""; position: absolute; inset: -8px; } /* касание не меньше 44px */
.check.on { background: var(--accent); border-color: var(--accent); }

/* ---------- список дел ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  height: 36px; padding: 0 14px; border-radius: 18px; font-size: 14px; font-weight: 500;
  background: var(--card); color: var(--text2); border: 1px solid var(--border);
}
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.task-row { display: flex; align-items: center; gap: 10px; padding: 14px 10px 14px 16px; cursor: pointer; }
.task-row + .task-row { border-top: 1px solid var(--line); }
.task-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 10px; background: var(--raised); color: var(--text2); }
.badge.overdue { background: var(--danger-bg); color: var(--danger-text); }
.badge.today, .badge.soon { background: var(--accent-bg); color: var(--accent-text); }
.bar { height: 6px; border-radius: 3px; background: #2E3138; overflow: hidden; margin: 6px 0; }
.bar > div { height: 100%; border-radius: 3px; background: #7A6430; }
.bar.overdue > div { background: var(--danger); }
.bar.today > div, .bar.soon > div { background: var(--accent); }

/* ---------- карточка дела ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin: -4px 0 8px; }
.link-btn { background: none; border: 0; padding: 10px 4px; color: var(--accent-text); font-size: 16px; }
.info-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; }
.info-row + .info-row { border-top: 1px solid var(--line); }
.info-row .label { flex: 1; font-size: 15px; }
.info-row .value { font-size: 15px; color: var(--hint); text-align: right; }
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 10px; background: var(--accent-bg); color: var(--accent-text); }
.pill.overdue { background: var(--danger-bg); color: var(--danger-text); }
.timeline { padding: 6px 16px; }
.tl-item { display: flex; gap: 14px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; width: 12px; }
.tl-dot { width: 12px; height: 12px; margin-top: 14px; border-radius: 6px; border: 2px solid #5A5F69; }
.tl-item:first-child .tl-dot { background: var(--accent); border-color: var(--accent); }
.tl-line { width: 2px; flex: 1; background: var(--line); }
.tl-item:last-child .tl-line { background: transparent; }
.tl-body { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 10px 0 12px; min-width: 0; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; }
.tl-date { font-size: 15px; font-weight: 600; }
.tl-note { font-size: 14px; color: var(--text2); overflow-wrap: anywhere; }

/* ---------- кнопки ---------- */
.btn {
  height: 50px; width: 100%; border-radius: 12px; border: 0; font-size: 16px; font-weight: 600;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
}
.btn.soft { background: var(--accent-bg); color: var(--accent-text); }
.btn.ghost { height: 44px; background: var(--card); color: var(--accent-text); border: 1px solid var(--border); font-weight: 500; font-size: 15px; }
.btn.danger { height: 44px; background: transparent; color: var(--danger-text); border: 1px solid #5A3326; font-weight: 500; font-size: 15px; }
.btn:disabled { opacity: .5; }
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px 16px calc(12px + var(--safe-bottom)); background: var(--card); border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.bottom-bar > div { display: flex; gap: 10px; max-width: 528px; margin: 0 auto; width: 100%; }
.bottom-bar > .btn { max-width: 528px; margin: 0 auto; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px); z-index: 5;
  width: 56px; height: 56px; border-radius: 28px; border: 0; background: var(--accent);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(245, 158, 11, .28);
}

/* ---------- нижняя навигация ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--line);
}
nav.tabs button {
  background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--hint);
}
nav.tabs button.on { color: var(--accent); font-weight: 600; }

/* ---------- формы ---------- */
.field { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.field-label { padding: 0 4px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text2); }
.input, .textarea {
  width: 100%; border: 1px solid transparent; border-radius: 12px; padding: 0 14px; height: 48px;
  background: var(--card); color: var(--text); font-size: 16px; outline: none;
}
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: none; }
.input:focus, .textarea:focus { border-color: var(--accent); }
.input::placeholder, .textarea::placeholder { color: #8A8F98; }
.input[type="date"] { color-scheme: dark; }
.stepper-card { background: var(--card); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; }
.stepper button { width: 44px; height: 40px; border: 0; background: none; font-size: 20px; color: var(--accent-text); }
.stepper span { min-width: 28px; text-align: center; font-size: 17px; font-weight: 600; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.grid3 .chip { width: 100%; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--raised); }
.segmented button { height: 36px; border: 0; border-radius: 9px; background: none; font-size: 14px; font-weight: 500; color: var(--text2); }
.segmented button.on { background: #3A3D45; color: var(--text); font-weight: 600; }
.summary { margin-top: 18px; background: var(--accent-bg); color: var(--accent-text); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.error { margin-top: 12px; color: var(--danger-text); font-size: 14px; }

/* ---------- мысли ---------- */
.capture { background: var(--card); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.capture .input { background: var(--bg); border-color: var(--border); }
.capture .chip { height: 34px; background: var(--raised); border-color: var(--raised); }
.capture .chip.on { background: var(--accent); border-color: var(--accent); }
.note-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 14px; }
.note-row + .note-row { border-top: 1px solid var(--line); }
.note-text { flex: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; cursor: pointer; }
.note-when { flex-shrink: 0; font-size: 13px; color: var(--hint); }
.note-when.danger { color: var(--danger); }

/* ---------- баннер «на главный экран» ---------- */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--card); border: 1px solid #4A3D1E; margin-bottom: 16px; }
.banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.banner .btn { width: auto; height: 36px; padding: 0 14px; border-radius: 18px; font-size: 14px; }
.icon-btn { width: 36px; height: 36px; border: 0; background: none; display: flex; align-items: center; justify-content: center; padding: 0; }

/* ---------- пустые состояния ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--hint); }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* ---------- шторка снизу ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20; opacity: 0; transition: opacity .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 85vh; overflow: auto;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 10px 16px calc(20px + var(--safe-bottom));
  transform: translateY(100%); transition: transform .22s ease-out;
}
.sheet-open .sheet-backdrop { opacity: 1; }
.sheet-open .sheet { transform: none; }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 6px; font-size: 19px; }
.sheet p { margin: 0 0 14px; color: var(--hint); font-size: 14px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

/* ---------- всплывашка ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 84px); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; transition: all .2s;
  background: #F2F3F5; color: #1B1D22; border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast button { background: none; border: 0; color: #9A5B00; font-weight: 700; padding: 4px 0; }

.loading { padding: 64px 0; text-align: center; color: var(--hint); }
