/* ═══════════════════════════════════════════════════════════════════════════
   Todo Cudak — arkusz stylów
   Dark first, jasny motyw przez [data-theme="light"], układ mobile-first.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0b0d12;
  --bg-soft:   #0f121a;
  --surface:   #14171f;
  --surface-2: #1a1e28;
  --surface-3: #212633;
  --border:    #242936;
  --border-2:  #2e3442;
  --text:      #e8eaf0;
  --text-dim:  #a2aabd;
  --muted:     #7d859a;
  --accent:    #4c7dff;
  --accent-2:  #6f9bff;
  --accent-soft: rgba(76, 125, 255, .14);
  --green:     #21c98a;
  --amber:     #ffb020;
  --red:       #ff5468;
  --purple:    #b57cff;

  --p1: #6b7488;
  --p2: #4c7dff;
  --p3: #ffb020;
  --p4: #ff5468;

  --r-sm: 9px;
  --r:    13px;
  --r-lg: 18px;
  --r-xl: 24px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.28);
  --shadow-2: 0 8px 24px -8px rgba(0,0,0,.5);
  --shadow-3: 0 24px 60px -18px rgba(0,0,0,.7);

  --sidebar-w: 268px;
  --detail-w:  400px;
  --ease: cubic-bezier(.32, .72, 0, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

[data-theme="light"] {
  --bg:        #f4f6fb;
  --bg-soft:   #eef1f8;
  --surface:   #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eff2f8;
  --border:    #e2e7f0;
  --border-2:  #d3dae7;
  --text:      #131722;
  --text-dim:  #4c5568;
  --muted:     #77809a;
  --accent-soft: rgba(76, 125, 255, .12);
  --shadow-1: 0 1px 2px rgba(20,30,60,.06);
  --shadow-2: 0 10px 26px -12px rgba(20,30,60,.18);
  --shadow-3: 0 26px 60px -20px rgba(20,30,60,.3);
  --p1: #8a93a8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { overflow: hidden; }

button, input, textarea, select {
  font: inherit; color: inherit;
}
button { cursor: pointer; background: none; border: 0; }
[hidden] { display: none !important; }
::placeholder { color: var(--muted); opacity: 1; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border-2); border-radius: 8px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ─────────────────────────────── przyciski ──────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--text);
  font-size: 14px; font-weight: 600;
  border: 1px solid var(--border);
  transition: transform .12s var(--ease), background .16s, border-color .16s, opacity .16s;
  white-space: nowrap;
}
.btn:hover { background: var(--border); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px -6px var(--accent);
}
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--red); border-color: transparent; background: rgba(255,84,104,.11); }
.btn-danger:hover { background: rgba(255,84,104,.2); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 15px; height: 15px; flex: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  color: var(--text-dim);
  transition: background .15s, color .15s, transform .12s var(--ease);
  flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.tiny { width: 26px; height: 26px; border-radius: 8px; }
.icon-btn.danger:hover { background: rgba(255,84,104,.14); color: var(--red); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.tiny svg { width: 14px; height: 14px; }

/* ─────────────────────────────── logowanie ──────────────────────────────── */

.login-screen {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: 24px calc(24px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom))
           calc(24px + env(safe-area-inset-left));
  background: var(--bg); overflow: auto; z-index: 50;
}
.login-aura {
  /* fixed, a nie absolute — inaczej ujemny inset rozpycha obszar przewijania
     i psuje wyśrodkowanie karty */
  position: fixed; inset: -20%;
  background:
    radial-gradient(38% 32% at 24% 18%, rgba(76,125,255,.26), transparent 68%),
    radial-gradient(34% 30% at 78% 78%, rgba(181,124,255,.2), transparent 66%),
    radial-gradient(30% 26% at 62% 12%, rgba(33,201,138,.13), transparent 70%);
  filter: blur(30px); pointer-events: none;
}
.login-card {
  position: relative; width: 100%; max-width: 392px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 34px 30px 30px;
  box-shadow: var(--shadow-3);
  backdrop-filter: blur(18px) saturate(1.4);
  animation: rise .45s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.login-mark {
  width: 50px; height: 50px; border-radius: 15px;
  display: grid; place-items: center; color: #fff; margin-bottom: 20px;
  background: linear-gradient(150deg, var(--accent), #7a5cff);
  box-shadow: 0 10px 26px -10px var(--accent);
}
.login-mark svg { width: 26px; height: 26px; }
.login-card h1 { margin: 0; font-size: 25px; font-weight: 680; letter-spacing: -.4px; }
.login-sub { margin: 6px 0 26px; color: var(--muted); font-size: 14.5px; }

.field { display: block; margin-bottom: 15px; }
.field > span {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 6px; letter-spacing: .02em;
}
.field input, .field textarea, .field select, .inp {
  width: 100%; padding: 11px 13px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  transition: border-color .16s, background .16s, box-shadow .16s;
  font-size: 15px;
}
.field input:focus, .field textarea:focus, .field select:focus, .inp:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.check-inline {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--text-dim); margin: 4px 0 22px;
  cursor: pointer;
}
.check-inline input { width: 16px; height: 16px; accent-color: var(--accent); }
.login-error {
  margin: 14px 0 0; padding: 10px 13px; border-radius: var(--r-sm);
  background: rgba(255,84,104,.12); color: var(--red);
  font-size: 13.5px; font-weight: 550;
}

/* ──────────────────────────────── szkielet ──────────────────────────────── */

.app { display: flex; height: 100%; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 0 0 calc(8px + env(safe-area-inset-bottom));
  overflow-y: auto; overflow-x: hidden;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  position: sticky; top: 0; background: var(--bg-soft); z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), #7a5cff); color: #fff;
  box-shadow: 0 6px 16px -8px var(--accent);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-text { font-size: 17px; font-weight: 680; letter-spacing: -.3px; }
.side-close { display: none; }

.streak-card {
  margin: 4px 12px 14px; padding: 12px 14px;
  background: linear-gradient(140deg, var(--accent-soft), transparent 80%), var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  display: flex; align-items: center; gap: 12px;
}
.streak-num {
  font-size: 26px; font-weight: 720; letter-spacing: -1px; line-height: 1;
  display: flex; align-items: baseline; gap: 3px;
}
.streak-num small { font-size: 11px; font-weight: 600; color: var(--muted); }
.streak-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.streak-label { font-size: 12px; font-weight: 620; color: var(--text-dim); }
.streak-sub { font-size: 11.5px; color: var(--muted); }
.streak-sub b { color: var(--text-dim); font-weight: 650; }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 10px;
  color: var(--text-dim); font-size: 14.5px; font-weight: 550;
  text-align: left; width: 100%;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 640; }
[data-theme="light"] .nav-item.active { color: var(--accent); }
.nav-ico { width: 18px; text-align: center; font-size: 14px; opacity: .85; flex: none; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  font-size: 11.5px; font-weight: 660; color: var(--muted);
  background: var(--surface-3); padding: 1px 7px; border-radius: 999px; min-width: 20px;
  text-align: center;
}
.nav-count:empty { display: none; }
.nav-count.hot { background: rgba(255,84,104,.16); color: var(--red); }
.nav-item.slim { padding: 7px 11px; font-size: 13.5px; }

.side-section { margin-top: 18px; }
.side-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.project-list { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; }
.project-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border-radius: 10px;
  color: var(--text-dim); font-size: 14px; font-weight: 540;
  transition: background .14s, color .14s;
  cursor: pointer; user-select: none;
}
.project-item:hover { background: var(--surface-3); color: var(--text); }
.project-item.active { background: var(--accent-soft); color: var(--text); font-weight: 620; }
.project-item.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.proj-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.proj-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-count { font-size: 11.5px; color: var(--muted); font-weight: 620; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.tag-pill {
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-dim); cursor: pointer;
  transition: background .14s, color .14s;
}
.tag-pill:hover { background: var(--border); color: var(--text); }
.tag-pill.active { background: var(--accent); color: #fff; }

.side-foot {
  margin-top: auto; padding: 14px 8px 4px;
  display: flex; flex-direction: column; gap: 1px;
  border-top: 1px solid var(--border);
}

.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 19;
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
  backdrop-filter: blur(2px);
}
body.sidebar-open .scrim { opacity: 1; pointer-events: auto; }

/* ───────────────────────────── główna kolumna ───────────────────────────── */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 8;
}
.menu-btn { display: none; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 {
  margin: 0; font-size: 20px; font-weight: 680; letter-spacing: -.4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-sub { font-size: 12.5px; color: var(--muted); }
.topbar-tools { display: flex; align-items: center; gap: 8px; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-ico {
  position: absolute; left: 10px; width: 15px; height: 15px;
  color: var(--muted); pointer-events: none;
}
#searchInput {
  width: 190px; padding: 8px 30px 8px 32px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; font-size: 14px;
  transition: width .2s var(--ease), border-color .16s, box-shadow .16s;
  -webkit-appearance: none;
}
#searchInput::-webkit-search-cancel-button { display: none; }
#searchInput:focus {
  outline: none; width: 240px; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.search-clear { position: absolute; right: 3px; }

.seg {
  display: flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 2px; gap: 2px;
}
.seg button {
  width: 30px; height: 27px; border-radius: 7px;
  color: var(--muted); font-size: 13px;
  transition: background .14s, color .14s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); }

/* ──────────────────────────── szybkie dodawanie ─────────────────────────── */

.composer { padding: 14px 20px 4px; }
.composer-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 5px 6px 5px 14px;
  transition: border-color .16s, box-shadow .16s;
}
.composer-row:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.composer-plus { color: var(--muted); font-size: 19px; font-weight: 400; line-height: 1; }
#quickAdd {
  flex: 1; min-width: 0; padding: 8px 0; background: none; border: 0;
  font-size: 15px;
}
#quickAdd:focus { outline: none; }
.composer-hint {
  margin: 8px 2px 0; font-size: 12.5px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.hint-chip {
  padding: 2px 8px; border-radius: 999px; background: var(--surface-3);
  color: var(--text-dim); font-weight: 600;
}
.hint-chip.accent { background: var(--accent-soft); color: var(--accent-2); }

/* ─────────────────────────────── obszar widoku ──────────────────────────── */

.view-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 10px 20px calc(90px + env(safe-area-inset-bottom));
  scroll-behavior: smooth;
}

.group-head {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 4px 8px; font-size: 12px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.group-head:first-child { padding-top: 6px; }
.group-head .line { flex: 1; height: 1px; background: var(--border); }
.group-head .n { color: var(--text-dim); }
.group-head.danger { color: var(--red); }

.empty {
  display: grid; place-items: center; gap: 10px;
  padding: 64px 20px; text-align: center; color: var(--muted);
}
.empty-mark { font-size: 40px; opacity: .45; }
.empty h3 { margin: 0; font-size: 17px; color: var(--text-dim); font-weight: 620; }
.empty p { margin: 0; font-size: 14px; max-width: 340px; }

/* ──────────────────────────────── zadanie ───────────────────────────────── */

.task-list { display: flex; flex-direction: column; gap: 5px; }

.task {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 13px 11px 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color .15s, background .15s, box-shadow .15s, opacity .2s, transform .12s var(--ease);
  position: relative;
  cursor: pointer;
}
.task:hover { border-color: var(--border-2); box-shadow: var(--shadow-1); }
.task.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.task.done { opacity: .52; }
.task.done .task-title { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.task.overdue { border-left: 2.5px solid var(--red); }
.task.dragging { opacity: .3; }
.task.just-done { animation: pop .32s var(--ease); }
@keyframes pop { 40% { transform: scale(1.012); } }

.grip {
  width: 20px; align-self: stretch; flex: none;
  display: grid; place-items: center;
  color: var(--border-2); cursor: grab;
  touch-action: none; border-radius: 6px;
  transition: color .14s, background .14s;
}
.grip:hover { color: var(--muted); background: var(--surface-3); }
.grip:active { cursor: grabbing; }
.grip svg { width: 12px; height: 16px; }

.checkbox {
  width: 21px; height: 21px; flex: none; margin-top: 1px;
  border: 1.9px solid var(--border-2); border-radius: 50%;
  display: grid; place-items: center;
  transition: border-color .16s, background .16s, transform .12s var(--ease);
  color: transparent;
}
.checkbox:hover { border-color: var(--green); transform: scale(1.08); }
.checkbox svg { width: 12px; height: 12px; }
.task.done .checkbox {
  background: var(--green); border-color: var(--green); color: #06231a;
}
.checkbox[data-p="3"] { border-color: color-mix(in srgb, var(--p3) 62%, var(--border-2)); }
.checkbox[data-p="4"] { border-color: color-mix(in srgb, var(--p4) 72%, var(--border-2)); }

.task-main { flex: 1; min-width: 0; }
.task-title-row { display: flex; align-items: baseline; gap: 8px; }
.task-title {
  font-size: 14.8px; font-weight: 540; line-height: 1.42;
  word-break: break-word; flex: 1; min-width: 0;
}
.task-title-input {
  font-size: 14.8px; font-weight: 540; width: 100%;
  background: var(--bg-soft); border: 1px solid var(--accent);
  border-radius: 7px; padding: 4px 7px; margin: -5px -8px;
}
.task-title-input:focus { outline: none; }

.task-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 6px; font-size: 12px;
}
.task-meta:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-dim); font-weight: 600;
  white-space: nowrap;
}
.chip.due { background: var(--accent-soft); color: var(--accent-2); }
.chip.due.overdue { background: rgba(255,84,104,.14); color: var(--red); }
.chip.due.today { background: rgba(255,176,32,.15); color: var(--amber); }
.chip.tag { background: transparent; border: 1px solid var(--border-2); color: var(--muted); }
.chip.proj { gap: 5px; }
.chip.repeat { color: var(--purple); background: rgba(181,124,255,.13); }
.chip.bell { color: var(--green); background: rgba(33,201,138,.13); }
.chip.subs { font-variant-numeric: tabular-nums; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; }
.chip svg { width: 11px; height: 11px; flex: none; }

.task-actions { display: flex; gap: 2px; align-self: center; opacity: 0; transition: opacity .15s; }
.task:hover .task-actions, .task:focus-within .task-actions { opacity: 1; }
@media (hover: none) { .task-actions { opacity: 1; } }

.subs-bar {
  height: 3px; background: var(--surface-3); border-radius: 3px;
  margin-top: 8px; overflow: hidden;
}
.subs-bar > i { display: block; height: 100%; background: var(--green); border-radius: 3px;
  transition: width .3s var(--ease); }

/* placeholder podczas przeciągania */
.drop-ph {
  border: 1.5px dashed var(--accent); border-radius: var(--r);
  background: var(--accent-soft); flex: none;
  animation: phIn .16s var(--ease);
}
@keyframes phIn { from { opacity: 0; } }

.drag-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.drag-ghost {
  position: absolute; pointer-events: none;
  box-shadow: var(--shadow-3); border-radius: var(--r);
  transform-origin: center; opacity: .96;
  transform: scale(1.02) rotate(.5deg);
}

/* ──────────────────────────────── tablica ───────────────────────────────── */

.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(268px, 1fr);
  gap: 12px; align-items: stretch;   /* równa wysokość = duża strefa zrzutu */
  overflow-x: auto; padding-bottom: 12px; min-height: 60vh;
}
.board-col {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 10px;
  display: flex; flex-direction: column; min-height: 180px;
}
.board-col.drop-active { border-color: var(--accent); background: var(--accent-soft); }
.board-col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 10px; font-size: 12.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim);
}
.board-col-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.board-col-head .n { margin-left: auto; color: var(--muted); font-size: 11.5px; }
/* flex:1 sprawia, że cała wolna wysokość kolumny jest strefą zrzutu */
.board-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 11px 12px;
  /* pan-y zostawia natywne przewijanie; przeciąganie startuje po przytrzymaniu
     i wtedy skrypt sam blokuje scroll przez preventDefault na touchmove */
  cursor: grab; touch-action: pan-y;
  transition: border-color .15s, box-shadow .15s, transform .12s var(--ease), opacity .2s;
}
.card:hover { border-color: var(--border-2); box-shadow: var(--shadow-1); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .3; }
.card-title { font-size: 14.3px; font-weight: 550; line-height: 1.4; word-break: break-word; }
.card.done .card-title { text-decoration: line-through; opacity: .65; }
.card-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; font-size: 11.5px; }
.card-prio { height: 3px; border-radius: 3px; margin: -11px -12px 9px; }

/* ─────────────────────────────── kalendarz ──────────────────────────────── */

.cal-head {
  display: flex; align-items: center; gap: 10px; padding: 4px 2px 14px;
}
.cal-head h2 {
  margin: 0; font-size: 17px; font-weight: 660; letter-spacing: -.2px;
  min-width: 176px; text-transform: capitalize;
}
.cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  margin-bottom: 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  text-align: center;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day {
  min-height: 96px; padding: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .15s, background .15s;
}
.cal-day.other { opacity: .42; }
.cal-day.today { border-color: var(--accent); background: var(--accent-soft); }
.cal-day.weekend { background: var(--bg-soft); }
.cal-day.drop-active { border-color: var(--accent); background: var(--accent-soft); }
.cal-num { font-size: 12px; font-weight: 660; color: var(--text-dim); }
.cal-day.today .cal-num { color: var(--accent-2); }
.cal-item {
  font-size: 11.5px; padding: 3px 6px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: grab; touch-action: pan-y;
  border-left: 2.5px solid var(--p2);
}
.cal-item.done { opacity: .5; text-decoration: line-through; }
.cal-item.dragging { opacity: .3; }
.cal-more { font-size: 10.5px; color: var(--muted); padding-left: 4px; }

/* ──────────────────────────────── notatki ───────────────────────────────── */

.notes-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 12px; align-items: start;
}
.note {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 13px 14px;
  transition: border-color .15s, box-shadow .15s, opacity .2s;
  position: relative;
}
.note:hover { border-color: var(--border-2); box-shadow: var(--shadow-1); }
.note.dragging { opacity: .3; }
.note[data-color="amber"]  { background: color-mix(in srgb, var(--amber) 11%, var(--surface)); }
.note[data-color="green"]  { background: color-mix(in srgb, var(--green) 11%, var(--surface)); }
.note[data-color="blue"]   { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.note[data-color="purple"] { background: color-mix(in srgb, var(--purple) 12%, var(--surface)); }
.note[data-color="red"]    { background: color-mix(in srgb, var(--red) 11%, var(--surface)); }
.note-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.note-title {
  flex: 1; font-size: 14.5px; font-weight: 650; min-width: 0;
  background: none; border: 0; padding: 0;
}
.note-title:focus { outline: none; }
.note-body {
  font-size: 13.8px; line-height: 1.55; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
  background: none; border: 0; padding: 0; width: 100%; resize: none;
  min-height: 22px; font-family: inherit;
}
.note-body:focus { outline: none; }
.note-body strong { color: var(--text); }
.note-foot {
  display: flex; align-items: center; gap: 4px; margin-top: 9px;
  opacity: 0; transition: opacity .15s;
}
.note:hover .note-foot, .note:focus-within .note-foot { opacity: 1; }
@media (hover: none) { .note-foot { opacity: 1; } }
.note-date { font-size: 11px; color: var(--muted); margin-right: auto; }
.note-pin { color: var(--amber); }
.swatches { display: flex; gap: 4px; }
.swatch {
  width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--border-2);
  transition: transform .12s var(--ease);
}
.swatch:hover { transform: scale(1.18); }
.swatch[data-color="default"] { background: var(--surface-3); }
.swatch[data-color="amber"]  { background: var(--amber); }
.swatch[data-color="green"]  { background: var(--green); }
.swatch[data-color="blue"]   { background: var(--accent); }
.swatch[data-color="purple"] { background: var(--purple); }
.swatch[data-color="red"]    { background: var(--red); }

/* ─────────────────────────── panel szczegółów ───────────────────────────── */

.detail {
  width: var(--detail-w); flex: none;
  display: flex; flex-direction: column;
  background: var(--bg-soft); border-left: 1px solid var(--border);
  animation: slideIn .28s var(--ease);
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }
.detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(11px + env(safe-area-inset-top)) 12px 11px;
  border-bottom: 1px solid var(--border);
}
.detail-head-actions { display: flex; align-items: center; gap: 2px; }
.detail-crumb {
  font-size: 12px; color: var(--muted); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px;
}
.detail-body {
  flex: 1; overflow-y: auto;
  padding: 16px 18px calc(28px + env(safe-area-inset-bottom));
}

.d-title {
  width: 100%; font-size: 19px; font-weight: 650; line-height: 1.35;
  background: none; border: 0; padding: 0; resize: none;
  font-family: inherit; letter-spacing: -.2px;
}
.d-title:focus { outline: none; }
.d-section { margin-top: 22px; }
.d-label {
  font-size: 11px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.d-row { display: flex; gap: 8px; flex-wrap: wrap; }
.d-notes {
  width: 100%; min-height: 92px; padding: 11px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); resize: vertical; font-family: inherit;
  font-size: 14px; line-height: 1.55;
}
.d-notes:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-soft); }

.prio-pick { display: flex; gap: 6px; }
.prio-btn {
  flex: 1; padding: 8px 4px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 620; color: var(--muted);
  transition: all .15s;
}
.prio-btn:hover { border-color: var(--border-2); }
.prio-btn[data-p="1"].on { background: color-mix(in srgb, var(--p1) 20%, var(--surface)); color: var(--p1); border-color: var(--p1); }
.prio-btn[data-p="2"].on { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent); }
.prio-btn[data-p="3"].on { background: rgba(255,176,32,.16); color: var(--amber); border-color: var(--amber); }
.prio-btn[data-p="4"].on { background: rgba(255,84,104,.16); color: var(--red); border-color: var(--red); }

.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.qd {
  padding: 5px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  transition: all .15s;
}
.qd:hover { border-color: var(--accent); color: var(--accent-2); }

.sub-list { display: flex; flex-direction: column; gap: 3px; }
.sub-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 8px;
  transition: background .14s;
}
.sub-row:hover { background: var(--surface); }
.sub-check {
  width: 17px; height: 17px; flex: none; border-radius: 5px;
  border: 1.8px solid var(--border-2); display: grid; place-items: center;
  color: transparent; transition: all .15s;
}
.sub-check:hover { border-color: var(--green); }
.sub-row.done .sub-check { background: var(--green); border-color: var(--green); color: #06231a; }
.sub-check svg { width: 11px; height: 11px; }
.sub-title {
  flex: 1; font-size: 13.8px; background: none; border: 0; padding: 2px 0; min-width: 0;
}
.sub-title:focus { outline: none; }
.sub-row.done .sub-title { text-decoration: line-through; color: var(--muted); }

.tag-input-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 5px 3px 9px; border-radius: 999px;
  background: var(--surface-3); font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.tag-chip button { color: var(--muted); line-height: 1; font-size: 14px; padding: 0 2px; }
.tag-chip button:hover { color: var(--red); }

.d-meta { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted); line-height: 1.7; }

.remind-state {
  margin-top: 9px; padding: 9px 11px; border-radius: var(--r-sm);
  background: rgba(33,201,138,.1); color: var(--green);
  font-size: 12.5px; font-weight: 560; line-height: 1.45;
}
.remind-state.off { background: var(--surface-3); color: var(--muted); }

/* ────────────────────────────── ustawienia ──────────────────────────────── */

.settings { max-width: 660px; }
.set-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px; margin-bottom: 14px;
}
.set-card h2 {
  margin: 0 0 4px; font-size: 16px; font-weight: 660; letter-spacing: -.2px;
}
.set-card p.hint { margin: 0 0 16px; font-size: 13px; color: var(--muted); line-height: 1.55; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 0; border-top: 1px solid var(--border);
}
.set-row:first-of-type { border-top: 0; }
.set-row-text { min-width: 0; }
.set-row-text b { display: block; font-size: 14px; font-weight: 600; }
.set-row-text span { font-size: 12.5px; color: var(--muted); }

.switch {
  width: 42px; height: 25px; border-radius: 999px; flex: none;
  background: var(--border-2); position: relative;
  transition: background .2s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(17px); }

.code-box {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; word-break: break-all; color: var(--text-dim);
  user-select: all; line-height: 1.6;
}
.mail-log { display: flex; flex-direction: column; gap: 5px; max-height: 240px; overflow-y: auto; }
.mail-row {
  display: flex; gap: 9px; align-items: baseline;
  font-size: 12px; padding: 7px 9px; border-radius: 8px; background: var(--bg-soft);
}
.mail-row .st { font-weight: 700; flex: none; }
.mail-row.sent .st { color: var(--green); }
.mail-row.error .st { color: var(--red); }
.mail-row .tm { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.mail-row .dt { color: var(--text-dim); min-width: 0; word-break: break-word; }

.banner {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px; border-radius: var(--r); margin-bottom: 14px;
  font-size: 13.5px; line-height: 1.55;
}
.banner.warn { background: rgba(255,176,32,.11); color: var(--amber); border: 1px solid rgba(255,176,32,.24); }
.banner.ok   { background: rgba(33,201,138,.1); color: var(--green); border: 1px solid rgba(33,201,138,.22); }
.banner b { font-weight: 700; }
.banner a { color: inherit; }

/* ───────────────────────────── paleta poleceń ───────────────────────────── */

.palette-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: start center; }
.palette-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.palette {
  position: relative; width: min(600px, calc(100% - 28px));
  margin-top: min(14vh, 110px);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  overflow: hidden; animation: rise .22s var(--ease) both;
}
#paletteInput {
  width: 100%; padding: 17px 20px; font-size: 16px;
  background: none; border: 0; border-bottom: 1px solid var(--border);
}
#paletteInput:focus { outline: none; }
.palette-results { max-height: min(52vh, 420px); overflow-y: auto; padding: 7px; }
.pal-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 10px; cursor: pointer;
  font-size: 14.2px;
}
.pal-item .pal-ico { width: 17px; text-align: center; color: var(--muted); flex: none; }
.pal-item .pal-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-item .pal-sub { font-size: 11.5px; color: var(--muted); flex: none; }
.pal-item.on { background: var(--accent-soft); }
.pal-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }
.palette-foot {
  display: flex; gap: 16px; padding: 9px 18px;
  border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted);
}
kbd {
  display: inline-block; padding: 1px 5px; margin-right: 3px;
  border: 1px solid var(--border-2); border-bottom-width: 2px;
  border-radius: 5px; font-family: inherit; font-size: 10.5px; color: var(--text-dim);
}

/* ──────────────────────────────── toasty ────────────────────────────────── */

.toasts {
  position: fixed; z-index: 80;
  left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(440px, calc(100% - 24px));
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px 11px 16px; width: 100%;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r); box-shadow: var(--shadow-3);
  font-size: 13.8px; pointer-events: auto;
  animation: toastIn .26s var(--ease) both;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.toast.leaving { animation: toastOut .2s var(--ease) both; }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }
.toast-txt { flex: 1; min-width: 0; }
.toast.err { border-color: rgba(255,84,104,.4); }
.toast.err .toast-txt { color: var(--red); }
.toast-undo {
  font-weight: 660; color: var(--accent-2); padding: 3px 9px; border-radius: 7px;
  flex: none;
}
.toast-undo:hover { background: var(--accent-soft); }

/* ────────────────────────────────── FAB ─────────────────────────────────── */

.fab {
  display: none;
  position: fixed; z-index: 12;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 18px;
  background: var(--accent); color: #fff;
  box-shadow: 0 12px 30px -10px var(--accent), var(--shadow-2);
  place-items: center;
  transition: transform .14s var(--ease);
}
.fab:active { transform: scale(.92); }
.fab svg { width: 24px; height: 24px; }

/* ───────────────────────────── responsywność ────────────────────────────── */

@media (max-width: 1180px) {
  .detail {
    position: fixed; z-index: 20; top: 0; right: 0; bottom: 0;
    width: min(430px, 100%); box-shadow: var(--shadow-3);
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 21; top: 0; bottom: 0; left: 0;
    width: min(300px, 84%);
    transform: translateX(-102%);
    transition: transform .28s var(--ease);
    box-shadow: var(--shadow-3);
  }
  body.sidebar-open .sidebar { transform: none; }
  .side-close { display: inline-flex; }
  .menu-btn { display: inline-flex; }
  .fab { display: grid; }
  .composer { padding: 12px 14px 2px; }
  .view-area { padding: 8px 14px calc(96px + env(safe-area-inset-bottom)); }
  .topbar { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .topbar-title h1 { font-size: 18px; }
  #searchInput { width: 38px; padding-right: 8px; cursor: pointer; }
  #searchInput:focus { width: min(52vw, 230px); cursor: text; }
  .seg { display: none; }
  .notes-grid { columns: 1; }
  .composer-btn { display: none; }
  .cal-day { min-height: 66px; padding: 5px; }
  .cal-item { font-size: 10.5px; padding: 2px 4px; }
}

@media (max-width: 560px) {
  .board { grid-auto-flow: row; grid-auto-columns: auto; }
  .task { padding: 10px 10px 10px 4px; }
  .set-card { padding: 16px; }
  .cal-day { min-height: 58px; }
  .cal-num { font-size: 11px; }
}

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