/* Doc_Database — interfejs w stylu iOS. Motywy (html[data-theme]): auto (jak system), light, dark, sepia, edge. */

:root {
  --bg: #f2f2f7;
  --elev: #ffffff;
  --field: #f2f2f7;
  --fill: rgba(118, 118, 128, .12);
  --text: #1c1c1e;
  --text-2: #6c6c70;
  --text-3: #aeaeb2;
  --sep: rgba(60, 60, 67, .16);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, .12);
  --danger: #ff3b30;
  --danger-soft: rgba(255, 59, 48, .12);
  --ok: #34c759;
  --bar: rgba(242, 242, 247, .82);
  --seg-on: #ffffff;
  --switch-off: rgba(120, 120, 128, .16);
  --toast: rgba(30, 30, 32, .94);
  --paper: #ffffff;               /* tło tekstu w trybie czytania */
  --ink: #1d1d1f;                 /* tekst w trybie czytania */
  --ink-2: #5c5c62;
  --hl-yellow: rgba(255, 214, 10, .42);
  --hl-green: rgba(52, 199, 89, .32);
  --hl-blue: rgba(10, 132, 255, .26);
  --hl-pink: rgba(255, 55, 135, .26);
  --radius: 14px;
  --pad: 16px;
  --top-h: 52px;
  --tab-h: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: light;
}
/* „Jak system” — ciemny, gdy system jest w trybie ciemnym */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]), :root[data-theme="auto"] {
    --bg: #000000;
    --elev: #1c1c1e;
    --field: #2c2c2e;
    --fill: rgba(118, 118, 128, .24);
    --text: #ffffff;
    --text-2: #98989f;
    --text-3: #636366;
    --sep: rgba(84, 84, 88, .55);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, .2);
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, .18);
    --ok: #30d158;
    --bar: rgba(22, 22, 24, .8);
    --seg-on: #636366;
    --switch-off: rgba(120, 120, 128, .32);
    --toast: rgba(58, 58, 60, .96);
    --paper: #000000;
    --ink: #d8d8dc;
    --ink-2: #9a9aa0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --elev: #1c1c1e;
  --field: #2c2c2e;
  --fill: rgba(118, 118, 128, .24);
  --text: #ffffff;
  --text-2: #98989f;
  --text-3: #636366;
  --sep: rgba(84, 84, 88, .55);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, .2);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, .18);
  --ok: #30d158;
  --bar: rgba(22, 22, 24, .8);
  --seg-on: #636366;
  --switch-off: rgba(120, 120, 128, .32);
  --toast: rgba(58, 58, 60, .96);
  --paper: #000000;
  --ink: #d8d8dc;
  --ink-2: #9a9aa0;
  color-scheme: dark;
}
/* Sepia — ciepły papier, mniej zmęczenia oczu wieczorem */
:root[data-theme="sepia"] {
  --bg: #f4ecd8;
  --elev: #fbf6e9;
  --field: #efe5cd;
  --fill: rgba(94, 72, 40, .1);
  --text: #3b2f22;
  --text-2: #7a6650;
  --text-3: #a8957c;
  --sep: rgba(94, 72, 40, .18);
  --accent: #a0522d;
  --accent-soft: rgba(160, 82, 45, .13);
  --danger: #b3261e;
  --danger-soft: rgba(179, 38, 30, .12);
  --ok: #4f7a28;
  --bar: rgba(244, 236, 216, .86);
  --seg-on: #fbf6e9;
  --switch-off: rgba(94, 72, 40, .2);
  --toast: rgba(59, 47, 34, .95);
  --paper: #f6efdc;
  --ink: #3b2f22;
  --ink-2: #6f5b45;
  --hl-yellow: rgba(230, 170, 30, .38);
  --hl-green: rgba(110, 150, 50, .3);
  --hl-blue: rgba(60, 120, 170, .25);
  --hl-pink: rgba(200, 80, 110, .25);
  color-scheme: light;
}
/* New Edge — głęboka granatowa czerń, neonowy gradient fiolet → cyjan, szkło */
:root[data-theme="edge"] {
  --bg: #07080f;
  --elev: #10131f;
  --field: #171b2b;
  --fill: rgba(140, 150, 255, .12);
  --text: #eef1ff;
  --text-2: #9aa3c7;
  --text-3: #5d6690;
  --sep: rgba(140, 150, 255, .16);
  --accent: #8b6cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(139, 108, 255, .18);
  --danger: #ff5c8a;
  --danger-soft: rgba(255, 92, 138, .16);
  --ok: #2ee6a6;
  --bar: rgba(9, 11, 20, .72);
  --seg-on: #262b44;
  --switch-off: rgba(140, 150, 255, .2);
  --toast: rgba(20, 22, 38, .96);
  --paper: #0b0d17;
  --ink: #e4e8ff;
  --ink-2: #9aa3c7;
  --hl-yellow: rgba(255, 214, 10, .3);
  --hl-green: rgba(46, 230, 166, .26);
  --hl-blue: rgba(34, 211, 238, .26);
  --hl-pink: rgba(255, 92, 186, .3);
  --edge-grad: linear-gradient(135deg, #8b6cff, #22d3ee);
  color-scheme: dark;
}

/* ---------- Podstawy ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
code {
  font: 13px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--fill);
  padding: 1px 5px;
  border-radius: 5px;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html.modal-open { overflow: hidden; }
.icon { width: 22px; height: 22px; flex: none; }

/* Elementy „aplikacyjne" nie zaznaczają się przy dłuższym przytrzymaniu */
.topbar, .tabbar, .btn, .icon-btn, .fchip, .row-link, .back-btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- Pasek górny ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: var(--safe-t);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep);
}
.topbar-inner {
  max-width: 760px;
  height: var(--top-h);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 max(8px, var(--safe-r)) 0 max(var(--pad), var(--safe-l));
}
.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
}
.brand img { border-radius: 7px; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Treść ---------- */
.content {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 max(var(--pad), var(--safe-r)) calc(40px + var(--safe-b)) max(var(--pad), var(--safe-l));
}
.has-tabbar .content { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 32px); }
.large-title {
  margin: 20px 4px 14px;
  font-size: 32px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.02em;
}
.section-title {
  margin: 28px 16px 8px;
  font-size: 13px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--text-2);
}
.footnote { margin: 10px 16px; font-size: 13px; color: var(--text-2); line-height: 1.45; }
.card {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--elev);
  border-radius: var(--radius);
}
.card-title { margin: 0 0 2px; font-size: 17px; font-weight: 600; }
.stack { display: grid; gap: 12px; }

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity .15s, transform .1s;
}
.btn:active { opacity: .7; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .icon { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-soft { background: var(--fill); color: var(--accent); }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:active { background: var(--fill); }
.icon-btn.danger { color: var(--danger); }
.link-btn {
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.08); }
  .icon-btn:hover { background: var(--fill); }
  .link-btn:hover { text-decoration: underline; }
}

/* ---------- Pola formularzy (min. 16 px — iOS nie powiększa strony) ---------- */
.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .field-group input::placeholder, .search input::placeholder { color: var(--text-3); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--elev);
  font-size: 17px;
  cursor: pointer;
}
.switch-row.inset { background: var(--field); }
.switch {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 16px;
  background: var(--switch-off);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16);
  transition: transform .2s;
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }

.segmented {
  display: flex;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill);
}
.segmented label { position: relative; flex: 1; cursor: pointer; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: block;
  padding: 8px 6px;
  border-radius: 8px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  transition: background .15s, box-shadow .15s;
}
.segmented input:checked + span { background: var(--seg-on); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------- Logowanie ---------- */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) max(20px, var(--safe-r)) calc(24px + var(--safe-b)) max(20px, var(--safe-l));
}
.login-form { width: 100%; max-width: 360px; display: grid; gap: 14px; text-align: center; }
.login-logo { margin: 0 auto 6px; border-radius: 18px; box-shadow: 0 8px 24px rgba(11, 87, 208, .25); }
.login-form h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.login-sub { margin: -8px 0 10px; color: var(--text-2); }
.field-group { background: var(--elev); border-radius: 12px; overflow: hidden; text-align: left; }
.field-group input {
  display: block;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.field-group input + input { border-top: .5px solid var(--sep); }
.field-group input:focus { background: var(--accent-soft); }
.login .switch-row { text-align: left; }
.inline-msg { margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 15px; }
.inline-msg.error { background: var(--danger-soft); color: var(--danger); }
.inline-msg.ok { background: rgba(52, 199, 89, .14); color: var(--ok); }
.app-version { margin: 20px 0 0; text-align: center; font-size: 12px; color: var(--text-3); }
.app-version-foot { margin-top: 32px; font-variant-numeric: tabular-nums; }

/* ---------- Wyszukiwarka i filtry ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px;
  border-radius: 11px;
  background: var(--fill);
  color: var(--text-2);
}
.search .icon { width: 19px; height: 19px; }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.filters {
  display: flex;
  gap: 8px;
  margin: 12px calc(-1 * var(--pad)) 0;
  padding: 2px var(--pad) 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filters::-webkit-scrollbar { display: none; }
.fchip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--sep);
  border-radius: 17px;
  background: var(--elev);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, color .15s, border-color .15s;
}
.fchip .dot, .pick-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--chip-bg); flex: none; }
.fchip.is-active { background: var(--chip-bg); border-color: transparent; color: var(--chip-fg); }
.fchip.is-active .dot { background: var(--chip-fg); opacity: .9; }
.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin: 10px 4px 6px;
  font-size: 13px;
  color: var(--text-2);
}

/* ---------- Listy (grupowane, jak w iOS) ---------- */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--elev);
  border-radius: var(--radius);
  overflow: hidden;
}
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 4px 6px 16px;
  scroll-margin-top: calc(var(--top-h) + var(--safe-t) + 16px);
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 16px;
  border-top: .5px solid var(--sep);
}
.doc-row + .doc-row::before { left: 58px; }
.row.is-first::before { display: none; }
.row.roomy { padding-top: 10px; padding-bottom: 10px; }
.row:target { animation: row-flash 2s ease-out; }
@keyframes row-flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }
.row-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
  color: inherit;
  text-decoration: none;
}
.row-link:active .row-title { color: var(--accent); }
.row-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.row-icon .icon { width: 18px; height: 18px; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { font-size: 17px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.row-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; font-size: 13px; color: var(--text-2); }
.row-sub > span + span::before { content: "·"; margin-right: 6px; }
.row-more { color: var(--text-2); }
.row .row-body > span > .chip { vertical-align: middle; }
.ver {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }

/* ---------- Foldery (jak kolekcje w Kindle) ---------- */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 600px) { .folder-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 740px) { .folder-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* „Wszystkie” jako szeroka karta na początku siatki */
.folder-grid > .is-all { grid-column: span 2; }
.folder-grid > .is-all .folder { aspect-ratio: 8 / 3; }
.folder-grid > .is-all .folder-name { font-size: 21px; }
.folder-grid > .is-all .folder-img { object-position: 50% 22%; }   /* szeroki kadr: górna część grafiki */

.folder {
  --chip-bg: var(--accent);
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 18px;
  background: var(--chip-bg);
  color: #fff;
  text-decoration: none;
  isolation: isolate;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 8px 24px -12px rgba(0, 0, 0, .35);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .18s;
}
.folder:active { transform: scale(.97); }
.folder:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.folder-img, .folder-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
  transition: transform .4s cubic-bezier(.2, .8, .2, 1);
}
/* Bez grafiki: gradient z koloru etykiety i duża ikona półki */
.folder.is-color, .folder-hero.is-color, .cover-thumb.is-color {
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, .28), transparent 55%),
    linear-gradient(150deg, var(--chip-bg), color-mix(in srgb, var(--chip-bg) 55%, #000));
}
.folder-glyph {
  position: absolute;
  right: -6%;
  top: -8%;
  width: 62%;
  height: auto;
  aspect-ratio: 1;
  color: #fff;
  opacity: .22;
  z-index: -1;
  stroke-width: 1.4;
}
.folder-shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top, rgba(0, 0, 0, .72) 0%, rgba(0, 0, 0, .28) 38%, rgba(0, 0, 0, 0) 62%);
}
.folder-name {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  display: -webkit-box;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .35);
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.folder-count {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 28px;
  height: 26px;
  padding: 0 9px;
  border-radius: 13px;
  background: rgba(20, 20, 24, .38);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border: .5px solid rgba(255, 255, 255, .28);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 25px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
@media (hover: hover) {
  .folder:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0, 0, 0, .08), 0 16px 32px -14px rgba(0, 0, 0, .45); }
  .folder:hover .folder-img { transform: scale(1.05); }
}

/* Nagłówek folderu z okładką */
.folder-hero {
  --chip-bg: var(--accent);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 190px;
  margin: 14px 0 16px;
  border-radius: 22px;
  background: var(--chip-bg);
  color: #fff;
  box-shadow: 0 10px 30px -16px rgba(0, 0, 0, .5);
}
@media (min-width: 600px) { .folder-hero { min-height: 230px; } }
.folder-hero .folder-glyph { width: 46%; right: -4%; top: -14%; }
.folder-hero .folder-shade { background: linear-gradient(to top, rgba(0, 0, 0, .74) 0%, rgba(0, 0, 0, .2) 55%, rgba(0, 0, 0, .12) 100%); }
.folder-hero-text { position: absolute; left: 18px; right: 18px; bottom: 16px; }
.folder-hero-text h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .35);
  overflow-wrap: break-word;
}
.folder-hero-text p { margin: 4px 0 0; font-size: 15px; opacity: .88; }
.hero-btn {
  position: absolute;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 14px 0 10px;
  border: .5px solid rgba(255, 255, 255, .3);
  border-radius: 18px;
  background: rgba(20, 20, 24, .36);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.hero-btn .icon { width: 20px; height: 20px; }
.hero-back { left: 12px; }
.hero-edit { right: 12px; padding-left: 12px; gap: 6px; }
.hero-btn:active { background: rgba(20, 20, 24, .55); }
@media (hover: hover) { .hero-btn:hover { background: rgba(20, 20, 24, .5); } }

/* Miniatura okładki na liście etykiet */
.label-cover {
  --chip-bg: var(--accent);
  flex: none;
  width: 56px;
  height: 42px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--chip-bg);
}
.label-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.label-cover.is-color {
  background: linear-gradient(150deg, var(--chip-bg), color-mix(in srgb, var(--chip-bg) 55%, #000));
}

/* Arkusz wyboru okładki */
.cover-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
@media (min-width: 480px) { .cover-pick { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cover-opt { position: relative; display: grid; gap: 5px; cursor: pointer; }
.cover-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cover-thumb {
  --chip-bg: var(--accent);
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  background: var(--fill);
  color: #fff;
  box-shadow: 0 0 0 0 var(--accent);
  transition: box-shadow .15s;
}
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cover-thumb .icon { width: 28px; height: 28px; }
.cover-thumb.is-upload:not(:has(img)) { background: var(--field); color: var(--accent); border: 1.5px dashed var(--sep); }
.cover-cap { font-size: 12.5px; color: var(--text-2); text-align: center; line-height: 1.25; }
.cover-opt input:checked + .cover-thumb { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5.5px var(--accent); }
.cover-opt input:checked + .cover-thumb + .cover-cap { color: var(--accent); font-weight: 600; }
.cover-opt input:focus-visible + .cover-thumb { outline: 2px solid var(--accent); outline-offset: 4px; }
.cover-opt input:checked + .cover-thumb::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 14px no-repeat;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 16px; }
.file-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-hint { margin: -6px 4px 12px; }

/* Postęp czytania na liście */
.progress {
  display: block;
  height: 3px;
  max-width: 240px;
  margin-top: 5px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p, 0%), var(--fill) var(--p, 0%));
}
.st { font-variant-numeric: tabular-nums; }
.st-new { color: var(--accent); font-weight: 600; }
.st-done { display: inline-flex; align-items: center; gap: 3px; color: var(--ok); font-weight: 500; }
.st-done .icon { width: 14px; height: 14px; }
.continue .section-title:first-child { margin-top: 4px; }
.continue .row-link { align-items: center; }
.continue .list + .section-title { margin-top: 24px; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--chip-bg, var(--fill));
  color: var(--chip-fg, var(--text));
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(#3b8cff, #0b57d0);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.avatar.muted { background: var(--fill); color: var(--text-2); }
.avatar.lg { width: 44px; height: 44px; font-size: 18px; }

/* ---------- Pusty stan ---------- */
.empty { padding: 48px 20px; text-align: center; color: var(--text-2); }
.empty p { margin: 6px 0; }
.empty .btn { margin-top: 14px; }
.empty-icon { width: 44px; height: 44px; color: var(--text-3); }
.empty-title { font-size: 20px; font-weight: 600; color: var(--text); }

/* ---------- Dolny pasek zakładek (administrator) ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--sep);
}
.tabbar-inner { display: flex; max-width: 560px; margin: 0 auto; }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--tab-h);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 500;
  text-decoration: none;
  touch-action: manipulation;
}
.tab .icon { width: 25px; height: 25px; }
.tab.is-active { color: var(--accent); }

/* Na dużych ekranach zakładki jako przełącznik segmentowy pod paskiem górnym */
@media (min-width: 900px) {
  .tabbar {
    position: static;
    padding: 16px 0 0;
    background: none;
    border: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tabbar-inner { width: max-content; max-width: none; padding: 3px; border-radius: 11px; background: var(--fill); }
  .tab { flex: none; flex-direction: row; gap: 7px; height: 34px; padding: 0 16px; border-radius: 9px; font-size: 14px; }
  .tab .icon { width: 18px; height: 18px; }
  .tab.is-active { background: var(--seg-on); color: var(--text); box-shadow: 0 3px 8px rgba(0, 0, 0, .1); }
  .has-tabbar .content { padding-bottom: 48px; }
}
@media (hover: hover) { .tab:not(.is-active):hover { color: var(--text); } }

/* ---------- Arkusze (dialog wysuwany od dołu) ---------- */
dialog.sheet {
  width: 100%;
  max-width: 560px;
  max-height: calc(100% - var(--safe-t) - 24px);
  margin: auto auto 0;
  padding: 0 0 var(--safe-b);
  border: 0;
  border-radius: 16px 16px 0 0;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .18);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .38); }
dialog.sheet[open] { animation: sheet-up .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 700px) {
  dialog.sheet { margin: auto; border-radius: 16px; padding-bottom: 8px; max-height: min(720px, 90vh); }
  dialog.sheet[open] { animation: sheet-pop .2s ease-out; }
  .sheet-grabber { display: none; }
}
@keyframes sheet-pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grabber { width: 36px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: var(--text-3); opacity: .6; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 10px 8px 6px 20px; }
.sheet-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
.acc-id { flex: 1; min-width: 0; }
.acc-id h2 { font-size: 18px; }
.sheet-body { padding: 4px 16px 20px; }
.sheet-body > .section-title:first-child { margin-top: 6px; }
.sheet .list .row-link { align-items: center; }
.sheet .list .row-link .row-title { font-size: 16px; }
.list .chev { display: grid; place-items: center; color: var(--text-3); margin-right: 8px; }
.list .chev .icon { width: 18px; height: 18px; }

.label-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pick { position: relative; cursor: pointer; }
.pick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.pick-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--sep);
  border-radius: 18px;
  background: var(--elev);
  font-size: 15px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.pick input:checked + .pick-chip { background: var(--chip-bg); color: var(--chip-fg); border-color: transparent; }
.pick input:checked + .pick-chip .dot { background: var(--chip-fg); }
.pick input:focus-visible + .pick-chip { outline: 2px solid var(--accent); outline-offset: 2px; }

.install-hint {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 12px;
  background: var(--elev);
  font-size: 14px;
  color: var(--text-2);
}
.install-hint .icon { color: var(--accent); margin-top: 2px; }
.install-hint p { margin: 0; line-height: 1.45; }
.install-hint strong { color: var(--text); }

/* ---------- Kolory etykiet ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 12px; padding: 4px 2px; }
.swatch {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--sw);
  cursor: pointer;
}
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.swatch:has(input:checked) { box-shadow: 0 0 0 3px var(--elev), 0 0 0 5px var(--sw); }
.sheet .swatch:has(input:checked) { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--sw); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- Wysyłanie ---------- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 28px 16px;
  border: 1.5px dashed var(--sep);
  border-radius: 12px;
  background: var(--field);
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dz-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 6px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.dz-title { font-size: 17px; font-weight: 600; color: var(--accent); }
.dz-hint { font-size: 14px; color: var(--text-2); }
.file-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--field); font-size: 15px; }
.file-list .icon { width: 18px; height: 18px; color: var(--accent); }
.file-list .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-list .size { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.file-list li.bad { color: var(--danger); }
.file-list li.bad .icon { color: var(--danger); }

/* ---------- Komunikaty (toast) ---------- */
.toasts {
  position: fixed;
  top: calc(var(--safe-t) + var(--top-h) + 10px);
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--toast);
  color: #fff;
  font-size: 15px;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  pointer-events: auto;
  cursor: pointer;
  animation: toast-in .3s cubic-bezier(.2, .8, .2, 1);
  transition: opacity .3s, transform .3s;
}
.toast .icon { width: 20px; height: 20px; margin-top: 1px; }
.toast.ok .icon { color: #30d158; }
.toast.error .icon { color: #ff6961; }
.toast.hide { opacity: 0; transform: translateY(-10px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* ---------- Czytnik dokumentu ---------- */
.page-viewer {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.viewer-bar { flex: none; }
.viewer-bar .topbar-inner { max-width: none; padding-left: max(4px, var(--safe-l)); }
.back-btn {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 44px;
  padding: 0 8px 0 2px;
  color: var(--accent);
  font-size: 17px;
  text-decoration: none;
}
.back-btn .icon { width: 26px; height: 26px; }
.viewer-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.ver-select {
  height: 32px;
  padding: 0 28px 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 7px center / 15px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
}
.viewer-note {
  padding: 8px max(16px, var(--safe-r)) 9px max(16px, var(--safe-l));
  border-top: .5px solid var(--sep);
  background: var(--accent-soft);
  font-size: 14px;
  text-align: center;
}
.viewer-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
}
.viewer-frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
/* width:1px + min-width:100% — iOS nie rozszerza ramki do szerokości treści
   (dokument szerszy od ekranu byłby ucięty z prawej strony) */
.viewer-frame iframe { width: 1px; min-width: 100%; }
@media (max-width: 480px) {
  .back-btn span { display: none; }
  .viewer-title { text-align: left; }
}

/* Dolny pasek czytnika: suwak pozycji, procent, czas do końca */
.reader-foot {
  flex: none;
  z-index: 30;
  padding: 6px max(var(--pad), var(--safe-r)) calc(6px + var(--safe-b)) max(var(--pad), var(--safe-l));
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--sep);
  -webkit-user-select: none;
  user-select: none;
}
.reader-foot-inner { max-width: 760px; margin: 0 auto; }
.reader-stats {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* Suwak w stylu iOS (pozycja w dokumencie, wielkość liter) */
.seek {
  --p: 0%;
  display: block;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-x;
  -webkit-appearance: none;
  appearance: none;
}
.seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--fill) var(--p));
}
.seek::-moz-range-track { height: 4px; border-radius: 2px; background: var(--fill); }
.seek::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.seek::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 0 0 .5px rgba(0, 0, 0, .08);
  -webkit-appearance: none;
  appearance: none;
}
.seek::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

/* Arkusz „Aa" */
.size-row { display: flex; align-items: center; gap: 12px; }
.size-btn {
  display: grid;
  place-items: center;
  width: 64px;
  height: 52px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: var(--elev);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.size-btn:active { background: var(--fill); }
.size-btn .a-sm { font-size: 15px; font-weight: 500; }
.size-btn .a-lg { font-size: 26px; font-weight: 500; }
.size-val { flex: 1; text-align: center; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Komunikat „Wznowiono od…" z przyciskiem */
.toast-text { flex: 1; }
.toast-action {
  flex: none;
  margin: -4px -6px -4px 0;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: #64d2ff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Tryb strony: ramka ma wysokość całej treści, przewija się cała strona
   (przewijanie wewnątrz <iframe> jest na iOS zawodne). Paski leżą nad treścią. */
.page-viewer.frame-page {
  display: block;
  height: auto;
  overflow: visible;
  padding-top: var(--viewer-top, calc(var(--top-h) + var(--safe-t)));
  padding-bottom: var(--viewer-foot, 60px);
}
.frame-page .viewer-bar,
.frame-page .reader-foot {
  position: fixed;
  left: 0;
  right: 0;
  transition: transform .25s ease;
}
.frame-page .viewer-bar { top: 0; }
.frame-page .reader-foot { bottom: 0; }
.frame-page .viewer-frame { overflow: visible; }
.frame-page .viewer-frame iframe { height: 100vh; }

/* Tryb skupienia: stuknięcie w tekst chowa paski (pasek statusu iOS zostaje czytelny) */
.bars-hidden .frame-page .viewer-bar { transform: translateY(calc(-100% + var(--safe-t))); }
.bars-hidden .frame-page .viewer-bar .topbar-inner,
.bars-hidden .frame-page .viewer-note { visibility: hidden; }
.bars-hidden .frame-page .reader-foot { transform: translateY(100%); }
.bars-hidden .page-viewer:not(.frame-page) .viewer-bar,
.bars-hidden .page-viewer:not(.frame-page) .reader-foot { display: none; }

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

/* =====================================================================
   Wersja 2.0: motywy, czytnik (etapy 2–3), lista
   ===================================================================== */

/* ---------- New Edge: gradient w tle, szklane powierzchnie, neonowy akcent ---------- */
[data-theme="edge"] body {
  background:
    radial-gradient(60vmax 45vmax at 0% 0%, rgba(139, 108, 255, .22), transparent 60%),
    radial-gradient(55vmax 40vmax at 100% 100%, rgba(34, 211, 238, .16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
[data-theme="edge"] .btn-primary { background: var(--edge-grad); box-shadow: 0 6px 22px -8px rgba(139, 108, 255, .8); }
[data-theme="edge"] .large-title {
  background: linear-gradient(90deg, #fff 0%, #c9bcff 45%, #7ee8fa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="edge"] .list, [data-theme="edge"] .card, [data-theme="edge"] dialog.sheet {
  border: 1px solid var(--sep);
  box-shadow: 0 0 0 1px rgba(139, 108, 255, .05), 0 12px 40px -18px rgba(139, 108, 255, .45);
}
[data-theme="edge"] .list { background: rgba(16, 19, 31, .78); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
[data-theme="edge"] .tab.is-active, [data-theme="edge"] .row-icon, [data-theme="edge"] .ver { color: #b9a8ff; }
[data-theme="edge"] .folder { box-shadow: 0 0 0 1px rgba(139, 108, 255, .25), 0 14px 34px -14px rgba(34, 211, 238, .45); }
[data-theme="edge"] .progress, [data-theme="edge"] .seek { --accent: #8b6cff; }
[data-theme="edge"] .avatar { background: var(--edge-grad); }
[data-theme="edge"] :focus-visible { outline-color: #22d3ee; }
[data-theme="sepia"] .avatar { background: linear-gradient(#c0743f, #8a4521); }
[data-theme="sepia"] .row-icon { background: rgba(160, 82, 45, .12); }

/* ---------- Wybór motywu ---------- */
.theme-pick { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.theme-opt {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 8px 2px 6px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  touch-action: manipulation;
}
.theme-opt.is-active { color: var(--accent); font-weight: 600; }
.theme-swatch {
  position: relative;
  display: grid;
  grid-template-rows: 1fr 6px 6px;
  gap: 4px;
  width: 54px;
  height: 54px;
  padding: 9px;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .1), 0 4px 10px -4px rgba(0, 0, 0, .3);
}
.theme-opt.is-active .theme-swatch { box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4.5px var(--accent); }
.theme-swatch i { display: block; border-radius: 3px; }
.theme-swatch i:first-child { border-radius: 5px; }
.sw-light { background: #f2f2f7; } .sw-light i { background: #fff; } .sw-light i + i { background: #007aff; } .sw-light i + i + i { background: #c7c7cc; }
.sw-dark { background: #000; } .sw-dark i { background: #1c1c1e; } .sw-dark i + i { background: #0a84ff; } .sw-dark i + i + i { background: #48484a; }
.sw-sepia { background: #f4ecd8; } .sw-sepia i { background: #fbf6e9; } .sw-sepia i + i { background: #a0522d; } .sw-sepia i + i + i { background: #cdbb9a; }
.sw-edge { background: radial-gradient(circle at 0 0, #3b2a7a, #07080f 70%); } .sw-edge i { background: #171b2b; } .sw-edge i + i { background: linear-gradient(90deg, #8b6cff, #22d3ee); } .sw-edge i + i + i { background: #2a3050; }
.sw-auto { background: linear-gradient(135deg, #f2f2f7 50%, #000 50%); } .sw-auto i { background: linear-gradient(135deg, #fff 50%, #1c1c1e 50%); } .sw-auto i + i { background: #007aff; } .sw-auto i + i + i { background: #8e8e93; }

/* ---------- Drobne elementy ---------- */
.offline-pill {
  display: none;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.is-offline .offline-pill { display: inline-flex; }
.btn-plain { background: none; color: var(--accent); font-weight: 500; }
.btn-plain:active { background: var(--fill); }
.btn-plain .icon { width: 19px; height: 19px; }
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border: 1px solid var(--sep);
  border-radius: 5px;
  background: var(--elev);
  font: 12px/18px ui-monospace, "SF Mono", Menlo, monospace;
  text-align: center;
}

/* Segmenty (filtr stanu, ustawienia czytnika, zakładki arkusza) */
.segmented-btns, .status-seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill);
}
.seg-btn {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 6px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, box-shadow .15s;
}
.seg-btn.is-active { background: var(--seg-on); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); font-weight: 600; }
[data-theme="edge"] .seg-btn.is-active { background: var(--edge-grad); color: #fff; }
.status-seg { margin: 12px 0 0; }
.tab-n { color: var(--text-2); font-weight: 500; }
.f-system, .f-serif, .f-book { font-size: 16px; margin-right: 2px; }
.f-system { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.f-serif { font-family: ui-serif, "New York", Georgia, serif; }
.f-book { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }

/* Lista: stan dokumentu */
.st-newer { color: #ff9500; font-weight: 500; }
.st-notes { display: inline-flex; align-items: center; gap: 2px; }
.st-notes .icon { width: 13px; height: 13px; }

/* ---------- Czytnik: pasek górny ---------- */
.viewer-bar .viewer-actions { gap: 0; }
.viewer-bar .viewer-actions .icon-btn { width: 40px; }
.viewer-bar .viewer-actions .offline-pill { margin-right: 4px; }
#bookmark-btn .bm-on { display: none; color: #ff3b30; }
#bookmark-btn.is-on .bm-on { display: block; }
#bookmark-btn.is-on .bm-off { display: none; }
@media (max-width: 400px) {
  .viewer-bar .viewer-actions .icon-btn { width: 36px; }
  .viewer-bar .ver, .viewer-bar .ver-select { display: none; }
}

/* Arkusz „Aa” */
.switch-row strong { font-weight: 600; }
.switch-sub { display: block; margin-top: 2px; font-size: 13px; color: var(--text-2); line-height: 1.35; }
.reading-opts { display: grid; gap: 10px; }
.opt-row { display: grid; gap: 6px; }
.opt-label { font-size: 13px; color: var(--text-2); padding-left: 2px; }

/* ---------- Tryb czytania ---------- */
.ra-viewport { display: none; }
/* Dokument z trybem czytania: do czasu przygotowania tekstu nie migaj oryginałem */
.want-reading .viewer-frame { visibility: hidden; }
.is-reading { background: var(--paper); }
.is-reading .viewer-frame { display: none; }
.is-reading .ra-viewport { display: block; }
.ra {
  --ra-font: -apple-system, BlinkMacSystemFont, sans-serif;
  --ra-size: 19px;
  --ra-lh: 1.6;
  --ra-pad: 24px;
  --ra-measure: 38em;
  max-width: calc(var(--ra-measure) + 2 * var(--ra-pad));
  margin: 0 auto;
  padding: 28px var(--ra-pad) 48px;
  color: var(--ink);
  font-family: var(--ra-font);
  font-size: var(--ra-size);
  line-height: var(--ra-lh);
  overflow-wrap: break-word;
  -webkit-text-size-adjust: 100%;
}
.ra.is-justify p, .ra.is-justify li, .ra.is-justify dd { text-align: justify; -webkit-hyphens: auto; hyphens: auto; }
.ra p, .ra ul, .ra ol, .ra dl, .ra blockquote, .ra pre, .ra table, .ra figure { margin: 0 0 .9em; }
.ra h1, .ra h2, .ra h3, .ra h4, .ra h5, .ra h6 {
  margin: 1.4em 0 .5em;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.01em;
  break-after: avoid;
}
.ra h1 { font-size: 1.6em; margin-top: .4em; }
.ra h2 { font-size: 1.32em; }
.ra h3 { font-size: 1.14em; }
.ra h4, .ra h5, .ra h6 { font-size: 1em; }
.ra a { color: var(--accent); }
.ra img { display: block; max-width: 100%; height: auto; margin: .6em auto; border-radius: 6px; }
.ra img.ra-svg { background: #fff; padding: 4px; }
.ra figure { margin-left: 0; margin-right: 0; }
.ra figcaption, .ra small { color: var(--ink-2); font-size: .85em; }
.ra blockquote { padding-left: 1em; border-left: 3px solid var(--sep); color: var(--ink-2); }
.ra pre { overflow-x: auto; padding: .7em .9em; border-radius: 8px; background: var(--fill); font-size: .8em; line-height: 1.45; white-space: pre-wrap; }
.ra code { font-size: .88em; }
.ra table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .82em; line-height: 1.4; }
.ra th, .ra td { padding: .35em .6em; border: 1px solid var(--sep); vertical-align: top; text-align: left; }
.ra th { background: var(--fill); }
.ra hr { border: 0; border-top: 1px solid var(--sep); margin: 1.5em 0; }
.ra ul, .ra ol { padding-left: 1.3em; }
.ra li + li { margin-top: .25em; }
.ra div + div { margin-top: .4em; }

/* Strony: kolumny CSS przesuwane w poziomie; obszar między paskami */
.ra-paged { overflow: hidden; height: 100%; }
.ra-paged .ra-viewport {
  position: fixed;
  top: var(--viewer-top, 60px);
  bottom: var(--viewer-foot, 60px);
  left: 0;
  right: 0;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}
.ra-paged .ra-pagebox { height: 100%; margin: 0 auto; overflow: hidden; }
.ra-paged .ra {
  max-width: none;
  height: 100%;
  margin: 0;
  padding: 28px 0;
  column-fill: auto;
  will-change: transform;
}
.ra-paged .ra img { max-height: var(--ra-h, 70vh); width: auto; break-inside: avoid; }
.ra-paged .ra pre, .ra-paged .ra table, .ra-paged .ra figure { break-inside: avoid; }

/* ---------- Zakreślenia ---------- */
mark.hl { color: inherit; border-radius: 2px; padding: .05em 0; cursor: pointer; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
mark.hl-yellow { background: var(--hl-yellow); }
mark.hl-green { background: var(--hl-green); }
mark.hl-blue { background: var(--hl-blue); }
mark.hl-pink { background: var(--hl-pink); }
mark.hl.is-selected { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Zakreślenie z notatką: kropkowane podkreślenie (bez zmiany układu tekstu — strony się nie przesuwają) */
mark.has-note {
  text-decoration: underline dotted var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.hl-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--viewer-foot, 64px) + 12px);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 24px);
  padding: 6px 8px;
  border-radius: 22px;
  background: var(--toast);
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  transform: translateX(-50%);
  -webkit-user-select: none;
  user-select: none;
}
.hl-dot {
  flex: none;
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, .7);
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
}
.hl-dot.is-active { box-shadow: 0 0 0 2px var(--toast), 0 0 0 4px #fff; }
.hl-dot.hl-yellow { background: #ffd60a; } .hl-dot.hl-green { background: #30d158; }
.hl-dot.hl-blue { background: #0a84ff; } .hl-dot.hl-pink { background: #ff375f; }
.hl-sep { width: 1px; height: 24px; background: rgba(255, 255, 255, .25); }
.hl-act {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 46px;
  padding: 2px 4px;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
  touch-action: manipulation;
}
.hl-act .icon { width: 20px; height: 20px; }
.hl-act.danger { color: #ff6961; }

/* ---------- Arkusz nawigacji: spis treści, zakładki, notatki ---------- */
dialog.sheet.sheet-tall { height: min(78vh, 720px); }
.tabs { margin-bottom: 12px; }
.nav-list .row { min-height: 0; padding: 0 4px 0 0; }
.nav-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 6px 11px 16px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
  text-align: left;
  cursor: pointer;
  flex-direction: row;
  flex-wrap: wrap;
}
.nav-btn:active { background: var(--fill); }
.nav-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.nav-text small, .nav-btn > small { display: block; width: 100%; margin-top: 2px; color: var(--text-2); font-size: 12.5px; }
.nav-icon { color: #ff3b30; }
.nav-icon .icon { width: 18px; height: 18px; }
.lvl-2 .nav-btn { padding-left: 30px; font-size: 15px; }
.lvl-3 .nav-btn { padding-left: 46px; font-size: 14px; color: var(--text-2); }
.nav-row.is-current .nav-text { color: var(--accent); font-weight: 600; }
.nav-here { flex: none; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; }
.nav-quote { display: block; width: 100%; padding: 2px 4px; border-radius: 4px; font-family: ui-serif, Georgia, serif; line-height: 1.45; }
.nav-quote.hl-yellow { background: var(--hl-yellow); } .nav-quote.hl-green { background: var(--hl-green); }
.nav-quote.hl-blue { background: var(--hl-blue); } .nav-quote.hl-pink { background: var(--hl-pink); }
.nav-note { display: flex; gap: 5px; width: 100%; margin-top: 6px; color: var(--text); font-size: 14px; }
.nav-note .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--accent); }
.nav-empty { padding: 18px 16px; color: var(--text-2); font-size: 14.5px; line-height: 1.45; }
.nav-empty .icon { width: 16px; height: 16px; vertical-align: -3px; }

/* Notatka */
.note-quote { margin: 0; padding: 10px 12px; border-left: 3px solid #ffd60a; border-radius: 6px; background: var(--elev); color: var(--text-2); font-family: ui-serif, Georgia, serif; font-size: 15px; line-height: 1.45; }
.note-text { height: auto; min-height: 120px; padding: 12px 14px; line-height: 1.45; resize: vertical; }

/* Więcej */
.offline-state { display: flex; gap: 8px; align-items: flex-start; }
.offline-state .icon { width: 20px; height: 20px; flex: none; color: var(--text-3); }
.offline-state.is-ok .icon { color: var(--ok); }

/* =====================================================================
   Wersja 2.1: tło strony w czytniku (niezależne od wyglądu aplikacji)
   ===================================================================== */

/* Ciemne tło: biały tekst na czarnym — także paski i arkusze czytnika, żeby nic nie raziło w ciemności */
.page-viewer.reader-dark {
  --bg: #000000;
  --elev: #1c1c1e;
  --field: #2c2c2e;
  --fill: rgba(118, 118, 128, .24);
  --text: #f0f0f0;
  --text-2: #98989f;
  --text-3: #636366;
  --sep: rgba(84, 84, 88, .55);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, .2);
  --bar: rgba(0, 0, 0, .86);
  --seg-on: #48484a;
  --switch-off: rgba(120, 120, 128, .32);
  --toast: rgba(44, 44, 46, .96);
  --paper: #000000;
  --ink: #f0f0f0;
  --ink-2: #a1a1a6;
  --hl-yellow: rgba(255, 214, 10, .34);
  --hl-green: rgba(48, 209, 88, .3);
  --hl-blue: rgba(10, 132, 255, .34);
  --hl-pink: rgba(255, 55, 135, .34);
  color-scheme: dark;
  background: #000;
}
[data-theme="edge"] .page-viewer.reader-dark { --accent: #8b6cff; }
.reader-dark .viewer-frame, .reader-dark .viewer-frame iframe { background: #000; }
/* Jasne tło: kolory zakreśleń dla jasnego papieru (także przy ciemnym motywie aplikacji) */
.page-viewer.reader-light {
  --hl-yellow: rgba(255, 214, 10, .42);
  --hl-green: rgba(52, 199, 89, .32);
  --hl-blue: rgba(10, 132, 255, .26);
  --hl-pink: rgba(255, 55, 135, .26);
}
/* Papier trybu czytania ma pierwszeństwo przed tłem motywu (np. gradient New Edge) */
body.page-viewer.is-reading.reader-dark, body.page-viewer.is-reading.reader-light { background: var(--paper); }
.reader-light .ra pre, .reader-light .ra th { background: rgba(0, 0, 0, .05); }
.reader-light .ra th, .reader-light .ra td, .reader-light .ra hr, .reader-light .ra blockquote { border-color: rgba(60, 40, 20, .18); }

/* Temperatura w oryginalnym wyglądzie: ciepła nakładka mnożona z dokumentem (białe → ciepłe, czarny tekst bez zmian) */
.warm-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: multiply;
  transition: background-color .2s;
}
.warm-overlay[hidden] { display: none; }
/* Nakładka zakrywa ramkę na całą jej wysokość (w trybie strony ramka jest wysoka jak dokument) */
.frame-page .viewer-frame.is-warm { position: relative; }

/* Wybór tła strony */
.bg-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.bg-opt {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
}
.bg-opt.is-active { color: var(--accent); font-weight: 600; }
.bg-swatch {
  display: grid;
  place-items: center;
  width: 100%;
  height: 58px;
  border-radius: 14px;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 22px;
  box-shadow: 0 0 0 1px var(--sep), 0 4px 10px -6px rgba(0, 0, 0, .35);
  transition: box-shadow .15s;
}
.bg-opt.is-active .bg-swatch { box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4.5px var(--accent); }
.bg-sw-auto { background: linear-gradient(135deg, var(--elev) 50%, var(--fill) 50%); color: var(--text); }
.bg-sw-light { background: #fff; color: #1d1d1f; }
.bg-sw-dark { background: #000; color: #f0f0f0; }
.bg-hint { margin: 4px 2px 0; font-size: 13px; color: var(--text-2); }
.warm-ctl { display: flex; align-items: center; gap: 10px; }
.warm-ctl .seek { flex: 1; }
.warm-end { font-size: 12.5px; color: var(--text-2); }
/* Suwak temperatury: pasek od bieli do ciepłego bursztynu */
.warm-seek::-webkit-slider-runnable-track { background: linear-gradient(to right, #ffffff, #ffcf94); box-shadow: inset 0 0 0 1px var(--sep); height: 8px; border-radius: 4px; }
.warm-seek::-webkit-slider-thumb { margin-top: -7px; }
.warm-seek::-moz-range-track { background: linear-gradient(to right, #ffffff, #ffcf94); height: 8px; border-radius: 4px; }
.warm-seek::-moz-range-progress { background: transparent; }
.app-look { display: grid; gap: 8px; margin-top: 6px; padding-top: 14px; border-top: .5px solid var(--sep); }

/* Dokument PDF na liście */
.row-icon.is-pdf {
  background: rgba(255, 59, 48, .13);
  color: #e0362c;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .02em;
}

/* =====================================================================
   Wersja 2.2: czytnik PDF (doc-pdf.php, assets/pdf-reader.mjs)
   ===================================================================== */
.is-pdf { overflow-x: auto; }
.pdf-view { position: relative; min-height: calc(100vh - var(--viewer-top, 60px) - var(--viewer-foot, 60px)); }
.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 100%;
  padding: 12px 0 16px;
}
.pdf-page {
  position: relative;
  flex: none;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .14), 0 8px 24px -14px rgba(0, 0, 0, .35);
  scroll-margin-top: var(--viewer-top, 60px);
}
.pdf-page:not(.is-drawn) {
  background: linear-gradient(100deg, #fff 30%, #f2f2f4 50%, #fff 70%) 0 0 / 300% 100%;
  animation: pdf-wait 1.4s linear infinite;
}
@keyframes pdf-wait { to { background-position: -150% 0; } }
.pdf-page canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
/* Temperatura jasnego tła: ciepły odcień mnożony z kartką (czarny tekst bez zmian) */
.pdf-page::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--pdf-tint, transparent);
  mix-blend-mode: multiply;
  pointer-events: none;
}
/* Ciemne tło: odwrócone kolory strony (biały tekst na czarnym), odcienie zachowane */
.reader-dark .pdf-page { background: #000; box-shadow: 0 0 0 1px #2c2c2e; }
.reader-dark .pdf-page:not(.is-drawn) { background: #111; animation: none; }
.reader-dark .pdf-page canvas.pdf-canvas { filter: invert(1) hue-rotate(180deg); }
.reader-dark .pdf-page.is-dark-page canvas.pdf-canvas { filter: none; }   /* strona już ciemna — bez odwracania */
.pdf-page canvas.pdf-imgs { z-index: 0; }
.reader-dark.is-pdf { background: #000; }
.reader-light.is-pdf { background: #e9e6e1; }

/* Warstwa tekstu PDF.js — przezroczysty tekst do zaznaczania i kopiowania */
.textLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: clip;
  opacity: 1;
  line-height: 1;
  text-align: initial;
  letter-spacing: normal;
  word-spacing: normal;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  caret-color: CanvasText;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer span, .textLayer br {
  position: absolute;
  color: transparent;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
  -webkit-user-select: text;
  user-select: text;
}
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) {
  z-index: 1;
  --font-height: 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1;
  --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { -webkit-user-select: none; user-select: none; cursor: default; }
.textLayer ::selection { background: rgba(0, 122, 255, .3); color: transparent; }
.textLayer .endOfContent {
  display: block;
  position: absolute;
  inset: 100% 0 0;
  z-index: 0;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
.textLayer.selecting .endOfContent { top: 0; }
.textLayer .find-flash { background: rgba(255, 204, 0, .45); border-radius: 2px; transition: background .6s; }

/* Wczytywanie / błąd */
.pdf-status {
  position: fixed;
  left: 50%;
  top: 45%;
  z-index: 20;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(320px, calc(100vw - 48px));
  padding: 22px 20px;
  border-radius: 18px;
  background: var(--elev);
  color: var(--text-2);
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
  transform: translate(-50%, -50%);
}
.pdf-status[hidden] { display: none; }
.pdf-status p { margin: 0; }
.pdf-status .empty-title { color: var(--text); }
.pdf-spinner { width: 28px; height: 28px; border: 3px solid var(--fill); border-top-color: var(--accent); border-radius: 50%; animation: pdf-spin .8s linear infinite; }
.pdf-status.is-error .pdf-spinner, .pdf-status.is-error .pdf-load { display: none; }
@keyframes pdf-spin { to { transform: rotate(360deg); } }
.pdf-load { width: 100%; height: 4px; overflow: hidden; border-radius: 2px; background: var(--fill); }
.pdf-load[hidden] { display: none; }
.pdf-load span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s; }

/* Układ „Strony”: jedna strona dopasowana do ekranu */
.pdf-paged.is-pdf { overflow: hidden; height: 100%; }
.pdf-paged .pdf-view {
  position: fixed;
  top: var(--viewer-top, 60px);
  bottom: var(--viewer-foot, 60px);
  left: 0;
  right: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}
.pdf-paged .pdf-pages { padding: 0; min-width: 0; }
.pdf-page[hidden] { display: none; }
.pdf-page.turn-next { animation: pdf-next .26s cubic-bezier(.2, .8, .2, 1); }
.pdf-page.turn-prev { animation: pdf-prev .26s cubic-bezier(.2, .8, .2, 1); }
@keyframes pdf-next { from { transform: translateX(14%); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes pdf-prev { from { transform: translateX(-14%); opacity: .3; } to { transform: none; opacity: 1; } }

/* Arkusze czytnika PDF */
.bg-sw-pdf { background: #fff; color: #1d1d1f; }
.size-btn:disabled { opacity: .4; }
.goto-page { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.goto-page label { flex: 1; font-size: 15px; color: var(--text-2); }
.goto-page .input { width: 96px; height: 40px; text-align: center; }
.goto-page .btn { min-height: 40px; padding: 0 14px; font-size: 15px; }
.find-form { margin-bottom: 4px; }
mark.find-hit { background: var(--hl-yellow); color: inherit; border-radius: 2px; }
