/* ========================================
   Apoidea Portfolio Generator
   Corporate Identity Design
   ======================================== */

/* Benutzerdefinierte Schriftart für Portfolio-Seiten */
@font-face {
    font-family: 'Fafers';
    src: url('FAFERS.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Apoidea CI Farben */
    --apoidea-teal: #2BBCB4;
    --apoidea-teal-dark: #1FA8A1;
    --apoidea-teal-light: #40D0C8;
    --apoidea-yellow: #E9A825;
    --apoidea-yellow-light: #F5BE4D;
    --apoidea-navy: #1B5E7A;
    --apoidea-skyblue: #A8D8D8;
    --apoidea-peach: #FAAA8D;
    --apoidea-olive: #9AAF4F;
    --apoidea-pink: #E95C94;
    --apoidea-white: #FFFFFF;
    
    /* UI Farben */
    --bg-sidebar: var(--apoidea-teal);
    --bg-sidebar-hover: var(--apoidea-teal-dark);
    --bg-main: #F0F8F8;
    --bg-page: #FFFFFF;
    --text-dark: #2C3E50;
    --text-light: #FFFFFF;
    --text-muted: #7A9A9A;
    --border: #D0E8E8;
    --shadow: rgba(27, 94, 122, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

/* ========================================
   App Layout
   ======================================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ========================================
   Sidebar - Apoidea Style
   ======================================== */
.sidebar {
    width: 320px;
    min-width: 320px;
    background: linear-gradient(180deg, var(--apoidea-teal) 0%, var(--apoidea-teal-dark) 100%);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
    contain: layout style;
}

/* Wolken-Dekoration unten */
.sidebar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 120'%3E%3Cpath fill='%23FFFFFF' fill-opacity='0.15' d='M0,64L48,69.3C96,75,192,85,288,80C384,75,480,53,576,48C672,43,768,53,864,69.3C960,85,1056,107,1152,101.3C1248,96,1344,64,1392,48L1440,32L1440,120L1392,120C1344,120,1248,120,1152,120C1056,120,960,120,864,120C768,120,672,120,576,120C480,120,384,120,288,120C192,120,96,120,48,120L0,120Z'%3E%3C/path%3E%3C/svg%3E") no-repeat bottom;
    background-size: cover;
    pointer-events: none;
}

.sidebar-header {
    padding: 25px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.05);
}

.logo-img {
    width: 55px;
    height: 55px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.sidebar-header h1 {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
}

.sidebar-header h1 span {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.85;
}

.sidebar-section {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-section h2 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

/* Ausklappbare Sections */
.sidebar-section.collapsible {
    padding: 0;
}

.section-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--apoidea-yellow) 0%, var(--apoidea-yellow-light) 100%);
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 700;
}

.section-toggle:hover {
    background: linear-gradient(135deg, var(--apoidea-yellow-light) 0%, var(--apoidea-yellow) 100%);
    transform: scale(1.01);
}

.section-toggle-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.section-toggle h2 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.current-format-hint {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.55);
}

.toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    background: rgba(0,0,0,0.15);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-toggle.open .toggle-icon {
    transform: rotate(180deg);
}

.section-toggle.open {
    background: var(--apoidea-yellow);
}

.section-content {
    padding: 12px 20px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.section-content.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Format Buttons */
.format-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.format-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    margin-top: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.format-section-label:first-child {
    margin-top: 0;
}

.format-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.1);
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: left;
}

.format-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: translateX(4px);
}

.format-btn.selected {
    background: var(--apoidea-yellow);
    color: var(--text-dark);
    border-color: var(--apoidea-yellow-light);
    box-shadow: 0 4px 15px rgba(233, 168, 37, 0.4);
}

.format-btn.favorite {
    background: rgba(233, 168, 37, 0.2);
    border-color: rgba(233, 168, 37, 0.4);
}

.format-btn.favorite:hover {
    background: rgba(233, 168, 37, 0.35);
}

.format-btn.favorite.selected {
    background: var(--apoidea-yellow);
    color: var(--text-dark);
}

.format-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
}

/* Image Upload */
.image-upload-area {
    border: 3px dashed rgba(255,255,255,0.4);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: rgba(255,255,255,0.05);
}

.image-upload-area:hover,
.image-upload-area.dragover {
    border-color: var(--apoidea-yellow);
    background: rgba(233, 168, 37, 0.15);
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.upload-icon {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 300;
    transition: all 0.25s ease;
}

.image-upload-area:hover .upload-icon {
    border-color: var(--apoidea-yellow);
    background: var(--apoidea-yellow);
    color: var(--text-dark);
}

#uploadText {
    font-size: 0.9rem;
    font-weight: 600;
}

.image-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.thumb {
    width: 65px;
    height: 65px;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: grab;
    border: 3px solid rgba(255,255,255,0.3);
    transition: all 0.2s ease;
}

.thumb:hover {
    border-color: var(--apoidea-yellow);
    transform: scale(1.05);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-number {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: var(--apoidea-yellow);
    color: var(--text-dark);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--apoidea-pink);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
}

.thumb:hover .thumb-remove {
    opacity: 1;
}

/* Options Section */
.sidebar-options {
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 14px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.option-toggle:hover {
    background: rgba(255,255,255,0.2);
}

.option-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    cursor: pointer;
    accent-color: var(--apoidea-yellow);
    -webkit-tap-highlight-color: transparent;
}

.option-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
}

/* Action Buttons */
.sidebar-actions {
    margin-top: auto;
    padding-bottom: 80px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
}

.sidebar-actions .btn-secondary,
.sidebar-actions .btn-primary {
    flex: 1;
    min-width: 100px;
}

/* Drucken-Button (einzelne Seite) */
.btn-print-single {
    padding: 14px 16px;
    background: rgba(255,255,255,0.15);
    color: var(--text-light);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 14px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s ease;
    flex: 1;
    min-width: 90px;
}

.btn-print-single:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}

/* Logout Button */
.btn-logout {
    padding: 14px 16px;
    background: rgba(233, 92, 148, 0.2);
    color: var(--text-light);
    border: 2px solid rgba(233, 92, 148, 0.4);
    border-radius: 14px;
    font-size: 1.1rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.btn-logout:hover {
    background: var(--apoidea-pink);
    border-color: var(--apoidea-pink);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(233, 92, 148, 0.4);
}

.btn {
    padding: 16px 24px;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: var(--apoidea-yellow);
    color: var(--text-dark);
    box-shadow: 0 4px 20px rgba(233, 168, 37, 0.4);
}

.btn-primary:hover {
    background: var(--apoidea-yellow-light);
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(233, 168, 37, 0.5);
}

.btn-secondary {
    background: rgba(255,255,255,0.15);
    color: var(--text-light);
    border: 2px solid rgba(255,255,255,0.3);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
}

/* ========================================
   Preview Area - Apoidea Style
   ======================================== */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 25px;
    overflow: hidden;
    position: relative;
    background: var(--bg-main);
    contain: layout style;
}

/* Fester Hintergrund der nicht scrollt */
.preview-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('background_querformat.png') center center no-repeat;
    background-size: cover;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.preview-area > * {
    position: relative;
    z-index: 1;
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
}

.preview-header h2 {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.3rem;
    color: var(--apoidea-teal-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.current-page-indicator {
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--apoidea-teal);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
}

.hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 8px 14px;
    border-radius: 20px;
}

/* Bearbeiten-Button (Tablet & Mobil) */
.btn-edit-fullscreen {
    display: none;
    background: var(--apoidea-yellow);
    color: var(--text-dark);
    border: none;
    padding: 10px 18px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(233, 168, 37, 0.4);
    transition: all 0.2s ease;
    margin-left: auto;
    min-height: 44px;
}

.btn-edit-fullscreen:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(233, 168, 37, 0.5);
}

.btn-edit-fullscreen:active {
    transform: scale(0.98);
}

/* Tablet & Mobil: Bearbeiten-Button anzeigen */
@media (max-width: 1200px) {
    .btn-edit-fullscreen {
        display: block;
    }
    
    .preview-header {
        justify-content: space-between;
    }
}

/* Auf kleineren Geräten: Hint ausblenden */
@media (max-width: 1000px) {
    .desktop-hint {
        display: none;
    }
}

/* Auf großen Tablets: Beides anzeigen */
@media (min-width: 1000px) and (max-width: 1200px) {
    .desktop-hint {
        display: block;
    }
    
    .btn-edit-fullscreen {
        margin-left: 15px;
    }
}

.preview-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    padding: 25px;
    background: linear-gradient(135deg, rgba(43, 188, 180, 0.15) 0%, rgba(27, 94, 122, 0.15) 100%);
    border-radius: 20px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.05);
    position: relative;
}

.preview-page {
    width: 210mm;
    height: 297mm;
    max-height: 297mm;
    background: white;
    box-shadow: 0 15px 50px var(--shadow);
    padding: 15mm;
    transform-origin: top center;
    border-radius: 4px;
    overflow: hidden;
    box-sizing: border-box;
    contain: layout style;
    content-visibility: auto;
    transform: translateZ(0);
}

.empty-state {
    height: 100%;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--apoidea-teal);
    text-align: center;
}

.empty-state p {
    font-size: 1.1rem;
    line-height: 1.6;
}

/* ========================================
   Portfolio Page Layout
   ======================================== */
.portfolio-page {
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
    height: 100%;
    max-height: calc(297mm - 30mm);
    position: relative;
    padding-bottom: 35mm;
    overflow: hidden;
    box-sizing: border-box;
}

/* Apoidea-Logo Footer in der Vorschau */
.preview-footer-logo {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.preview-footer-logo img {
    width: 25mm;
    height: 25mm;
}

/* Überschrift */
.portfolio-title {
    width: 100%;
    border: 2px solid var(--border);
    padding: 10px 14px;
    margin-bottom: 20px;
    font-size: 18pt;
    font-weight: bold;
    min-height: 44px;
    outline: none;
    border-radius: 8px;
    transition: all 0.25s ease;
    background: #FAFFFE;
}

.portfolio-title:hover {
    border-color: var(--apoidea-teal);
}

.portfolio-title:focus {
    border-color: var(--apoidea-yellow);
    box-shadow: 0 0 0 4px rgba(233, 168, 37, 0.2);
    background: white;
}

.portfolio-title:empty:before {
    content: attr(data-placeholder);
    color: #AAA;
}

.portfolio-title.centered {
    text-align: center;
}

.portfolio-textbox.text-centered {
    text-align: center;
}

/* Zeilen mit Bild + Text */
.portfolio-row {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    animation: fadeIn 0.4s ease-out;
    align-items: flex-start;
}

/* Textfeld */
.portfolio-textbox {
    flex: 1;
    border: 2px solid var(--border);
    padding: 10px 12px;
    font-size: 12pt;
    line-height: 1.5;
    min-height: 80px;
    max-height: 100%;
    outline: none;
    border-radius: 8px;
    transition: all 0.25s ease;
    overflow: hidden;
    background: #FAFFFE;
    
    /* Linksbündig */
    text-align: left;
    
    /* Silbentrennung */
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    
    /* Hurenkinder & Schusterjungen vermeiden */
    orphans: 3;
    widows: 3;
}

.portfolio-textbox:hover {
    border-color: var(--apoidea-teal);
}

.portfolio-textbox:focus {
    border-color: var(--apoidea-yellow);
    box-shadow: 0 0 0 4px rgba(233, 168, 37, 0.2);
    background: white;
}

.portfolio-textbox:empty:before {
    content: attr(data-placeholder);
    color: #AAA;
}

/* Bildbereich */
.portfolio-image-slot {
    border: 3px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F8FFFF 0%, #F0F8F8 100%);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.portfolio-image-slot:hover {
    border-color: var(--apoidea-teal);
    background: linear-gradient(135deg, #E8F8F8 0%, #D8F0F0 100%);
    transform: scale(1.01);
}

.portfolio-image-slot.has-image {
    border: none;
    border-radius: 8px;
}

.portfolio-image-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 50%;
    border-radius: 6px;
}

/* Bilder mit Interaktion */
.portfolio-image-slot.has-image {
    position: relative;
    overflow: hidden;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.portfolio-image-slot.has-image:active {
    cursor: grabbing;
}

.portfolio-image-slot.has-image img {
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.portfolio-image-slot .placeholder-text {
    color: var(--apoidea-teal);
    font-size: 11pt;
    text-align: center;
    font-weight: 500;
}

/* Größen */
.size-9 {
    width: 9cm;
    height: 9cm;
}

/* Kleinere Höhe für 3-Reihen-Layouts */
.size-9-small {
    width: 9cm;
    height: 6.5cm;
}

.size-11 {
    width: 11cm;
    height: 9cm;
}

.size-11-hoch {
    width: 11cm;
    height: 14cm;
}

.size-11-quer {
    width: 17cm;
    height: 11cm;
}

/* 1x Hochformat Layout */
.portfolio-single {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.portfolio-single .portfolio-image-slot {
    margin-bottom: 12px;
}

.portfolio-single .portfolio-textbox {
    width: 100%;
    min-height: 80px;
    text-align: center;
}


/* ========================================
   Seiten-Verwaltung (Multi-Page)
   ======================================== */
.pages-section {
    padding: 12px 20px !important;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.pages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.pages-header h2 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.page-count {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.15);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

/* Seiten-Thumbnails Container */
.page-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 4px;
}

.page-thumbnails::-webkit-scrollbar {
    width: 4px;
}

.page-thumbnails::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

.page-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

/* Einzelne Seiten-Thumbnail */
.page-thumb {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.08);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-thumb:hover {
    background: rgba(255,255,255,0.15);
    transform: translateX(3px);
}

.page-thumb.active {
    background: var(--apoidea-yellow);
    border-color: var(--apoidea-yellow-light);
    color: var(--text-dark);
}

.page-thumb.active .page-thumb-format {
    color: rgba(0,0,0,0.6);
}

/* Vorschau-Box */
.page-thumb-preview {
    width: 36px;
    height: 48px;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    overflow: hidden;
}

.page-thumb-empty {
    font-size: 1.2rem;
    color: #ccc;
}

/* Layout-Vorschau in Thumbnail */
.page-thumb-layout {
    width: 100%;
    height: 100%;
    padding: 3px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.page-thumb-layout.single {
    align-items: center;
    justify-content: center;
}

.page-thumb-layout.single .layout-img {
    width: 70%;
    height: 55%;
    background: var(--apoidea-teal);
    border-radius: 2px;
}

.page-thumb-layout.single .layout-text {
    width: 90%;
    height: 15%;
    background: #ddd;
    border-radius: 1px;
    margin-top: 2px;
}

.layout-row {
    display: flex;
    gap: 2px;
    flex: 1;
}

.layout-row .layout-img {
    width: 45%;
    background: var(--apoidea-teal);
    border-radius: 2px;
}

.layout-row .layout-text {
    flex: 1;
    background: #ddd;
    border-radius: 1px;
}

.page-thumb-layout.rows-3 .layout-row {
    gap: 1px;
}

.page-thumb-layout.rows-3 .layout-img {
    width: 40%;
}

/* Seiten-Info */
.page-thumb-info {
    flex: 1;
    min-width: 0;
}

.page-thumb-number {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
}

.page-thumb-format {
    display: block;
    font-size: 0.7rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Aktions-Buttons */
.page-thumb-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-thumb:hover .page-thumb-actions {
    opacity: 1;
}

.page-thumb.active .page-thumb-actions {
    opacity: 1;
}

.page-thumb-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.page-thumb-btn:hover {
    background: rgba(0,0,0,0.25);
    transform: scale(1.1);
}

.page-thumb-delete:hover {
    background: var(--apoidea-pink);
}

/* Neue Seite Button */
.btn-add-page {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.1);
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 10px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-page:hover {
    background: rgba(255,255,255,0.2);
    border-color: var(--apoidea-yellow);
    transform: scale(1.02);
}

.btn-add-page .add-icon {
    width: 22px;
    height: 22px;
    background: var(--apoidea-yellow);
    color: var(--text-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
}

/* Mobile Anpassungen für Seiten-Panel */
@media (max-width: 1000px) {
    .pages-section {
        padding: 8px 12px !important;
    }
    
    .pages-header h2 {
        font-size: 0.75rem;
    }
    
    /* Horizontales Scrolling auf Tablets/Smartphones */
    .page-thumbnails {
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 8px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }
    
    .page-thumb {
        flex-shrink: 0;
        flex-direction: column;
        width: 80px;
        padding: 6px;
        gap: 4px;
        position: relative;
    }

    .page-thumb-preview {
        width: 100%;
        height: 56px;
    }

    .page-thumb-info {
        text-align: center;
        width: 100%;
    }

    .page-thumb-number {
        font-size: 0.7rem;
    }

    .page-thumb-format {
        display: none;
    }

    .page-thumb-actions {
        position: absolute;
        top: 3px;
        right: 3px;
        opacity: 1;
    }

    .page-thumb-btn {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }
    
    .btn-add-page {
        flex-shrink: 0;
        width: 60px;
        flex-direction: column;
        padding: 8px;
        gap: 4px;
    }
    
    .btn-add-page span:last-child {
        font-size: 0.65rem;
    }
    
    .btn-add-page .add-icon {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 600px) {
    .page-thumb {
        width: 70px;
    }

    .page-thumb-preview {
        height: 48px;
    }

    .btn-add-page {
        width: 60px;
    }
}


/* ========================================
   Print Styles - Exakte A4 Formatierung
   ======================================== */

/* Print-Template im normalen Modus verstecken */
.print-only,
#printTemplate {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}

@media print {
    /* A4 Seitengröße - margin:0 verhindert Browser-Kopf-/Fußzeilen (URL, Datum, Seitenzahl) */
    @page {
        size: A4 portrait;
        margin: 0;
    }
    
    /* Farbdruck + alle Animationen deaktivieren */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        animation: none !important;
        transition: none !important;
    }
    
    /* Reset */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
    
    /* Alles verstecken */
    body > *:not(#printTemplate) {
        display: none !important;
    }
    
    /* Print-Template anzeigen */
    #printTemplate {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        left: auto !important;
    }
    
    /* Seiten-Wrapper */
    .print-page-wrapper {
        box-sizing: border-box;
        background: white;
        padding: 10mm 15mm 12mm 15mm;
        width: 210mm;
        height: 297mm;
        max-height: 297mm;
        overflow: hidden;
        position: relative;
        page-break-inside: avoid;
        break-inside: avoid;
        page-break-after: always;
    }

    .print-page-wrapper:not(:first-child) {
        page-break-before: always;
        break-before: page;
    }

    .print-page-wrapper:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    
    /* Portfolio-Page im Print */
    #printTemplate .portfolio-page {
        font-family: 'Calibri', 'Segoe UI', Arial, sans-serif !important;
        color: #000 !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        overflow: hidden !important;
        opacity: 1 !important;
    }
    
    /* Titel im Print */
    #printTemplate .portfolio-title {
        font-family: 'Calibri', 'Segoe UI', Arial, sans-serif !important;
        font-size: 18pt !important;
        font-weight: bold !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 0 6mm 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
    }
    
    #printTemplate .portfolio-title.centered {
        text-align: center !important;
    }

    #printTemplate .portfolio-textbox.text-centered {
        text-align: center !important;
    }

    /* Zeilen im Print */
    #printTemplate .portfolio-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 6mm !important;
        margin-bottom: 8mm !important;
        align-items: flex-start !important;
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    #printTemplate .portfolio-row:last-child {
        margin-bottom: 0 !important;
    }
    
    /* Textbox im Print */
    #printTemplate .portfolio-textbox {
        flex: 1 !important;
        font-family: 'Calibri', 'Segoe UI', Arial, sans-serif !important;
        font-size: 12pt !important;
        line-height: 1.4 !important;
        color: #000 !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
        text-align: left !important;
        -webkit-hyphens: auto !important;
        hyphens: auto !important;
        overflow: hidden !important;
        opacity: 1 !important;
    }
    
    /* Bild-Slots im Print */
    #printTemplate .portfolio-image-slot {
        flex-shrink: 0 !important;
        border: none !important;
        background: transparent !important;
        overflow: hidden !important;
        opacity: 1 !important;
    }
    
    #printTemplate .portfolio-image-slot.size-9 {
        width: 9cm !important;
        height: 9cm !important;
    }
    
    #printTemplate .portfolio-image-slot.size-9-small {
        width: 9cm !important;
        height: 6.5cm !important;
    }
    
    #printTemplate .portfolio-image-slot.size-11 {
        width: 11cm !important;
        height: 9cm !important;
    }
    
    #printTemplate .portfolio-image-slot.size-11-hoch {
        width: 11cm !important;
        height: 14cm !important;
    }

    #printTemplate .portfolio-image-slot.size-11-quer {
        width: 17cm !important;
        height: 11cm !important;
    }
    
    /* Single Layout im Print */
    #printTemplate .portfolio-single {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 6mm !important;
    }
    
    #printTemplate .portfolio-single .portfolio-textbox {
        width: 100% !important;
        text-align: center !important;
    }
    
    /* Bilder im Print */
    #printTemplate .portfolio-image-slot img {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border-radius: 0 !important;
    }

    /* Logo-Footer im Print */
    .print-footer-logo {
        position: absolute !important;
        bottom: 8mm !important;
        left: 0 !important;
        right: 0 !important;
        display: flex !important;
        justify-content: center !important;
    }

    .print-footer-logo img {
        width: 25mm !important;
        height: 25mm !important;
    }
}


/* ========================================
   Modal - Installations-Hinweis
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-main);
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--apoidea-teal);
    color: white;
}

.modal-logo {
    width: 60px;
    height: 60px;
    display: block;
    margin: 0 auto 15px;
}

.modal h2 {
    text-align: center;
    font-family: 'Quicksand', sans-serif;
    color: var(--apoidea-teal-dark);
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.modal > p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.install-instructions {
    background: var(--bg-main);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

.instruction {
    margin-bottom: 15px;
}

.instruction:last-child {
    margin-bottom: 0;
}

.instruction strong {
    display: block;
    color: var(--apoidea-teal-dark);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.instruction ol {
    margin: 0;
    padding-left: 20px;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.instruction li {
    margin-bottom: 5px;
}

.icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--apoidea-teal);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    font-size: 0.8rem;
    vertical-align: middle;
}

.privacy-notice {
    background: linear-gradient(135deg, rgba(43, 188, 180, 0.1) 0%, rgba(27, 94, 122, 0.1) 100%);
    border: 1px solid var(--apoidea-teal);
    border-radius: 10px;
    padding: 12px 15px;
    font-size: 0.8rem;
    color: var(--text-dark);
    margin-bottom: 20px;
    line-height: 1.5;
}

.privacy-notice strong {
    color: var(--apoidea-teal-dark);
}

.modal-btn {
    width: 100%;
    margin-bottom: 10px;
}

.dont-show-again {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}

.dont-show-again input {
    cursor: pointer;
}

/* Welcome Modal - Installations-Anleitung */
.welcome-modal {
    max-width: 450px;
}

.welcome-modal h3 {
    font-family: 'Quicksand', sans-serif;
    color: var(--apoidea-teal-dark);
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.install-section {
    background: var(--bg-main);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 20px;
}

.install-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.install-step {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px 14px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--apoidea-teal);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.step-text {
    font-size: 0.9rem;
    color: var(--text-dark);
    line-height: 1.4;
}

.icon-badge-large {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--apoidea-navy);
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    font-size: 0.9rem;
    vertical-align: middle;
    margin: 0 2px;
}

/* Mobile Welcome Modal */
@media (max-width: 600px) {
    .welcome-modal {
        padding: 20px 16px;
    }
    
    .welcome-modal h3 {
        font-size: 1rem;
    }
    
    .install-section {
        padding: 14px;
    }
    
    .install-step {
        padding: 10px 12px;
    }
    
    .step-text {
        font-size: 0.85rem;
    }
}

/* Privacy Footer in Sidebar */
.privacy-footer {
    padding: 12px 20px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
    text-align: center;
    cursor: pointer;
    transition: color 0.2s ease;
    margin-top: auto;
}

.privacy-footer:hover {
    color: rgba(255,255,255,0.9);
}

/* App Footer - nur im Hochformat/Mobil sichtbar */
.app-footer {
    width: 100%;
    padding: 16px 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.35);
    color: rgba(0, 0, 0, 0.7);
    font-size: 0.7rem;
    line-height: 1.5;
    display: none;
}

.app-footer p {
    margin: 0;
}

.app-footer-privacy {
    margin-top: 6px !important;
    font-weight: 700;
    color: #000;
}

.app-footer-detail {
    color: rgba(0, 0, 0, 0.55);
    font-size: 0.65rem;
}

/* Footer nur im Hochformat (column-Layout) anzeigen */
@media (max-width: 1000px) and (orientation: portrait) {
    .app-footer {
        display: block;
    }
}

@media print {
    .app-footer {
        display: none !important;
    }
}

/* Mobile Modal Anpassungen */
@media (max-width: 600px) {
    .modal {
        padding: 20px;
        border-radius: 16px;
    }
    
    .modal-logo {
        width: 50px;
        height: 50px;
    }
    
    .modal h2 {
        font-size: 1.2rem;
    }
    
    .install-instructions {
        padding: 12px;
    }
    
    .instruction ol {
        font-size: 0.8rem;
    }
}

/* ========================================
   Responsive - Tablet & Smartphone
   ======================================== */

/* Tablet & Mobil */
@media (max-width: 1000px) {
    html, body {
        overflow: auto;
        height: auto;
    }
    
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    
    /* === SIDEBAR KOMPAKT === */
    .sidebar {
        width: 100%;
        min-width: auto;
        flex-shrink: 0;
    }
    
    .sidebar::after {
        display: none;
    }
    
    .sidebar-header {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .logo-img {
        width: 32px;
        height: 32px;
    }
    
    .sidebar-header h1 {
        font-size: 0.9rem;
    }
    
    .sidebar-header h1 span {
        display: none;
    }
    
    .sidebar-section {
        padding: 8px 12px;
    }
    
    .sidebar-section h2 {
        font-size: 0.7rem;
        margin-bottom: 6px;
    }
    
    .sidebar-section.collapsible {
        padding: 0;
    }
    
    .section-toggle {
        padding: 10px 12px;
    }
    
    .section-content {
        padding: 8px 12px;
    }
    
    .section-content.collapsed {
        padding-top: 0;
        padding-bottom: 0;
    }
    
    /* Format-Buttons horizontal */
    .format-list {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }
    
    .format-section-label {
        display: none;
    }
    
    .format-btn {
        padding: 8px 12px;
        min-height: 44px;
        font-size: 0.75rem;
        border-radius: 20px;
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    .format-btn.favorite {
        order: -1;
    }
    
    .format-icon {
        display: none;
    }
    
    /* Bilder-Upload kompakt */
    .image-upload-area {
        padding: 10px;
        border-radius: 8px;
    }
    
    .upload-icon {
        width: 28px;
        height: 28px;
        font-size: 1rem;
        border-width: 2px;
    }
    
    #uploadText {
        font-size: 0.7rem;
    }
    
    .upload-content {
        flex-direction: row;
        gap: 8px;
    }
    
    .image-thumbs {
        display: flex;
        gap: 5px;
        margin-top: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .thumb {
        width: 70px;
        height: 70px;
        border-radius: 8px;
        flex-shrink: 0;
        border-width: 2px;
    }

    .thumb-number {
        width: 18px;
        height: 18px;
        font-size: 0.65rem;
        bottom: 3px;
        left: 3px;
    }

    .thumb-remove {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
        top: 3px;
        right: 3px;
        opacity: 1;
    }
    
    /* Options kompakt */
    .sidebar-options {
        padding: 6px 12px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .option-toggle {
        padding: 8px 10px;
        border-radius: 8px;
        flex: 1;
        min-width: 120px;
    }
    
    .option-label {
        font-size: 0.75rem;
    }
    
    /* Aktionen horizontal */
    .sidebar-actions {
        padding: 8px 12px;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
    }
    
    .btn {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.8rem;
        border-radius: 8px;
    }
    
    .btn-logout {
        flex: 0;
        padding: 10px 14px;
        font-size: 1rem;
    }
    
    .btn-print-single {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.75rem;
        min-width: 70px;
    }
    
    /* Privacy Footer auf mobil ausblenden */
    .privacy-footer {
        display: none;
    }
    
    /* === VORSCHAU === */
    .preview-area {
        flex: 1;
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        min-height: 60vh;
    }
    
    .preview-area::before {
        opacity: 0.2;
    }
    
    .preview-header {
        padding: 8px 12px;
        margin-bottom: 10px;
        border-radius: 10px;
    }
    
    .preview-header h2 {
        font-size: 1rem;
    }
    
    .hint {
        font-size: 0.7rem;
        padding: 5px 10px;
    }
    
    .preview-container {
        padding: 10px;
        border-radius: 12px;
        min-height: 45vh;
        overflow: auto;
        align-items: flex-start;
        justify-content: center;
    }
    
    /* Vorschau-Seite - breiter skaliert für bessere Lesbarkeit */
    .preview-page {
        transform-origin: top center;
        transform: scale(0.48);
        width: 210mm;
        min-height: 297mm;
        margin-bottom: -380px;
    }
}

/* Größere Tablets (iPad portrait: 768-1000px) */
@media (min-width: 768px) and (max-width: 1000px) {
    .preview-page {
        transform: scale(0.55);
        margin-bottom: -350px;
    }

    .format-btn {
        padding: 10px 14px;
        font-size: 0.8rem;
    }

    .privacy-footer {
        display: block;
    }

    /* Touch targets: 44px minimum (Apple HIG) */
    .btn {
        min-height: 44px;
    }

    .option-toggle {
        min-height: 44px;
    }

    .section-toggle {
        min-height: 44px;
    }

    /* Better spacing for sidebar on iPad portrait */
    .sidebar-actions {
        gap: 10px;
    }

    .sidebar-section {
        padding: 10px 16px;
    }

    .section-content {
        padding: 10px 16px;
    }

    /* Wider preview container for iPad */
    .preview-container {
        padding: 16px;
    }

    /* Format list: hide scrollbar but keep scrollable */
    .format-list {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .format-list::-webkit-scrollbar {
        display: none;
    }
}

/* iPad landscape and larger tablets (1001-1199px) */
@media (min-width: 1001px) and (max-width: 1199px) {
    /* Sidebar narrower to give more space to preview */
    .sidebar {
        width: 280px;
        min-width: 280px;
    }

    .preview-page {
        transform: scale(0.72);
        transform-origin: top center;
        margin-bottom: -200px;
    }

    /* Touch targets for iPad landscape */
    .btn {
        min-height: 44px;
    }

    .option-toggle {
        min-height: 44px;
    }

    .section-toggle {
        min-height: 44px;
    }
}

/* Smartphone */
@media (max-width: 600px) {
    /* Header noch kompakter */
    .sidebar-header {
        padding: 6px 10px;
    }
    
    .logo-img {
        width: 26px;
        height: 26px;
    }
    
    .sidebar-header h1 {
        font-size: 0.85rem;
    }
    
    /* Sections kompakter */
    .sidebar-section {
        padding: 6px 10px;
    }
    
    .section-toggle {
        padding: 8px 10px;
    }
    
    .section-toggle h2 {
        font-size: 0.8rem;
    }
    
    /* Format-Buttons kleiner */
    .format-btn {
        padding: 6px 10px;
        min-height: 44px;
        font-size: 0.7rem;
    }
    
    /* Bilder-Upload einzeilig */
    .image-upload-area {
        padding: 8px 12px;
    }
    
    .upload-icon {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }
    
    #uploadText {
        font-size: 0.75rem;
    }
    
    /* Buttons kleiner */
    .btn {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    
    .btn-logout {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    /* Vorschau-Bereich */
    .preview-area {
        padding: 8px;
        min-height: 50vh;
    }
    
    .preview-header {
        padding: 8px 12px;
        margin-bottom: 8px;
    }
    
    .preview-header h2 {
        font-size: 0.9rem;
    }
    
    .hint {
        font-size: 0.65rem;
        padding: 4px 8px;
    }
    
    .preview-container {
        padding: 6px;
        min-height: 40vh;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        overflow: auto;
    }
    
    /* Seite so skalieren, dass sie in die Breite passt */
    .preview-page {
        transform-origin: top center;
        transform: scale(0.42);
        width: 210mm;
        min-height: 297mm;
        margin-bottom: -170mm;
        flex-shrink: 0;
    }
    
    /* Bearbeiten-Button - kürzerer Text auf Smartphone */
    .btn-edit-fullscreen {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}

/* Kleine Smartphones (iPhone SE etc.) */
@media (max-width: 380px) {
    .sidebar-header h1 {
        font-size: 0.75rem;
    }
    
    .format-btn {
        padding: 5px 8px;
        min-height: 44px;
        font-size: 0.65rem;
    }
    
    .preview-page {
        transform: scale(0.36);
        margin-bottom: -190mm;
    }
}

/* Landscape-Modus */
@media (max-height: 500px) and (orientation: landscape) {
    .app-container {
        flex-direction: row;
        height: 100vh;
    }
    
    .sidebar {
        width: 260px;
        min-width: 260px;
        max-height: 100vh;
        overflow-y: auto;
    }
    
    .format-list {
        flex-wrap: wrap;
    }
    
    .preview-area {
        min-height: auto;
        height: 100vh;
    }
    
    .preview-container {
        height: calc(100vh - 70px);
        min-height: auto;
    }
    
    .preview-page {
        transform: scale(0.38);
        margin-bottom: -450px;
    }
    
    .privacy-footer {
        display: block;
    }
}

/* ========================================
   Animationen
   ======================================== */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(15px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.format-btn.selected {
    animation: pulse 0.3s ease-out;
}

/* ========================================
   Vollbild-Bearbeitungsmodus (Tablet Hochformat)
   ======================================== */
.fullscreen-edit-overlay {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.3s ease;
    /* Safe area insets for iPads with home bar */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.fullscreen-edit-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.fullscreen-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--apoidea-teal);
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.fullscreen-edit-title {
    font-weight: 700;
    font-size: 1rem;
}

.fullscreen-edit-close {
    background: var(--apoidea-yellow);
    color: var(--text-dark);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    min-height: 44px;
}

.fullscreen-edit-close:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.fullscreen-edit-close:active {
    transform: scale(0.98);
}

.fullscreen-edit-container {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
    -webkit-overflow-scrolling: touch;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

/* Skalierung für verschiedene Bildschirmgrößen */

/* iPad landscape (1024-1366px) - edit page fits well */
@media (min-width: 1024px) and (max-width: 1400px) {
    .fullscreen-edit-container {
        justify-content: center;
    }

    .fullscreen-edit-page {
        transform: scale(0.95);
        transform-origin: top center;
        margin-bottom: -15mm;
    }
}

@media (max-width: 900px) {
    .fullscreen-edit-page {
        transform: scale(0.85);
        margin-bottom: -50mm;
    }
}

/* iPad portrait (768-834px) */
@media (min-width: 768px) and (max-width: 900px) {
    .fullscreen-edit-container {
        justify-content: center;
    }

    .fullscreen-edit-page {
        transform: scale(0.85);
        transform-origin: top center;
        margin-bottom: -50mm;
    }

    .fullscreen-edit-header {
        padding: 14px 20px;
    }
}

@media (max-width: 700px) {
    .fullscreen-edit-page {
        transform: scale(0.7);
        margin-bottom: -90mm;
        margin-right: -60mm;
    }
}

@media (max-width: 500px) {
    .fullscreen-edit-page {
        transform: scale(0.52);
        margin-bottom: -145mm;
        margin-right: -100mm;
    }

    .fullscreen-edit-container {
        padding: 10px;
    }
}

@media (max-width: 400px) {
    .fullscreen-edit-page {
        transform: scale(0.45);
        margin-bottom: -165mm;
        margin-right: -115mm;
    }
}

.fullscreen-edit-page {
    background: white;
    width: 210mm;
    min-width: 210mm;
    height: 297mm;
    min-height: 297mm;
    padding: 15mm;
    box-shadow: 0 4px 30px rgba(0,0,0,0.15);
    box-sizing: border-box;
    transform-origin: top left;
}

/* Vollbild behält das echte A4-Layout */
.fullscreen-edit-page .portfolio-page {
    height: 100%;
    max-height: calc(297mm - 30mm);
    padding: 0;
    padding-bottom: 35mm;
}

.fullscreen-edit-page .portfolio-title {
    font-size: 18pt;
}

.fullscreen-edit-page .portfolio-title.centered {
    text-align: center;
}

.fullscreen-edit-page .portfolio-textbox.text-centered {
    text-align: center;
}

.fullscreen-edit-page .portfolio-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.fullscreen-edit-page .portfolio-textbox {
    flex: 1;
    font-size: 12pt;
}

.fullscreen-edit-page .portfolio-image-slot.size-9 {
    width: 9cm !important;
    height: 9cm !important;
}

.fullscreen-edit-page .portfolio-image-slot.size-9-small {
    width: 9cm !important;
    height: 6.5cm !important;
}

.fullscreen-edit-page .portfolio-image-slot.size-11 {
    width: 11cm !important;
    height: 9cm !important;
}

.fullscreen-edit-page .portfolio-image-slot.size-11-hoch {
    width: 11cm !important;
    height: 14cm !important;
}

.fullscreen-edit-page .portfolio-image-slot.size-11-quer {
    width: 17cm !important;
    height: 11cm !important;
}


/* Auf mobilen Geräten: Textfelder als klickbar markieren */
@media (max-width: 1024px) {
    .preview-page .portfolio-textbox,
    .preview-page .portfolio-title {
        cursor: pointer;
    }
    
    .preview-page .portfolio-textbox:focus,
    .preview-page .portfolio-title:focus {
        outline: 3px solid var(--apoidea-yellow);
        outline-offset: 2px;
    }
}

/* ========================================
   Login Screen - Clientseitig
   ======================================== */
.login-overlay {
    /* Kein position:fixed - blockiert Tastatur in iOS-PWA-Standalone */
    min-height: 100vh;
    min-height: -webkit-fill-available;
    background: linear-gradient(135deg, #E8F5F4 0%, #D4EFED 50%, #C0E9E6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

@keyframes floatBg {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(-2%, 2%) rotate(1deg); }
}

.login-container {
    position: relative;
    background: white;
    padding: 2.5rem 2rem;
    border-radius: 24px;
    box-shadow:
        0 20px 60px rgba(43, 188, 180, 0.15),
        0 8px 25px rgba(0, 0, 0, 0.08);
    max-width: 400px;
    width: 100%;
    text-align: center;
    animation: loginSlideUp 0.6s ease-out;
    overflow: visible;
}

@keyframes loginSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-container .decoration {
    position: absolute;
    opacity: 0.5;
    pointer-events: none;
    font-size: 32px;
    z-index: -1;
}

.login-container .deco-1 {
    top: 10px;
    right: 10px;
}

.login-container .deco-2 {
    bottom: 10px;
    left: 10px;
    font-size: 28px;
}

.login-logo {
    width: 90px;
    height: 90px;
    margin-bottom: 1.2rem;
    filter: drop-shadow(0 4px 12px rgba(43, 188, 180, 0.3));
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.login-title {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--apoidea-teal);
    margin-bottom: 0.3rem;
}

.login-subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-error {
    background: #ffebee;
    color: #c62828;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    border-left: 4px solid #c62828;
    animation: shake 0.5s ease;
    display: none;
}

.login-error:not(:empty) {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.login-form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.login-form-group label {
    display: block;
    font-weight: 600;
    color: #444;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-form-group input {
    width: 100%;
    padding: 0.9rem 1rem;
    padding-right: 3rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    /* min. 16px verhindert iOS-Auto-Zoom und Tastatur-Blockade */
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #fafafa;
    /* Explizit Touch-Eingabe erlauben (iOS-PWA-Fix) */
    -webkit-user-select: text;
    user-select: text;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.login-form-group input:focus {
    outline: none;
    border-color: var(--apoidea-teal);
    background: white;
    box-shadow: 0 0 0 4px rgba(43, 188, 180, 0.1);
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 10px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    background: rgba(43, 188, 180, 0.1);
}

.password-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.eye-icon {
    font-size: 1.2rem;
    line-height: 1;
    user-select: none;
}

.login-btn {
    width: 100%;
    padding: 0.9rem 1.5rem;
    background: linear-gradient(135deg, var(--apoidea-teal) 0%, var(--apoidea-teal-dark) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(43, 188, 180, 0.4);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(43, 188, 180, 0.5);
}

.login-btn:active {
    transform: translateY(0);
}

.login-footer {
    margin-top: 1.2rem;
    font-size: 0.75rem;
    color: #999;
}

.login-privacy {
    margin-top: 1.2rem;
    padding: 0.8rem 1rem;
    background: linear-gradient(135deg, rgba(43, 188, 180, 0.08) 0%, rgba(27, 94, 122, 0.08) 100%);
    border-radius: 10px;
    font-size: 0.75rem;
    color: #555;
    line-height: 1.5;
}

.login-privacy strong {
    color: var(--apoidea-teal-dark);
    display: block;
    margin-bottom: 0.3rem;
}

/* Mobile Login */
@media (max-width: 600px) {
    .login-container {
        padding: 1.5rem;
        border-radius: 18px;
    }
    
    .login-logo {
        width: 70px;
        height: 70px;
    }
    
    .login-title {
        font-size: 1.3rem;
    }
    
    .login-container .decoration {
        font-size: 24px;
        opacity: 0.3;
    }
    
    .login-container .deco-1 {
        top: 8px;
        right: 8px;
    }
    
    .login-container .deco-2 {
        bottom: 8px;
        left: 8px;
        font-size: 20px;
    }
}

/* iOS PWA Standalone: Extra Padding für Tastatur */
@media (max-width: 600px) and (display-mode: standalone) {
    .login-container {
        padding-bottom: 50vh;
    }
}

/* ========================================
   Zeichenzähler für Textfelder
   ======================================== */
.portfolio-textbox-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.portfolio-textbox-wrapper .portfolio-textbox {
    flex: 1;
    margin-bottom: 0;
}

.char-counter {
    font-size: 9pt;
    color: #999;
    text-align: right;
    padding: 4px 8px 2px 0;
    font-family: 'Nunito', sans-serif;
    transition: color 0.2s ease;
    user-select: none;
}

.char-counter.near-limit {
    color: var(--apoidea-yellow);
    font-weight: 600;
}

.char-counter.over-limit {
    color: var(--apoidea-pink);
    font-weight: 700;
}

/* Print: Zeichenzähler ausblenden */
@media print {
    .char-counter {
        display: none !important;
    }
    
    .portfolio-textbox-wrapper {
        display: contents;
    }
}

/* Fullscreen-Modus: Zeichenzähler anpassen */
.fullscreen-edit-page .char-counter {
    font-size: 10pt;
    padding: 6px 10px 4px 0;
}

/* Mobile: Zeichenzähler etwas kleiner */
@media (max-width: 600px) {
    .char-counter {
        font-size: 8pt;
        padding: 3px 6px 1px 0;
    }
}
