/* Планер Ники — тёплый «бумажный» стиль. Цвета категорий — как в легенде документа. */

:root {
  --bg: #fbf5ee;
  --bg-2: #f5ece2;
  --card: #fffdfa;
  --ink: #3a2e29;
  --muted: #8d7c72;
  --line: #eee2d6;
  --accent: #d46a86;
  --accent-ink: #fff;
  --accent-soft: #fbe3ea;
  --shadow: 0 1px 2px rgba(80, 50, 30, .05), 0 8px 24px rgba(80, 50, 30, .07);
  --radius: 22px;
  --serif: "New York", ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, sans-serif;

  --c-practice: #5fb884;
  --c-study:    #5f95dc;
  --c-driving:  #ee9a4b;
  --c-health:   #e56b6b;
  --c-work:     #e2b93b;
  --c-dev:      #9d7fdc;
  --c-move:     #a77b5d;
  --c-personal: #ec7fb0;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1715;
    --bg-2: #231e1b;
    --card: #28221f;
    --ink: #f4e9e0;
    --muted: #a8978c;
    --line: #3a322d;
    --accent: #ee8aa4;
    --accent-ink: #2a1a1f;
    --accent-soft: #4a2b34;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --c-practice: #6fcb95;
    --c-study:    #78a9ec;
    --c-driving:  #f3a864;
    --c-health:   #f07e7e;
    --c-work:     #ecc758;
    --c-dev:      #b096ea;
    --c-move:     #c49677;
    --c-personal: #f394c0;
    color-scheme: dark;
  }
}

.c-practice { --c: var(--c-practice); }
.c-study    { --c: var(--c-study); }
.c-driving  { --c: var(--c-driving); }
.c-health   { --c: var(--c-health); }
.c-work     { --c: var(--c-work); }
.c-dev      { --c: var(--c-dev); }
.c-move     { --c: var(--c-move); }
.c-personal { --c: var(--c-personal); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 22px; }
h3 { font-size: 21px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.err { color: var(--c-health); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.hint { font-size: 13px; margin: -6px 0 10px; }

/* --- загрузка ---------------------------------------------------------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot-logo { width: 44px; height: 44px; border-radius: 14px; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.85); opacity: .6; } }

/* --- вход -------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border-radius: 28px;
  box-shadow: var(--shadow); padding: 36px 28px 24px; text-align: center;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1);
}
.login-logo { border-radius: 20px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 30px; margin: 16px 0 4px; }
.login-card p.muted { margin: 0 0 24px; font-size: 15px; }
.login-card .field { text-align: left; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* --- поля и кнопки ----------------------------------------------------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 4px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--bg);
  border-radius: 14px; padding: 12px 14px; outline: none; font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.field input[type="date"], .field input[type="time"] { min-height: 48px; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .check-add input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.field input { display: block; min-width: 0; max-width: 100%; }

.btn {
  border: 0; border-radius: 14px; padding: 11px 18px; font-weight: 600; font-size: 15px;
  background: var(--bg-2); transition: transform .1s, filter .15s, background .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.soft { background: var(--accent-soft); color: var(--accent); padding: 8px 14px; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger-ghost { background: transparent; color: var(--c-health); padding-left: 4px; }
.btn.wide { width: 100%; padding: 14px; font-size: 16px; margin-top: 6px; }
.btn:disabled { opacity: .6; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 0; background: var(--card);
  box-shadow: var(--shadow); display: grid; place-items: center; color: var(--muted);
}
.icon-btn.small { width: 36px; height: 36px; border-radius: 12px; box-shadow: none; background: var(--bg-2); }
.icon-btn.small svg { width: 18px; height: 18px; stroke-width: 2.2; }

.chip {
  border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  background: var(--bg-2); color: var(--ink); display: inline-flex; align-items: center; gap: 6px;
  transition: opacity .15s, background .15s;
}
.chip.ghost { color: var(--accent); background: var(--accent-soft); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.chip.cat { background: color-mix(in srgb, var(--c) 16%, var(--card)); }
.chip.cat.off { opacity: .38; background: var(--bg-2); }
.chip.cat.sel { background: var(--c); color: #fff; }
.chip.cat.sel .dot { background: #fff; }
.pill { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* --- каркас ------------------------------------------------------------ */
.app {
  max-width: 1180px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 100px);
  animation: fade .35s ease;
}
@keyframes fade { from { opacity: 0; } }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.hello { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.wave { color: var(--accent); font-size: 22px; }
.today { font-size: 14px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* Вкладки: снизу на телефоне, сверху на широком экране. */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 12px); z-index: 20;
  display: flex; gap: 4px; padding: 6px; border-radius: 24px;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: 0 10px 30px rgba(60, 30, 20, .16); border: 1px solid var(--line);
}
.tabs button {
  border: 0; background: transparent; color: var(--muted); border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 18px; font-size: 11px; font-weight: 600; transition: background .2s, color .2s;
}
.tabs button.active { background: var(--accent-soft); color: var(--accent); }
.tab { animation: fade .25s ease; }

.fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 88px); z-index: 19;
  width: 56px; height: 56px; border-radius: 20px; border: 0;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent);
  display: grid; place-items: center; transition: transform .15s;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* --- календарь --------------------------------------------------------- */
.month-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.month-head h2 { flex: 1; text-align: center; font-size: 21px; text-transform: capitalize; white-space: nowrap; min-width: 0; }
@media (min-width: 640px) { .month-head h2 { font-size: 25px; } }
.month-head .chip { order: 5; }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays span { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding-bottom: 6px; }
.weekdays span:nth-child(n+6) { color: var(--accent); }
.grid { touch-action: pan-y; }
.grid.slide-l { animation: slideL .28s ease; }
.grid.slide-r { animation: slideR .28s ease; }
@keyframes slideL { from { opacity: 0; transform: translateX(24px); } }
@keyframes slideR { from { opacity: 0; transform: translateX(-24px); } }

.cell {
  min-height: 64px; padding: 4px 0 6px; border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  border-top: 1px solid var(--line); text-align: center; position: relative;
}
.cell .num {
  align-self: center; width: 30px; height: 30px; line-height: 30px; border-radius: 50%;
  font-size: 15px; font-weight: 500; transition: background .15s;
}
.cell.other .num { color: var(--muted); opacity: .45; }
.cell.today .num { color: var(--accent); font-weight: 800; box-shadow: inset 0 0 0 1.5px var(--accent); }
.cell.sel .num { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.cell:hover .num { background: var(--bg-2); }
.cell.sel:hover .num { background: var(--accent); }

.bar {
  height: 6px; border-radius: 4px; margin: 0 3px; background: var(--c);
  font-size: 11px; font-weight: 600; line-height: 16px; color: #fff; text-align: left;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.bar.gap { visibility: hidden; }
.bar.cl { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.cr { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bar .lbl { display: none; }
.cell.other .bar { opacity: .4; }
.more { font-size: 10px; color: var(--muted); line-height: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

/* день */
.day-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.day-weekday { font-size: 14px; text-transform: capitalize; }
.day-head h2 { font-size: 26px; }
.day-list { display: flex; flex-direction: column; gap: 8px; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; font-size: 15px; }
.empty .big { font-size: 30px; display: block; margin-bottom: 4px; }

.ev {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  border-radius: 16px; background: color-mix(in srgb, var(--c) 13%, var(--card));
  border-left: 5px solid var(--c); cursor: pointer; transition: transform .12s;
}
.ev:active { transform: scale(.985); }
.ev .body { flex: 1; min-width: 0; }
.ev .title { font-weight: 600; overflow-wrap: anywhere; }
.ev.done .title { text-decoration: line-through; color: var(--muted); }
.ev .meta { font-size: 13px; color: var(--muted); }

.check {
  flex: none; width: 26px; height: 26px; border-radius: 9px; border: 2px solid var(--c, var(--accent));
  background: transparent; display: grid; place-items: center; padding: 0; transition: background .2s;
}
.check svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .3s ease .05s; }
.check.on { background: var(--c, var(--accent)); animation: pop .3s ease; }
.check.on svg { stroke-dashoffset: 0; }
@keyframes pop { 40% { transform: scale(1.18); } }

.timeline { margin-top: 18px; position: relative; }
.timeline:empty { display: none; }
.timeline h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.tl { position: relative; margin-left: 46px; border-left: 1.5px dashed var(--line); }
.tl .hour { position: absolute; left: -46px; font-size: 12px; color: var(--muted); transform: translateY(-50%); }
.tl .hline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); opacity: .7; }
.tl .blk {
  position: absolute; left: 8px; right: 4px; border-radius: 12px; padding: 6px 10px;
  background: color-mix(in srgb, var(--c) 22%, var(--card)); border-left: 4px solid var(--c);
  font-size: 13px; font-weight: 600; overflow: hidden; cursor: pointer;
}
.tl .blk small { display: block; font-weight: 500; color: var(--muted); }
.tl .now { position: absolute; left: -4px; right: 0; height: 2px; background: var(--accent); }
.tl .now::before { content: ""; position: absolute; left: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* --- финансы ----------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat.accent { grid-column: 1 / -1; }
@media (min-width: 640px) { .stat.accent { grid-column: auto; } }
.stat { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .v { font-family: var(--serif); font-size: 26px; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.stat .s { font-size: 12px; color: var(--muted); }
.stat.accent { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #f0a35e)); color: #fff; }
.stat.accent .k, .stat.accent .s { color: rgba(255, 255, 255, .85); }
.progress { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; margin-top: 10px; }
.stat.accent .progress { background: rgba(255, 255, 255, .3); }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); width: 0; transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.stat.accent .progress i { background: #fff; }

.rows { display: flex; flex-direction: column; }
.r {
  display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-top: 1px solid var(--line);
  cursor: pointer; border-radius: 12px; transition: background .15s;
}
.r:first-child { border-top: 0; }
.r:hover { background: var(--bg); }
.r .body { flex: 1; min-width: 0; }
.r .title { font-weight: 600; overflow-wrap: anywhere; }
.r .meta { font-size: 13px; color: var(--muted); }
.r .amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.r .amt.zero { color: var(--muted); font-weight: 500; }
.r .amt small { display: block; text-align: right; font-weight: 500; font-size: 12px; color: var(--muted); }
.r.total { cursor: default; border-top: 2px solid var(--line); }
.r.total:hover { background: none; }
.r.total .title { font-family: var(--serif); font-size: 18px; }
.r.total .amt { font-family: var(--serif); font-size: 20px; color: var(--accent); }
.ico {
  flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 15px;
}

.chart { height: 170px; margin: 4px 0 6px; }
.chart svg { width: 100%; height: 100%; stroke: none; }
.chart .plan { fill: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.chart .fact { fill: var(--accent); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart-legend { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 4px; margin-left: 8px; }
.chart-legend .sw:first-child { margin-left: 0; }
.sw.plan { background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.sw.fact { background: var(--accent); }

/* --- переезд ----------------------------------------------------------- */
.hero {
  display: flex; align-items: center; gap: 20px; padding: 24px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c-move) 85%, #000 0%), color-mix(in srgb, var(--c-move) 55%, var(--accent)));
  color: #fff;
}
.hero .k { font-size: 14px; opacity: .85; font-weight: 500; }
.hero .big { font-family: var(--serif); font-size: 54px; line-height: 1; font-weight: 700; letter-spacing: -.02em; }
.hero .big small { font-size: 20px; font-weight: 500; margin-left: 6px; }
.hero .when { opacity: .85; margin-top: 6px; font-size: 14px; }
.hero .body { flex: 1; }
.ring { width: 96px; height: 96px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .bg { stroke: rgba(255, 255, 255, .25); }
.ring .fg { stroke: #fff; transition: stroke-dashoffset 1s cubic-bezier(.2, .8, .2, 1); }
.ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.ring .pct small { display: block; font-size: 10px; font-weight: 500; opacity: .85; text-align: center; margin-top: -4px; }

.status {
  flex: none; border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700;
  transition: background .2s, color .2s;
}
.status.todo { background: var(--bg-2); color: var(--muted); }
.status.doing { background: color-mix(in srgb, var(--c-work) 25%, var(--card)); color: color-mix(in srgb, var(--c-work) 60%, var(--ink)); }
.status.done { background: color-mix(in srgb, var(--c-practice) 22%, var(--card)); color: color-mix(in srgb, var(--c-practice) 70%, var(--ink)); }
.stage-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--bg-2); color: var(--muted);
}
.stage-num.done { background: var(--c-practice); color: #fff; }

.checklist { display: flex; flex-direction: column; }
.ci { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--line); }
.ci:first-child { border-top: 0; }
.ci .check { --c: var(--c-move); }
.ci .t { flex: 1; cursor: pointer; transition: color .2s; overflow-wrap: anywhere; }
.ci.done .t { color: var(--muted); text-decoration: line-through; }
.check-add { display: flex; gap: 8px; margin-top: 12px; }
.check-add input {
  flex: 1; min-width: 0; border: 1.5px solid var(--line); background: var(--bg); border-radius: 14px;
  padding: 10px 14px; outline: none; font-size: 16px;
}

/* --- шторка ------------------------------------------------------------ */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(40, 25, 20, .35);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 18px);
  animation: sheetUp .32s cubic-bezier(.2, .9, .25, 1);
}
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin-bottom: 16px; }
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.spacer { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { display: flex; background: var(--bg-2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 10px; padding: 8px 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); z-index: 60;
  transform: translate(-50%, calc(-100% - 60px)); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); transition: transform .3s cubic-bezier(.2, .9, .25, 1); pointer-events: none;
  max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); }

/* --- широкий экран ----------------------------------------------------- */
@media (min-width: 640px) {
  .cell { min-height: 92px; }
  .bar { height: 16px; padding: 0 6px; }
  .bar .lbl { display: inline; }
  .card { padding: 22px; }
}
@media (min-width: 960px) {
  .app { padding-top: 28px; padding-bottom: 40px; }
  .top { margin-bottom: 8px; }
  .tabs {
    position: sticky; top: 12px; left: auto; bottom: auto; transform: none;
    width: max-content; margin: 0 auto 22px; flex-direction: row;
  }
  .tabs button { flex-direction: row; gap: 8px; font-size: 14px; padding: 9px 18px; }
  .tabs svg { width: 18px; height: 18px; }
  .fab { display: none; }
  .cal-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  .money-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
  .day-card { position: sticky; top: 90px; }
  .backdrop { align-items: center; }
  .sheet { border-radius: 28px; animation: rise .25s ease; }
  .grabber { display: none; }
}

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