/* Планер: слева календарь месяца, справа текущие дела и выполненные. На телефоне календарь выезжает по кнопке. */
:root {
  --bg: #f5f5f8; --surface: #ffffff; --sunken: #efeef3; --fg: #1d1b22; --muted: #77727f; --faint: #a9a4b1;
  --line: #e5e2ea; --accent: #cf4479; --accent-ink: #ffffff; --accent-soft: #fbe8f0; --danger: #d0453b;
  --ok: #3d8a5c; --shadow: 0 1px 2px rgba(29, 27, 34, .05), 0 8px 24px rgba(29, 27, 34, .06);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 12px; --r-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131216; --surface: #1b1a1f; --sunken: #17161b; --fg: #ecebf0; --muted: #9c97a4; --faint: #6c6773;
    --line: #2b2930; --accent: #ef78a4; --accent-ink: #1a0e14; --accent-soft: #3a2230; --danger: #ef6b62;
    --ok: #6fc592; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
/* iOS увеличивает страницу при фокусе на поле со шрифтом < 16px — на телефоне у всех полей 16px */
@media (max-width: 820px) { input, textarea, select { font-size: 16px !important; } }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- каркас ---------- */
.app { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; display: grid;
       grid-template-columns: 300px minmax(0, 1fr); gap: 32px; align-items: start; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.brand .sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .spacer { flex: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
            border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.icon-btn:hover { color: var(--fg); }
.icon-btn svg { width: 18px; height: 18px; }
#calToggle { display: none; }

/* ---------- календарь ---------- */
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px;
       box-shadow: var(--shadow); position: sticky; top: 20px; }
.cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 12px; }
.cal-head .title { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; text-transform: capitalize; white-space: nowrap; }
.cal-head button { border: 0; background: none; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); }
.cal-head button:hover { background: var(--sunken); color: var(--fg); }
.cal-head .title { overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.cal-head button { font-size: 18px; line-height: 1; }
.cal-head .today-btn i { display: block; width: 8px; height: 8px; margin: auto; border-radius: 50%; background: var(--accent); }
.weekdays, .days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.weekdays span { text-align: center; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
                 color: var(--faint); padding-bottom: 6px; }
.day { position: relative; aspect-ratio: 1; border: 0; background: none; border-radius: 10px;
       font-variant-numeric: tabular-nums; font-size: 14px; display: grid; place-items: center; }
.day:hover { background: var(--sunken); }
.day.out { color: var(--faint); }
.day.weekend:not(.out) { color: var(--muted); }
.day.today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); font-weight: 600; }
.day.sel { background: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: none; }
.day.drop { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.dots { position: absolute; bottom: 5px; left: 0; right: 0; display: flex; justify-content: center; gap: 3px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.dots i.late { background: var(--danger); }
.dots i.done { background: var(--faint); }
.day.sel .dots i { background: var(--accent-ink); }
.cal-foot { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.stat { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted);
        background: none; border: 0; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; text-align: left; }
.stat:hover { background: var(--sunken); color: var(--fg); }
.stat b { font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }
.stat.late b { color: var(--danger); }
.stat.active { background: var(--accent-soft); color: var(--fg); }

/* ---------- дела ---------- */
.main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.view-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
.view-head .reset { border: 0; background: none; color: var(--accent); font-size: 14px; padding: 0; }

.add { display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
       padding: 6px 6px 6px 14px; box-shadow: var(--shadow); align-items: center; }
.add:focus-within { border-color: var(--accent); }
.add input[type=text] { flex: 1; width: 0; min-width: 0; border: 0; background: none; padding: 8px 0; outline: none; }
.add input::placeholder { color: var(--faint); }
.add .when { border: 1px solid var(--line); background: var(--sunken); color: var(--muted); border-radius: 8px;
             padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.add .when.set { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.add .go { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 7px 14px;
           font-weight: 600; font-size: 14px; }

.group { display: grid; gap: 8px; }
.group-head { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .08em;
              text-transform: uppercase; color: var(--muted); font-weight: 600; }
.group-head .n { font-variant-numeric: tabular-nums; color: var(--faint); }
.group-head button { border: 0; background: none; padding: 0; color: inherit; font: inherit; letter-spacing: inherit;
                     text-transform: inherit; display: inline-flex; gap: 6px; align-items: center; }
.group-head svg { width: 14px; height: 14px; transition: transform .15s; }
.group-head button[aria-expanded=false] svg { transform: rotate(-90deg); }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--r); box-shadow: var(--shadow); }
.list:empty { display: none; }
.empty { color: var(--faint); font-size: 14px; padding: 18px; text-align: center; border: 1px dashed var(--line);
         border-radius: var(--r); }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px 11px 6px; border-top: 1px solid var(--line);
        background: var(--surface); }
.task:first-child { border-top: 0; border-radius: var(--r) var(--r) 0 0; }
.task:last-child { border-radius: 0 0 var(--r) var(--r); }
.task:only-child { border-radius: var(--r); }
.handle { border: 0; background: none; color: var(--faint); width: 20px; height: 26px; padding: 0; touch-action: none;
          cursor: grab; flex: none; display: grid; place-items: center; opacity: .6; }
.task:hover .handle { opacity: 1; }
.handle svg { width: 14px; height: 14px; }
.check { flex: none; width: 22px; height: 22px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--faint);
         background: none; display: grid; place-items: center; padding: 0; transition: .15s; }
.check:hover { border-color: var(--accent); }
.check svg { width: 12px; height: 12px; opacity: 0; color: var(--accent-ink); }
.task.done .check { background: var(--accent); border-color: var(--accent); }
.task.done .check svg { opacity: 1; }
.body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding-top: 1px; }
.text { overflow-wrap: anywhere; cursor: text; border-radius: 4px; }
.task.done .text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.edit { flex: 1; min-width: 0; width: 100%; border: 0; border-bottom: 1.5px solid var(--accent); background: none;
        padding: 0 0 2px; outline: none; }
.due { border: 0; background: var(--sunken); color: var(--muted); font-size: 12px; border-radius: 6px; padding: 2px 8px;
       white-space: nowrap; font-variant-numeric: tabular-nums; }
.due.today { background: var(--accent-soft); color: var(--accent); }
.due.late { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.due.none { background: none; color: var(--faint); padding-left: 0; padding-right: 0; opacity: 0; }
.task:hover .due.none, .due.none:focus-visible { opacity: 1; }
.meta { font-size: 12px; color: var(--faint); white-space: nowrap; }
.del { flex: none; border: 0; background: none; color: var(--faint); width: 26px; height: 26px; border-radius: 6px;
       display: grid; place-items: center; opacity: 0; }
.task:hover .del, .del:focus-visible { opacity: 1; }
.del:hover { color: var(--danger); background: var(--sunken); }
.del svg { width: 14px; height: 14px; }

/* перетаскивание */
.task.ghost { opacity: .35; }
.floating { position: fixed; z-index: 50; pointer-events: none; box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
            border-radius: var(--r); border: 1px solid var(--accent); }

/* всплывашка срока */
.pop { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
       box-shadow: var(--shadow); padding: 10px; display: grid; gap: 8px; width: 220px; }
.pop input { width: 100%; border: 1px solid var(--line); background: var(--sunken); border-radius: 8px; padding: 6px 8px; }
.pop .row { display: flex; gap: 6px; flex-wrap: wrap; }
.pop .row button { flex: 1; border: 1px solid var(--line); background: none; border-radius: 8px; padding: 5px 8px;
                   font-size: 13px; white-space: nowrap; }
.pop .row button:hover { border-color: var(--accent); color: var(--accent); }

/* уведомление снизу */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
         background: var(--fg); color: var(--bg); border-radius: 10px; padding: 10px 14px; display: flex; gap: 14px;
         align-items: center; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 70;
         max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; }

.sync { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); opacity: .7; }
.sync.off { background: var(--danger); }

/* ---------- телефон ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 48px; gap: 18px; }
  #calToggle { display: inline-grid; }
  .cal { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; top: auto; border-radius: 18px 18px 0 0;
         padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateY(105%);
         transition: transform .25s ease; max-height: 88vh; overflow: auto; }
  .cal.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none;
           transition: opacity .2s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .day { font-size: 15px; }
  .due.none, .del { opacity: 1; }
  .handle { opacity: 1; }
}
@media (min-width: 821px) { .scrim { display: none; } }

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

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
              box-shadow: var(--shadow); padding: 28px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 22px; font-weight: 600; }
.login p { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.login label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login input { border: 1px solid var(--line); background: var(--sunken); border-radius: 10px; padding: 10px 12px;
               outline: none; }
.login input:focus { border-color: var(--accent); }
.login button { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 11px;
                font-weight: 600; margin-top: 4px; }
.login .err { color: var(--danger); font-size: 14px; }
