/* ==========================================================================
   Zmienne i podstawy
   Motyw ustawia theme.js przez atrybut <html data-theme="light|dark">.
   ========================================================================== */

/* Motyw jasny (domyślny) */
:root {
  color-scheme: light;

  --bg: #f5f5ef;
  --text: #203c35;
  --muted: #68776f;
  --faint: #87958b;
  --surface: #fffefa;
  --soft: #e8eee3;
  --line: #dce3da;

  --control: #ffffff;
  --control-hover: #eaf0e8;
  --control-text: #163d36;

  --green: #163d36;
  --green-hover: #28594c;
  --on-green: #ffffff;
  --accent: #d08b43;
  --focus: #ceaa65;
  --danger: #ab3434;

  --event-bg: #f6f8f2;
  --event-border: #dfe5db;
  --remote-bg: #e1e6e0;
  --remote-border: #bdc7bd;
  --custom-bg: #fcf2df;
  --custom-border: #deb473;
  --gap-stripe-1: #e3ece0;
  --gap-stripe-2: #f4f7f1;
  --gap-border: #b4c5b1;
  --session-fg: #6d3fc0;
  --session-bg: #f6f2fc;
  --session-badge-bg: #ede5fb;
  --session-border: #cab6ef;
  --now-color: #d9383a;
  --grid-five: #dfe7dc;
  --grid-quarter: #c7d4c3;
  --grid-hour: #a3b69e;
  --today-border: #5a8d70;
  --slot-height: 15px;
  --head-height: 52px;

  --shadow: #12382725;
  --backdrop: #0b231c66;

  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

/* Motyw ciemny */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1715;
  --text: #e2ebe6;
  --muted: #9db0a6;
  --faint: #73867c;
  --surface: #16211e;
  --soft: #1e2d29;
  --line: #2b3b36;

  --control: #1b2925;
  --control-hover: #243632;
  --control-text: #cfe6dc;

  --green: #2f7a68;
  --green-hover: #3a8d79;
  --on-green: #ffffff;
  --accent: #e0a15e;
  --focus: #d9b46e;
  --danger: #f08a8a;

  --event-bg: #1b2724;
  --event-border: #2b3b36;
  --remote-bg: #111917;
  --remote-border: #2a3c36;
  --custom-bg: #2a2015;
  --custom-border: #7a582b;
  --gap-stripe-1: #1f312c;
  --gap-stripe-2: #15221e;
  --gap-border: #3d5950;
  --session-fg: #c9b0ff;
  --session-bg: #1d192b;
  --session-badge-bg: #2b2242;
  --session-border: #4e3d78;
  --now-color: #ff6b6b;
  --grid-five: #243631;
  --grid-quarter: #314942;
  --grid-hour: #46665d;
  --today-border: #4f9a7a;

  --shadow: #00000080;
  --backdrop: #000000aa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

html.modal-open,
body.modal-open {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

body.modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  touch-action: none;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   Nagłówek i typografia
   ========================================================================== */

header,
main {
  max-width: 1500px;
  margin: auto;
  padding: 30px 36px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 32px;
  padding-bottom: 22px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.view-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.view-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 13px;
  border-radius: 9px;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.view-tab:hover {
  background: var(--control-hover);
  color: var(--text);
}

.view-tab.active {
  background: var(--green);
  color: var(--on-green);
  box-shadow: 0 2px 8px var(--shadow);
}

.view-tab.active:hover {
  background: var(--green-hover);
  color: var(--on-green);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  background: var(--accent);
  color: #ffffff;
  line-height: 1;
}

.live-clock-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.live-clock-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e12d39;
  box-shadow: 0 0 0 2px rgba(225, 45, 57, 0.25);
  animation: liveClockPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes liveClockPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.88);
  }
}

header p {
  color: var(--muted);
  margin: 0;
}

main {
  padding-top: 0;
}

h1 {
  font-size: 40px;
  letter-spacing: -1.8px;
  margin: 0;
}

h1 span {
  color: var(--accent);
}

h2 {
  margin: 8px 0;
  font-size: 25px;
  letter-spacing: -0.7px;
}

h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

p {
  line-height: 1.6;
}

.eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--muted);
}

.hint,
small {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.hint {
  margin: 15px 0;
}

.error {
  color: var(--danger);
  font-size: 13px;
}

/* ==========================================================================
   Układy pomocnicze
   ========================================================================== */

.actions,
.pair,
.dialogfoot,
.dialoghead {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pair {
  align-items: stretch;
}

.pair > label {
  flex: 1;
  min-width: 130px;
}

.pair > label.color-label {
  flex: 0 0 auto;
  min-width: 80px;
}

/* ==========================================================================
   Przyciski
   ========================================================================== */

button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--control-text);
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button .ph {
  font-size: 16px;
  line-height: 1;
}

button:hover {
  background: var(--control-hover);
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.primary {
  background: var(--green);
  color: var(--on-green);
  border-color: var(--green);
}

.primary:hover {
  background: var(--green-hover);
}

#editModeToggle[aria-pressed="true"] {
  background: var(--green);
  color: var(--on-green);
  border-color: var(--green);
}

#editModeToggle[aria-pressed="true"]:hover {
  background: var(--green-hover);
}

.danger {
  color: var(--danger);
}

/* ==========================================================================
   Pasek narzędzi i status
   ========================================================================== */

.menu-toggle,
.mobile-only {
  display: none;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}

.status {
  font-size: 12px;
  padding: 10px 14px;
  background: var(--soft);
  border-radius: 8px;
  min-height: 38px;
}

/* ==========================================================================
   Nawigacja tygodnia
   ========================================================================== */

.weekbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin: 30px 0 20px;
}

.weekbar p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.weekbar-actions {
  align-items: center;
}

.datejump {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0 4px;
  white-space: nowrap;
}

.datejump input {
  width: auto;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.2;
  border-radius: 9px;
}

/* ==========================================================================
   Kalendarz i siatka godzinowa (wiersze co 5 minut)
   ========================================================================== */

/* Pasek przełączania dni na telefonie (styl USOS) — ukryty na komputerze */
.mobile-day-tabs {
  display: none;
}

.calendar-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
}

.calendar {
  display: grid;
  grid-template-columns: 62px repeat(7, minmax(155px, 1fr));
  gap: 8px;
  align-items: start;
}

.calendar.has-special-days {
  --head-height: 78px;
}

/* Kolumna godzin po lewej od poniedziałku */
.time-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  position: sticky;
  left: 0;
  z-index: 4;
  user-select: none;
}

.time-head {
  height: var(--head-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.time-head .ph {
  font-size: 15px;
}

.time-slots {
  position: relative;
  width: 100%;
}

.time-slot {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--slot-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 7px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.time-slot.hour {
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  border-top: 1px solid var(--grid-hour);
  background: var(--soft);
}

.time-slot.hour:first-child {
  border-top: none;
}

.time-slot.quarter {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  border-top: 1px solid var(--grid-quarter);
  background: #ffffff08;
}

.time-slot.five {
  font-size: 8.5px;
  color: var(--faint);
  border-top: 1px solid var(--grid-five);
}

/* Kolumna pojedynczego dnia */
.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.day.today {
  border-color: var(--today-border);
}

.day.holiday {
  background: var(--event-bg);
  opacity: 0.95;
}

.day.session {
  background: var(--session-bg);
  border-color: var(--session-border);
}

.day.session .dayhead {
  background: var(--session-badge-bg);
}

.day-top {
  height: var(--head-height);
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.dayhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 10px 12px;
  flex: 1;
  cursor: default;
  background: transparent;
  transition: background 0.15s ease;
  user-select: none;
}

.dayhead.editable {
  cursor: pointer;
}

.dayhead.editable:hover {
  background: var(--soft);
}

.today .dayhead {
  background: var(--soft);
}

.dayhead-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.dayhead span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.dayhead strong {
  font-size: 19px;
  font-weight: 600;
}

.dayhead-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  opacity: 0.7;
}

.dayhead.editable:hover .dayhead-add {
  opacity: 1;
}

.calendar.has-today-done-stack {
  --head-height: 98px;
}

.today-done-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.3;
  background: linear-gradient(135deg, #059669 0%, #0d9488 55%, #0284c7 100%);
  color: #ffffff;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  white-space: nowrap;
  user-select: none;
}

:root[data-theme="dark"] .today-done-pill {
  background: linear-gradient(135deg, #059669 0%, #0891b2 100%);
  color: #f0fdfa;
  border-top: 1px solid rgba(94, 234, 212, 0.45);
  box-shadow: 0 -1px 8px rgba(16, 185, 129, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.today-done-pill i {
  font-size: 12px;
  color: #a7f3d0;
  flex-shrink: 0;
}

:root:not([data-theme="dark"]) .today-done-pill i {
  color: #d1fae5;
}

.today-done-pill[hidden] {
  display: none !important;
}

/* Wskaźnik dnia specjalnego w nagłówku kolumny */
.special-day-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 10px;
  border-top: 1px dashed var(--line);
  line-height: 1.3;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
}

.special-day-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: block;
  position: relative;
}

.special-day-label-inner {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
}

.special-day-label.is-overflowing {
  mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 14px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 14px), transparent 100%);
}

.special-day-label.is-overflowing .special-day-label-inner {
  animation: specialBadgeMarquee var(--marquee-time, 7s) ease-in-out infinite;
}

.special-day-badge:hover .special-day-label.is-overflowing .special-day-label-inner {
  animation-play-state: paused;
}

@keyframes specialBadgeMarquee {
  0%, 18% {
    transform: translateX(0);
  }
  50%, 68% {
    transform: translateX(var(--marquee-shift, 0px));
  }
  100% {
    transform: translateX(0);
  }
}

.special-day-badge.editable {
  cursor: pointer;
}

.special-day-badge .ph {
  font-size: 12px;
  flex-shrink: 0;
}

.special-day-badge.holiday {
  background: #ffdede22;
  color: var(--danger);
  border-top-color: var(--danger);
}

.special-day-badge.session {
  background: var(--session-badge-bg);
  color: var(--session-fg);
  border-top-color: var(--session-border);
}

.special-day-badge.swap {
  background: #ceaa6522;
  color: var(--accent);
  border-top-color: var(--accent);
}

.special-day-badge.rector {
  background: #6b7b8e2e;
  color: var(--text);
  border-top-color: var(--muted);
}

/* Siatka 5-minutowa dla pojedynczego dnia — oparta na rzeczywistych liniach border-top
   o identycznych współrzędnych top jak kolumna godzin, dzięki czemu przy skalowaniu (np. 90%)
   linie nie znikają ani nie rozjeżdżają się względem godzin i bloków zajęć. */
.day-timeline {
  position: relative;
  width: 100%;
}

.timeline-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.timeline-slot {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--slot-height);
}

.timeline-slot.hour {
  border-top: 1px solid var(--grid-hour);
}

.timeline-slot.hour:first-child {
  border-top: none;
}

.timeline-slot.quarter {
  border-top: 1px solid var(--grid-quarter);
}

.timeline-slot.five {
  border-top: 1px solid var(--grid-five);
}

.day-timeline.editable {
  cursor: cell;
}

.day-empty-overlay {
  position: absolute;
  inset: 12px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}

.day-empty-overlay.session-empty {
  color: var(--session-fg);
  font-weight: 600;
  opacity: 0.85;
}

.day-empty-btn {
  position: absolute;
  top: 16px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 1px dashed var(--line);
  background: var(--surface);
  color: var(--faint);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  padding: 10px 8px;
  transition: all 0.15s ease;
  z-index: 1;
}

.day-empty-btn:hover {
  background: var(--soft);
  color: var(--control-text);
  border-style: solid;
}

/* Okienko między zajęciami — pełne (nieprzezroczyste) ukośne pasy zakrywają kreski siatki 5-minutowej w tle */
.gap-block {
  position: absolute;
  left: 4px;
  right: 4px;
  background: repeating-linear-gradient(
    -45deg,
    var(--gap-stripe-1) 0px,
    var(--gap-stripe-1) 8px,
    var(--gap-stripe-2) 8px,
    var(--gap-stripe-2) 16px
  );
  border: 1.5px dashed var(--gap-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 8px;
  color: var(--text);
  text-align: center;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--surface);
}

.gap-block .gap-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
  color: var(--text);
}

.gap-block .gap-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.2;
}

.gap-block.cancelled-by-rector {
  opacity: 0.25;
  filter: grayscale(1);
}

/* Nakładka godzin / dnia rektorskiego (zaszarza okres lub cały dzień na planie) */
.rector-overlay {
  position: absolute;
  left: 3px;
  right: 3px;
  z-index: 4;
  pointer-events: none;
  border-radius: 10px;
  border: 1.5px dashed var(--muted);
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(90, 98, 108, 0.24),
      rgba(90, 98, 108, 0.24) 9px,
      rgba(45, 50, 56, 0.34) 9px,
      rgba(45, 50, 56, 0.34) 18px
    );
  backdrop-filter: grayscale(0.85) blur(1px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
}

.rector-overlay.full-day {
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 0;
  border: none;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(82, 88, 96, 0.32),
      rgba(82, 88, 96, 0.32) 10px,
      rgba(40, 44, 50, 0.44) 10px,
      rgba(40, 44, 50, 0.44) 20px
    );
}

.rector-overlay-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: 0 6px 20px var(--shadow);
  text-align: center;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rector-overlay-title {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.rector-overlay-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.rector-overlay-free {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--soft);
  padding: 3px 7px;
  border-radius: 6px;
  margin-top: 2px;
  line-height: 1.3;
}

/* Pojedyncze zajęcia na osi czasu — wysokość odpowiada czasowi trwania */
.event {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2.5px;
  text-align: left;
  border: 1px solid var(--event-border);
  border-left: 4px solid var(--type-badge-fg, var(--green));
  border-radius: 8px;
  padding: 6px 9px;
  background: var(--event-bg);
  overflow: hidden;
  z-index: 2;
  box-shadow: 0 2px 6px #00000014;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.event:hover {
  z-index: 3;
  box-shadow: 0 4px 12px var(--shadow);
}

/* Tła i akcenty dopasowane do typu zajęć (inne niż Zdalnie i Wydarzenie własne) */
.event.type-lecture {
  --type-bg: #eef2fb;
  --type-border: #c9d5ee;
  --type-badge-bg: #dce5f8;
  --type-badge-fg: #2b4c8c;
  background: var(--type-bg);
  border-color: var(--type-border);
}

.event.type-lab {
  --type-bg: #eaf6f6;
  --type-border: #bce0e0;
  --type-badge-bg: #d3efef;
  --type-badge-fg: #1b6568;
  background: var(--type-bg);
  border-color: var(--type-border);
}

.event.type-project {
  --type-bg: #f3effb;
  --type-border: #d5c7ee;
  --type-badge-bg: #e6dcf8;
  --type-badge-fg: #58358a;
  background: var(--type-bg);
  border-color: var(--type-border);
}

.event.type-exercise {
  --type-bg: #edf7ef;
  --type-border: #c2dec8;
  --type-badge-bg: #d8efe0;
  --type-badge-fg: #236339;
  background: var(--type-bg);
  border-color: var(--type-border);
}

.event.type-seminar {
  --type-bg: #faeff5;
  --type-border: #e6c6d6;
  --type-badge-bg: #f3d9e7;
  --type-badge-fg: #7e2b58;
  background: var(--type-bg);
  border-color: var(--type-border);
}

.event.type-exam {
  --type-bg: #fdedee;
  --type-border: #ebbcc0;
  --type-badge-bg: #fad7da;
  --type-badge-fg: #94242b;
  background: var(--type-bg);
  border-color: var(--type-border);
  border-left-width: 5px;
}

.event.type-retake {
  --type-bg: #fff2e6;
  --type-border: #f0c299;
  --type-badge-bg: #fde1c6;
  --type-badge-fg: #9a4406;
  background: var(--type-bg);
  border-color: var(--type-border);
  border-left-width: 5px;
}

.event.type-test {
  --type-bg: #fef8e4;
  --type-border: #ead28c;
  --type-badge-bg: #faeab4;
  --type-badge-fg: #7c5800;
  background: var(--type-bg);
  border-color: var(--type-border);
  border-left-width: 5px;
}

.event.type-defense {
  --type-bg: #f1ecfd;
  --type-border: #cbbaf5;
  --type-badge-bg: #e2d6fc;
  --type-badge-fg: #512da8;
  background: var(--type-bg);
  border-color: var(--type-border);
  border-left-width: 5px;
}

.event.type-consult {
  --type-bg: #eef5f9;
  --type-border: #c4d9e6;
  --type-badge-bg: #d9eaf4;
  --type-badge-fg: #265978;
  background: var(--type-bg);
  border-color: var(--type-border);
}

.event.type-makeup {
  --type-bg: #f4f6ea;
  --type-border: #d4dcB8;
  --type-badge-bg: #e6eccf;
  --type-badge-fg: #4e5d1e;
  background: var(--type-bg);
  border-color: var(--type-border);
}

:root[data-theme="dark"] .event.type-lecture {
  --type-bg: #182235;
  --type-border: #2b3e63;
  --type-badge-bg: #223354;
  --type-badge-fg: #a8c5ff;
}

:root[data-theme="dark"] .event.type-lab {
  --type-bg: #14282b;
  --type-border: #254b52;
  --type-badge-bg: #1d3c42;
  --type-badge-fg: #8ce4ea;
}

:root[data-theme="dark"] .event.type-project {
  --type-bg: #221b33;
  --type-border: #3f3160;
  --type-badge-bg: #31254d;
  --type-badge-fg: #cdb4ff;
}

:root[data-theme="dark"] .event.type-exercise {
  --type-bg: #16291e;
  --type-border: #294c38;
  --type-badge-bg: #203d2c;
  --type-badge-fg: #9be6b5;
}

:root[data-theme="dark"] .event.type-seminar {
  --type-bg: #2b1924;
  --type-border: #522e44;
  --type-badge-bg: #402335;
  --type-badge-fg: #f5add4;
}

:root[data-theme="dark"] .event.type-exam {
  --type-bg: #2f181b;
  --type-border: #5c2c32;
  --type-badge-bg: #472126;
  --type-badge-fg: #ffadb3;
}

:root[data-theme="dark"] .event.type-retake {
  --type-bg: #301e12;
  --type-border: #633c20;
  --type-badge-bg: #4a2c17;
  --type-badge-fg: #ffc28e;
}

:root[data-theme="dark"] .event.type-test {
  --type-bg: #2b2412;
  --type-border: #574820;
  --type-badge-bg: #403517;
  --type-badge-fg: #f5da8a;
}

:root[data-theme="dark"] .event.type-defense {
  --type-bg: #211936;
  --type-border: #463375;
  --type-badge-bg: #322454;
  --type-badge-fg: #d2baff;
}

:root[data-theme="dark"] .event.type-consult {
  --type-bg: #16242e;
  --type-border: #2a4557;
  --type-badge-bg: #203645;
  --type-badge-fg: #9dd4f5;
}

:root[data-theme="dark"] .event.type-makeup {
  --type-bg: #222616;
  --type-border: #414a29;
  --type-badge-bg: #32391f;
  --type-badge-fg: #d2e396;
}

/* Zajęcia zdalne (przyciemnione, ale w pełni czytelne) */
.event.remote {
  background: var(--remote-bg);
  border-color: var(--remote-border);
  border-left: 4px dashed var(--type-badge-fg, var(--green));
  color: var(--text);
}

/* Wydarzenia własne / poza przedmiotem (wyróżnione ciepłym tłem i obramowaniem) */
.event.custom-event {
  background: var(--custom-bg);
  border-color: var(--custom-border);
  border-left: 5px solid var(--accent);
}

/* Zajęcia odwołane przez godziny / dzień rektorski */
.event.cancelled-by-rector {
  filter: grayscale(0.9);
  opacity: 0.45;
  border-style: dashed;
}

.event.cancelled-by-rector .name {
  text-decoration: line-through;
}

/* Zajęcia trwające w tej chwili (podświetlone przez wskaźnik czasu na żywo) */
.event.is-now {
  box-shadow: 0 0 0 2px var(--now-color), 0 6px 16px var(--shadow);
  z-index: 3;
}

/* Wskaźnik aktualnej godziny na żywo (styl USOS) */
.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid var(--now-color);
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: center;
}

.now-line .now-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--now-color);
  margin-left: -4px;
  box-shadow: 0 0 0 3px #d9383a33;
  flex-shrink: 0;
}

.now-line .now-badge {
  margin-left: 4px;
  padding: 1.5px 6px;
  border-radius: 999px;
  background: var(--now-color);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px var(--shadow);
  white-space: nowrap;
}

.event-top-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 3px 4px;
  width: 100%;
  min-width: 0;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.event .time {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin-right: auto;
  white-space: nowrap;
}

.type-tag,
.remote-tag,
.custom-tag,
.rector-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.25px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--type-badge-bg, var(--surface));
  color: var(--type-badge-fg, var(--text));
  border: 1px solid var(--type-border, var(--line));
  max-width: 100%;
  min-width: 0;
}

.type-tag > span,
.remote-tag > span,
.custom-tag > span,
.rector-tag > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-tag .ph,
.remote-tag .ph,
.custom-tag .ph,
.rector-tag .ph {
  flex-shrink: 0;
}

.type-tag {
  margin-top: 2px;
}

.remote-tag {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.rector-tag {
  background: #6b7b8e33;
  color: var(--muted);
  border-color: var(--muted);
}

.custom-tag {
  background: #d08b4326;
  color: var(--accent);
  border-color: var(--custom-border);
}

.event .name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.24;
  width: 100%;
  overflow-wrap: anywhere;
}

.event.medium-block .name {
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.event.short-block .name,
.event.compact .name {
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

.event .meta {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.25;
  width: 100%;
  overflow-wrap: anywhere;
}

.event.medium-block .meta,
.event.short-block .meta {
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

.event.compact {
  padding: 3px 6px;
}

.event.compact .name {
  font-size: 11px;
}

.details-badge.remote {
  background: var(--remote-bg);
  color: var(--text);
  border: 1px solid var(--remote-border);
}

.details-badge.custom {
  background: var(--custom-bg);
  color: var(--accent);
  border: 1px solid var(--custom-border);
}

/* ==========================================================================
   Stopka
   ========================================================================== */

.app-footer {
  max-width: 1500px;
  margin: 36px auto 0;
  padding: 22px 36px 36px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.app-footer .copyright {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.2px;
}

/* ==========================================================================
   Okna dialogowe i formularze
   ========================================================================== */

dialog {
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 25px;
  width: min(560px, calc(100% - 24px));
  max-height: 90vh;
  box-shadow: 0 22px 80px var(--shadow);
  overscroll-behavior: contain;
  touch-action: pan-y;
}

dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(3px);
}

.dialoghead {
  justify-content: space-between;
  margin-bottom: 18px;
}

.dialoghead h2 {
  font-size: 22px;
  margin: 0;
}

.dialoghead button {
  font-size: 20px;
  padding: 5px 12px;
}

.dialogfoot {
  justify-content: flex-end;
  margin-top: 18px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  margin: 12px 0;
}

label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

label.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
  font-size: 14px;
  color: inherit;
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  width: 100%;
  min-width: 0;
}

input[type="color"] {
  width: 80px;
  height: 40px;
  padding: 4px;
}

textarea {
  min-height: 70px;
  resize: vertical;
}

/* Okno szczegółów zajęć */
.details-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--green);
}

.details-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.details-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.details-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  background: var(--green);
  color: var(--on-green);
}

.details-badge.subtle {
  background: var(--soft);
  color: var(--text);
  font-weight: 600;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 0;
}

.details-grid > div {
  background: var(--soft);
  padding: 10px 12px;
  border-radius: 8px;
}

.details-grid dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}

.details-grid dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.details-section {
  background: var(--soft);
  padding: 12px 14px;
  border-radius: 10px;
}

.details-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.details-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 0 0 6px;
}

.details-section-head h3 {
  margin: 0;
}

.copy-note-btn {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
}

.copy-note-btn.copied,
.kanban-note-action-btn.copied,
.rich-link-copy.copied {
  background: var(--green);
  color: var(--on-green);
  border-color: var(--green);
}

.details-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

/* Klikalne linki i przycisk kopiowania wewnątrz notatek / opisów */
.rich-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  vertical-align: baseline;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 4px 1px 6px;
  margin: 1px 2px;
}

.rich-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--green);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  max-width: 100%;
  min-width: 0;
}

:root[data-theme="dark"] .rich-link {
  color: #7ad6be;
}

.rich-link:hover {
  color: var(--accent);
}

.rich-link-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

.rich-link-copy {
  padding: 2px 5px;
  font-size: 11px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.rich-link-copy:hover {
  background: var(--soft);
  color: var(--text);
}

/* Lista przedmiotów */
.subjectrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.subjectrow-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.subjectrow-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.subjectrow-details {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subjectrow button {
  padding: 7px 9px;
  font-size: 12px;
}

/* Masowe usuwanie i czyszczenie */
.bulk-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.bulk-section:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.bulk-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 8px;
}

.seriesrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--soft);
}

.seriesrow-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.seriesrow-title {
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.seriesrow-meta {
  font-size: 11px;
  color: var(--muted);
}

.seriesrow button {
  padding: 6px 10px;
  font-size: 12px;
  flex-shrink: 0;
}

/* Lista dni w strukturze roku */
.dialog-subhead {
  font-size: 15px;
  margin: 18px 0 10px;
  border-top: 1px solid var(--line);
  padding-top: 15px;
}

.specialdayrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--soft);
  margin-bottom: 8px;
}

.specialdayrow-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.specialdayrow-date {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.specialdayrow-desc {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.specialdayrow button {
  padding: 6px 10px;
  font-size: 12px;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.holiday {
  background: #ffdede33;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.badge.session {
  background: var(--session-badge-bg);
  color: var(--session-fg);
  border: 1px solid var(--session-border);
}

.badge.swap {
  background: #ceaa6533;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.badge.rector {
  background: #6b7b8e33;
  color: var(--text);
  border: 1px solid var(--muted);
}

/* ==========================================================================
   Tablica Kanban (osobny widok SPA + osobny plik kanban.json)
   ========================================================================== */

.kanban-view {
  margin-top: 24px;
}

.kanban-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.kanban-bar-info p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.kanban-filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.kanban-filter-item {
  margin: 0;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kanban-filter-item select,
.kanban-filter-item input {
  padding: 8px 11px;
  font-size: 13px;
  border-radius: 9px;
  min-width: 155px;
}

.kanban-search-wrap input {
  min-width: 210px;
}

.kanban-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(var(--kanban-cols, 3), minmax(290px, 1fr));
  gap: 14px;
  align-items: start;
}

.kanban-col {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  min-height: 420px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kanban-col.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus);
}

.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  border-radius: 13px 13px 0 0;
}

.kanban-col-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.kanban-col-title-wrap .ph {
  font-size: 17px;
  color: var(--green);
}

.kanban-col.is-done-col .kanban-col-title-wrap .ph {
  color: var(--today-border);
}

.kanban-col-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-col-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

.kanban-col-add-btn {
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 13px;
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  flex: 1;
}

.kanban-empty-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 110px;
  border: 1.5px dashed var(--line);
  background: transparent;
  color: var(--faint);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  padding: 16px;
}

.kanban-empty-col .ph {
  font-size: 20px;
}

.kanban-empty-col:not(.readonly):hover {
  background: var(--surface);
  color: var(--control-text);
  border-style: solid;
}

.kanban-empty-col.readonly {
  cursor: default;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 11px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 6px #00000010;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.kanban-card.editable {
  cursor: grab;
}

.kanban-card:hover {
  box-shadow: 0 6px 16px var(--shadow);
}

.kanban-card.dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.kanban-card.priority-high {
  border-left-color: var(--danger);
}

.kanban-card.priority-medium {
  border-left-color: var(--accent);
}

.kanban-card.priority-low {
  border-left-color: var(--today-border);
}

.kanban-card.is-done {
  opacity: 0.78;
}

.kanban-card.is-done .kanban-card-title-btn {
  text-decoration: line-through;
  color: var(--muted);
}

.kanban-card-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.kanban-prio-badge,
.kanban-subject-badge,
.kanban-due-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 6px;
  border-radius: 5px;
  line-height: 1.3;
}

.kanban-prio-badge.priority-high {
  background: #ab343422;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.kanban-prio-badge.priority-medium {
  background: #d08b4324;
  color: var(--accent);
  border: 1px solid var(--custom-border);
}

.kanban-prio-badge.priority-low {
  background: var(--soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.kanban-subject-badge {
  background: var(--soft);
  color: var(--control-text);
  border: 1px solid var(--line);
  text-transform: none;
  font-weight: 700;
  font-size: 10.5px;
  max-width: 100%;
}

.kanban-subject-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kanban-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  cursor: grab;
  padding: 1px 2px;
}

.kanban-card-title-btn {
  all: unset;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
  color: var(--text);
  text-align: left;
  overflow-wrap: anywhere;
}

.kanban-card-title-btn:hover {
  color: var(--accent);
}

.kanban-card-desc-wrap {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: text;
}

.kanban-card-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.48;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
  max-height: 92px;
  overflow-y: auto;
}

.kanban-desc-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  border-top: 1px dashed var(--line);
  padding-top: 5px;
}

.kanban-note-action-btn {
  padding: 3px 7px;
  font-size: 10.5px;
  border-radius: 5px;
}

/* Checklista na karcie */
.kanban-card-checklist {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kanban-check-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.kanban-check-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kanban-check-bar {
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.kanban-check-fill {
  height: 100%;
  background: var(--today-border);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.kanban-card-checkitems {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kanban-card-checkitem {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 7px;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  color: var(--text);
}

.kanban-card-checkitem input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 1px 0 0;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.kanban-card-checkitem.done span {
  text-decoration: line-through;
  color: var(--muted);
}

.kanban-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

.kanban-due-badge.normal {
  background: var(--soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.kanban-due-badge.due-soon {
  background: #d08b4324;
  color: var(--accent);
  border: 1px solid var(--custom-border);
}

.kanban-due-badge.overdue {
  background: #ab343424;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.kanban-due-badge.done {
  background: var(--soft);
  color: var(--today-border);
  border: 1px solid var(--line);
}

.kanban-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.kanban-icon-btn {
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 12px;
}

/* Edytor checklisty w oknie modalnym */
.kanban-checklist-editor {
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.kanban-checklist-editor .field-label {
  font-size: 12px;
  font-weight: 600;
}

.kanban-checklist-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.kanban-draft-checkrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-draft-checkrow input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.kanban-draft-checkrow input[type="text"] {
  padding: 7px 10px;
  font-size: 13px;
}

.kanban-checklist-add {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-checklist-add button {
  flex-shrink: 0;
  white-space: nowrap;
}

.kanban-col-form {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

/* ==========================================================================
   Responsywność
   ========================================================================== */

@media (max-width: 1100px) {
  .calendar {
    grid-template-columns: 56px repeat(7, minmax(150px, 1fr));
  }
}

/* Telefony i mniejsze tablety: widok jednego wybranego dnia z paskiem przełączania (styl USOS) */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .menu-toggle,
  .mobile-only {
    display: inline-flex;
  }

  header,
  main,
  .app-footer {
    padding-left: 10px;
    padding-right: 10px;
  }

  .app-footer {
    margin-top: 24px;
    padding-top: 16px;
    padding-bottom: 24px;
  }

  header {
    padding-top: 12px;
    padding-bottom: 8px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  h1 {
    font-size: 22px;
    letter-spacing: -1px;
  }

  .header-actions {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .header-actions button {
    font-size: 12px;
    white-space: nowrap;
    padding: 8px 10px;
  }

  /* Skrócone przyciski edycji i dodawania na pasku górnym telefonu (ikona) */
  #editModeToggle .btn-label,
  #addEvent .btn-label,
  #manageKanbanColsBtn .btn-label,
  #addKanbanCardBtn .btn-label {
    display: none;
  }

  .brand-wrap {
    gap: 10px;
    width: 100%;
    justify-content: space-between;
  }

  .view-tabs {
    padding: 3px;
  }

  .view-tab {
    padding: 6px 10px;
    font-size: 12px;
  }

  .menu-toggle[aria-expanded="true"] {
    background: var(--green);
    color: var(--on-green);
    border-color: var(--green);
  }

  /* Rozwijany panel hamburgera z narzędziami i chmurą */
  .nav-panel {
    display: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 14px 36px var(--shadow);
  }

  .nav-panel.open {
    display: block;
  }

  .toolbar {
    flex-direction: column;
    gap: 8px;
    padding-bottom: 10px;
  }

  .toolbar .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .toolbar .actions button {
    width: 100%;
    justify-content: flex-start;
    padding: 9px 10px;
    font-size: 12px;
  }

  .status {
    margin: 10px 0 0;
    padding: 8px 10px;
    min-height: 0;
    font-size: 11px;
    overflow-wrap: anywhere;
  }

  button {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Zwarty nagłówek tygodnia i nawigacja w jednej linii */
  .weekbar {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    margin: 4px 0 8px;
  }

  .weekbar .eyebrow {
    display: none;
  }

  .weekbar h2 {
    font-size: 16px;
    margin: 0;
  }

  .weekbar p {
    font-size: 11px;
    line-height: 1.35;
  }

  .weekbar .actions {
    width: 100%;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .datejump {
    margin-left: auto;
    gap: 4px;
  }

  .datejump-label {
    display: none;
  }

  .datejump input {
    padding: 7px 8px;
    font-size: 12px;
  }

  /* Pasek dni tygodnia (PN | WT | ŚR | CZ | PT | SB | ND) */
  .mobile-day-tabs {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 11px;
    overflow: hidden;
    margin-bottom: 10px;
  }

  .mobile-day-tab {
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    padding: 8px 2px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
  }

  .mobile-day-tab:hover {
    background: var(--soft);
  }

  .mobile-day-tab .tab-code {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.4px;
  }

  .mobile-day-tab .tab-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
  }

  .mobile-day-tab .tab-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: transparent;
    margin-top: 1px;
  }

  .mobile-day-tab .tab-dot.has-events {
    background: var(--green);
  }

  .mobile-day-tab.is-session .tab-code {
    color: var(--session-fg);
  }

  .mobile-day-tab.is-today .tab-code {
    color: var(--today-border);
  }

  .mobile-day-tab.active {
    background: var(--soft);
    color: var(--text);
    border-bottom-color: var(--accent);
  }

  .mobile-day-tab.active .tab-code {
    color: var(--accent);
  }

  .calendar-scroll {
    overflow-x: hidden;
  }

  .calendar {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 6px;
  }

  .calendar .day:not(.mobile-active) {
    display: none;
  }

  .calendar .day.mobile-active {
    will-change: transform, opacity;
  }

  .calendar .day.mobile-active.slide-next {
    animation: mobileSlideNext 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .calendar .day.mobile-active.slide-prev {
    animation: mobileSlidePrev 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  /* Widok mobilny tablicy Kanban (jedna aktywna kolumna + pasek przełączania kolumn) */
  .kanban-view {
    margin-top: 8px;
  }

  .kanban-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
  }

  .kanban-bar .eyebrow {
    display: none;
  }

  .kanban-bar h2 {
    font-size: 16px;
    margin: 0;
  }

  .kanban-bar-info p {
    font-size: 11px;
  }

  .kanban-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .kanban-filter-item select,
  .kanban-filter-item input {
    min-width: 0;
    padding: 7px 9px;
    font-size: 12px;
  }

  .kanban-search-wrap {
    grid-column: 1 / -1;
  }

  .mobile-kanban-tabs {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  }

  .kanban-scroll {
    overflow-x: hidden;
  }

  .kanban-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .kanban-board .kanban-col:not(.mobile-active) {
    display: none;
  }

  .kanban-board .kanban-col.mobile-active.slide-next {
    animation: mobileSlideNext 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .kanban-board .kanban-col.mobile-active.slide-prev {
    animation: mobileSlidePrev 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .hint {
    font-size: 11px;
  }
}

@keyframes mobileSlideNext {
  from {
    opacity: 0.35;
    transform: translate3d(34px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes mobileSlidePrev {
  from {
    opacity: 0.35;
    transform: translate3d(-34px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}
