/* «Планы» — личные дела владельца. Своя палитра (не цвета лаборатории):
   тёплая бумага + глубокий индиго, статусы — спокойные насыщенные цвета. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece5;
  --line: #e4e0d7;
  --ink: #1d1c21;
  --muted: #6e6b76;
  --accent: #4c3fd1;
  --accent-soft: #e9e6fb;
  --on-accent: #ffffff;

  --st-plan: #64748b;  --st-plan-bg: #eef1f5;
  --st-work: #2563eb;  --st-work-bg: #e3ecfd;
  --st-wait: #9333ea;  --st-wait-bg: #f3e8fd;
  --st-done: #15803d;  --st-done-bg: #e2f4e8;
  --st-cancel: #8a8792; --st-cancel-bg: #efeef1;

  --late: #dc2f3c;  --late-bg: #fde7e8;
  --today: #c26a00; --today-bg: #fdf0db;

  --r: 18px;
  --r-sm: 12px;
  --shadow: 0 1px 2px rgba(30, 25, 10, .05), 0 4px 16px rgba(30, 25, 10, .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 68px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141417; --surface: #1d1d22; --surface-2: #26262d; --line: #2f2f37;
    --ink: #f2f1f5; --muted: #9c9aa6; --accent: #8b80ff; --accent-soft: #2a2650; --on-accent: #12101f;
    --st-plan: #a3b1c6; --st-plan-bg: #262b33;
    --st-work: #6ea2ff; --st-work-bg: #1d2a44;
    --st-wait: #c48bff; --st-wait-bg: #2f2140;
    --st-done: #4ccb7a; --st-done-bg: #193323;
    --st-cancel: #8f8c99; --st-cancel-bg: #26262c;
    --late: #ff6b74; --late-bg: #3a1c20; --today: #ffb347; --today-bg: #3a2a14;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--late); min-height: 1.2em; font-size: 14px; }

/* ---------- каркас ---------- */
.app { min-height: 100vh; }
.main { padding: calc(env(safe-area-inset-top) + 14px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); max-width: 760px; margin: 0 auto; }
.top { display: flex; align-items: flex-end; justify-content: space-between; margin: 4px 2px 14px; }
.top h1 { font-size: 30px; line-height: 1.1; margin: 2px 0 0; letter-spacing: -.02em; }
.top-date { color: var(--muted); font-size: 14px; font-weight: 500; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); font-size: 19px; }

.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.nav button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 14px; }
.nav button .ic { width: 24px; height: 24px; display: grid; place-items: center; }
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav button.active { color: var(--accent); }
.nav-brand { display: none; }
.logo { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--accent), #8f5cf6); color: #fff; font-size: 34px; font-weight: 800; }
.logo.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 17px; margin: 0; }

/* ---------- быстрый ввод ---------- */
.quick { position: relative; display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.quick input { flex: 1; min-width: 0; height: 52px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 16px;
  padding: 0 16px; outline: none; box-shadow: var(--shadow); }
.quick input:focus { border-color: var(--accent); }
.quick .btn { width: 52px; height: 52px; font-size: 26px; padding: 0; border-radius: 16px; }
.quick-hint { flex-basis: 100%; font-size: 13px; color: var(--accent); min-height: 0; padding-left: 6px; }
.quick-hint:empty { display: none; }

.btn { border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 650; background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: var(--late-bg); color: var(--late); }
.btn.big { width: 100%; height: 54px; font-size: 17px; }
.btn.ghost { background: none; color: var(--accent); padding: 8px 10px; }

/* ---------- виджеты ---------- */
.widgets { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.w { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 15px; border: 0; text-align: left; position: relative; overflow: hidden; min-height: 104px; display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; }
.w-label { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.w-num { font-size: 34px; font-weight: 750; letter-spacing: -.03em; line-height: 1.05; margin-top: 6px; }
.w-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.w.today { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 16px; background: linear-gradient(135deg, var(--accent), #7a54ef); color: #fff; }
.w.today .w-label, .w.today .w-sub { color: rgba(255,255,255,.8); }
.w.today .w-body { flex: 1; }
.w.today .w-list { margin-top: 6px; font-size: 14px; color: rgba(255,255,255,.95); }
.w.today .w-list div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring { width: 78px; height: 78px; flex: none; }
.ring circle { fill: none; stroke-width: 9; }
.ring .bg { stroke: rgba(255,255,255,.25); }
.ring .fg { stroke: #fff; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .5s; }
.ring text { fill: #fff; font-size: 20px; font-weight: 750; text-anchor: middle; dominant-baseline: central; }
.w.late .w-num { color: var(--late); }
.w.late.zero .w-num { color: var(--st-done); }
.w.work .w-num { color: var(--st-work); }
.w.wait .w-num { color: var(--st-wait); }
.w.done7 .w-num { color: var(--st-done); }
.w .bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.w .bar i { display: block; height: 100%; background: var(--st-work); border-radius: 3px; }
.w.week { grid-column: 1 / -1; min-height: 0; }
.week-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 84px; margin-top: 10px; }
.wb { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.wb .col { width: 100%; max-width: 30px; border-radius: 8px; background: var(--surface-2); position: relative; overflow: hidden; min-height: 6px; }
.wb .col i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--st-done); }
.wb .col.has { background: var(--accent-soft); }
.wb span { font-size: 11px; color: var(--muted); font-weight: 600; }
.wb.is-today span { color: var(--accent); }
.wb b { font-size: 12px; font-weight: 700; }

/* ---------- списки ---------- */
.group { margin-bottom: 22px; }
.group h2 { font-size: 15px; margin: 0 4px 8px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.group h2 .cnt { background: var(--surface-2); color: var(--muted); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.group.late h2 { color: var(--late); }
.cards { display: flex; flex-direction: column; gap: 8px; }
.card { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: var(--r-sm); padding: 13px 14px; box-shadow: var(--shadow); cursor: pointer; border-left: 4px solid transparent; transition: transform .12s; }
.card:active { transform: scale(.985); }
.card.is-late { border-left-color: var(--late); }
.card.is-today { border-left-color: var(--today); }
.card.sel { outline: 2px solid var(--accent); }
.chk { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2.2px solid var(--line); background: none; margin-top: 1px; display: grid; place-items: center; color: transparent; font-size: 15px; font-weight: 800; padding: 0; }
.chk:hover { border-color: var(--st-done); }
.card.done .chk { background: var(--st-done); border-color: var(--st-done); color: #fff; }
.card.cancel .chk { border-style: dashed; }
.c-body { flex: 1; min-width: 0; }
.c-title { font-weight: 600; word-wrap: break-word; }
.card.done .c-title, .card.cancel .c-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.c-note { color: var(--muted); font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.c-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; align-items: center; }
.pill { font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.pill.plan { color: var(--st-plan); background: var(--st-plan-bg); }
.pill.work { color: var(--st-work); background: var(--st-work-bg); }
.pill.wait { color: var(--st-wait); background: var(--st-wait-bg); }
.pill.done { color: var(--st-done); background: var(--st-done-bg); }
.pill.cancel { color: var(--st-cancel); background: var(--st-cancel-bg); }
.pill.date { color: var(--muted); background: var(--surface-2); }
.pill.rep { color: var(--accent); background: var(--accent-soft); }
.f-hint { font-size: 13px; color: var(--muted); margin-top: -4px; }
.pill.date.late { color: var(--late); background: var(--late-bg); }
.pill.date.today { color: var(--today); background: var(--today-bg); }
.prog { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.prog .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--st-work); border-radius: 3px; }
.prog span { font-size: 12px; color: var(--muted); font-weight: 700; min-width: 34px; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty .big { font-size: 40px; margin-bottom: 6px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 -2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--surface); border-radius: 20px; padding: 7px 14px; font-size: 14px; font-weight: 600; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- календарь ---------- */
.cal { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px; margin-bottom: 18px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head b { font-size: 17px; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dw { text-align: center; font-size: 12px; color: var(--muted); font-weight: 650; padding: 4px 0; }
.cal-d { aspect-ratio: 1 / 1; border: 0; background: none; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-weight: 600; font-size: 15px; }
.cal-d.out { color: var(--muted); opacity: .45; }
.cal-d.today { color: var(--accent); background: var(--accent-soft); }
.cal-d.sel { background: var(--accent); color: var(--on-accent); }
.dots { display: flex; gap: 2px; height: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--st-plan); }
.cal-d.sel .dots i { background: var(--on-accent) !important; }
.dots i.late { background: var(--late); } .dots i.done { background: var(--st-done); } .dots i.work { background: var(--st-work); } .dots i.wait { background: var(--st-wait); }

/* ---------- карточка дела (шторка) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 8, 20, .38); z-index: 30; }
.side { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--surface);
  border-radius: 24px 24px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px); box-shadow: 0 -10px 40px rgba(0,0,0,.18);
  animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.f-title { width: 100%; border: 0; outline: none; background: none; font-size: 22px; font-weight: 700; padding: 4px 0; resize: none; }
.f-note { width: 100%; border: 1.5px solid var(--line); outline: none; background: var(--bg); border-radius: 14px; padding: 12px; min-height: 84px; resize: vertical; }
.f-note:focus { border-color: var(--accent); }
.f-sec { margin-top: 18px; }
.f-lbl { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; display: flex; justify-content: space-between; }
.seg { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.seg button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 9px 2px; font-size: 12.5px; font-weight: 650; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.seg button .ic { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; margin: 2px 0; }
.seg button.plan .ic { color: var(--st-plan); } .seg button.work .ic { color: var(--st-work); background: linear-gradient(90deg, currentColor 50%, transparent 50%); } .seg button.wait .ic { color: var(--st-wait); border-style: dotted; } .seg button.done .ic { color: var(--st-done); background: currentColor; } .seg button.cancel .ic { color: var(--st-cancel); border-style: dashed; }
.seg button.on.plan { border-color: var(--st-plan); background: var(--st-plan-bg); color: var(--st-plan); }
.seg button.on.work { border-color: var(--st-work); background: var(--st-work-bg); color: var(--st-work); }
.seg button.on.wait { border-color: var(--st-wait); background: var(--st-wait-bg); color: var(--st-wait); }
.seg button.on.done { border-color: var(--st-done); background: var(--st-done-bg); color: var(--st-done); }
.seg button.on.cancel { border-color: var(--st-cancel); background: var(--st-cancel-bg); color: var(--st-cancel); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input[type=date], .row input[type=time], .f-in { height: 46px; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 0 12px; outline: none; }
.f-in { width: 100%; }
.row input[type=date] { flex: 1; min-width: 150px; }
.row input[type=time] { width: 120px; }
.range { width: 100%; accent-color: var(--accent); height: 30px; }
.pct-marks { display: flex; justify-content: space-between; }
.pct-marks button { border: 0; background: var(--surface-2); border-radius: 10px; padding: 6px 0; width: 18%; font-weight: 650; font-size: 13px; }
.pct-marks button.on { background: var(--accent); color: var(--on-accent); }
.f-actions { display: flex; gap: 10px; margin-top: 24px; }
.f-actions .btn { flex: 1; height: 50px; }
.f-foot { margin-top: 14px; font-size: 12.5px; color: var(--muted); text-align: center; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); max-width: 92vw; }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 750; padding: 0; filter: brightness(1.6); }

/* ---------- вход ---------- */
.vhod { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.vhod-box { width: 100%; max-width: 340px; text-align: center; }
.vhod-box h1 { margin: 0 0 4px; }
.vhod-box input { width: 100%; height: 54px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 16px; font-size: 20px; text-align: center; letter-spacing: .3em; margin: 14px 0 10px; outline: none; }

/* ---------- настройки ---------- */
.set-item { background: var(--surface); border-radius: var(--r-sm); padding: 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.set-item h3 { margin: 0 0 4px; font-size: 16px; }
.set-item p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.set-item code { display: block; background: var(--bg); border-radius: 10px; padding: 10px; font-size: 12px; word-break: break-all; margin: 8px 0; }
.set-item ol { margin: 6px 0 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
.set-item ol li { margin-bottom: 4px; }

/* ---------- мини-окно (виджет для Windows) ---------- */
body.mini .nav, body.mini .top, body.mini .quick { display: none; }
body.mini .main { padding: 10px; }
body.mini .widgets { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
body.mini .w { min-height: 0; padding: 10px; }
body.mini .w.today { grid-column: 1 / -1; }
body.mini .w.week, body.mini .w.done7, body.mini .w-sub { display: none; }
body.mini .w-num { font-size: 26px; }

/* ---------- компьютер ---------- */
@media (min-width: 980px) {
  .nav { top: 0; right: auto; bottom: 0; width: 230px; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 22px 14px; border-top: 0; border-right: 1px solid var(--line); background: var(--surface); }
  .nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; padding: 0 10px 18px; }
  .nav button { flex: none; flex-direction: row; gap: 12px; font-size: 15px; padding: 11px 12px; justify-content: flex-start; }
  .nav button.active { background: var(--accent-soft); }
  .main { margin-left: 230px; margin-right: 420px; max-width: none; padding: 28px 34px 40px; }
  .main.no-side { margin-right: 0; max-width: 980px; }
  .widgets { grid-template-columns: repeat(4, 1fr); }
  .w.today { grid-column: span 2; grid-row: span 1; }
  .w.week { grid-column: span 2; }
  .side { left: auto; top: 0; right: 0; bottom: 0; width: 420px; max-height: none; border-radius: 0; border-left: 1px solid var(--line);
    padding: 26px 26px 30px; box-shadow: none; animation: none; }
  .grab { display: none; }
  .scrim { display: none; }
  .toast { bottom: 26px; }
  body.mini .main { margin: 0; }
}
