/* ================================================================
   FzTransfer — Album Creator Styles
   ================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Globalne wyłączenie double-tap zoom na iOS Safari.
   touch-action: manipulation = tap + pan, bez double-tap zoom i pinch-zoom.
   Elementy które potrzebują pinch/pan (ramki zdjęć, canvas) nadpisują
   własnym touch-action: none lub touch-action: pan-y. */
html {
    touch-action: manipulation;
}
body {
    touch-action: manipulation;
}

:root {
    --album-primary: #000000;
    --album-primary-light: #222222;
    --album-accent: #09CF91;
    --album-accent-hover: #A4F6D1;
    --album-accent-light: #A4F6D1;
    --album-bg: #f0f0f0;
    --album-surface: #ffffff;
    --album-text: #212121;
    --album-text-secondary: #757575;
    --album-success: #09CF91;
    --album-error: #e53935;
    --album-border: #e0e0e0;
    --album-shadow: rgba(0,0,0,0.12);
    --album-spiral: #1a1a1a;
    --album-page-shadow: rgba(0,0,0,0.08);

    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--album-bg);
    color: var(--album-text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Gdy edytor aktywny — cały kreator mieści się w viewport, bez scrolla pionowego */
body.album-mode-editor {
    height: 100vh;
    overflow: hidden;
}

/* ================================================================
   HEADER
   ================================================================ */
.album-header {
    background: #000;
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    min-height: 48px;
}

.album-header-title {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.album-header-info {
    font-size: 0.8rem;
    opacity: 0.85;
}

.album-header-price {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 2px 8px;
    background: rgba(255,255,255,0.18);
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    vertical-align: middle;
    letter-spacing: 0.01em;
}

.album-header-actions {
    display: flex;
    gap: 8px;
}

.album-header-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.album-header-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* "Od nowa" — subtelny przycisk, mniej prominentny od Save */
.album-header-btn--ghost {
    background: transparent;
    color: rgba(255,255,255,0.55);
    border-color: rgba(255,255,255,0.18);
    font-size: 0.75rem;
    padding: 4px 9px;
}
.album-header-btn--ghost:hover {
    background: rgba(255, 80, 80, 0.18);
    color: #ffcdd2;
    border-color: rgba(255, 100, 100, 0.4);
}

/* "Wyślij album" — zielony akcent marki */
.album-header-btn--submit {
    background: var(--album-accent);
    border-color: var(--album-accent);
    color: #000;
    font-weight: 700;
}
.album-header-btn--submit:hover {
    background: var(--album-accent-hover);
    border-color: var(--album-accent-hover);
}

/* ================================================================
   SETUP SCREEN (Krok 1: wybór formatu + upload zdjęć)
   ================================================================ */
.album-setup {
    max-width: 520px;
    margin: 40px auto;
    padding: 0 16px;
}

.album-setup-card {
    background: var(--album-surface);
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 4px 20px var(--album-shadow);
}

.album-setup-icon {
    text-align: center;
    font-size: 3rem;
    margin-bottom: 12px;
}

.album-setup-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--album-primary);
    margin-bottom: 24px;
}

.album-field {
    margin-bottom: 20px;
}

.album-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--album-text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Format toggle buttons */
.album-format-group {
    display: flex;
    gap: 8px;
}

.album-format-btn {
    flex: 1;
    padding: 14px 8px;
    border: 2px solid var(--album-border);
    border-radius: 10px;
    background: var(--album-surface);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
}

.album-format-btn.active {
    border-color: var(--album-primary);
    background: rgba(26, 35, 126, 0.06);
    color: var(--album-primary);
    font-weight: 700;
}

.album-format-btn:hover:not(.active) {
    border-color: var(--album-primary-light);
}

.album-format-btn .format-size {
    font-size: 1.2rem;
    font-weight: 700;
    display: block;
}

.album-format-btn .format-label {
    font-size: 0.75rem;
    color: var(--album-text-secondary);
    margin-top: 2px;
}

/* Pages count */
.album-pages-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.album-pages-input {
    width: 70px;
    padding: 10px;
    border: 2px solid var(--album-border);
    border-radius: 8px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
}

.album-pages-input:focus {
    outline: none;
    border-color: var(--album-primary);
}

.album-pages-hint {
    font-size: 0.8rem;
    color: var(--album-text-secondary);
}

/* Layout mode buttons */
.album-mode-group {
    display: flex;
    gap: 8px;
}

.album-mode-btn {
    flex: 1;
    padding: 10px 6px;
    border: 2px solid var(--album-border);
    border-radius: 10px;
    background: var(--album-surface);
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: border-color 0.2s, background 0.2s;
}

.album-mode-btn.active {
    border-color: var(--album-primary);
    background: rgba(26, 35, 126, 0.06);
}

.album-mode-btn:hover:not(.active) {
    border-color: var(--album-primary-light);
}

.album-mode-btn .mode-icon {
    font-size: 1.4rem;
}

.album-mode-btn .mode-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--album-text);
}

.album-mode-btn.active .mode-label {
    color: var(--album-primary);
}

.album-mode-btn .mode-desc {
    font-size: 0.65rem;
    color: var(--album-text-secondary);
}

.album-mode-btn .mode-pages {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--album-primary);
    margin-top: 2px;
}

.album-mode-btn:not(.active) .mode-pages {
    color: var(--album-text-secondary);
}

.album-mode-btn .mode-surfaces {
    font-size: 0.65rem;
    color: var(--album-text-secondary);
}

@media (max-width: 340px) {
    .album-mode-group { flex-direction: column; }
}

/* Pool mode select and primary layout button */
.album-pool-select {
    padding: 3px 6px;
    border: 1px solid var(--album-border);
    border-radius: 6px;
    background: var(--album-surface);
    font-size: 0.75rem;
    max-width: 110px;
    color: var(--album-text);
}

/* Sort mode radio */
.album-sort-group {
    display: flex;
    gap: 16px;
}

.album-sort-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
}

.album-sort-option input[type="radio"] {
    accent-color: var(--album-primary);
    width: 18px;
    height: 18px;
}

/* Upload area */
.album-upload-area {
    border: 2px dashed var(--album-primary-light);
    border-radius: 12px;
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(26, 35, 126, 0.02);
    margin-top: 8px;
}

.album-upload-area:hover,
.album-upload-area.dragover {
    border-color: var(--album-primary);
    background: rgba(26, 35, 126, 0.06);
}

.album-upload-area.dragover {
    transform: scale(1.01);
}

.album-upload-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.album-upload-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--album-primary);
    margin-bottom: 4px;
}

.album-upload-hint {
    font-size: 0.8rem;
    color: var(--album-text-secondary);
}

/* Podpowiedź dla użytkowników iOS — widoczna tylko na urządzeniach dotykowych */
.album-upload-ios-hint {
    display: none;
    font-size: 0.72rem;
    color: var(--album-text-secondary);
    margin-top: 6px;
    line-height: 1.4;
    max-width: 280px;
}
@media (hover: none) and (pointer: coarse) {
    .album-upload-ios-hint { display: block; }
}

.album-upload-count {
    margin-top: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--album-success);
    display: none;
}

.album-upload-count.visible {
    display: block;
}

#albumFileInput {
    display: none;
}

/* Create button */
.album-create-btn {
    width: 100%;
    padding: 16px;
    margin-top: 24px;
    border: none;
    border-radius: 12px;
    background: var(--album-accent);
    color: #000;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 12px rgba(9, 207, 145, 0.3);
}

.album-create-btn:hover {
    transform: translateY(-1px);
    background: var(--album-accent-hover);
    box-shadow: 0 6px 16px rgba(9, 207, 145, 0.4);
}

.album-create-btn:active {
    transform: translateY(0);
}

.album-create-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ================================================================
   EDITOR LAYOUT (Krok 3: główny edytor albumu)
   ================================================================ */
.album-editor {
    display: none;
    flex-direction: column;
    height: calc(100vh - 48px); /* minus header */
    overflow: hidden;
    box-sizing: border-box; /* padding-bottom zmniejsza flex-content, nie dodaje wysokosci */
    padding-bottom: 56px; /* rezerwuje miejsce dla fixed .album-action-bar */
}

.album-editor.active {
    display: flex;
}

/* Panel stylu tekstu otwarty → push spread w górę żeby był nad panelem.
   --fz-panel-h ustawiany przez fz-text-overlay.js po zmierzeniu offsetHeight.
   Dotyczy OBU platform — na desktopie panel ma ograniczoną wysokość (patrz niżej). */
body.fz-panel-style .album-editor {
    padding-bottom: var(--fz-panel-h, 56px);
}

/* Desktop: ogranicz wysokość inner panelu (55vh na laptopie = ~500px → za dużo).
   Na desktopie panel wyjeżdża z dołu tak samo jak na mobile, ale jest niższy. */
@media (min-width: 601px) {
    .fz-to-panel .fz-to-panel-inner {
        max-height: 40vh;
    }
}

/* Transition padding-bottom (obie platformy) */
.album-editor {
    transition: padding-bottom 0.25s ease;
}

/* Spread area (main content) */
.album-spread-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 44px 12px 12px;  /* top: 44px = miejsce na frame toolbar; bottom: 12px przerwa */
    overflow: hidden;
    position: relative;
    background: var(--album-bg);
    min-height: 0;
    /* Prevent browser from intercepting pan/pinch as page scroll.
       Without this iOS scrolls the page instead of panning photo in frame. */
    touch-action: none;
}

/* ================================================================
   SPREAD VIEW (open album: left page + spiral + right page)
   ================================================================ */
.album-spread {
    display: flex;
    align-items: stretch;
    max-width: 95%;
    max-height: 100%;
    user-select: none;
    -webkit-user-select: none;
}

.album-page {
    position: relative;
    background: white;
    overflow: visible;  /* toolbar w .album-frame musi wychodzić poza granicę strony */
    flex-shrink: 0;
}

.album-page-left {
    border-radius: 4px 0 0 4px;
    box-shadow:
        -3px 4px 12px rgba(0,0,0,0.12),
        inset -8px 0 12px -4px var(--album-page-shadow);
}

.album-page-right {
    border-radius: 0 4px 4px 0;
    box-shadow:
        3px 4px 12px rgba(0,0,0,0.12),
        inset 8px 0 12px -4px var(--album-page-shadow);
}

/* Page number overlay */
.album-page-number {
    position: absolute;
    bottom: 4px;
    font-size: 0.65rem;
    color: rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 5;
}

.album-page-left .album-page-number {
    left: 8px;
}

.album-page-right .album-page-number {
    right: 8px;
}

/* Spiral binding — SVG wire-o rendered by JS in fz-album-spread.js.
   8px ≈ 2mm przy 96dpi; SVG jest szerszy i wychodzi na strony (overflow:visible). */
.album-spiral {
    width: 8px;
    flex-shrink: 0;
    position: relative;
    overflow: visible;
    z-index: 10;
    background: linear-gradient(to right, #666, #bbb 50%, #666);
}

/* Canvas is positioned absolute, wider than the div to overlap page edges */
#albumSpiralCanvas {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    display: block;
}

/* ================================================================
   FRAMES (photo slots within a page)
   ================================================================ */
.album-frame {
    position: absolute;
    overflow: hidden;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.album-frame:hover {
    box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.3);
}

.album-frame.active {
    box-shadow: 0 0 0 3px var(--album-primary);
    z-index: 20;
    overflow: visible;  /* allow toolbar to float above frame */
}

.album-frame.swap-source {
    box-shadow: 0 0 0 3px var(--album-accent);
    animation: album-pulse 1.5s infinite;
}

.album-frame.swap-target {
    box-shadow: 0 0 0 3px var(--album-primary-light);
    background: rgba(57, 73, 171, 0.08);
}

.album-frame.drag-over {
    box-shadow: 0 0 0 3px var(--album-success);
    background: rgba(76, 175, 80, 0.08);
}

@keyframes album-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--album-accent); }
    50% { box-shadow: 0 0 0 5px var(--album-accent-light); }
}

/* Clip container — child of .album-frame, clips photo to frame bounds.
   Needed because .album-frame.active { overflow:visible } to show toolbar above,
   but we still want the photo itself clipped to the frame rectangle. */
.album-frame-clip {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 1;
}

/* Photo inside frame — JS sets explicit px cover dimensions after DOM insertion
   (_applyCoverSizing). CSS object-fit:cover is visual fallback before JS runs. */
.album-frame-photo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    pointer-events: none;
    will-change: transform;
}

/* Empty frame placeholder */
.album-frame-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #bbb;
    font-size: 0.7rem;
    pointer-events: none;
}

.album-frame-empty-icon {
    font-size: 1.5rem;
    margin-bottom: 2px;
}

/* Mini toolbar (appears on active frame — floats above it) */
.album-frame-toolbar {
    position: absolute;
    top: -38px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 2px;
    background: rgba(0,0,0,0.82);
    border-radius: 8px;
    padding: 4px 6px;
    z-index: 30;
    white-space: nowrap;
}

.album-frame.active .album-frame-toolbar {
    display: flex;
}

.album-frame-toolbar-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.album-frame-toolbar-btn:hover {
    background: rgba(255,255,255,0.15);
}

/* ================================================================
   NAVIGATION: spread arrows
   ================================================================ */
.album-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.4);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    touch-action: manipulation; /* zapobiega zoom na double-tap iOS */
}

.album-nav-arrow:hover {
    background: rgba(0,0,0,0.6);
}

.album-nav-arrow.prev { left: 8px; }
.album-nav-arrow.next { right: 8px; }

.album-nav-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ================================================================
   BOTTOM PANEL: page thumbnails + photo pool
   ================================================================ */
.album-bottom-panel {
    flex-shrink: 0;
    background: var(--album-surface);
    border-top: 2px solid var(--album-border);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08); /* delikatny cień oddziela panel od spreadu */
    display: flex;
    flex-direction: column;
    max-height: 40vh;  /* JS overrides with explicit height + max-height:none */
    overflow: hidden;
}

/* Drag handle — pozioma kreska pozwalająca zmienić rozmiar sekcji */
.album-resize-handle {
    height: 8px;
    flex-shrink: 0;
    cursor: ns-resize;
    background: transparent;
    position: relative;
    z-index: 5;
    touch-action: none;
}
.album-resize-handle::after {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 36px; height: 3px;
    background: rgba(0,0,0,0.12);
    border-radius: 2px;
    transition: background 0.2s;
}
.album-resize-handle:hover::after {
    background: var(--album-primary, #3949ab);
}

/* Page thumbnails strip — flex:1 fills space above pool; height set by JS when resize panel grows */
.album-pages-strip {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    border-bottom: 1px solid var(--album-border);
    min-height: 64px;
    flex: 1;
    align-items: center;
}

.album-pages-strip::-webkit-scrollbar {
    height: 4px;
}

.album-pages-strip::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.album-thumb {
    flex-shrink: 0;
    width: 62px;
    height: 44px; /* landscape ~21/15 ratio */
    border: 2px solid var(--album-border);
    /* Mobile: touch-action:none blocks browser gestures so pointer events
       (tap, long-press drag) work reliably. Strip scroll handled by JS. */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    overflow: hidden;
}

.album-thumb.active {
    border-color: var(--album-primary);
    box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.3);
}

.album-thumb.swap-highlight {
    border-color: var(--album-accent);
    animation: album-pulse 1.5s infinite;
}

.album-thumb-label {
    position: absolute;
    bottom: 1px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.55rem;
    color: var(--album-text-secondary);
    background: rgba(255,255,255,0.8);
}

.album-thumb canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.album-thumb.dragging {
    opacity: 0.5;
    transform: scale(0.9);
}

/* ── Przycisk "×" usuwania rozkładówki ──────────────────────────────── */
.album-thumb-del {
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 0 3px 0 4px;  /* zaokrąglony wewnętrzny róg + thumb border-radius */
    background: rgba(211, 47, 47, 0.85);
    color: #fff;
    font-size: 0.65rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;                  /* ukryty, widoczny na hover thumba */
    transition: opacity 0.15s, background 0.15s;
    z-index: 4;
    -webkit-tap-highlight-color: transparent;
}

.album-thumb:hover .album-thumb-del,
.album-thumb:focus-within .album-thumb-del {
    opacity: 1;
}

.album-thumb-del:hover {
    background: rgba(198, 40, 40, 1);
}

/* Na dotyku: zawsze widoczny (hover nie istnieje) */
@media (hover: none) {
    .album-thumb-del { opacity: 0.8; }
}

/* ── Przycisk "+" wstawiania rozkładówki ────────────────────────────── */
.album-thumb-add-spread {
    flex-shrink: 0;
    align-self: center;
    width: 22px;
    height: 28px;
    border: 1.5px dashed var(--album-border);
    border-radius: 5px;
    background: transparent;
    color: var(--album-text-secondary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0 6px;
    opacity: 0.45;
    transition: opacity 0.15s, border-color 0.15s, color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.album-thumb-add-spread:hover {
    opacity: 1;
    border-color: var(--album-primary);
    color: var(--album-primary);
    background: rgba(26, 35, 126, 0.07);
}

/* Wersja "na końcu" — nieco szersza żeby +  był wyraźny */
.album-thumb-add-spread--end {
    width: 28px;
    margin-left: 8px;
    margin-right: 4px;
}

/* Photo pool — flex-row: strip on left (flex:1), add button on right */
.album-pool {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-shrink: 0;
    overflow: hidden;
    min-height: 40px;  /* pozwala puli się zwężać pod haką — miniatury rosną w to miejsce */
    border-top: 1px solid var(--album-border);
}

.album-pool.collapsed {
    max-height: 36px;
    overflow: hidden;
}

.album-pool-strip {
    display: flex;
    flex: 1;
    gap: 4px;
    padding: 4px 8px 4px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 40px;  /* spójne z .album-pool — pula może się zwężać */
    align-items: center;
}

.album-pool-photo {
    flex-shrink: 0;
    height: var(--pool-photo-h, 52px);
    width: auto;
    border-radius: 4px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.album-pool-photo:hover {
    border-color: var(--album-primary-light);
    transform: scale(1.05);
}

.album-pool-photo.selected {
    border-color: var(--album-accent);
    box-shadow: 0 0 0 2px var(--album-accent-light);
}

.album-pool-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    font-size: 0.8rem;
    color: #bbb;
    font-style: italic;
}

/* ================================================================
   BOTTOM ACTION BAR
   ================================================================ */
.album-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 340;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--album-surface);
    border-top: 1px solid var(--album-border);
    gap: 8px;
}

.album-action-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    touch-action: manipulation; /* zapobiega zoom na double-tap iOS */
}

.album-action-btn.primary {
    background: var(--album-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(26, 35, 126, 0.3);
}

.album-action-btn.primary:hover {
    background: var(--album-primary-light);
}

.album-action-btn.secondary {
    background: var(--album-bg);
    color: var(--album-text);
    border: 1px solid var(--album-border);
}

.album-action-btn.secondary:hover {
    background: var(--album-border);
}

.album-action-btn.submit {
    background: var(--album-accent);
    color: #000;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(9, 207, 145, 0.3);
}

.album-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ================================================================
   SWAP HINT (floating banner during swap mode)
   ================================================================ */
.album-swap-hint {
    position: fixed;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--album-accent);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 300;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: none;
    white-space: nowrap;
    animation: album-slideDown 0.3s ease;
}

.album-swap-hint.visible {
    display: flex;
    align-items: center;
    gap: 8px;
}

.album-swap-hint-close {
    background: rgba(255,255,255,0.3);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes album-slideDown {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ================================================================
   LOADING OVERLAY
   ================================================================ */
.album-loading {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.9);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.album-loading.visible {
    display: flex;
}

.album-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--album-border);
    border-top-color: var(--album-primary);
    border-radius: 50%;
    animation: album-spin 0.8s linear infinite;
}

@keyframes album-spin {
    to { transform: rotate(360deg); }
}

.album-loading-text {
    margin-top: 16px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--album-text-secondary);
}

.album-loading-progress {
    margin-top: 12px;
    width: 200px;
    height: 4px;
    background: var(--album-border);
    border-radius: 2px;
    overflow: hidden;
}

.album-loading-progress-bar {
    height: 100%;
    background: var(--album-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ================================================================
   LAYOUT CHANGE BUTTON (per page)
   ================================================================ */
.album-layout-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: none;
    border-radius: 0 0 0 36px; /* quarter-circle bottom-left */
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    cursor: pointer;
    z-index: 25;
    padding: 5px 5px 0 0;
    opacity: 1;              /* zawsze widoczny — mobile i desktop */
    transition: opacity 0.2s, background 0.2s;
    touch-action: none;
}
.album-layout-btn:active {
    background: rgba(0, 0, 0, 0.7);
}
.album-page-left .album-layout-btn {
    right: auto;
    left: 0;
    border-radius: 0 0 36px 0; /* quarter-circle bottom-right */
    padding: 5px 0 0 5px;
    justify-content: flex-start;
}
.album-page-left:hover .album-layout-btn,
.album-page-right:hover .album-layout-btn {
    opacity: 1;
}

/* ================================================================
   TEMPLATE PICKER MODAL
   ================================================================ */
.album-template-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 400;
}

.album-template-modal.visible {
    display: flex;
}

.album-template-modal-content {
    background: var(--album-surface);
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
    animation: album-slideUp 0.3s ease;
}

@keyframes album-slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.album-template-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.album-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.album-template-card {
    border: 2px solid var(--album-border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.album-template-card:hover {
    border-color: var(--album-primary-light);
}

.album-template-card.active {
    border-color: var(--album-primary);
    background: rgba(26, 35, 126, 0.06);
}

.album-template-card img {
    width: 100%;
    aspect-ratio: 15 / 21;
    object-fit: contain;
    border-radius: 4px;
    background: #f5f5f5;
}

.album-template-card-label {
    font-size: 0.7rem;
    color: var(--album-text-secondary);
    margin-top: 4px;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 600px) {
    .album-spread-area {
        padding: 8px 4px;
    }
    .album-spiral {
        width: 6px;  /* 6px na wąskich ekranach */
    }
    .album-thumb {
        width: 50px;
        height: 36px; /* landscape */
    }
    .album-frame-toolbar {
        top: -32px;
    }
    .album-frame-toolbar-btn {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .album-nav-arrow {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

@media (min-width: 601px) and (max-width: 1024px) {
    .album-spread-area {
        padding: 12px 8px;
    }
}

@media (min-width: 1025px) {
    .album-bottom-panel {
        max-height: 30vh;  /* JS overrides with explicit height for resize functionality */
    }
}

/* ================================================================
   MARKETPLACE DASHBOARD (Scenario 2)
   ================================================================ */
.album-marketplace-dashboard {
    padding: 24px 16px;
    max-width: 600px;
    margin: 0 auto;
}

.dash-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--album-text);
    margin: 0 0 4px 0;
}

.dash-customer {
    font-size: 0.9rem;
    color: var(--album-text-secondary);
    margin: 0 0 20px 0;
}

.dash-album-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dash-album-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--album-surface);
    border: 1px solid var(--album-border);
    border-radius: 12px;
    padding: 16px;
    gap: 12px;
}

.dash-album-card.done {
    opacity: 0.6;
}

.dash-album-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: var(--album-text);
}

.dash-album-info p {
    font-size: 0.85rem;
    color: var(--album-text-secondary);
    margin: 0;
}

.dash-album-status {
    margin-top: 4px !important;
}

.dash-done {
    color: var(--album-success);
    font-weight: 600;
}

.dash-pending {
    color: var(--album-accent);
}

.dash-album-action {
    flex-shrink: 0;
}

.dash-btn-design {
    background: var(--album-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

.dash-btn-design:active {
    transform: scale(0.96);
}

.dash-btn-done {
    background: var(--album-border);
    color: var(--album-text-secondary);
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.95rem;
    cursor: default;
    min-height: 44px;
}

.dash-all-done {
    text-align: center;
    font-size: 1.1rem;
    color: var(--album-success);
    font-weight: 600;
    margin-top: 20px;
}

/* ================================================================
   SUCCESS SCREEN
   ================================================================ */
.album-success {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 24px;
    text-align: center;
}

.album-success.active {
    display: flex;
}

.album-success-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.album-success-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--album-success);
    margin-bottom: 8px;
}

.album-success-text {
    font-size: 1rem;
    color: var(--album-text-secondary);
    max-width: 400px;
    line-height: 1.5;
}

/* ================================================================
   COVER PAGES — okładki albumu (pierwsza i ostatnia strona)
   ================================================================ */

/* ── Linen canvas cover — slate blue-gray fabric texture ──────────── */
/*    Aby użyć prawdziwego zdjęcia tkaniny:
 *    1. Zapisz obraz jako img/cover-linen.jpg w katalogu projektu
 *    2. Zastąp całą sekcję background: niżej na:
 *       background: #5c7480 url('../img/cover-linen.jpg') repeat;
 *       background-size: 300px 300px;
 *    ─────────────────────────────────────────────────────────────── */
.album-cover-page {
    /* Kolor bazowy tkaniny slate-blue #5c7480 */
    background-color: #5c7480;
    /* Splot płócienny — poziome i pionowe nitki */
    background-image:
        /* Pionowe nitki — jasne */
        repeating-linear-gradient(
            90deg,
            transparent                  0px,
            transparent                  2.5px,
            rgba(255,255,255,0.055)      2.5px,
            rgba(255,255,255,0.055)      3px,
            transparent                  3px,
            transparent                  6px
        ),
        /* Poziome nitki — jasne */
        repeating-linear-gradient(
            0deg,
            transparent                  0px,
            transparent                  2.5px,
            rgba(255,255,255,0.055)      2.5px,
            rgba(255,255,255,0.055)      3px,
            transparent                  3px,
            transparent                  6px
        ),
        /* Pionowe nitki — ciemne (cień pod nicią) */
        repeating-linear-gradient(
            90deg,
            transparent                  0px,
            transparent                  3px,
            rgba(0,0,0,0.08)             3px,
            rgba(0,0,0,0.08)             3.5px,
            transparent                  3.5px,
            transparent                  6px
        ),
        /* Poziome nitki — ciemne */
        repeating-linear-gradient(
            0deg,
            transparent                  0px,
            transparent                  3px,
            rgba(0,0,0,0.08)             3px,
            rgba(0,0,0,0.08)             3.5px,
            transparent                  3.5px,
            transparent                  6px
        );
    cursor: default;
    overflow: visible;
    position: relative;
}

/* Warstwa szumu — naturalna niejednorodność włókien */
.album-cover-page::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72 0.68' numOctaves='3' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0.4'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.13'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

/* Gruba krawędź zewnętrzna (~3mm) — dopasowana do koloru tkaniny */
.album-page-left.album-cover-page::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 3px;
    bottom: 3px;
    width: 6px;
    background: linear-gradient(to right, #3a4f58, #4e6870);
    border-radius: 2px 0 0 2px;
    z-index: 5;
}

/* Prawy cover: krawędź po prawej */
.album-page-right.album-cover-page::before {
    content: '';
    position: absolute;
    right: -6px;
    top: 3px;
    bottom: 3px;
    width: 6px;
    background: linear-gradient(to left, #3a4f58, #4e6870);
    border-radius: 0 2px 2px 0;
    z-index: 5;
}

/* Background image layer for cover pages — stretches to fill entire area */
.album-cover-bg {
    position: absolute;
    inset: 0;
    background-size: 100% 100%;   /* stretch to fill — no cropping, no letterbox */
    background-repeat: no-repeat;
    z-index: 2;                    /* above ::after noise overlay (z-index:1) */
}

/* When a cover image is present — hide the fabric-edge strips (::before)
   and noise overlay (::after) so only the photo is visible */
.album-cover-page:has(.album-cover-bg)::before,
.album-cover-page:has(.album-cover-bg)::after {
    display: none;
}

.album-cover-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 3;  /* above .album-cover-bg (z-index:2) */
}

.album-cover-label {
    color: rgba(255, 255, 255, 0.65);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    user-select: none;
}

/* "Zmień okładkę" button on cover pages */
.album-change-cover-btn {
    opacity: 0;
    transition: opacity 0.2s;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}
.album-cover-page:hover .album-change-cover-btn {
    opacity: 1;
}
@media (hover: none) {
    .album-change-cover-btn { opacity: 0.7; }
}

/* ================================================================
   FZ.TextOverlay — style blokow tekstu, resize handles, bottom sheet
   ================================================================ */

/* ── Blok tekstu na stronie ────────────────────────────────────── */
.fz-to-block {
    border: 2px solid transparent;
    border-radius: 3px;
    transition: border-color 0.15s;
    padding: 0 2px; /* 0px góra/dół — ramka trzyma się tekstu; 2px po bokach */
    /* Wysokosc auto — blok rozciaga sie z trescia */
    /* overflow: visible — uchwyt resize/rotate wychodza poza blok */
    transform-origin: center center;
}
/* Kursor tekstowy podczas edycji */
.fz-to-block[data-editing="1"] { cursor: text !important; }
.fz-to-text[contenteditable="true"] { caret-color: #fff; cursor: text; }
.fz-to-block:active {
    border-color: rgba(0, 102, 255, 0.3);
}
.fz-to-selected {
    border-color: #0066ff !important;
    box-shadow: 0 0 0 1px rgba(0, 102, 255, 0.2);
}

/* ── Resize handles (4 narozniki) ────────────────────────────── */
.fz-to-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    background: #0066ff;
    border: 2px solid #fff;
    border-radius: 50%;
    z-index: 30;
    touch-action: none;
    pointer-events: auto;
    cursor: nwse-resize;
}
.fz-to-handle-nw { top: -9px; left: -9px; cursor: nwse-resize; }
.fz-to-handle-ne { top: -9px; right: -9px; cursor: nesw-resize; }
.fz-to-handle-sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.fz-to-handle-se { bottom: -9px; right: -9px; cursor: nwse-resize; }

/* ── Uchwyt obrotu (pod blokiem, srodek) ─────────────────────── */
.fz-to-rotate-line {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: #0066ff;
    pointer-events: none;
    z-index: 29;
}
.fz-to-rotate-handle {
    position: absolute;
    bottom: -42px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    background: #0066ff;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: grab;
    touch-action: none;
    pointer-events: auto;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.fz-to-rotate-handle::before {
    content: '↻';
    font-size: 13px;
    color: #fff;
    line-height: 1;
}
.fz-to-rotate-handle:active { cursor: grabbing; }

/* ── Mini toolbar nad blokiem ────────────────────────────────── */
.fz-to-mini-toolbar {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    background: #222;
    border-radius: 6px;
    padding: 3px 6px;
    white-space: nowrap;
    z-index: 35;
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.fz-to-tbtn {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 12px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    /* System font — nie dziedziczy kroju wybranego przez użytkownika */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    touch-action: manipulation;
    line-height: 1;
}
.fz-to-tbtn:active { background: rgba(255,255,255,0.15); }
.fz-to-tbtn-danger { color: #ff5252; }
/* Ikona-only: kwadratowy przycisk z SVG */
.fz-to-tbtn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.fz-to-tbtn-confirm {
    background: #09CF91;
    border-radius: 4px;
}
.fz-to-tbtn-confirm:active { background: #07b07c; }

/* Fixed toolbar — na mobile przyklejony do dołu ekranu (poza kontekstem zoom) */
.fz-to-fixed-toolbar {
    position: fixed !important;
    bottom: 12px !important;
    top: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 10000 !important;
    /* Większe przyciski dla kciuka */
    padding: 4px 8px;
    gap: 6px;
}
.fz-to-fixed-toolbar .fz-to-tbtn-icon {
    width: 36px;
    height: 36px;
}

/* ── Przycisk T (dodaj tekst) — D-ksztalt (polkole) pod layout-btn ── */
/* Prawa strona: plaska krawedz przy prawej krawedzi strony, polkole w lewo */
/* Lewa  strona: plaska krawedz przy lewej  krawedzi strony, polkole w prawo */
.album-text-btn {
    position: absolute;
    top: 36px;               /* zaraz pod layout-btn */
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 18px 0 0 18px;  /* D-ksztalt: lewa polowa zaokraglona, prawa plaska */
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 17px;
    font-weight: 900;
    font-family: Arial, Helvetica, sans-serif;
    cursor: pointer;
    z-index: 25;             /* powyzej overlay (z-index: 20) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    touch-action: none;
    transition: opacity 0.2s, background 0.2s;
    opacity: 1;              /* zawsze w pelni widoczny — mobile i desktop */
}
/* Lewa strona spreadu: D-ksztalt lustrzany */
.album-page-left .album-text-btn {
    right: auto;
    left: 0;
    border-radius: 0 18px 18px 0;  /* D-ksztalt: prawa polowa zaokraglona, lewa plaska */
}
/* Na desktopie: pelna widocznosc przy hover */
.album-page-left:hover .album-text-btn,
.album-page-right:hover .album-text-btn { opacity: 1; }
.album-text-btn:active { background: rgba(0, 0, 0, 0.7); }

/* ── Text Panel (position:fixed — nie rusza layoutu albumu) ──── */

/* Panel i fixed-toolbar nie mogą się na siebie nakładać — panel ma wyższy z-index */
body.fz-sheet-open .fz-to-fixed-toolbar {
    display: none !important; /* panel zastępuje floating toolbar */
}
/* Podczas edycji tekstu — blokuj scroll strony (iOS przesuwa body gdy klawiatura pojawia się) */
body.fz-typing {
    overflow: hidden;
    /* touch-action:none USUNIĘTE — blokowało interakcje z panelem (handle, przyciski) */
}

.fz-to-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10500; /* wyższy niż toolbar (10000) */
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
    /* Animacja: panel wysuwa sie od dolu */
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.fz-to-panel-open {
    transform: translateY(0);
}
/* Inner panel (styl czcionki, kolor itp.) — UKRYTY w trybie klawiatury (więcej miejsca na album).
   Widoczny w trybie stylu (klasa fz-style-mode dodawana przez JS po double-tap lub swipe-up). */
.fz-to-panel-inner {
    display: none;
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}
.fz-to-panel.fz-style-mode .fz-to-panel-inner {
    display: block;
}

/* ── TopBar: [Usuń] | [━━ handle ━━] | [Zatwierdź] ──────────── */
.fz-to-panel-topbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 6px 12px;
    border-bottom: none;
    flex-shrink: 0;
    min-height: 56px;
    gap: 6px;
}
.fz-to-panel.fz-style-mode .fz-to-panel-topbar {
    border-bottom: 1px solid #f0f0f0;
}

/* Przycisk "Zatwierdź" — zawsze zielony, zawsze zamyka panel */
.fz-to-panel-confirm-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: var(--album-accent, #09CF91);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    white-space: nowrap;
    line-height: 1;
}
.fz-to-panel-confirm-btn:active { opacity: 0.75; }

/* Przycisk "Cofnij" w topbarze panelu tekstu — obok ✓ */
.fz-to-panel-undo-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: 1.5px solid #d0d0d0;
    background: transparent;
    color: #333;
    cursor: pointer;
    touch-action: manipulation;
    padding: 0;
    margin-right: 14px;
}
.fz-to-panel-undo-btn:active { opacity: 0.75; }
.fz-to-panel-undo-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Przycisk "Usuń" w nagłówku panelu */
.fz-to-panel-del-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1.5px solid #e53935;
    background: transparent;
    color: #e53935;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    white-space: nowrap;
    line-height: 1;
}
.fz-to-panel-del-btn:active { opacity: 0.75; }

/* Uchwyt — tapnięcie zamyka panel */
.fz-to-panel-handle {
    flex: 1; /* zajmuje środek między przyciskami Usuń i Edytuj */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 8px 16px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.fz-to-panel-handle-bar {
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
}

/* ── Przycisk zatwierdzenia (widoczny zawsze gdy panel otwarty) ─ */
.fz-to-confirm-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}
.fz-to-confirm-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 18px;
    height: 40px;
    border-radius: 20px;
    background: #09CF91;
    color: #fff;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}
.fz-to-confirm-btn--visible { display: flex; }
.fz-to-confirm-btn:active { filter: brightness(0.85); }

/* ── Font picker (horizontal scroll) ─────────────────────────── */
.fz-to-font-picker {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 12px;
    scrollbar-width: none;
}
.fz-to-font-picker::-webkit-scrollbar { display: none; }
.fz-to-font-chip {
    flex-shrink: 0;
    padding: 9px 20px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background: #f0f0f0;
    color: #333;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.fz-to-font-chip:active { background: #e0e0e0; }
.fz-to-font-active {
    border-color: var(--album-accent, #09CF91);
    color: var(--album-accent, #09CF91);
    background: #e8faf5;
}

/* ── Controls row — jeden poziomy, scrollowalny wiersz ──────── */
.fz-to-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.fz-to-controls::-webkit-scrollbar { display: none; }

/* Pionowy separator między grupami w ctrlRow */
.fz-to-ctrl-sep {
    width: 1px;
    min-width: 1px;
    height: 24px;
    background: #ddd;
    flex-shrink: 0;
}
.fz-to-ctrl-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.fz-to-ctrl-label {
    color: #555;
    font-size: 12px;
    min-width: 36px;
    text-align: center;
}

/* Size/opacity slider */
.fz-to-slider {
    width: 80px;
    accent-color: var(--album-accent, #09CF91);
    height: 4px;
    flex-shrink: 0;
}

/* Alignment buttons */
.fz-to-align-group { gap: 4px; }
.fz-to-align-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f0f0f0;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.fz-to-align-active {
    border-color: var(--album-accent, #09CF91);
    color: var(--album-accent, #09CF91);
    background: #e8faf5;
}

/* Bold button */
.fz-to-bold-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f0f0f0;
    color: #333;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
    font-family: serif;
    touch-action: manipulation;
}
.fz-to-bold-btn:disabled { opacity: 0.3; cursor: default; }
.fz-to-bold-active {
    border-color: var(--album-accent, #09CF91);
    color: var(--album-accent, #09CF91);
    background: #e8faf5;
}

/* Suwak krycia — trochę węższy niż suwak rozmiaru */
.fz-to-opacity-group .fz-to-slider { width: 60px; }

/* ── Color row — osobna linia pod ctrlRow, scrollowalna ─────── */
.fz-to-color-row {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible; /* nie ucinaj górnej obwódki (np. białego swatcha) */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 2px 12px; /* 4px góra — obwódka swatcha nie ucięta przez wiersz wyżej */
    align-items: center;
}
.fz-to-color-row::-webkit-scrollbar { display: none; }
.fz-to-color-swatch {
    width: 36px;
    height: 36px;
    flex-shrink: 0; /* zapobiega ściskaniu kółek w flex-wrap:nowrap → owalna forma */
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color 0.15s, transform 0.15s;
}
.fz-to-color-swatch:active { transform: scale(1.15); }
.fz-to-color-active {
    border-color: #333;
    box-shadow: 0 0 0 2px var(--album-accent, #09CF91);
}
/* Custom color picker — kółko z tęczowym gradientem otwierające native picker */
.fz-to-color-custom {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #bbb;
    cursor: pointer;
    padding: 0;
    background: conic-gradient(red 0deg, yellow 60deg, lime 120deg, cyan 180deg, blue 240deg, magenta 300deg, red 360deg);
    flex-shrink: 0;
    overflow: hidden;
    touch-action: manipulation;
}
.fz-to-color-custom::-webkit-color-swatch-wrapper { padding: 0; border-radius: 50%; }
.fz-to-color-custom::-webkit-color-swatch { border: none; border-radius: 50%; opacity: 0; }
.fz-to-color-custom::-moz-color-swatch { border: none; border-radius: 50%; opacity: 0; }

/* OK button — confirms color and keeps panel open */
.fz-to-color-ok {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--album-accent, #09CF91);
    background: transparent;
    color: var(--album-accent, #09CF91);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.fz-to-color-ok:active { background: var(--album-accent, #09CF91); color: #fff; }

/* ── Efekty: Cień + Obrys ────────────────────────────────────── */
.fz-to-effects-wrap {
    border-top: 1px solid #eee;
    padding-top: 10px;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
/* Sekcja (Cień / Obrys) — wyraźnie oddzielona */
.fz-to-effect-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8f8f8;
    border-radius: 10px;
    padding: 8px 10px;
    border: 1px solid #ebebeb;
}
/* Nagłówek sekcji: [toggle] [kąt] [kolor] */
.fz-to-effect-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
/* Blok suwaków z etykietami */
.fz-to-sliders-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
/* Pojedynczy wiersz: ikona + etykieta + suwak */
.fz-to-slider-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.fz-to-slider-icon {
    font-size: 13px;
    color: #888;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}
.fz-to-slider-label {
    font-size: 12px;
    color: #666;
    width: 58px;
    flex-shrink: 0;
    white-space: nowrap;
}
/* Suwak zajmujący całą pozostałą szerokość */
.fz-to-slider-full {
    flex: 1;
    min-width: 80px;
}
.fz-to-toggle {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid #ddd;
    background: #f0f0f0;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.fz-to-toggle-active {
    background: #e8faf5;
    border-color: var(--album-accent, #09CF91);
    color: var(--album-accent, #09CF91);
}
.fz-to-effect-slider { min-width: 40px; }
.fz-to-color-input {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #ddd;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
    background: none;
}
.fz-to-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.fz-to-color-input::-webkit-color-swatch { border: none; border-radius: 50%; }
.fz-to-color-input:disabled { opacity: 0.3; cursor: default; }

/* Kąt cienia — w nagłówku sekcji: "Kąt" + suwak + "135°", flex: 1 wypełnia przestrzeń */
.fz-to-angle-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0; /* pozwala kurczyć się w flex head */
}
.fz-to-angle-prefix {
    font-size: 12px;
    color: #666;
    flex-shrink: 0;
    white-space: nowrap;
}
/* Wartość kąta w stopniach — po prawej suwaka */
.fz-to-angle-val {
    font-size: 12px;
    color: #444;
    font-weight: 600;
    min-width: 34px;
    text-align: right;
    flex-shrink: 0;
}
/* Suwak kąta — rozciąga się między etykietą a wartością */
.fz-to-angle-slider {
    flex: 1;
    min-width: 60px;
}

/* Hidden textarea — mobile keyboard trigger + input receiver */
/* WAŻNE: top:0 left:0 żeby Android nie scrollował strony przy focus.
   Rozmiar 120x48px (nie 1x1px) — na niektórych Android Chrome textarea z overflow:hidden
   i minimalnym rozmiarem może nie wysyłać zdarzeń input/compositionupdate prawidłowo.
   opacity:0 + pointer-events:none = niewidoczna, ale klawiatura działa. */
.fz-to-mobile-ta {
    position: fixed;
    top: 0;
    left: 0;
    width: 120px;
    height: 48px;
    opacity: 0;
    font-size: 16px; /* min 16px żeby iOS nie robiło autozoomu */
    border: none;
    outline: none;
    padding: 0;
    resize: none;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
    color: transparent;
    background: transparent;
    caret-color: transparent;
}

/* ── Migający kursor podczas edycji tekstu na mobile ── */
/* Klasa fz-editing dodawana do .fz-to-text przez _activateEditing */
.fz-to-text.fz-editing::after {
    content: '|';
    display: inline;
    font-weight: 300;
    opacity: 1;
    animation: fz-cursor-blink 1s step-end infinite;
    /* Kursor nie dziedziczy text-stroke ani text-shadow — czysta kreska */
    -webkit-text-stroke: 0px !important;
    text-shadow: none !important;
    filter: none !important;
    margin-left: 1px;
}
@keyframes fz-cursor-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ── Pasek edycji rozmiaru czcionki (pełnoekranowy overlay nad klawiaturą) ── */
.fz-size-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;           /* korygowany przez JS do keyboardH */
    z-index: 10010;
    background: #fff;
    border-top: 2px solid #e0e0e0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}
.fz-size-bar-input {
    flex: 1;
    font-size: 42px;
    font-weight: 700;
    text-align: center;
    border: none;
    border-bottom: 3px solid #1a73e8;
    outline: none;
    background: transparent;
    color: #1a1a1a;
    max-width: 180px;
    min-width: 80px;
    /* Disable spinner arrows */
    -moz-appearance: textfield;
}
.fz-size-bar-input::-webkit-outer-spin-button,
.fz-size-bar-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.fz-size-bar-unit {
    font-size: 22px;
    color: #aaa;
    font-weight: 300;
    flex-shrink: 0;
}
.fz-size-bar-done {
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.4);
}
