/* Album – system wizualny. Bez zewnętrznych zasobów, czcionki systemowe. */
:root {
  --bg: #F5F6F7;
  --surface: #FFFFFF;
  --text: #14171A;
  --muted: #5B646C;        /* 5,7:1 na --bg */
  --line: #E2E5E8;
  --accent: #0F766E;       /* 5,5:1 na bieli */
  --accent-hover: #0B5F58;
  --accent-soft: #DDF1EE;
  --accent-ink: #0B5F58;   /* tekst na --accent-soft */
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --warn-soft: #FEF3C7;
  --viewer-bg: #0E1013;
  --viewer-text: #E8EAED;
  --viewer-muted: #A3AAB2;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(20,23,26,.06), 0 4px 16px rgba(20,23,26,.06);
  --shadow-lg: 0 12px 40px rgba(20,23,26,.22);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --topbar-h: 60px;
  --sidebar-w: 220px;
  --bottomnav-h: 60px;
  --tap: 44px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; vertical-align: middle; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.dark :focus-visible, .viewer :focus-visible { outline-color: #5EEAD4; }

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--text); color: #fff; padding: 10px 14px; border-radius: var(--r-md); }
.skip-link:focus { top: 8px; }

/* ---------- Układ ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.1rem; min-height: var(--tap); }
.logo:hover { color: var(--text); }
.logo-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--accent); color: #fff; }
.search { flex: 1; max-width: 520px; position: relative; margin: 0 auto 0 12px; }
.search input { width: 100%; height: 40px; padding: 0 14px 0 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font: inherit; color: var(--text); }
.search input:focus-visible { background: #fff; outline-offset: 0; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.topbar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }

.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  flex: none; width: var(--sidebar-w); padding: 16px 12px;
  position: sticky; top: var(--topbar-h); align-self: flex-start;
  height: calc(100vh - var(--topbar-h)); border-right: 1px solid var(--line); background: var(--surface);
}
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 0 14px; margin-bottom: 4px;
  border-radius: var(--r-md); color: var(--text); text-decoration: none; font-weight: 500;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item.is-disabled { color: var(--muted); cursor: default; }
.nav-item.is-disabled:hover { background: none; }
.nav-label { line-height: 1.25; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; line-height: 1; }
.nav-soon { margin-left: auto; font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; max-width: 1600px; outline: none; }
.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .spacer { flex: 1; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.breadcrumbs a { color: var(--muted); text-decoration: none; padding: 4px 2px; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--text); font-weight: 500; }

@media (max-width: 719px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .logo-text, .btn-label { display: none; }
  .btn-label.keep { display: inline; }
  .search { margin-left: 0; }
  .shell { display: block; padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
  .sidebar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; top: auto; width: auto;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding: 4px 8px env(safe-area-inset-bottom);
    display: flex; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line);
  }
  .nav-item { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 0 4px; margin: 0; font-size: .72rem; }
  .nav-soon { display: none; }
  .nav-item { position: relative; }
  .nav-badge { position: absolute; top: 2px; left: calc(50% + 6px); margin-left: 0; min-width: 18px; height: 18px; font-size: .68rem; }
  .main { padding: 16px 12px 32px; }
  h1 { font-size: 1.3rem; }
}

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border: 1px solid transparent; border-radius: var(--r-md);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--text); border-color: var(--line);
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--bg); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(20,23,26,.06); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8F1C12; border-color: #8F1C12; color: #fff; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn-icon { width: var(--tap); padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.btn-primary):not(.btn-danger).is-loading::after { border-color: var(--accent); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Chipy ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font: inherit; font-size: .88rem; color: var(--text); text-decoration: none; cursor: pointer;
}
button.chip, a.chip { min-height: 36px; }
.chip:hover { border-color: #C5CBD1; color: var(--text); }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip-static { cursor: default; background: var(--bg); color: var(--muted); }
.chip-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.chip-warn { background: var(--warn-soft); border-color: transparent; color: #7A4B00; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Karty ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.card-pad-lg { padding: 28px; }
.card-link { display: block; text-decoration: none; color: inherit; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.card-link:hover { color: inherit; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.album-card .cover { aspect-ratio: 4 / 3; background: var(--accent-soft) center / cover no-repeat; display: grid; place-items: center; color: var(--accent); position: relative; }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-card .cover .chip { position: absolute; top: 10px; left: 10px; }
.album-card .meta { padding: 12px 14px 14px; }
.album-card .meta h3 { margin: 0 0 2px; }
@media (max-width: 719px) { .album-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

/* ---------- Formularze ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .field-label { font-weight: 600; font-size: .9rem; }
.field input[type=text], .field input[type=password], .field input[type=email], .field input[type=date],
.field input[type=search], .field input[type=number], .field select, .field textarea, .input {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid #C5CBD1; border-radius: var(--r-md);
  background: #fff; color: var(--text); font: inherit;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .input:focus-visible { outline-offset: 0; border-color: var(--accent); }
.field-hint { font-size: .85rem; color: var(--muted); }
.field-error { font-size: .85rem; color: var(--danger); font-weight: 500; }
.field.has-error input { border-color: var(--danger); }
.input-group { display: flex; gap: 8px; }
.input-group .input, .input-group input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); }
.alert { padding: 12px 14px; border-radius: var(--r-md); margin-bottom: 16px; background: var(--accent-soft); color: var(--accent-ink); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: #7A4B00; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 20px; }
.tab { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.tab[aria-selected="true"], .tab.is-active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- Modal (natywny <dialog>) ---------- */
dialog.modal {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0;
  border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: auto;
}
dialog.modal::backdrop { background: rgba(14,16,19,.55); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; flex: 1; font-size: 1.1rem; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--bg); }
@media (max-width: 719px) {
  dialog.modal { width: 100vw; max-width: none; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
}
dialog.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Toasty ---------- */
.toast-region { position: fixed; z-index: 200; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(420px, calc(100vw - 24px)); }
@media (max-width: 719px) { .toast-region { bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px; border-radius: var(--r-md); background: #14171A; color: #fff; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.toast-success { background: #0B5F58; }
.toast-error { background: #B42318; }
.toast.is-leaving { opacity: 0; transition: opacity .25s; }

/* ---------- Siatka justowana i kafelki ---------- */
.day-group { margin-bottom: 28px; }
.day-title { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 1rem; font-weight: 600; }
.day-title .muted { font-weight: 400; font-size: .9rem; }
.grid-justified { display: flex; flex-wrap: wrap; gap: 4px; }
.grid-justified::after { content: ""; flex-grow: 1000000; }
.grid-justified > .tile { flex-grow: 1; /* ustaw inline: style="flex-basis:Wpx;aspect-ratio:w/h" lub width/height na <img> */ }
.tile {
  position: relative; display: block; overflow: hidden; border-radius: var(--r-sm); background: #DDE1E5;
  cursor: pointer; min-width: 80px; max-width: 100%; flex-basis: calc(var(--tile-ar, 1.5) * 200px); height: auto; aspect-ratio: var(--tile-ar, 1.5);
  color: inherit; text-decoration: none; border: 0; padding: 0;
}
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.tile img.is-loaded, .tile img[src]:not([data-src]) { opacity: 1; }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.28), transparent 40%); opacity: 0; transition: opacity .15s; pointer-events: none; }
.tile:hover::after, .tile.is-selected::after, .selecting .tile::after { opacity: 1; }
.tile-check {
  position: absolute; top: 8px; left: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; border: 2px solid #fff; background: rgba(0,0,0,.25);
  opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-check, .tile:focus-visible .tile-check, .selecting .tile-check { opacity: 1; }
.tile.is-selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile.is-selected img { transform: scale(.92); border-radius: 4px; }
.tile img { transition: opacity .25s, transform .15s; }
.tile.is-selected .tile-check { opacity: 1; background: var(--accent); border-color: var(--accent); }
.tile-badge { position: absolute; right: 8px; bottom: 8px; z-index: 2; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; }
.tile-video-placeholder { display: grid; place-items: center; width: 100%; height: 100%; background: #2A2F35; color: #fff; }
.tile-folder { display: flex; flex-direction: column; justify-content: flex-end; padding: 12px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; flex-basis: 200px; aspect-ratio: 4/3; }
.tile-folder .icon { margin-bottom: auto; }
@media (max-width: 719px) { .grid-justified { gap: 2px; } .tile { min-width: 60px; flex-basis: calc(var(--tile-ar, 1.5) * 110px); } }

/* ---------- Pasek zaznaczenia ---------- */
.selection-bar {
  position: fixed; z-index: 40; left: 50%; bottom: 24px; transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; max-width: calc(100vw - 24px);
  background: var(--text); color: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  transition: transform .2s ease-out; visibility: hidden;
}
.selection-bar.is-visible { transform: translate(-50%, 0); visibility: visible; }
.selection-bar .count { font-weight: 600; margin-right: 8px; white-space: nowrap; }
.selection-bar .btn { background: transparent; border-color: transparent; color: #fff; }
.selection-bar .btn:hover { background: rgba(255,255,255,.14); }
.selection-bar .btn-danger { background: var(--danger); }
.selection-bar :focus-visible { outline-color: #5EEAD4; }
@media (max-width: 719px) {
  .selection-bar { bottom: calc(var(--bottomnav-h) + 12px + env(safe-area-inset-bottom)); }
  .selection-bar .btn-label { display: none; }
}

/* ---------- Podgląd (ciemny) ---------- */
.dark, .viewer { --bg: #0E1013; --surface: #1A1D21; --text: #E8EAED; --muted: #A3AAB2; --line: #2B3036; --accent: #2DD4BF; --accent-hover: #5EEAD4; --accent-soft: #123A36; --accent-ink: #99F6E4; }
body.dark { background: var(--bg); color: var(--text); }
.viewer { position: fixed; inset: 0; z-index: 90; background: var(--viewer-bg); color: var(--viewer-text); display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.viewer-bar .spacer { flex: 1; }
.viewer .btn { background: transparent; border-color: transparent; color: var(--viewer-text); }
.viewer .btn:hover { background: rgba(255,255,255,.12); }
.viewer-stage { flex: 1; position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden; touch-action: none; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; display: grid; place-items: center; border: 0; border-radius: var(--r-md); background: rgba(0,0,0,.35); color: #fff; cursor: pointer; }
.viewer-nav:hover { background: rgba(0,0,0,.6); }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }
.viewer-info { width: 320px; padding: 20px; background: #15181C; border-left: 1px solid var(--line); overflow: auto; }
.viewer-strip { display: flex; gap: 4px; padding: 8px; overflow-x: auto; background: rgba(0,0,0,.5); }
.viewer-strip img { height: 56px; border-radius: 4px; opacity: .6; cursor: pointer; }
.viewer-strip img.is-current { opacity: 1; outline: 2px solid var(--accent); }
.viewer-body { flex: 1; display: flex; min-height: 0; }
@media (max-width: 719px) { .viewer-info { position: absolute; inset: auto 0 0 0; width: auto; max-height: 60%; border-left: 0; border-top: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; } .viewer-nav { display: none; } }

/* ---------- Różne ---------- */
.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty .icon { color: var(--accent); margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.center-card { width: min(420px, 100%); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.skeleton { background: linear-gradient(90deg, #E8EBEE 25%, #F2F4F6 50%, #E8EBEE 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print { .topbar, .sidebar, .selection-bar, .toast-region { display: none !important; } }

/* atrybut hidden zawsze ukrywa element (klasy .btn/.chip itp. ustawiają display i go nadpisywały) */
[hidden] { display: none !important; }
