/* Wspólne zmienne CSS */
:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --surface: #f8fafc;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  --accent-start: #2563eb;
  --accent-end: #7c3aed;
  --glass: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.6));
  --glass-dark: linear-gradient(180deg, rgba(17, 24, 39, 0.65), rgba(17, 24, 39, 0.55));
  --phi: 1.618;
  /* golden ratio */
  accent-color: var(--primary);
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --surface: #0b1220;
  --border: #1f2937;
  --primary: #60a5fa;
  --primary-contrast: #06121f;
  --danger: #f87171;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  /* Accent override for better contrast on buttons */
  --accent-start: #60a5fa;
  --accent-end: #a78bfa;
}

/* Wspólne style podstawowe */
[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1000px 600px at 10% -10%, rgba(124, 58, 237, 0.08), transparent 60%) no-repeat,
    radial-gradient(800px 500px at 100% 10%, rgba(37, 99, 235, 0.08), transparent 60%) no-repeat,
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
  overflow: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

/* Style desktopowe (domyślne, stosowane dla ekranów > 820px) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: 10px 14px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
}

.brand .logo {
  font-size: 1.3rem;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.period {
  min-width: 200px;
  text-align: center;
  font-weight: 700;
}

.view-switch,
.date-switch {
  display: flex;
  align-items: center;
  gap: 6px;
}

.container {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
  will-change: transform;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  background: var(--border);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: var(--primary-contrast);
  border: 0;
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.25);
}

.btn.primary:hover {
  transform: translateY(-2px) scale(1.01);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
  border: none;
}

.view-btn.active {
  background: var(--border);
}

.ripple {
  position: absolute;
  border-radius: 999px;
  transform: scale(0);
  background: color-mix(in srgb, var(--text) 15%, #fff);
  opacity: 0.35;
  pointer-events: none;
  animation: ripple .6s ease-out;
}

@keyframes ripple {
  to {
    transform: scale(12);
    opacity: 0;
  }
}

html.theme-anim * {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease, outline-color .25s ease;
}

#calendar-root[data-anim="forward"]>* {
  animation: slideInFromRight .38s cubic-bezier(.2, .75, .2, 1);
}

#calendar-root[data-anim="back"]>* {
  animation: slideInFromLeft .38s cubic-bezier(.2, .75, .2, 1);
}

#calendar-root[data-anim="pop"]>* {
  animation: fadePop .32s ease;
}

#calendar-root[data-anim="flip-forward"]>* {
  animation: flipFwd .5s cubic-bezier(.2, .75, .2, 1);
  transform-origin: center right;
}

#calendar-root[data-anim="flip-back"]>* {
  animation: flipBack .5s cubic-bezier(.2, .75, .2, 1);
  transform-origin: center left;
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(30px) scale(.98);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-30px) scale(.98);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes fadePop {
  from {
    opacity: 0;
    transform: scale(.98);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes flipFwd {
  from {
    opacity: 0;
    transform: perspective(1000px) rotateY(-75deg) scale(.96);
  }

  to {
    opacity: 1;
    transform: perspective(1000px) rotateY(0) scale(1);
  }
}

@keyframes flipBack {
  from {
    opacity: 0;
    transform: perspective(1000px) rotateY(75deg) scale(.96);
  }

  to {
    opacity: 1;
    transform: perspective(1000px) rotateY(0) scale(1);
  }
}

.month-grid {
  display: grid;
  gap: 10px;
}

.month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.mh-cell {
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  font-size: .8rem;
  letter-spacing: .02em;
}

.month-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.day-cell {
  border: 1px solid var(--border);
  border-radius: 16px;
  min-height: 120px;
  background: var(--bg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease;
}

.day-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.12);
}

.day-cell .day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px dashed var(--border);
}

.day-cell .day-number {
  font-weight: 800;
}

.day-cell.today {
  outline: 2px solid color-mix(in srgb, var(--accent-start) 60%, transparent);
}

.day-cell .events-wrap {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-pill {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.10);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  transition: background .18s ease, transform .18s ease;
}

.event-pill:hover {
  background: rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.more-pill {
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.author-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 10px;
  font-weight: 700;
  margin-right: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}


.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.week-col {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  overflow: hidden;
}

.week-col-head {
  background: var(--surface);
  padding: 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.week-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.week-event {
  border-left: 3px solid var(--primary);
  padding: 8px 10px;
  background: rgba(37, 99, 235, 0.10);
  border-radius: 10px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.week-event .time {
  font-size: 0.85rem;
  color: var(--muted);
}

.day-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
}

.day-row .time {
  color: var(--muted);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-weight: 700;
}

.form-row input,
.form-row textarea,
.form-row select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent-start) 30%, transparent);
  border-color: color-mix(in srgb, var(--accent-start) 40%, var(--border));
}

.grid2 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid3 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.user-checklist {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.user-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
}

.user-checklist label:hover {
  background: color-mix(in srgb, var(--border) 60%, transparent);
}

.chips-row .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}

.chip:hover {
  background: var(--surface);
  transform: translateY(-1px);
}

.chip:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent-start) 40%, transparent);
  outline-offset: 2px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1000;
}

#modal-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}

#modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(820px, 96vw);
  max-height: min(92vh, 92dvh);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
  display: grid;
  grid-template-rows: auto 1fr auto;
  z-index: 1001;
}

.modal-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

.modal-body {
  padding: 16px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.modal-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--surface) 75%, transparent) 40%, color-mix(in srgb, var(--surface) 95%, transparent)), var(--bg);
  border-top: 1px solid var(--border);
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
}

.modal-close:hover,
.modal-close:focus-visible {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border-radius: 8px;
  outline: none;
}

#modal {
  will-change: transform, opacity;
}

#modal:not(.sheet) {
  transform: translate(-50%, -50%) scale(.985);
  opacity: 0;
  transition: transform .25s cubic-bezier(.2, .75, .2, 1), opacity .25s ease;
}

#modal.open:not(.sheet) {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.dow label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}

.dow input {
  margin: 0;
}

.age-inline {
  font-weight: 800;
  margin-left: 6px;
  color: var(--text);
  opacity: 0.95;
}

.upcoming-wrap {
  display: block;
}

.upcoming-list {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.up-item {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 18px;
  overflow: hidden;
  transform: translate3d(0, 24px, 0) scale(0.985) rotateX(0) rotateY(0);
  opacity: .001;
  transition: transform .7s cubic-bezier(.2, .75, .2, 1), opacity .7s ease, box-shadow .3s ease;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  will-change: transform, opacity;
  transform-style: preserve-3d;
}

.up-item.reveal {
  transform: translate3d(0, 0, 0) scale(1);
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .up-item:hover {
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.20);
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0) scale(1.015);
  }
}

.up-img-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--surface);
  overflow: hidden;
}

.up-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.05) translateZ(0);
  opacity: 0;
  transition: opacity .6s ease, transform .9s ease;
  will-change: transform, opacity;
}

.up-img.img-loaded {
  opacity: 1;
  transform: scale(1);
}

.up-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  height: 100%;
}

.up-content {
  padding: 14px;
}

.up-content h3 {
  margin: 0 0 6px;
  font-weight: 800;
}

.up-time {
  color: var(--muted);
  font-size: 0.9rem;
}

.up-desc {
  margin: 8px 0 0;
  color: var(--text);
}

.tooltip {
  position: fixed;
  z-index: 1500;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
  font-size: .9rem;
  pointer-events: none;
  transform: translateY(-6px);
  opacity: 0;
  animation: tooltip-in .16s ease forwards;
}

@keyframes tooltip-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1600;
  display: grid;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  animation: toast-in .25s ease forwards;
}

.toast.success {
  border-left: 4px solid #16a34a;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.warn {
  border-left: 4px solid #f59e0b;
}

.toast .t-close {
  margin-left: 8px;
  cursor: pointer;
  opacity: .7;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 700px at 0% 0%, rgba(124, 58, 237, 0.14), transparent 50%) no-repeat,
    radial-gradient(900px 600px at 100% 0%, rgba(37, 99, 235, 0.14), transparent 50%) no-repeat,
    var(--bg);
}

.auth-card {
  width: min(440px, 94vw);
  border-radius: 20px;
  padding: 22px 22px 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
}

.auth-card h1 {
  margin: 6px 0 14px;
  font-weight: 800;
}

.auth-form .form-row {
  margin-bottom: 12px;
}

.auth-form input {
  width: 100%;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  margin-bottom: 10px;
}

.auth-brand .logo {
  font-size: 1.4rem;
}

main#app {
  flex: 1 0 auto;
}

.footer {
  flex: 0 0 auto;
  margin-top: auto;
  text-align: center;
  padding: 20px;
  opacity: 0.9;
}

/* Style dla urządzeń mobilnych (≤ 820px) */
@media (max-width: 820px) {

  /* Hamburger i nav drawer */
  #nav-toggle {
    display: inline-flex;
    width: 42px;
    height: 40px;
    align-items: center;
    justify-content: center;
  }

  .hamburger-box {
    width: 22px;
    height: 16px;
    position: relative;
    display: inline-block;
  }

  .hamburger-inner,
  .hamburger-inner::before,
  .hamburger-inner::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    transition: transform .2s ease, opacity .2s ease, top .2s ease;
  }

  .hamburger-inner {
    top: 50%;
    transform: translateY(-50%);
  }

  .hamburger-inner::before {
    top: -6px;
  }

  .hamburger-inner::after {
    top: 6px;
  }

  .hamburger.active .hamburger-inner {
    transform: translateY(-50%) rotate(45deg);
  }

  .hamburger.active .hamburger-inner::before {
    top: 0;
    transform: rotate(90deg);
  }

  .hamburger.active .hamburger-inner::after {
    opacity: 0;
  }

  .nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
    z-index: 1200;
  }

  .nav-overlay.open {
    opacity: 1;
    visibility: visible;
  }

  .nav-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    background: var(--bg);
    color: var(--text);
    border-right: none;
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.18);
    transform: translateX(-105%);
    transition: transform .25s cubic-bezier(.2, .75, .2, 1);
    z-index: 1201;
    display: flex;
    flex-direction: column;
  }

  .nav-drawer.open {
    transform: translateX(0);
  }

  .nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .nav-title {
    font-weight: 800;
  }

  .nav-close {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--muted);
  }

  .nav-content {
    padding: clamp(12px, 4vw, 22px);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: calc(12px * var(--phi));
  }

  .nav-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .nav-section-title {
    font-weight: 800;
    font-size: .9rem;
    color: var(--muted);
  }

  .nav-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: calc(8px * var(--phi));
  }

  .nav-item.btn {
    padding: 8px 12px;
  }

  .nav-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .nav-user {
    color: var(--muted);
  }

  /* Topbar i akcje */
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .period {
    text-align: left;
  }

  html.nav-ready .topnav {
    display: flex;
  }

  html.nav-ready .topnav .date-switch {
    display: none;
  }

  html.nav-ready .actions .user-info,
  html.nav-ready .actions .btn.primary,
  html.nav-ready .actions a[href*="/admin/"],
  html.nav-ready .actions a[href*="/login"] {
    display: none !important;
  }

  .actions a.icon-only.btn {
    width: 42px;
    min-width: 42px;
    padding: 8px 0;
    text-align: center;
  }

  .container {
    max-width: none;
    width: 100%;
    padding: clamp(12px, 4vw, 20px);
  }

  .footer {
    width: 100%;
    padding: clamp(12px, 4vw, 20px);
  }
}

/* Style dla bardzo małych ekranów (≤ 640px) */
@media (max-width: 640px) {
  .grid2 {
    grid-template-columns: 1fr;
  }

  .grid3 {
    grid-template-columns: 1fr;
  }

  .mh-cell {
    font-size: .75rem;
  }

  .day-cell {
    min-height: 100px;
  }

  .modal {
    width: 100vw;
    max-height: 96dvh;
    border-radius: 18px;
  }

  .modal.sheet {
    top: auto;
    bottom: 0;
    left: 50%;
    width: 100vw;
    max-width: 100vw;
    max-height: 96dvh;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    transform: translate(-50%, var(--sheet-offset, 110%));
    transition: transform .35s cubic-bezier(.2, .75, .2, 1);
  }

  #modal.sheet {
    transform: translate(-50%, var(--sheet-offset, 110%));
  }

  .modal-header {
    padding-top: 22px;
  }

  .modal-header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 30%, transparent);
    display: block;
  }

  .modal.sheet.open {
    --sheet-offset: 0px;
  }

  .modal.sheet.half {
    --sheet-offset: 46dvh;
  }
}

/* Kompaktowy kalendarz dla urządzeń mobilnych */
@media (max-width: 820px) {
  html.compact .month-days {
    gap: 6px;
  }

  html.compact .day-cell {
    min-height: 95px;
    border-radius: 14px;
  }

  html.ultra-compact .day-cell {
    min-height: 76px;
    border-radius: 12px;
  }

  html.compact .day-cell .day-head {
    padding: 6px 8px;
  }

  html.ultra-compact .day-cell .day-head {
    padding: 4px 6px;
  }

  html.compact .day-cell .events-wrap {
    gap: 5px;
    padding: 6px 8px;
  }

  html.ultra-compact .day-cell .events-wrap {
    gap: 4px;
    padding: 4px 6px;
  }

  html.compact .event-pill {
    padding: 4px 6px;
    font-size: .82rem;
  }

  html.ultra-compact .event-pill {
    padding: 3px 5px;
    font-size: .78rem;
  }

  html.compact .month-days .events-wrap .event-pill:nth-child(n+3):not(.more-pill) {
    display: inline-block;
    width: 8px;
    height: 8px;
    padding: 0;
    border: none;
    border-radius: 999px;
    overflow: hidden;
    text-indent: -9999px;
    background: color-mix(in srgb, var(--primary) 50%, transparent);
  }

  html.ultra-compact .month-days .events-wrap .event-pill:nth-child(n+2):not(.more-pill) {
    display: inline-block;
    width: 8px;
    height: 8px;
    padding: 0;
    border: none;
    border-radius: 999px;
    text-indent: -9999px;
  }

  html.compact .more-pill {
    font-size: .8rem;
  }

  html.compact .week-grid {
    grid-template-columns: 1fr;
  }

  html.compact .week-event {
    padding: 6px 8px;
    font-size: .9rem;
  }

  html.compact .day-row {
    grid-template-columns: 90px 1fr;
    gap: 8px;
  }

  html.ultra-compact .day-row {
    grid-template-columns: 70px 1fr;
  }
}

/* Responsywność widoku tygodniowego */
@media (max-width: 900px) {
  .week-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Style wydruku */
@media print {
  body {
    color: #000;
    background: #fff;
  }

  .topbar,
  .actions,
  .modal,
  .footer,
  .nav-overlay,
  .nav-drawer {
    display: none !important;
  }

  .month-days .day-cell {
    min-height: 80px;
    page-break-inside: avoid;
  }

  .event-pill {
    background: #eee;
  }
}

/* ========== Patch: mobilna nawigacja i drobne poprawki responsywności ========== */

/* Burger domyślnie ukryty na desktopie */
#nav-toggle {
  display: none;
}

@media (max-width: 820px) {
  #nav-toggle {
    display: inline-flex;
  }
}

/* .period bez wymuszania szerokości na wąskich ekranach */
@media (max-width: 820px) {
  .period {
    min-width: 0;
  }
}

/* Przyciski w topnav bez min-width (lepsze zawijanie/ścieśnianie) */
.topnav .btn {
  min-width: 0;
}

/* Chips: poziomy scroll na wąskich ekranach */
@media (max-width: 640px) {
  .chips-row .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 6px;
  }

  .chips-row .chips::-webkit-scrollbar {
    height: 6px;
  }

  .chips-row .chips::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--border) 70%, transparent);
    border-radius: 999px;
  }
}

/* Globalny focus ring (a11y) */
*:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent-start) 50%, transparent);
  outline-offset: 2px;
}

/* Widok dnia – jedną kolumną na bardzo wąskich */
@media (max-width: 560px) {
  .day-row {
    grid-template-columns: 1fr;
  }
}

/* Dni tygodnia – 4 kolumny na bardzo wąskich */
@media (max-width: 520px) {
  .dow {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Brak poziomego scrolla */
html,
body {
  overflow-x: hidden;
}

#app,
.container,
.topbar,
.nav-drawer,
.modal {
  max-width: 100%;
}

/* Ultra-wąskie: ikony bez labeli w drawerze */
@media (max-width: 380px) {
  .nav-row .nav-item .label {
    display: none;
  }

  .nav-row .nav-item .icon {
    margin-right: 0;
  }
}

/* Smartfony w pionie: modal domyślnie wyśrodkowany (nie full-screen) */
@media (max-width: 640px) {
  .modal {
    width: min(94vw, 560px);
    /* zamiast 100vw */
    max-height: 92dvh;
    border-radius: 18px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* centralnie */
  }

  /* jeśli aktywujesz .sheet w JS – będzie full-width od dołu */
  .modal.sheet {
    top: auto;
    bottom: 0;
    left: 50%;
    width: 100vw;
    max-width: 100vw;
    max-height: 96dvh;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    transform: translate(-50%, var(--sheet-offset, 110%));
    transition: transform .35s cubic-bezier(.2, .75, .2, 1);
  }

  #modal.sheet {
    transform: translate(-50%, var(--sheet-offset, 110%));
  }
}

/* ========== Safe-area + brak poziomego scrolla ========== */
html,
body {
  overflow-x: hidden;
}

#app,
.container,
.topbar,
.nav-drawer,
.modal {
  max-width: 100%;
}

/* iOS notch: dodaj wewnętrzne odstępy w headerze i footerze */
@supports (padding: max(0px)) {
  .topbar {
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
  }

  .footer {
    padding-bottom: max(20px, calc(20px + env(safe-area-inset-bottom)));
  }
}

/* ========== Tryb phone-portrait (≤480px, pion) ========== */
@media (max-width: 480px) and (orientation: portrait) {
  html.phone-portrait .container {
    padding: 12px;
  }

  html.phone-portrait .month-header {
    gap: 4px;
  }

  html.phone-portrait .mh-cell {
    font-size: .7rem;
    letter-spacing: .01em;
  }

  html.phone-portrait .month-days {
    gap: 4px;
  }

  html.phone-portrait .day-cell {
    min-height: 72px;
    border-radius: 12px;
  }

  html.phone-portrait .day-cell .day-head {
    padding: 4px 6px;
  }

  html.phone-portrait .day-cell .day-number {
    font-size: .9rem;
  }

  /* Wydarzenia jako kropki (ikony zamiast tekstu) w siatce miesiąca */
  html.phone-portrait .month-days .events-wrap {
    gap: 4px;
    padding: 4px 6px;
  }

  html.phone-portrait .month-days .event-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 18px;
    /* height to fit avatar */
    padding: 0;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    font-size: 0;
    /* Hide text node */
    background: transparent;
    box-shadow: none;
  }

  html.phone-portrait .month-days .event-pill .author-avatar {
    margin-right: 0;
    width: 16px;
    height: 16px;
    font-size: 9px;
  }

  /* Fallback for events without avatar (if any, though pill logic has avatar) or just as dot */

  html.phone-portrait .month-days .more-pill {
    font-size: .75rem;
    padding: 0;
    color: var(--muted);
  }

  /* Ikony zamiast napisów w przełączniku widoków */
  html.phone-portrait .view-switch {
    gap: 4px;
  }

  html.phone-portrait .view-switch .btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    font-size: 0;
    /* ukryj tekst */
  }

  html.phone-portrait .view-switch .btn[data-view="month"]::before {
    content: "📅";
    font-size: 18px;
  }

  html.phone-portrait .view-switch .btn[data-view="week"]::before {
    content: "🗓️";
    font-size: 18px;
  }

  html.phone-portrait .view-switch .btn[data-view="day"]::before {
    content: "📆";
    font-size: 18px;
  }

  html.phone-portrait .view-switch .btn[data-view="upcoming"]::before {
    content: "⭐";
    font-size: 18px;
  }

  /* „Dziś” jako ikona */
  html.phone-portrait #btn-today {
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 0;
    display: inline-grid;
    place-items: center;
  }

  html.phone-portrait #btn-today::before {
    content: "📍";
    font-size: 18px;
  }

  /* Nawigacja okresu – zostawiamy same strzałki (już masz), ścieśniamy */
  html.phone-portrait .date-switch {
    gap: 4px;
  }

  /* Okno modalne wyśrodkowane na telefonach (domyślnie), „sheet” tylko gdy .sheet */
  html.phone-portrait .modal {
    width: min(94vw, 560px);
    max-height: 92dvh;
    border-radius: 18px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  html.phone-portrait .modal.sheet {
    top: auto;
    bottom: 0;
    left: 50%;
    width: 100vw;
    max-width: 100vw;
    max-height: 96dvh;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    transform: translate(-50%, var(--sheet-offset, 110%));
  }
}

/* Ultra-wąskie: w szufladzie chowamy etykiety przy strzałkach */
@media (max-width: 380px) {
  .nav-row .nav-item .label {
    display: none;
  }

  .nav-row .nav-item .icon {
    margin-right: 0;
  }
}

/* Header: ukryj tekstowy tytuł na mobile (gdyby jeszcze był w DOM) */
@media (max-width: 820px) {
  .brand .title {
    display: none !important;
  }
}

/* Phone portrait: jeden rząd ikonek: Dziś + widoki */
@media (max-width: 480px) and (orientation: portrait) {
  html.phone-portrait {
    --icon-btn: 36px;
    --icon-gap: 6px;
  }

  /* Topnav: jedna linia, bez zawijania, wyśrodkowana */
  html.phone-portrait .topnav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--icon-gap);
    flex-wrap: nowrap;
    min-width: 0;
  }

  html.phone-portrait .view-switch {
    display: flex;
    align-items: center;
    gap: var(--icon-gap);
    flex-wrap: nowrap;
  }

  /* Ikonki jako równe, okrągłe guziki (bez tekstu) */
  html.phone-portrait #btn-today,
  html.phone-portrait .view-switch .btn {
    width: var(--icon-btn);
    height: var(--icon-btn);
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    font-size: 0;
    /* ukryj tekst */
    min-width: 0;
  }

  html.phone-portrait #btn-today::before {
    content: "📍";
    font-size: 18px;
  }

  html.phone-portrait .view-switch .btn[data-view="month"]::before {
    content: "📅";
    font-size: 18px;
  }

  html.phone-portrait .view-switch .btn[data-view="week"]::before {
    content: "🗓️";
    font-size: 18px;
  }

  html.phone-portrait .view-switch .btn[data-view="day"]::before {
    content: "📆";
    font-size: 18px;
  }

  html.phone-portrait .view-switch .btn[data-view="upcoming"]::before {
    content: "⭐";
    font-size: 18px;
  }

  /* Schowaj przełączanie okresu w topbar (już było, ale doprecyzowujemy) */
  html.nav-ready .topnav .date-switch {
    display: none !important;
  }
}

/* Jeszcze ciaśniejsze ikonki na ultra-wąskich (np. 320–360px) */
@media (max-width: 360px) and (orientation: portrait) {
  html.phone-portrait {
    --icon-btn: 34px;
    --icon-gap: 6px;
  }

  html.phone-portrait #btn-today::before,
  html.phone-portrait .view-switch .btn::before {
    font-size: 16px;
  }
}

@media (max-width: 320px) and (orientation: portrait) {
  html.phone-portrait {
    --icon-btn: 30px;
    --icon-gap: 5px;
  }

  html.phone-portrait #btn-today::before,
  html.phone-portrait .view-switch .btn::before {
    font-size: 15px;
  }
}

/* Phone portrait: chowamy logo, hamburger po lewej, ikonki w jednej linii */
@media (max-width: 480px) and (orientation: portrait) {
  .brand .logo {
    display: none !important;
  }

  /* usuń logo */

  /* Zmniejszamy odstępy w topbar */
  .topbar {
    gap: 8px;
    grid-template-columns: auto 1fr auto;
  }

  html.phone-portrait {
    --icon-btn: 36px;
    --icon-gap: 6px;
  }

  /* Topnav: wyśrodkowana, bez zawijania, równe odstępy */
  html.phone-portrait .topnav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--icon-gap);
    flex-wrap: nowrap;
    min-width: 0;
  }

  /* Jeden rząd: Dziś + 4 widoki */
  html.phone-portrait .view-switch {
    display: flex;
    align-items: center;
    gap: var(--icon-gap);
    flex-wrap: nowrap;
  }

  /* Ikonki = równe guziki, bez tekstu */
  html.phone-portrait #btn-today,
  html.phone-portrait .view-switch .btn {
    width: var(--icon-btn);
    height: var(--icon-btn);
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    font-size: 0;
    /* ukryj tekst */
    min-width: 0;
  }

  /* Unikalne ikony dla każdego przycisku */
  html.phone-portrait #btn-today::before {
    content: "🎯";
    font-size: 18px;
  }

  /* Dziś */
  html.phone-portrait .view-switch .btn[data-view="month"]::before {
    content: "📅";
    font-size: 18px;
  }

  /* Miesiąc */
  html.phone-portrait .view-switch .btn[data-view="week"]::before {
    content: "🗓️";
    font-size: 18px;
  }

  /* Tydzień */
  html.phone-portrait .view-switch .btn[data-view="day"]::before {
    content: "🕒";
    font-size: 18px;
  }

  /* Dzień */
  html.phone-portrait .view-switch .btn[data-view="upcoming"]::before {
    content: "🔔";
    font-size: 18px;
  }

  /* Nadchodzące */

  /* Schowaj przełączanie okresu w topbar (oszczędzamy miejsce) */
  html.nav-ready .topnav .date-switch {
    display: none !important;
  }
}

/* Jeszcze ciaśniej na bardzo wąskich (np. 320–360px) */
@media (max-width: 360px) and (orientation: portrait) {
  html.phone-portrait {
    --icon-btn: 34px;
    --icon-gap: 6px;
  }

  html.phone-portrait #btn-today::before,
  html.phone-portrait .view-switch .btn::before {
    font-size: 16px;
  }
}

@media (max-width: 320px) and (orientation: portrait) {
  html.phone-portrait {
    --icon-btn: 30px;
    --icon-gap: 5px;
  }

  html.phone-portrait #btn-today::before,
  html.phone-portrait .view-switch .btn::before {
    font-size: 15px;
  }
}

/* ========== Dolny pasek nawigacji (tylko phone-portrait) ========== */
.m-footer-nav {
  display: none;
}

/* domyślnie ukryty */

@media (max-width: 480px) and (orientation: portrait) {

  /* Dodatkowa przestrzeń na fixed stopkę, by nie zasłaniała treści */
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    padding: 8px calc(12px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
    background: color-mix(in oklab, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 18px rgba(0, 0, 0, 0.06);
    margin: 0;
  }

  /* Ukryj standardowy tekst stopki */
  .footer>span {
    display: none;
  }

  /* Nowa nawigacja w stopce */
  .m-footer-nav {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 10px;
  }

  .mf-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    min-width: 0;
    font-size: 18px;
  }

  .mf-period {
    min-width: 0;
    text-align: center;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Szuflada: usuń sekcję "Nawigacja" (prev/next/today) na phone-portrait */
  .nav-content .nav-section:first-of-type {
    display: none;
  }
}

/* ========== Dolny pasek nawigacji (phone portrait + phone landscape) ========== */
.m-footer-nav {
  display: none;
}

/* domyślnie ukryty */

/* Pokaż pasek: 
   - w pionie: szerokość ≤ 480px
   - w poziomie: wysokość ≤ 480px (typowy „telefon w poziomie”) */
@media (max-width: 480px) and (orientation: portrait),
(max-height: 480px) and (orientation: landscape) {

  /* Dodaj miejsce na fixed stopkę, by nie zasłaniała treści */
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    padding: 8px calc(12px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
    background: color-mix(in oklab, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 18px rgba(0, 0, 0, 0.06);
    margin: 0;
  }

  /* Ukryj standardowy tekst stopki */
  .footer>span {
    display: none;
  }

  /* Nowa nawigacja w stopce */
  .m-footer-nav {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    /* ◀ | okres | Dziś | ▶ */
    align-items: center;
    gap: 10px;
  }

  .mf-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    min-width: 0;
    font-size: 18px;
  }

  .mf-period {
    min-width: 0;
    text-align: center;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Ukryj duplikaty nawigacji w topbarze (strzałki + Dziś) */
  .topnav .date-switch {
    display: none !important;
  }

  #btn-today {
    display: none !important;
  }

  /* Szuflada: usuń całą sekcję "Nawigacja" (Today/Prev/Next) na małych ekranach */
  .nav-content .nav-section:first-of-type {
    display: none;
  }
}

@media (max-height: 380px) and (orientation: landscape) {
  .mf-btn {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  body {
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }
}

/* ========== Phone-landscape: ładne, równe kafelki w widoku Miesiąc ========== */
@media (orientation: landscape) and (max-height: 480px) {
  html.phone-landscape .container {
    padding: 10px;
  }

  html.phone-landscape .month-header {
    gap: 4px;
  }

  html.phone-landscape .mh-cell {
    font-size: .7rem;
    letter-spacing: .01em;
  }

  html.phone-landscape .month-days {
    gap: 4px;
  }

  html.phone-landscape .day-cell {
    min-height: 0;
    height: auto;
    aspect-ratio: 1 / 1;
    /* równiutkie kwadraty */
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  html.phone-landscape .day-cell .day-head {
    padding: 4px 6px;
    border-bottom: 1px dashed var(--border);
  }

  html.phone-landscape .day-cell .day-number {
    font-size: .9rem;
  }

  /* Wydarzenia jako kropki (jak w pionie) */
  html.phone-landscape .month-days .events-wrap {
    padding: 4px 6px;
    gap: 4px;
    flex-wrap: wrap;
  }

  html.phone-landscape .month-days .event-pill {
    display: inline-block;
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    text-indent: -9999px;
    overflow: hidden;
    background: color-mix(in srgb, var(--primary) 55%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 60%, transparent);
  }

  html.phone-landscape .month-days .more-pill {
    font-size: .72rem;
    padding: 0;
    color: var(--muted);
  }

  /* Ikonowe przyciski w topbarze (jak w pionie) */
  html.phone-landscape .view-switch .btn,
  html.phone-landscape #btn-today {
    width: 34px;
    height: 34px;
    min-width: 0;
    font-size: 0;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
  }

  html.phone-landscape #btn-today::before {
    content: "🎯";
    font-size: 16px;
  }

  html.phone-landscape .view-switch .btn[data-view="month"]::before {
    content: "📅";
    font-size: 16px;
  }

  html.phone-landscape .view-switch .btn[data-view="week"]::before {
    content: "🗓️";
    font-size: 16px;
  }

  html.phone-landscape .view-switch .btn[data-view="day"]::before {
    content: "🕒";
    font-size: 16px;
  }

  html.phone-landscape .view-switch .btn[data-view="upcoming"]::before {
    content: "🔔";
    font-size: 16px;
  }

  /* Dla pewności: strzałki daty nie w topbarze (na dole już masz pasek) */
  .topnav .date-switch {
    display: none !important;
  }
}

/* Weekend: subtelne tło w siatce miesiąca (poniedziałek=kolumna 1) */
.month-header .mh-cell:nth-child(7n),
.month-days .day-cell:nth-child(7n) {
  background: color-mix(in oklab, var(--surface) 90%, transparent);
}

.month-header .mh-cell:nth-child(7n-1),
.month-days .day-cell:nth-child(7n-1) {
  background: color-mix(in oklab, var(--surface) 92%, transparent);
}

/* Wyróżnienie świąt (jeśli komórka ma klasę .holiday) */
.day-cell.holiday {
  outline: 2px dashed color-mix(in srgb, var(--accent-start) 45%, transparent);
  outline-offset: -2px;
}

.day-cell .day-head .holiday-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  font-size: .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  color: var(--text);
}

/* Empty state dla zakładki Dziś */
.today-empty {
  border: 1px dashed var(--border);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.today-empty .today-title {
  font-weight: 800;
}

.today-empty .today-sub {
  color: var(--muted);
}

/* Nameday panel */
#today-nameday {
  --nd-bg: #f8fafc;
  --nd-border: #e5e7eb;
  --nd-chip-bg: #eef2ff;
  --nd-chip-text: #3730a3;
  --nd-muted: #6b7280;

  background: var(--nd-bg);
  border: 1px solid var(--nd-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

#today-nameday .nameday-title {
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: .5em;
}

#today-nameday .nameday-title::before {
  content: "🍰";
  filter: saturate(1.2);
}

#today-nameday .nameday-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

#today-nameday .nameday-list li {
  background: var(--nd-chip-bg);
  color: var(--nd-chip-text);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, .15);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
  line-height: 1.25;
  white-space: nowrap;
  /* pojawienie się z lekkim „stagger” */
  animation: nd-pop .24s ease-out both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

#today-nameday .nameday-empty {
  color: var(--nd-muted);
  font-style: italic;
}

/* Puls całego panelu po aktualizacji (np. o północy) */
#today-nameday.pulse {
  animation: nd-pulse 0.85s ease-out;
}

/* Animacje */
@keyframes nd-pop {
  from {
    transform: translateY(2px) scale(.98);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes nd-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, .22);
  }

  60% {
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  #today-nameday {
    --nd-bg: rgba(255, 255, 255, .04);
    --nd-border: rgba(255, 255, 255, .12);
    --nd-chip-bg: rgba(59, 130, 246, .14);
    --nd-chip-text: #c7d2fe;
    --nd-muted: #9ca3af;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  }

  #today-nameday .nameday-list li {
    border-color: rgba(59, 130, 246, .25);
  }
}

/* Szacunek dla prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {

  #today-nameday .nameday-list li,
  #today-nameday.pulse {
    animation: none !important;
  }
}

/* Countdown w panelu Dzień */
.dp-countdown {
  margin: 10px 0 14px;
}

.dp-upcoming-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  gap: 6px;
}

.dp-upcoming-list .dp-up-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(59, 130, 246, .06);
  border: 1px solid rgba(59, 130, 246, .15);
  border-radius: 10px;
  padding: 6px 10px;
}

.dp-upcoming-list .evt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}

.dp-upcoming-list .badge {
  background: #111827;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
}

@media (prefers-color-scheme: dark) {
  .dp-upcoming-list .dp-up-item {
    background: rgba(59, 130, 246, .12);
    border-color: rgba(59, 130, 246, .25);
  }

  .dp-upcoming-list .badge {
    background: #e5e7eb;
    color: #111827;
  }
}

/* === Rozszerzona pogoda w panelu "Dzień" === */
.dp-forecast {
  --box-bg: #f8fafc;
  --box-bd: #e5e7eb;
  --chip-bg: #eef2ff;
  --chip-bd: rgba(59, 130, 246, .18);
  --muted: #6b7280;

  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--box-bd);
  border-radius: 12px;
  background: var(--box-bg);
}

.dp-forecast .label {
  font-weight: 600;
  margin-bottom: 6px;
}

.dp-hrs {
  margin-bottom: 8px;
}

.dp-hrs-list,
.dp-days-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dp-hrs-list .h,
.dp-days-list .d {
  background: var(--chip-bg);
  border: 1px solid var(--chip-bd);
  border-radius: 10px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
}

.dp-hrs-list .h .t {
  font-weight: 600;
}

.dp-hrs-list .h .i {
  font-size: 16px;
  line-height: 1;
}

.dp-hrs-list .h .v {
  font-weight: 600;
}

.dp-hrs-list .h .w,
.dp-hrs-list .h .g,
.dp-hrs-list .h .p {
  color: var(--muted);
  font-size: 12px;
}

.dp-days-list .d .d-label {
  min-width: 3ch;
  text-transform: capitalize;
  font-weight: 600;
}

.dp-days-list .d .i {
  font-size: 16px;
  line-height: 1;
}

.dp-days-list .d .v {
  font-weight: 500;
}

.dp-days-list .d .w,
.dp-days-list .d .g,
.dp-days-list .d .p {
  color: var(--muted);
  font-size: 12px;
}

.dp-daylen {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.dp-daylen .dp-daylen-val {
  font-weight: 600;
}

.dp-daylen .dp-daylen-diff {
  color: var(--muted);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .dp-forecast {
    --box-bg: rgba(255, 255, 255, .04);
    --box-bd: rgba(255, 255, 255, .12);
    --chip-bg: rgba(59, 130, 246, .10);
    --chip-bd: rgba(59, 130, 246, .28);
    --muted: #9ca3af;
  }
}

/* Responsywnie – ciaśniej na wąskich ekranach */
@media (max-width: 480px) {

  .dp-hrs-list .h,
  .dp-days-list .d {
    padding: 6px 8px;
    gap: 6px;
  }

  .dp-hrs-list .h .g,
  .dp-hrs-list .h .w {
    display: none;
  }

  /* ukryj porywy i wiatr w bardzo wąskim układzie */
}

/* Kontrast w trybie jasnym (admin) */
html[data-theme="light"] body,
html[data-theme="light"] .admin-header,
html[data-theme="light"] .admin-container,
html[data-theme="light"] .panel,
html[data-theme="light"] .card,
html[data-theme="light"] .table,
html[data-theme="light"] .table-wrap,
html[data-theme="light"] .wrap,
html[data-theme="light"] .box {
  color: #111827;
  /* czarny na białym */
}

/* Linki/przyciski w headerze — ciemny tekst w light mode */
html[data-theme="light"] .admin-header nav a.btn,
html[data-theme="light"] .admin-header nav .btn {
  color: #111827;
}

/* Nagłówki w light mode */
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4 {
  color: #111827;
}

/* Mniej „blade” opisy w light mode */
html[data-theme="light"] .muted {
  color: #374151;
  /* ciemniejszy szary dla lepszej czytelności */
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
}

.loading-overlay[hidden] {
  display: none !important;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Imieniny – czytelny, ciemny tekst w trybie jasnym (nadpisanie z wysoką specyficznością) */
html[data-theme="light"] body .dp-nameday-panel,
html[data-theme="light"] body .dp-nameday-panel .nameday-title,
html[data-theme="light"] body .dp-nameday-panel .nameday-list li,
html[data-theme="light"] body .dp-nameday-panel .nameday-empty {
  color: #374151 !important;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  padding: 10px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s ease;
}

.gallery-item:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.gallery-item .check {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.gallery-item.selected .check {
  display: flex;
}

/* === Nowy Dashboard "Dzień" (Grid Layout) === */

.day-panel {
  padding: 10px 0 20px 0;
}

.dp-dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  /* Mobile default */
}

/* Karty */
.dp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
}

.dp-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 97%, var(--primary) 3%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.dp-ch-icon {
  font-size: 1.1em;
}

.dp-card-body {
  padding: 16px;
  flex: 1;
}

/* 1. Nadchodzące (Upcoming) */
.dp-card-upcoming .dp-countdown {
  margin: 0;
}

.dp-upcoming-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dp-up-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--surface) 50%, transparent);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: transform 0.1s, border-color 0.1s;
}

.dp-up-item:hover {
  border-color: var(--primary);
  transform: translateX(2px);
}

.dp-up-item:empty::after {
  content: attr(data-empty);
  color: var(--muted);
  font-style: italic;
  font-size: 0.9em;
}

/* 2. Pogoda (Weather) - Restyled */
.dp-weather {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
}

.dp-w-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dp-w-big {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dp-w-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.dp-temp {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.dp-w-meta {
  text-align: right;
  line-height: 1.3;
}

.dp-astro-row {
  display: flex;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 12px;
}

.dp-forecast .dp-sub-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 10px 0 6px 0;
  font-weight: 600;
}

/* 3. Dziś (Info) */
.dp-nameday-panel {
  margin: 0 0 16px 0;
  padding: 10px;
  background: color-mix(in srgb, var(--primary) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
  border-radius: 10px;
}

#today-nameday.dp-nameday-panel {
  margin-top: 0;
  box-shadow: none;
}

.dp-nameday-panel .nameday-title {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.dp-facts-list {
  display: grid;
  gap: 10px;
}

.dp-fact {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.dp-fact .f-icon {
  font-size: 1.2rem;
  background: var(--bg-body);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.dp-fact .f-content {
  flex: 1;
  font-size: 0.95rem;
}

.dp-fact .f-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* 4. Actions & Mood */
.dp-quick-actions {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.dp-quick-actions .btn {
  justify-content: center;
  width: 100%;
}

.dp-mood-widget {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
}

.dp-mood-list {
  display: flex;
  justify-content: space-between;
  margin: 8px 0;
}

.dp-footer-actions {
  text-align: center;
}

/* Desktop Grid (min-width: 800px) */
@media (min-width: 800px) {
  .dp-dashboard-grid {
    grid-template-columns: repeat(12, 1fr);
    align-items: start;
  }

  .dp-card-upcoming {
    grid-column: span 12;
  }

  .dp-card-weather {
    grid-column: span 7;
  }

  .dp-card-today {
    grid-column: span 5;
  }

  .dp-card-actions {
    grid-column: span 12;
  }

  .dp-card-actions .dp-card-body {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: space-around;
  }

  .dp-quick-actions {
    margin: 0;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .dp-mood-widget {
    margin: 0;
    border: none;
    background: none;
    padding: 0;
  }
}

/* Ultra large screens */
@media (min-width: 1200px) {
  .dp-card-upcoming {
    grid-column: span 4;
    grid-row: span 2;
  }

  .dp-card-weather {
    grid-column: span 8;
  }

  .dp-card-today {
    grid-column: span 5;
  }

  .dp-card-actions {
    grid-column: span 3;
  }

  .dp-card-actions .dp-card-body {
    display: block;
  }

  .dp-quick-actions {
    grid-template-columns: 1fr;
  }
}

/* Dark mode tweaks */
@media (prefers-color-scheme: dark) {
  .dp-card {
    background: color-mix(in srgb, var(--surface) 95%, white 5%);
  }

  .dp-card-header {
    background: rgba(255, 255, 255, 0.03);
  }

  .dp-fact .f-icon {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .dp-mood-widget {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
  }
}