/* Notatnik - Kalendarz (od 0.10.0, crm/kalendarz.js): pasek, mały miesiąc z boku od 900 px, siatka godzin Dnia
   i Tygodnia z przyklejonym nagłówkiem dni i wierszem "cały dzień", Miesiąc w 6 tygodniach, Harmonogram jako lista.
   Wydarzenie ma swój kolor w --kl-c (tekst w --kl-t), zadania obrys, notatki tło kartki. Twarde kąty jak w Hegios. */

.kl { --kl-g: 52px; --kl-linia: #E3E7ED; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.kl input, .kl textarea { -webkit-user-select: text; user-select: text; }
svg.ik.xs { width: 13px; height: 13px; }
/* Kalendarz zajmuje całą treść (#tresc bez odstępów i bez własnego przewijania); przewija się .kl-main */
#tresc:has(> #view-cal:not([hidden])) { position: relative; overflow: hidden; }
#view-cal { position: absolute; inset: 0; }
#view-cal .kl { height: 100%; display: flex; flex-direction: column; }
.kl-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 12px 32px; background: var(--h-surface); border-bottom: 1px solid var(--h-border); flex-wrap: wrap; }
.kl-bar .h-btn { min-height: 40px; }
.kl-utworz { padding-left: 12px; }
.kl-utworz .ik { width: 18px; height: 18px; }
.kl-strz { display: inline-flex; }
.kl-strz .h-icon-btn { width: 40px; height: 40px; color: var(--h-text); }
.kl-tytul { flex: 1 1 auto; margin: 0; font-size: var(--h-fs-18, 18px); font-weight: var(--h-fw-sem); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kl-tytul::first-letter { text-transform: uppercase; }
.kl-widoki button { min-height: 40px; }

.kl-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.kl-side { overflow-y: auto; padding: 16px 16px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.kl-main { position: relative; min-width: 0; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    background: var(--h-surface); border-left: 1px solid var(--h-border); }
.kl-main.kl-month { display: flex; flex-direction: column; }
.kl-month .kl-mg { flex: 1 0 auto; }
.kl-stan { margin: 0; padding: 10px 16px; font-size: var(--h-fs-13); color: var(--h-text-muted); background: var(--h-info-bg); border-bottom: 1px solid var(--h-border); }

/* -- mały miesiąc i przełączniki -- */
.kl-mini-h { display: flex; align-items: center; gap: 2px; margin-bottom: 4px; }
.kl-mini-h b { flex: 1 1 auto; font-size: var(--h-fs-13); font-weight: var(--h-fw-sem); }
.kl-mini-h b::first-letter { text-transform: uppercase; }
.kl-mini-h .h-icon-btn { width: 32px; height: 32px; color: var(--h-text); }
.kl-mini-g { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: var(--h-fs-11, 11px); }
.kl-mini-g > span { color: var(--h-text-muted); font-weight: var(--h-fw-sem); padding: 4px 0; }
.kl-mini-d { appearance: none; border: 0; background: none; font: inherit; font-size: 12px; height: 28px; cursor: pointer; color: var(--h-text); font-variant-numeric: tabular-nums; }
.kl-mini-d:hover { background: var(--h-bg); }
.kl-mini-d.other { color: var(--h-text-muted); opacity: .6; }
.kl-mini-d.in { background: var(--h-accent-bg); }
.kl-mini-d.today { background: var(--h-accent); color: #fff; font-weight: var(--h-fw-sem); }
.kl-pokaz { display: flex; flex-direction: column; gap: 2px; }
.kl-pk { min-height: 36px; }
.kl-pk input { accent-color: var(--h-accent); }
.kl-pk-task input { accent-color: var(--h-graphite); }
.kl-pk-note input { accent-color: #B08A1E; }

/* -- Dzień i Tydzień: nagłówek dni i wiersz "cały dzień" przyklejone u góry przewijania -- */
.kl-top { position: sticky; top: 0; z-index: 4; background: var(--h-surface); border-bottom: 1px solid var(--h-border); }
.kl-head, .kl-ad, .kl-scroll { display: grid; grid-template-columns: var(--kl-g) minmax(0, 1fr); }
.kl-head { grid-template-columns: var(--kl-g) repeat(var(--kl-n), minmax(0, 1fr)); }
.kl-dh { appearance: none; border: 0; background: none; font: inherit; color: var(--h-text-muted); padding: 8px 0 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; border-left: 1px solid var(--kl-linia); }
.kl-dh-w { font-size: 11px; font-weight: var(--h-fw-sem); letter-spacing: .4px; text-transform: uppercase; }
.kl-dh-n { font-size: 22px; line-height: 36px; width: 36px; height: 36px; color: var(--h-text); font-variant-numeric: tabular-nums; }
.kl-dh.we .kl-dh-w { color: var(--h-error); }
.kl-dh.today .kl-dh-w { color: var(--h-accent); }
.kl-dh.today .kl-dh-n { background: var(--h-accent); color: #fff; border-radius: 50%; }
.kl-dh:hover .kl-dh-n { background: var(--h-bg); }
.kl-dh.today:hover .kl-dh-n { background: var(--h-accent-dark); }
.kl-ad { border-top: 1px solid var(--kl-linia); min-height: 28px; }
.kl-ad-l { font-size: 10px; color: var(--h-text-muted); text-align: right; padding: 6px 6px 0 0; line-height: 1.2; }
.kl-ad-g { display: grid; grid-template-columns: repeat(var(--kl-n), minmax(0, 1fr)); grid-auto-rows: 26px; padding: 1px 0 3px; position: relative; }
.kl-ad-d { border-left: 1px solid var(--kl-linia); cursor: pointer; }
.kl-ad-d:hover { background: rgba(46, 100, 168, .04); }
.kl-ad-p { position: relative; z-index: 1; padding: 1px 2px; min-width: 0; pointer-events: none; }
.kl-ad-p > * { pointer-events: auto; }
.kl-ad .kl-duch { margin: 1px 2px; position: relative; z-index: 2; }

.kl-scroll { position: relative; }
.kl-godz { position: relative; z-index: 0; }
.kl-godz span { position: absolute; right: 6px; transform: translateY(-50%); font-size: 10px; color: var(--h-text-muted); font-variant-numeric: tabular-nums; }
.kl-cols { display: grid; grid-template-columns: repeat(var(--kl-n), minmax(0, 1fr)); position: relative;
    background-image: linear-gradient(var(--kl-linia) 1px, transparent 1px); background-size: 100% 48px; touch-action: pan-y; }
.kl-col { position: relative; border-left: 1px solid var(--kl-linia); cursor: default; }
.kl-col.today { background: rgba(46, 100, 168, .03); }
.kl-now { position: absolute; left: -1px; right: 0; height: 2px; background: #D93025; z-index: 3; pointer-events: none; }
.kl-now::before { content: ''; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: #D93025; }

/* -- bloki wydarzeń i zadań w siatce -- */
.kl-ev { position: absolute; overflow: hidden; padding: 2px 6px; font-size: 12px; line-height: 1.3; cursor: pointer; z-index: 2;
    background: var(--kl-c, var(--h-accent)); color: var(--kl-t, #fff); border: 1px solid var(--h-surface); display: flex; flex-direction: column; touch-action: pan-y; }
.kl-ev-n { font-weight: var(--h-fw-sem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; max-width: 100%; }
/* krótki blok: jedna linia "tytuł, 16:30" ucięta wielokropkiem na końcu, jak w Google */
.kl-ev.is-krotki, .kl-ev.kl-task.is-krotki { display: block; white-space: nowrap; text-overflow: ellipsis; padding-top: 0; padding-bottom: 0; line-height: 20px; }
.kl-ev.is-krotki > * { display: inline; vertical-align: middle; }
.kl-ev.is-krotki .ik { display: inline-block; margin-right: 4px; vertical-align: -2px; }
.kl-ev-t { opacity: .92; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kl-ev-res { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.kl-ev:focus-visible { outline: 2px solid var(--h-text); outline-offset: 1px; }
.kl-ev.kl-task { background: var(--h-surface); color: var(--h-text); border: 1px solid var(--h-graphite); flex-direction: row; align-items: center; gap: 4px; white-space: nowrap; }
.kl-ev.kl-task .ik { flex-shrink: 0; width: 13px; height: 13px; }
.kl-ev.is-done .kl-ev-n, .kl-chip.is-done .kl-chip-n, .kl-ag-p.is-done .kl-ag-tt { text-decoration: line-through; opacity: .6; }
.kl-ev.is-ciagniety { opacity: .85; box-shadow: var(--h-shadow-lg); z-index: 6; cursor: grabbing; pointer-events: none; }
.kl-duch { background: var(--h-accent); color: #fff; opacity: .85; box-shadow: var(--h-shadow-lg); z-index: 5; pointer-events: none; }
.kl-duch.is-caly { position: relative; padding: 2px 6px; font-size: 12px; font-weight: var(--h-fw-sem); height: 22px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
body.kl-ciagnie, body.kl-ciagnie * { cursor: grabbing !important; }

/* -- pozycje w kratkach (Miesiąc, cały dzień) -- */
.kl-chip { appearance: none; border: 0; font: inherit; font-size: 12px; line-height: 20px; height: 22px; width: 100%; min-width: 0; padding: 0 6px; text-align: left; cursor: pointer;
    display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; color: var(--h-text); background: none; touch-action: pan-y; }
/* kratka to nie blok siatki: bez położenia, ramki i tła bloku (.kl-ev) */
.kl-chip.kl-ev, .kl-chip.kl-task { position: relative; z-index: auto; flex-direction: row; align-items: center; padding: 0 6px; border: 0; background: none; color: var(--h-text); }
.kl-chip-n { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kl-chip-t { color: var(--h-text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.kl-chip.is-czas::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--kl-c, var(--h-accent)); flex-shrink: 0; }
.kl-chip.kl-task.is-czas::before { display: none; }
.kl-chip.kl-ev.is-caly { background: var(--kl-c, var(--h-accent)); color: var(--kl-t, #fff); font-weight: var(--h-fw-sem); }
.kl-chip.kl-task.is-caly { border: 1px solid var(--h-graphite); background: var(--h-surface); line-height: 18px; }
.kl-chip.kl-note { background: #FBF3D5; color: #4A3B06; }
.kl-chip .ik { width: 13px; height: 13px; flex-shrink: 0; }
.kl-chip:hover { filter: brightness(.96); }
.kl-chip.is-czas:hover { background: var(--h-bg); filter: none; }
.kl-chip.is-ciagniety { opacity: .85; box-shadow: var(--h-shadow-lg); position: relative; z-index: 6; pointer-events: none; }
.kl-ad-p.od-wczesniej .kl-chip { padding-left: 10px; clip-path: polygon(6px 0, 100% 0, 100% 100%, 6px 100%, 0 50%); }
.kl-ad-p.dalej .kl-chip { clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 50%, calc(100% - 6px) 100%, 0 100%); }

/* -- Miesiąc -- */
.kl-mdow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--kl-linia); position: sticky; top: 0; background: var(--h-surface); z-index: 3; }
.kl-mdow span { text-align: center; font-size: 11px; font-weight: var(--h-fw-sem); letter-spacing: .4px; text-transform: uppercase; color: var(--h-text-muted); padding: 8px 0; }
.kl-mdow span.we { color: var(--h-error); }
.kl-mg { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(80px, 1fr); }
.kl-mc { border-right: 1px solid var(--kl-linia); border-bottom: 1px solid var(--kl-linia); padding: 2px 2px 4px; min-width: 0; display: flex; flex-direction: column; gap: 1px; cursor: pointer; touch-action: pan-y; }
.kl-mc:nth-child(7n) { border-right: 0; }
.kl-mc.other { background: #FAFBFC; }
.kl-mc.other .kl-mc-n { color: var(--h-text-muted); }
.kl-mc.is-cel { background: var(--h-accent-bg); }
.kl-mc-n { appearance: none; border: 0; background: none; font: inherit; font-size: 12px; font-weight: var(--h-fw-med); align-self: center; min-width: 26px; height: 26px; padding: 0 6px; cursor: pointer; color: var(--h-text); border-radius: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kl-mc-n:hover { background: var(--h-bg); }
.kl-mc.today .kl-mc-n { background: var(--h-accent); color: #fff; }
.kl-more { appearance: none; border: 0; background: none; font: inherit; font-size: 12px; font-weight: var(--h-fw-sem); color: var(--h-text-muted); text-align: left; padding: 0 6px; cursor: pointer; height: 20px; }
.kl-more:hover { color: var(--h-text); background: var(--h-bg); }
.kl-mc .kl-duch.is-caly { margin: 0; }

/* -- Harmonogram -- */
.kl-ag { padding: 8px 0; }
.kl-ag-d { display: grid; grid-template-columns: 120px minmax(0, 1fr); border-bottom: 1px solid var(--kl-linia); padding: 6px 16px; }
.kl-ag-n { appearance: none; border: 0; background: none; font: inherit; display: flex; align-items: baseline; gap: 8px; padding: 6px 0; cursor: pointer; color: var(--h-text); text-align: left; align-self: start; }
.kl-ag-n b { font-size: 22px; font-weight: var(--h-fw-reg); min-width: 30px; font-variant-numeric: tabular-nums; }
.kl-ag-n span { font-size: 12px; color: var(--h-text-muted); text-transform: uppercase; letter-spacing: .3px; }
.kl-ag-d.today .kl-ag-n b { color: var(--h-accent); font-weight: var(--h-fw-sem); }
.kl-ag-l { display: flex; flex-direction: column; }
.kl-ag-p { appearance: none; border: 0; background: none; font: inherit; display: grid; grid-template-columns: 24px 120px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px; text-align: left; cursor: pointer; color: var(--h-text); }
.kl-ag-p:hover { background: var(--h-bg); }
.kl-ag-k { display: flex; justify-content: center; }
.kl-ag-k i { width: 10px; height: 10px; border-radius: 50%; background: var(--kl-c, var(--h-accent)); }
.kl-ag-k .ik { width: 15px; height: 15px; }
.kl-ag-t { font-size: 13px; color: var(--h-text-muted); font-variant-numeric: tabular-nums; }
.kl-ag-tt { font-weight: var(--h-fw-med); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kl-ag-tt small { display: block; font-weight: var(--h-fw-reg); color: var(--h-text-muted); font-size: 12px; }
.kl-ag-pusto { padding: 48px 16px; }

/* -- dymek wydarzenia i szybkie okno -- */
.kl-pop, .kl-quick { position: fixed; z-index: 60; background: var(--h-surface); border: 1px solid var(--h-border); box-shadow: 0 8px 28px rgba(35,39,46,.22);
    width: 380px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 80px); overflow-y: auto; padding: 8px 16px 16px; }
.kl-pop.is-arkusz, .kl-quick.is-arkusz { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto; max-width: none; border-width: 1px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.kl-pop-a { display: flex; justify-content: flex-end; gap: 2px; margin: 0 -8px 4px 0; }
.kl-pop-a .h-icon-btn { width: 40px; height: 40px; color: var(--h-text-muted); }
.kl-pop-a .h-icon-btn:hover { color: var(--h-text); background: var(--h-bg); }
.kl-pop-r { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; padding: 6px 0; font-size: var(--h-fs-14); }
.kl-pop-r .ik { width: 18px; height: 18px; color: var(--h-text-muted); justify-self: center; margin-top: 1px; }
.kl-pop-r h3 { margin: 0; font-size: 20px; font-weight: var(--h-fw-reg); line-height: 1.3; word-break: break-word; }
.kl-pop-k { width: 14px; height: 14px; margin: 6px auto 0; display: block; }
.kl-pop-s { color: var(--h-text-muted); font-size: var(--h-fs-13); }
.kl-pop-s::first-letter { text-transform: uppercase; }
.kl-pop-o { white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow-y: auto; -webkit-user-select: text; user-select: text; }

.kl-q-h { display: flex; justify-content: flex-end; margin: 0 -8px 0 0; }
.kl-q-h .h-icon-btn { width: 40px; height: 40px; color: var(--h-text-muted); }
.kl-q-tytul { width: 100%; font-size: 20px; border: 0; border-bottom: 2px solid var(--h-border); padding: 6px 2px; margin-bottom: 12px; background: none; }
.kl-q-tytul:focus { outline: none; border-bottom-color: var(--h-accent); }
.kl-q-typ { margin-bottom: 12px; }
.kl-q-typ button { min-height: 36px; }
.kl-q-p { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.kl-q-l { display: inline-flex; align-items: center; gap: 8px; }
.kl-q-l .ik { width: 18px; height: 18px; color: var(--h-text-muted); }
.kl-q-p .h-input { padding: 8px 8px; min-height: 40px; }
.kl-q-czas { display: inline-flex; align-items: center; gap: 6px; }
.kl-q-czas[hidden] { display: none; }
.kl-q-caly { min-height: 40px; }
.kl-q-nota { display: none; gap: 8px; margin-bottom: 4px; }
.kl-quick.is-note .kl-q-nota { display: flex; }
.kl-q-nota .h-btn { flex: 1 1 0; min-height: 44px; }
.kl-q-nota .ik { width: 16px; height: 16px; }
.kl-q-a { display: flex; justify-content: flex-end; gap: 8px; }
.kl-q-a .h-btn { min-height: 40px; }

/* -- pełne okno wydarzenia -- */
.kl-ed { width: 560px; max-width: calc(100vw - 16px); }
.kl-ed-b { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; max-height: calc(100dvh - 200px); overflow-y: auto; }
.kl-ed-tytul { font-size: 20px; border: 0; border-bottom: 2px solid var(--h-border); padding: 6px 2px; background: none; }
.kl-ed-tytul:focus { outline: none; border-bottom-color: var(--h-accent); }
.kl-ed-r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kl-ed-r > .h-input, .kl-ed-r > .h-select { flex: 1 1 160px; min-width: 0; min-height: 40px; }
.kl-ed-czas .h-input[type="time"] { flex: 0 1 120px; }
.kl-ed-l { width: 40px; flex-shrink: 0; display: inline-flex; justify-content: center; color: var(--h-text-muted); font-size: var(--h-fs-13); }
.kl-ed-l .ik { width: 18px; height: 18px; }
.kl-ed-opis { align-items: flex-start; }
.kl-ed-opis .h-textarea { flex: 1 1 auto; }
.kl-ed-wl { border-left: 2px solid var(--h-border); margin-left: 19px; padding: 4px 0 4px 20px; display: flex; flex-direction: column; gap: 8px; }
.kl-ed-wl .kl-ed-l { width: auto; justify-content: flex-start; min-width: 52px; }
.kl-ed-num { width: 72px; flex: 0 0 72px !important; }
.kl-ed-dni { gap: 4px; }
.kl-ed-dzien { appearance: none; border: 1px solid var(--h-border-strong); background: var(--h-surface); font: inherit; font-size: 12px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: var(--h-text); }
.kl-ed-dzien.is-on { background: var(--h-accent); border-color: var(--h-accent); color: #fff; }
.kl-ed-kon .h-select { flex: 0 1 120px; }
.kl-ed-kon .h-input[type="date"] { flex: 0 1 170px; }
.kl-ed-kolory { display: flex; flex-wrap: wrap; gap: 6px; }
.kl-ed-kolor { appearance: none; border: 2px solid transparent; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; outline-offset: 2px; }
.kl-ed-kolor.is-on { box-shadow: 0 0 0 2px var(--h-surface), 0 0 0 4px var(--h-text); }
.kl-ed-kk { width: 14px; height: 14px; border-radius: 50%; display: block; }
.kl-ed .act-dlg-actions .kl-ed-usun { margin-right: auto; }
.kl-zakres-l { display: flex; flex-direction: column; gap: 4px; padding: 8px 0 12px; }
.kl-zakres-o { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.kl-zakres-o input { width: 18px; height: 18px; accent-color: var(--h-accent); }

/* -- węższe ekrany -- */
@media (max-width: 1100px) {
    .kl-body { grid-template-columns: 200px minmax(0, 1fr); }
    .kl-side { padding-left: 16px; }
}
@media (max-width: 899px) {
    .kl-body { grid-template-columns: minmax(0, 1fr); }
    .kl-side { display: none; }
    .kl-main { border-left: 0; padding-bottom: env(safe-area-inset-bottom); }
    .kl-bar { padding: 8px 12px; gap: 6px; }
    .kl-tytul { font-size: 16px; }
    .kl-widoki { order: 6; flex: 1 1 100%; display: flex; }
    .kl-widoki button { flex: 1 1 0; justify-content: center; text-align: center; padding-left: 2px; padding-right: 2px; font-size: 13px; }
    .kl-utworz span { display: none; }
    .kl-utworz { padding: 0 10px; }
    .kl { --kl-g: 40px; }
    .kl-dh-n { font-size: 18px; width: 30px; height: 30px; line-height: 30px; }
    .kl-mg { grid-auto-rows: minmax(72px, 1fr); }
    .kl-mc .kl-chip { font-size: 11px; padding: 0 3px; height: 18px; line-height: 18px; }
    .kl-mc .kl-chip-t, .kl-mc .kl-chip.is-czas::before { display: none; }
    .kl-ag-d { grid-template-columns: 64px minmax(0, 1fr); padding: 6px 8px; }
    .kl-ag-n { flex-direction: column; gap: 0; }
    .kl-ag-p { grid-template-columns: 20px 88px minmax(0, 1fr); padding: 4px; }
}
@media (max-width: 480px) {
    .kl-ad-l { font-size: 9px; padding-right: 3px; }
    .kl-ev { padding: 1px 3px; font-size: 11px; }
}
