/* Jasna sakura: papier washi, tusz sumi, akcent kōbai, pieczątka shu. */

:root {
  color-scheme: only light;
  --bg: #FAF6F1;          /* washi 生成り */
  --surface: #FFFFFF;
  --fill: #F3ECE6;        /* ciepłe tło segmentów i pól pomocniczych */
  --line: #E9DFD5;        /* ciepła linia podziału */
  --line-strong: #DCCFC3; /* obrys pól */
  --ink: #2A2422;         /* sumi */
  --ink-2: #6F625C;       /* tekst drugorzędny, AA na bg, surface i sakura */
  --accent: #B83A5E;      /* kōbai 紅梅 */
  --accent-press: #9E3050;
  --sakura: #FBEAEE;      /* 桜色: zaznaczenia, chipy i pole pod wykresem */
  --sakura-mid: #EDB3C3;  /* tylko dekoracja, nigdy tekst */
  --shu: #C2452D;         /* 朱: destrukcja i hanko */
  --matcha: #4E6B3A;      /* plakietki: Best match i wzrost ceny */
  --matcha-bg: #EEF2E6;
  --binder: #DDD0C3;      /* okładka segregatora: płócienny karton */
  --sheet: #FFFCF8;       /* strona z kieszeniami: folia na białym podkładzie */
  --ring: #CFC5BC;        /* metal ringów i listwy */
  --radius: 14px;         /* karty, panele, listy */
  --radius-control: 10px; /* przyciski, pola, notki */
  --shadow: 0 1px 2px rgba(42, 36, 34, 0.06), 0 6px 20px rgba(42, 36, 34, 0.07);
  --tabbar-h: 58px;
  --dur: 180ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
}

/* App shell: dokument nigdy się nie przewija, przewija się tylko main.
   Safari na iOS nie zwija wtedy paska narzędzi i belka stoi zawsze tak samo. */
html {
  color-scheme: only light;
  background: var(--bg);
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  padding-right: env(safe-area-inset-right);
  padding-left: env(safe-area-inset-left);
  padding-bottom: env(safe-area-inset-bottom);
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  display: inline-block;
  flex: none;
  width: 24px;
  height: 24px;
  vertical-align: middle;
}

p { margin: 0; }

img, video, canvas { max-width: 100%; }

main, section, .title-row, .top-row { min-width: 0; }

main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 8px 16px 32px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* W aplikacji safe-area na dole bierze tab bar, nie body. */
body.in-app { padding-bottom: 0; }

/* Main kończy się nad tab barem, więc nie trzeba go nadrabiać paddingiem. */
body.in-app main { padding-bottom: 32px; }

/* Ze stałym przyciskiem na dole dock kończy treść tuż nad tab barem. */
body.in-app.docked main { padding-bottom: 0; }

h1, h2, h3 { margin: 0; }

h2 {
  margin: 4px 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  overflow-wrap: break-word;
}

.screen-title {
  margin: 8px 0 14px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.subtitle,
.setline {
  color: var(--ink-2);
  font-size: 15px;
}

.setline { margin: 0 0 16px; }

.fine {
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 14px;
  overflow-wrap: anywhere;
}

/* Kontrolki */

button, input, select, textarea {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}

button {
  margin: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
}

button:disabled { cursor: default; }

button, .file, summary, a, select {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.file:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary,
.ghost,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 18px;
  border-radius: var(--radius-control);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), opacity var(--dur) var(--ease), transform 120ms var(--ease);
}

.primary {
  background: var(--accent);
  color: #FFFFFF;
}

.primary:active:not(:disabled) { background: var(--accent-press); }

.ghost {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.ghost:active:not(:disabled) { background: var(--fill); }

.ghost.small {
  min-height: 44px;
  padding: 0 14px;
  font-size: 15px;
}

.ghost.small .icon { width: 18px; height: 18px; color: var(--accent); }

.danger {
  background: var(--surface);
  color: var(--shu);
  box-shadow: inset 0 0 0 1px #E8C4BB;
}

.danger.armed {
  background: var(--shu);
  color: #FFFFFF;
  box-shadow: none;
}

.texty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 4px;
  border-radius: var(--radius-control);
  color: var(--accent);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.texty:active:not(:disabled) { color: var(--accent-press); }

.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  margin-left: -8px;
  padding: 0 10px 0 2px;
  border-radius: var(--radius-control);
  color: var(--accent);
  font-size: 16px;
  font-weight: 500;
}

.back .icon { width: 22px; height: 22px; }

button:disabled,
.file:has(input:disabled) { opacity: 0.5; }

button.is-busy:disabled,
button.is-done:disabled { opacity: 1; }

.is-busy .spin,
.spinner {
  animation: spin 1.6s linear infinite;
}

.is-busy .spin {
  width: 18px;
  height: 18px;
  --flower-core: transparent;
  --flower-stamen: transparent;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* Pola */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0 0 14px;
}

.field-label {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 16px;
  caret-color: var(--accent);
  transition: box-shadow var(--dur) var(--ease);
}

/* Pole w fokusie: jeden pierścień w kolorze akcentu, bez podwójnego obrysu. */
input:focus,
select:focus,
textarea:focus,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%236F625C' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}

input[type="search"] {
  appearance: none;
  -webkit-appearance: none;
  padding-left: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='7' cy='7' r='4.25' fill='none' stroke='%236F625C' stroke-width='1.5'/%3E%3Cpath d='M10.4 10.4L13.2 13.2' fill='none' stroke='%236F625C' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 13px 50%;
  background-size: 16px 16px;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button {
  -webkit-appearance: none;
  appearance: none;
}

/* Wybór setu: lista pod polem filtruje się na żywo. */
.set-field input[type="search"] { scroll-margin-top: 12px; }

.set-list {
  max-height: min(320px, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.set-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 16px;
  line-height: 1.3;
}

.set-option:last-child { border-bottom: 0; }
.set-option small { color: var(--ink-2); font-size: 13px; }
.set-option:active { background: var(--fill); }
.set-option[aria-selected="true"] { background: var(--sakura); }

.set-list-note {
  margin: 0;
  padding: 10px 12px;
  color: var(--ink-2);
  font-size: 14px;
}

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

::placeholder { color: var(--ink-2); opacity: 0.8; }

/* Nagłówek */

.top {
  position: relative;
  flex: none;
  z-index: 4;
  /* +10px: na iOS Liquid Glass rozmywa pas tuż pod paskiem statusu. */
  padding-top: calc(env(safe-area-inset-top) + 10px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 12px 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand-flower {
  width: 24px;
  height: 24px;
  color: var(--accent);
  --flower-core: var(--surface);
}

.hanko {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--shu);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  box-shadow: inset 0 0 0 2px var(--shu), inset 0 0 0 3px rgba(255, 255, 255, 0.5);
}

.top-actions {
  display: flex;
  align-items: center;
  flex: none;
  gap: 2px;
}

#open-settings {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-control);
  color: var(--ink);
}

#open-settings:active { color: var(--accent); background: var(--fill); }

#open-settings .icon { width: 22px; height: 22px; }

/* Tab bar: ostatni wiersz flexa w body, nie position: fixed.
   W DOM stoi przed main, order przenosi go na dół. Ujemne marginesy
   znoszą boczny safe-area body, żeby tło szło od krawędzi do krawędzi. */

.tabbar {
  position: relative;
  z-index: 5;
  order: 1;
  flex: none;
  margin: 0 calc(-1 * env(safe-area-inset-right)) 0 calc(-1 * env(safe-area-inset-left));
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 4px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.tabbar button {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  max-width: 220px;
  min-height: 50px;
  padding: 2px 8px 4px;
  border-radius: var(--radius-control);
  color: var(--ink-2);
  transition: color var(--dur) var(--ease);
}

.tabbar button[aria-current="page"] { color: var(--accent); }

.tab-icon {
  position: relative;
  display: inline-flex;
}

.tab-icon .icon { width: 26px; height: 26px; }

.tab-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge {
  position: absolute;
  top: -3px;
  left: calc(100% - 8px);
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}

/* Login */

#view-login {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 40px);
  padding-top: env(safe-area-inset-top);
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 24px 0 40px;
  text-align: center;
}

.login-flower {
  width: 76px;
  height: 76px;
  margin-bottom: 18px;
  color: var(--accent);
  --flower-core: var(--bg);
}

.login-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 6px;
  font-size: 30px;
  letter-spacing: -0.015em;
}

.login-title .hanko {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: 15px;
}

#view-login .subtitle { margin: 0 0 32px; }

#login-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

#login-form .primary { width: 100%; }

/* Brak połączenia przy starcie: ten sam układ co logowanie, kwiat przygaszony. */

#view-offline {
  display: grid;
  place-items: center;
  min-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 40px);
  padding-top: env(safe-area-inset-top);
}

.offline-flower { color: var(--sakura-mid); }

#view-offline .subtitle { margin: 0 0 32px; }

#offline-retry { width: 100%; }

.login-petals {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 20px);
  right: calc(env(safe-area-inset-right) + 18px);
  width: 90px;
  height: 90px;
  pointer-events: none;
  color: var(--sakura-mid);
}

.login-petals .icon { position: absolute; width: 14px; height: 18px; opacity: 0.7; }
.login-petals .p1 { top: 6px; right: 10px; transform: rotate(28deg); }
.login-petals .p2 { top: 38px; right: 52px; width: 10px; height: 13px; transform: rotate(-36deg); opacity: 0.5; }
.login-petals .p3 { top: 62px; right: 4px; width: 12px; height: 15px; transform: rotate(140deg); opacity: 0.6; }

/* Scan */

.segmented {
  display: flex;
  gap: 2px;
  margin: 0 0 16px;
  padding: 3px;
  border-radius: var(--radius-control);
  background: var(--fill);
}

.segmented button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.note {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--fill);
  color: var(--ink);
  font-size: 15px;
}

.frame {
  position: relative;
  height: min(46svh, 440px);
  max-width: 100%;
  aspect-ratio: 63 / 88;
  margin: 0 auto 16px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.frame.is-live { background: var(--ink); box-shadow: none; }

#live {
  position: absolute;
  inset: 0;
}

/* Cyfrowy zoom 2× (SCAN_ZOOM w app-camera.js). Karta wypełnia ramkę, gdy telefon jest
   ~20 cm od niej, a z tej odległości iPhone łapie ostrość. Z 8–10 cm nie łapie. */
#live video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(2);
}

#view-scan.upright #live video { transform: none; }

.hold-still {
  position: absolute;
  z-index: 1;
  left: 56px;
  right: 56px;
  bottom: 46px;
  margin: 0;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 0 2px rgba(42, 36, 34, 0.5);
  pointer-events: none;
}

/* Lock często nie wchodzi (iOS). Wtedy w poziomie sam skan zostaje pionowy.
   Najpierw wyśrodkowanie, potem obrót wokół środka. Odwrotna kolejność zjeżdża z ekranu. */
#view-scan.upright {
  position: fixed;
  z-index: 8;
  left: 50%;
  top: 50%;
  box-sizing: border-box;
  width: 100vh;
  height: 100vw;
  margin: 0;
  padding:
    calc(8px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
  overflow: auto;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  transform: translate(-50%, -50%) rotate(90deg);
}

#view-scan.upright.upright-secondary {
  transform: translate(-50%, -50%) rotate(-90deg);
}

.corner {
  position: absolute;
  z-index: 4;
  width: 28px;
  height: 28px;
  border: 0 solid var(--accent);
  pointer-events: none;
}

.corner.tl { top: 14px; left: 14px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 8px; }
.corner.tr { top: 14px; right: 14px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 8px; }
.corner.bl { bottom: 14px; left: 14px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 8px; }
.corner.br { bottom: 14px; right: 14px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 8px; }

.frame.is-live .corner {
  border-color: #FFFFFF;
  filter: drop-shadow(0 0 2px rgba(42, 36, 34, 0.5));
}

.cam-idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 28px;
  text-align: center;
}

.cam-start {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--sakura);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(184, 58, 94, 0.18);
  transition: transform 120ms var(--ease), background-color var(--dur) var(--ease);
}

.cam-start:active:not(:disabled) { transform: scale(0.96); }

.cam-start .icon { width: 36px; height: 36px; }

.cam-caption {
  font-size: 16px;
  font-weight: 600;
}

.cam-hint {
  max-width: 24ch;
  color: var(--ink-2);
  font-size: 14px;
}

.cam-stop {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.cam-stop .icon { width: 20px; height: 20px; }

/* Wybór tylnego obiektywu: mała okrągła ikona jak przy zamykaniu. Nazwa kamery idzie do aria-label. */
.cam-lens {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.cam-lens .icon { width: 22px; height: 22px; }

.cam-lens:disabled { opacity: 0.6; }

.frame-busy {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
  animation: fade-in var(--dur) var(--ease);
}

.spinner {
  width: 52px;
  height: 52px;
  color: var(--accent);
  --flower-core: var(--bg);
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

#cam-shoot { width: 100%; }

.file {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.file input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
}

.panel {
  margin-top: 16px;
  padding: 0 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

details.panel[open] { padding-bottom: 16px; }

summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-control);
}

summary::-webkit-details-marker { display: none; }

summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin: 0 4px 0 auto;
  border-top: 1.6px solid var(--ink-2);
  border-right: 1.6px solid var(--ink-2);
  transform: rotate(135deg) translate(-2px, 2px);
  transition: transform var(--dur) var(--ease);
}

details[open] > summary::after { transform: rotate(-45deg) translate(-1px, 2px); }

details[open] > form { animation: reveal var(--dur) var(--ease); }

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 10px;
}

#manual-form .primary { width: 100%; }

#unfound.panel { padding: 16px; }

#unfound > .section-label { margin-top: 0; }

#unfound .fine {
  margin-top: 0;
  margin-bottom: 14px;
}

#unfound .primary { width: 100%; }

#unfound .ghost.file {
  width: 100%;
  margin-bottom: 14px;
}

/* Link Cardmarketu: wyszukiwanie w Safari, potem wklejenie adresu karty. */
#wrong-card { margin-top: 20px; padding: 16px; }

#wrong-card > .section-label { margin-top: 0; }

#wrong-card .fine { margin-top: 0; margin-bottom: 14px; }

.link-button {
  width: 100%;
  margin-bottom: 14px;
}

.paste-row {
  display: flex;
  gap: 10px;
}

.paste-row .primary,
#unfound .paste-row .primary { flex: 1; width: auto; }

.paste-row .ghost { flex: 0 0 auto; }

#custom-album-slot {
  display: block;
  min-width: 0;
}

/* Wyniki */

.chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  margin: 2px 0 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--sakura);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.chip-key {
  color: var(--ink-2);
  font-weight: 500;
}

#reading:empty { display: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.match {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 8px 8px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: left;
  transition: box-shadow var(--dur) var(--ease), transform 120ms var(--ease);
}

.match:active:not(:disabled) { transform: scale(0.985); }

.match.best { box-shadow: inset 0 0 0 1.5px var(--accent); }

.match .thumb { margin-bottom: 6px; }

.match .name {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.match .meta {
  display: block;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* Warianty karty pod numerem: holo i reverse holo w kolorze akcentu, zwykła szara. */
.match-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.match-kinds:empty { display: none; }

.match-kind {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.match-kind.is-foil {
  background: var(--sakura);
  box-shadow: none;
  color: var(--accent);
}

.best-badge {
  align-self: flex-start;
  margin-bottom: 2px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--matcha-bg);
  color: var(--matcha);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.match.is-busy:disabled { opacity: 1; }

.card-busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(250, 246, 241, 0.8);
  animation: fade-in var(--dur) var(--ease);
}

.card-busy .spinner { width: 40px; height: 40px; }

/* Miniatury: stałe proporcje karty, bez skakania layoutu */

.thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 63 / 88;
  overflow: hidden;
  border-radius: var(--radius-control);
  background: var(--fill);
}

.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--line-strong);
  --flower-core: var(--fill);
  --flower-stamen: var(--fill);
}

.placeholder .icon { width: 42%; height: auto; aspect-ratio: 1; }

/* Szczegóły i wpis */

.card-view { display: block; }

.card-media {
  width: min(70%, 280px);
  margin: 4px auto 20px;
}

.card-media .thumb {
  border-radius: 12px;
  background: transparent;
  box-shadow: var(--shadow);
}

.card-media .thumb:has(.placeholder) { background: var(--fill); box-shadow: none; }

.card-view h2 { font-size: 26px; }

.card-view .setline { margin-bottom: 4px; }

.card-view .stats { margin: 0 0 16px; color: var(--ink-2); font-size: 14px; }

.price-hero {
  margin: 16px 0 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.price-label {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.price-now {
  margin: 2px 0 2px;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.price-now.none {
  color: var(--ink-2);
  font-size: 24px;
  font-weight: 600;
}

.price-extra {
  color: var(--ink-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.price-extra:empty { display: none; }

.price-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 14px;
}

.section-label {
  margin: 24px 4px 8px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.list {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.variant {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  text-align: left;
  transition: background-color var(--dur) var(--ease);
}

.variant + .variant { border-top: 1px solid var(--line); }

.variant[aria-checked="true"] { background: var(--sakura); }

.radio {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  color: #FFFFFF;
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.radio .icon { width: 14px; height: 14px; opacity: 0; }

.variant[aria-checked="true"] .radio {
  background: var(--accent);
  box-shadow: none;
}

.variant[aria-checked="true"] .radio .icon { opacity: 1; }

.variant-name {
  min-width: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.variant-price {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.form-card {
  padding: 16px 16px 2px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.photo-pick {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
}

.photo-pick .fine { margin: 0; }

.photo-pick .ghost,
.photo-pick .file { width: 100%; }

.photo-pick .texty { justify-self: start; }

.qty {
  display: flex;
  gap: 8px;
  align-items: center;
}

.qty input {
  width: 72px;
  flex: 0 0 72px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.qty .ghost {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 12px;
}

.links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  border-radius: var(--radius-control);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
}

.danger-zone { margin-top: 24px; }

.danger-zone .danger { width: 100%; }

.danger-zone .fine { margin-top: 8px; text-align: center; }

/* Przycisk główny przyklejony do dołu main, czyli tuż nad tab barem. */
.dock {
  position: sticky;
  z-index: 3;
  bottom: 0;
  margin: 20px -16px 0;
  padding: 10px 16px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.dock .primary,
.dock > .ghost { width: 100%; }

.dock > .ghost { margin-bottom: 8px; }

.wish-slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.wish-slot .ghost,
.wish-slot .danger { width: 100%; }

.wish-state {
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--sakura);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.primary.is-done { background: var(--matcha); }

/* Kolekcja */

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-row .screen-title,
.title-row h2 { min-width: 0; overflow-wrap: anywhere; }

.total {
  margin: 0 0 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.total-label {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.total-value {
  margin: 2px 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.total-sub {
  color: var(--ink-2);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.total .fine { margin-top: 6px; }

/* Ustawienia */

.settings-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.settings-card h3 {
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.settings-lead {
  color: var(--ink);
  font-size: 15px;
}

#export-link,
#export-link:visited {
  width: 100%;
  margin-top: 16px;
  color: #FFFFFF;
  text-decoration: none;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.settings-actions .primary,
.settings-actions .ghost,
.settings-actions .danger { width: 100%; }

.settings-card .fine { margin-top: 10px; }

.settings-card + .settings-card { margin-top: 12px; }

/* Aplikacja iOS trzyma kolekcję u siebie: bez wylogowania i bez pobierania pliku z serwera. */
.is-ios .web-only { display: none !important; }

.app-version {
  margin-top: 10px;
  color: var(--ink-2);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

#view-settings #logout { width: 100%; }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar input { flex: 1; min-width: 0; }

.album-view { margin: 12px 0 0; }
.album-view button { min-height: 36px; }
#collection-list { margin-top: 12px; }

.album-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 8px 8px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform 120ms var(--ease);
}

.album-tile:active:not(:disabled) { transform: scale(0.985); }
.album-tile .album-pattern {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  padding: 12px 8px;
  border-radius: 8px;
  text-align: center;
}

.album-tile .album-name {
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.album-tile .meta { display: block; color: var(--ink-2); font-size: 14px; }

.cover-section { margin-top: 16px; }

.cover-section .field-label { margin: 14px 0 8px; }
.cover-section .field-label:first-child { margin-top: 0; }

.cover-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cover-colours { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.colour-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  padding: 6px 4px 8px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.15;
  box-shadow: inset 0 0 0 1px var(--line);
}

.colour-choice[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--accent); }

.colour-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(42, 36, 34, 0.12);
}

#album-form { margin-top: 12px; padding-top: 16px; padding-bottom: 16px; }

.reveal:not([hidden]) { animation: reveal var(--dur) var(--ease); }

.wish-search {
  margin: 0 0 16px;
  padding: 16px 16px 16px;
}

.wish-search .primary { width: 100%; }

#collection-list,
#wishlist-list { margin-top: 16px; }

#collection-list:empty,
#wishlist-list:empty { display: none; }

.wish-row {
  grid-template-columns: 50px minmax(0, 1fr) auto;
  grid-template-areas:
    "thumb text value"
    "thumb action action";
  row-gap: 8px;
}

.wish-row.has-market {
  grid-template-areas:
    "thumb text value"
    "thumb market market"
    "thumb action action";
}

.wish-row .links {
  grid-area: market;
  margin-top: 0;
  min-width: 0;
}

.wish-row::after { content: none; }

.wish-row .thumb { grid-area: thumb; align-self: center; }

.wish-row .row-text { grid-area: text; }

.wish-row .row-value { grid-area: value; align-self: center; }

.wish-actions {
  grid-area: action;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wish-remove {
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
}

.rowcard {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto 10px;
  column-gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px 10px 12px;
  text-align: left;
  transition: background-color var(--dur) var(--ease);
}

.rowcard:active:not(:disabled) { background: var(--fill); }

.rowcard + .rowcard { border-top: 1px solid var(--line); }

.rowcard .thumb,
.rowcard .album-pattern { width: 50px; border-radius: 6px; }

.rowcard .placeholder .icon { width: 60%; }

.row-text { min-width: 0; }

.row-text .name,
.row-text .meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-text .name { font-size: 16px; font-weight: 600; }

.row-text .album-name { font-weight: 700; }

.row-text .meta { color: var(--ink-2); font-size: 14px; }

.row-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.row-value.none { color: var(--ink-2); font-weight: 500; }

.rowcard::after {
  content: "";
  width: 7px;
  height: 7px;
  border-top: 1.6px solid var(--ink-2);
  border-right: 1.6px solid var(--ink-2);
  transform: rotate(45deg);
  justify-self: end;
  opacity: 0.7;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 16px 24px;
  text-align: center;
}

.empty .icon {
  width: 64px;
  height: 64px;
  margin-bottom: 10px;
  color: var(--sakura-mid);
  --flower-core: var(--bg);
}

.empty-title { font-size: 17px; font-weight: 600; }

.empty-text { color: var(--ink-2); font-size: 15px; }

.empty .primary { margin-top: 14px; min-width: 200px; }

/* Album */

#album-title { margin-bottom: 2px; }

/* Nazwa albumu: złote litery. Nazwy kart zostają sumi. */
.album-name {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #7A5210;
}

/* Złota folia tylko na dużym napisie okładki segregatora. */
.cover-name .album-name {
  letter-spacing: 0.06em;
  color: #8A5E10;
  background-image: linear-gradient(180deg, #8A5E10 0%, #C6A15A 32%, #FFF1C2 48%, #E3C56A 62%, #8C6414 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 1px 0 rgba(90, 58, 8, 0.45));
}

#album-stats { font-variant-numeric: tabular-nums; }

.album-export,
.album-export:visited {
  width: 100%;
  color: var(--ink);
  text-decoration: none;
}

.album-export-note { margin: 8px 0 0; }

#view-album .web-only { margin-top: 20px; }

#album-tools { margin: 0 0 16px; padding-top: 16px; padding-bottom: 16px; }

#album-rename-form .button-row { grid-template-columns: 1fr; }

#album-tools .danger { width: 100%; margin-top: 12px; }

#album-tools .fine { margin-top: 8px; text-align: center; }

/* Statystyki */

.stats-change {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.stats-since {
  color: var(--ink-2);
  font-size: 14px;
}

.delta {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.delta.up {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--matcha-bg);
  color: var(--matcha);
}

.delta.down { color: var(--shu); }

.delta.flat {
  color: var(--ink-2);
  font-weight: 600;
}

.total-chart { margin-top: 14px; }

.total-chart .chart { aspect-ratio: 320 / 132; }

.total-chart.compact .chart { aspect-ratio: 320 / 84; }

.chart-note { margin-top: 6px; }

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-up { color: var(--matcha); }
.chart-down { color: var(--shu); }
.chart-flat { color: var(--accent); }

.chart-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-guide {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.chart-point { fill: currentColor; }

/* Pole zmiany od ceny otwarcia. Płaskie, bez gradientu. */
.chart-up .chart-area { fill: var(--matcha-bg); }
.chart-down .chart-area { fill: color-mix(in srgb, var(--shu) 14%, white); }
.chart-flat .chart-area { fill: var(--sakura); }

.chart-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart-axis span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-axis span:last-child { text-align: right; }

.bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 6px;
  align-items: baseline;
}

.bar-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
}

.bar-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.bar-track {
  grid-column: 1 / -1;
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--fill);
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.bar-meta {
  grid-column: 1 / -1;
  margin-top: -2px;
  color: var(--ink-2);
  font-size: 14px;
}

.quiet {
  margin: 0 2px 8px;
  color: var(--ink-2);
  font-size: 15px;
}

.mover {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  column-gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 10px 14px 10px 12px;
}

.mover + .mover { border-top: 1px solid var(--line); }

.mover .thumb { width: 50px; border-radius: 6px; }

.mover .placeholder .icon { width: 60%; }

.mover .delta { justify-self: end; white-space: nowrap; }

.mover-chart {
  grid-column: 2 / -1;
  grid-row: 2;
  min-width: 0;
}

.mover-chart .chart {
  width: 100%;
  height: auto;
  aspect-ratio: 320 / 132;
}

.spark { margin-top: 12px; }

.spark .chart {
  width: 100%;
  height: auto;
  aspect-ratio: 320 / 132;
}

.spark-caption {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Toast */

.status {
  position: fixed;
  z-index: 6;
  left: max(calc(env(safe-area-inset-left) + 16px), calc(50% - 280px));
  right: max(calc(env(safe-area-inset-right) + 16px), calc(50% - 280px));
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 4px 16px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: #FFFFFF;
  box-shadow: var(--shadow);
  font-size: 15px;
  line-height: 1.35;
  animation: toast-in var(--dur) var(--ease);
}

body.in-app .status {
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
}

body.in-app.docked .status {
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 84px);
}

.status p {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  overflow-wrap: anywhere;
}

.status.error {
  padding-right: 4px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #E8C4BB, var(--shadow);
}

.status.error p::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 8px 1px 0;
  border-radius: 50%;
  background: var(--shu);
}

.status-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-control);
  color: var(--ink-2);
}

.status-close .icon { width: 20px; height: 20px; }

/* Akcja w toaście, np. „Reload” po nowej wersji. Biała i podkreślona na ciemnym tle sumi. */
.status-action {
  flex: none;
  min-height: 44px;
  margin-right: -8px;
  padding: 0 8px;
  border-radius: var(--radius-control);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.status-action:active:not(:disabled) { opacity: 0.7; }

.status.error .status-action { margin-right: 0; color: var(--accent); }

/* Segregator w albumie: strony z kieszeniami jak Ultra Pro / Vault X.
   Bez gradientów: głębia z warstwowych cieni, refleks folii to jednolita biała smuga. */

.binder-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  margin: 0 0 14px;
}

.binder-controls .segmented { margin: 0; }
.binder-view { flex: 1 1 auto; }
.binder-pockets { flex: 0 0 auto; }

.binder-pockets button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  padding: 0 9px;
  font-variant-numeric: tabular-nums;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 3px);
  gap: 1.5px;
}

.mini-grid[data-cols="2"] { grid-template-columns: repeat(2, 3px); }

.mini-grid i {
  display: block;
  width: 3px;
  height: 4px;
  border-radius: 0.5px;
  background: currentColor;
}

.binder {
  position: relative;
}

/* Okładka: płótno, w środku strony. Lewy pas to grzbiet z ringami. */
.binder-body {
  position: relative;
  padding: 8px 8px 8px 6px;
  border-radius: var(--radius);
  background: var(--binder);
  box-shadow:
    inset 0 0 0 1px rgba(42, 36, 34, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    var(--shadow);
}

.binder-pages {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-radius: 8px;
}

.binder-pages::-webkit-scrollbar { display: none; }
.binder-pages:focus-visible { outline-offset: 3px; }

.binder-page {
  display: flex;
  flex-direction: column;
  flex: 0 0 100%;
  min-width: 0;
  padding: 4px 8px 12px 22px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.binder-page.is-cover { padding-left: 40px; }

.binder-page.is-filler { display: none; }

/* Strona: folia na kartonie, pod nią krawędzie kolejnych kartek. */
.binder-sheet {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 9px 9px 10px 30px;
  overflow: hidden;
  border-radius: 3px 7px 7px 3px;
  background: var(--sheet);
  box-shadow:
    0 0 0 1px rgba(42, 36, 34, 0.08),
    1px 2px 0 0 var(--sheet),
    1px 2px 0 1px rgba(42, 36, 34, 0.08),
    2px 4px 0 0 var(--sheet),
    2px 4px 0 1px rgba(42, 36, 34, 0.1),
    0 6px 14px rgba(42, 36, 34, 0.14);
}

.binder[data-pockets="4"] .binder-sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }

/* Listwa z dziurkami przy grzbiecie: grubsza, lekko zmatowiona folia. */
.binder-sheet::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 26px;
  border-right: 1px solid rgba(42, 36, 34, 0.08);
  background: rgba(42, 36, 34, 0.025);
  pointer-events: none;
}

/* Jeden ukośny refleks folii przez całą stronę. */
.binder-sheet::after {
  content: "";
  position: absolute;
  top: -30%;
  left: 60%;
  width: 14%;
  height: 160%;
  background: rgba(255, 255, 255, 0.24);
  transform: rotate(24deg);
  pointer-events: none;
  z-index: 2;
}

.binder-holes {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;
  width: 14px;
  pointer-events: none;
}

.binder-holes span {
  position: absolute;
  left: 0;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--binder);
  box-shadow: inset 0 1.5px 2px rgba(42, 36, 34, 0.38), 0 1px 0 rgba(255, 255, 255, 0.95);
}

.binder-holes span:nth-child(1),
.binder-spine .ring:nth-child(1) { top: 16%; }
.binder-holes span:nth-child(2),
.binder-spine .ring:nth-child(2) { top: 50%; }
.binder-holes span:nth-child(3),
.binder-spine .ring:nth-child(3) { top: 84%; }

/* Kieszeń: przezroczysty rękaw. Podwójna linia zgrzewu wypada w środku przerwy. */
.pocket {
  position: relative;
  display: block;
  min-width: 0;
  padding: 0;
  aspect-ratio: 66 / 92;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(42, 36, 34, 0.1),
    inset 0 2px 4px rgba(42, 36, 34, 0.06);
  outline: 1px solid rgba(42, 36, 34, 0.06);
  outline-offset: 2px;
}

.pocket:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Przytrzymanie karty to początek przeciągania: bez menu, zaznaczania i systemowego drag obrazka. */
.pocket {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.pocket img { -webkit-user-drag: none; }

/* Szczelina u góry kieszeni z wcięciem na kciuk. */
.pocket::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 7%;
  right: 7%;
  height: 1px;
  background: rgba(42, 36, 34, 0.14);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  z-index: 3;
  pointer-events: none;
}

.pocket::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  width: 24%;
  height: 7px;
  margin-left: -12%;
  border-radius: 0 0 999px 999px;
  background: var(--sheet);
  box-shadow: inset 0 -1px 0 rgba(42, 36, 34, 0.14), 0 1px 0 rgba(255, 255, 255, 0.9);
  z-index: 3;
  pointer-events: none;
}

/* Karta 63:88, wsunięta do dna kieszeni, rogi jak w prawdziwej karcie. */
.pocket-card,
.pocket-under {
  position: absolute;
  left: 4.5%;
  right: 4.5%;
  bottom: 3%;
  aspect-ratio: 63 / 88;
  border-radius: 4.6% / 3.3%;
}

.pocket-card {
  z-index: 1;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 0.5px rgba(42, 36, 34, 0.2), 0 1px 2px rgba(42, 36, 34, 0.24);
  transition: transform var(--dur) var(--ease);
}

.pocket-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pocket:active .pocket-card { transform: translateY(-3px); }

/* Druga i kolejna sztuka: krawędź karty za kartą. */
.pocket-under {
  z-index: 0;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong), 0 1px 2px rgba(42, 36, 34, 0.18);
  transform: translate(3px, -4px) rotate(1.5deg);
}

.pocket-count {
  position: absolute;
  right: 7%;
  bottom: 5%;
  z-index: 4;
  min-width: 26px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--sakura);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 1.5px var(--surface), 0 1px 3px rgba(42, 36, 34, 0.22);
}

.pocket-card.is-blank {
  display: grid;
  place-items: center;
  padding: 10%;
  background: var(--fill);
}

.pocket-blank {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
  --flower-core: var(--fill);
  --flower-stamen: var(--fill);
}

.pocket-blank .icon { width: 28px; height: 28px; color: var(--line-strong); }

/* Plus w pustej kieszeni poza Arrange. Cały rękaw zostaje celem tapnięcia. */
.pocket-plus {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  color: var(--accent);
  pointer-events: none;
}

/* Grzbiet z ringami. Ringi stoją, kartki przesuwają się pod nimi. */
.binder-spine {
  position: absolute;
  top: 12px;
  bottom: 20px;
  left: 0;
  width: 48px;
  pointer-events: none;
  z-index: 3;
}

.binder-spine::before {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -14px;
  left: 0;
  width: 6px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: rgba(42, 36, 34, 0.07);
}

.ring {
  position: absolute;
  left: 1px;
  width: 44px;
  height: 8px;
  margin-top: -4px;
  border-radius: 999px;
  background: var(--ring);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.75),
    inset 0 -2px 0 rgba(42, 36, 34, 0.16),
    0 1px 2px rgba(42, 36, 34, 0.3);
}

.binder-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.binder-step {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.binder-step:active:not(:disabled) { background: var(--fill); }
.binder-step .icon { width: 22px; height: 22px; }
.binder-step .flip { transform: scaleX(-1); }

.binder-count {
  min-width: 12em;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Układanie kart: tryb Arrange (tap, tap) i przeciąganie po przytrzymaniu. */
.binder-arrange,
#binder-blanks,
#binder-add-page { flex: 0 0 auto; }

.binder-arrange.is-on,
#binder-blanks.is-on {
  background: var(--sakura);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.binder-hint {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 15px;
}

/* W trybie Arrange puste kieszenie też są celem: delikatny przerywany obrys. */
.binder.is-arranging .pocket.is-empty,
.binder.is-dragging .pocket.is-empty {
  outline: 1px dashed var(--sakura-mid);
  outline-offset: -3px;
}

.pocket.is-picked {
  background: var(--sakura);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.pocket.is-picked .pocket-card {
  transform: translateY(-4px);
  box-shadow: 0 0 0 2px var(--accent), 0 6px 12px rgba(42, 36, 34, 0.22);
}

.pocket.is-target {
  background: var(--sakura);
  box-shadow: inset 0 0 0 2px var(--accent);
  outline: 0;
}

.pocket.is-lifted .pocket-card,
.pocket.is-lifted .pocket-under,
.pocket.is-lifted .pocket-count { opacity: 0.25; }

.pocket.is-lifted { box-shadow: inset 0 0 0 1px rgba(42, 36, 34, 0.1); }

/* Podniesiona karta idzie za palcem. Pozycję i skalę ustawia transform z app.js. */
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  bottom: auto;
  z-index: 60;
  margin: 0;
  pointer-events: none;
  transition: none;
  will-change: transform;
  box-shadow: 0 0 0 0.5px rgba(42, 36, 34, 0.2), 0 12px 28px rgba(42, 36, 34, 0.28);
}

body.is-dragging-card,
body.is-dragging-card * {
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

/* Karta przytrzymana przy krawędzi: strzałka strony, która zaraz się przewróci. */
.binder[data-edge="prev"] .binder-step:first-child,
.binder[data-edge="next"] .binder-step:last-child {
  background: var(--sakura);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Tkanina i strona albumu. Tylko pod [data-theme], chrom aplikacji zostaje sakurą. */
.binder[data-theme="blue"] { --binder: #D7E6EC; --sheet: #EEF4F6; }
.binder[data-theme="pink"] { --binder: #F6E1E8; --sheet: #FBF3F6; }
.binder[data-theme="green"] { --binder: #DCE8D6; --sheet: #F1F6EE; }
.binder[data-theme="sand"] { --binder: #DDD0C3; --sheet: #F7F1EA; }

.album-pattern[data-theme="blue"],
.album-tile[data-theme="blue"]::before,
.colour-choice[data-theme="blue"] .colour-swatch { background: #D7E6EC; }

.album-pattern[data-theme="pink"],
.album-tile[data-theme="pink"]::before,
.colour-choice[data-theme="pink"] .colour-swatch { background: #F6E1E8; }

.album-pattern[data-theme="green"],
.album-tile[data-theme="green"]::before,
.colour-choice[data-theme="green"] .colour-swatch { background: #DCE8D6; }

.album-pattern[data-theme="sand"],
.album-tile[data-theme="sand"]::before,
.colour-choice[data-theme="sand"] .colour-swatch { background: #DDD0C3; }

.album-pattern {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 63 / 88;
  overflow: hidden;
  border-radius: var(--radius-control);
  background: var(--binder);
  box-shadow: inset 0 0 0 1px #C6A15A;
}

/* Okładka segregatora: tkanina, złota ramka i nazwa. Bez kieszeni i dziurek. */
.binder-page.is-cover .binder-sheet {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 18px;
  background: var(--binder);
  border-radius: 7px;
  box-shadow:
    0 0 0 1px rgba(42, 36, 34, 0.08),
    0 6px 14px rgba(42, 36, 34, 0.14);
}

.binder-page.is-cover .binder-sheet::before {
  top: 12px;
  right: 12px;
  bottom: 12px;
  left: 12px;
  width: auto;
  border: 1px solid #C6A15A;
  border-radius: 4px;
  background: transparent;
  box-shadow: 0 0 0 4px rgba(198, 161, 90, 0.28);
}

.binder-page.is-cover .binder-sheet::after,
.binder-page.is-cover .binder-holes { content: none; display: none; }

.cover-name {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 88%;
  margin: 0;
  text-align: center;
}

.cover-name::before,
.cover-name::after {
  content: "";
  display: block;
  width: min(168px, 72%);
  height: 1px;
  background: #C6A15A;
  box-shadow: 0 1px 0 #FFF1C2;
}

.cover-name .album-name {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}

/* Okładka albumu w widoku Covers: grzbiet segregatora po lewej. */
.album-tile {
  position: relative;
  padding-left: 18px;
}

.album-tile::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 10px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--binder);
  box-shadow: inset -1px 0 0 rgba(42, 36, 34, 0.1), inset 1px 0 0 rgba(255, 255, 255, 0.5);
}

/* Przejścia */

main > section:not([hidden]) { animation: view-in var(--dur) var(--ease); }

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

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

/* Desktop */

@media (min-width: 800px) {
  /* Main przewija się na całą szerokość (pasek przewijania przy krawędzi okna),
     a kolumna treści ma te same 760px co wcześniej (728 + 2 x 16 paddingu). */
  .top-row {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
  }

  main > section {
    max-width: 728px;
    margin-left: auto;
    margin-right: auto;
  }

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

  .card-view {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    column-gap: 32px;
    align-items: start;
  }

  .card-media {
    position: sticky;
    top: 15px; /* od krawędzi treści main (8px paddingu), razem 23px pod nagłówkiem jak wcześniej */
    width: 100%;
    margin: 8px 0 0;
  }

  .dock { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }

  .tabbar button { flex: 0 1 180px; }
}

/* Premiery i ceny zakupu. Data międzynarodowa (Szwecja) dostaje tło sakura. */

.segmented.compact button {
  padding: 0 4px;
  font-size: 14px;
  line-height: 1.15;
}

.place-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--sakura);
}

.place-banner strong {
  display: block;
  font-size: 15px;
}

.place-banner p {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.35;
}

.release {
  padding: 14px 16px;
}

.release + .release { border-top: 1px solid var(--line); }

.release-name {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.release-sub,
.release-scope {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.region-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.region-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.region-chip.here { background: var(--sakura); }

.release-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.offer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 16px;
}

.offer + .offer { border-top: 1px solid var(--line); }

.offer-shop {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.offer-title,
.offer-meta {
  margin: 2px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.offer-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.offer-price {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

a.ghost { text-decoration: none; }

#offers-links { margin-top: 16px; }

/* Rozłożony segregator: lewa i prawa strona, grzbiet z ringami pośrodku.
   Wychodzi poza kolumnę 728px, ale zostaje w main (overflow-x: hidden). */
@media (min-width: 900px) {
  /* Szerokość z wysokości okna, żeby cała rozkładówka i licznik mieściły się na ekranie.
     Na desktopie 100vh = 100dvh, a var() z nieznaną jednostką nie ma fallbacku. */
  .binder {
    --binder-fit: 1.55;
    --binder-w: clamp(640px, calc((100vh - 400px) * var(--binder-fit)), min(1000px, calc(100vw - 64px)));
    width: var(--binder-w);
    margin-left: calc((100% - var(--binder-w)) / 2);
  }

  .binder[data-pockets="12"] { --binder-fit: 1.2; }

  .binder-body { padding: 10px; }

  .binder-page { flex-basis: 50%; }
  .binder-page.is-filler { display: block; }

  /* Lewa strona (nieparzysta) ma dziurki po prawej, prawa po lewej. Snap tylko na rozkładówkę. */
  .binder-page:nth-child(odd) { padding: 4px 26px 12px 8px; }
  .binder-page:nth-child(even) { padding: 4px 8px 12px 26px; scroll-snap-align: none; }

  .binder-page:nth-child(odd) .binder-sheet {
    padding: 9px 30px 10px 9px;
    border-radius: 7px 3px 3px 7px;
    box-shadow:
      0 0 0 1px rgba(42, 36, 34, 0.08),
      -1px 2px 0 0 var(--sheet),
      -1px 2px 0 1px rgba(42, 36, 34, 0.08),
      -2px 4px 0 0 var(--sheet),
      -2px 4px 0 1px rgba(42, 36, 34, 0.1),
      0 6px 14px rgba(42, 36, 34, 0.14);
  }

  .binder-page:nth-child(odd) .binder-sheet::before {
    left: auto;
    right: 0;
    border-right: 0;
    border-left: 1px solid rgba(42, 36, 34, 0.08);
  }

  .binder-page:nth-child(odd) .binder-holes { left: auto; right: 6px; }

  .binder-page.is-cover { padding: 4px 26px 12px 8px; }

  .binder-page.is-cover .binder-sheet {
    padding: 28px 22px;
    border-radius: 7px;
    box-shadow:
      0 0 0 1px rgba(42, 36, 34, 0.08),
      0 6px 14px rgba(42, 36, 34, 0.14);
  }

  .binder-page.is-cover .binder-sheet::before {
    top: 14px;
    right: 14px;
    bottom: 14px;
    left: 14px;
    width: auto;
    border: 1px solid #C6A15A;
    border-right: 1px solid #C6A15A;
    border-left: 1px solid #C6A15A;
    background: transparent;
  }

  .cover-name .album-name { font-size: 32px; }

  .binder-spine {
    top: 14px;
    bottom: 22px;
    left: 50%;
    width: 90px;
    margin-left: -45px;
  }

  /* Metalowa listwa mechanizmu w zagięciu grzbietu. */
  .binder-spine::before {
    top: -4px;
    bottom: -4px;
    left: 50%;
    width: 16px;
    margin-left: -8px;
    border-radius: 5px;
    background: var(--ring);
    box-shadow:
      inset 0 0 0 1px rgba(42, 36, 34, 0.1),
      inset 2px 0 0 rgba(255, 255, 255, 0.6),
      0 1px 3px rgba(42, 36, 34, 0.25);
  }

  .ring { left: 0; width: 100%; height: 9px; margin-top: -4.5px; }
}
