:root {
    --bg-color: #0a0a0a;
    --accent-color: #eb8921;
    --text-color: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(255, 255, 255, 0.03);
    --top-bar-h: 42px;
    --bottom-bar-h: 48px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'Montserrat', sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* V1070: Universal Scrollbar Cleanup */
::-webkit-scrollbar {
    display: none;
}
* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* V1075: Exception for Admin Panel Name Input */
#new-catalog-name {
    user-select: text !important;
    -webkit-user-select: text !important;
}

/* --- LOADING OVERLAY --- */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100000;
}

.brand-entrance {
    margin-bottom: 40px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.splash-emblem {
    height: 80px; /* Reduced from 100px for better mobile fit */
    max-width: 85vw; /* Safety: Never wider than 85% of screen */
    width: auto;
    object-fit: contain;
    margin-bottom: 30px;
    filter: drop-shadow(0 10px 30px rgba(235, 137, 33, 0.2));
    animation: splashEntrance 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes splashEntrance {
    0% { opacity: 0; transform: scale(0.9) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.brand-logo {
    font-family: 'Montserrat', sans-serif;
    font-size: 48px;
    font-weight: 300;
    letter-spacing: 20px;
    margin-right: -20px;
    color: white;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.loading-spinner {
    width: 30px;
    height: 30px;
    margin-left: -5px;
    /* Offset calibration for GND brand tracking */
    border: 2px solid rgba(235, 137, 33, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

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

#loading-progress-container {
    width: 200px;
    height: 2px;
    background: rgba(255, 255, 255, 0.05);
    margin-top: 20px;
    border-radius: 2px;
    overflow: hidden;
}

#loading-progress-bar {
    width: 0%;
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

/* --- LIBRARY VIEW --- */
#library-view {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    padding: 20px 40px; /* Reduced from 60px 40px */
    overflow-y: auto;
    background: var(--bg-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
}

/* --- LIBRARY BRANDING (V344) --- */
#library-view {
    padding-top: 20px;
    background: #050505;
    min-height: 100vh;
}

.library-header {
    text-align: center;
    margin-bottom: 25px; /* Reduced from 60px */
    padding: 0 40px;
    position: relative; 
    display: flex;
    flex-direction: column;
    align-items: center;
}

.library-top-left-logo {
    position: absolute;
    top: -10px;
    left: 20px;
    height: 60px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.library-top-left-logo:hover {
    transform: scale(1.1);
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.2));
}

.lib-logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

#admin-trigger {
    background: rgba(255, 255, 255, 0.03);
    /* Neutral glass */
    border: 1px solid rgba(235, 137, 33, 0.4);
    /* Thinner accent border */
    color: var(--accent-color);
    padding: 24px 50px;
    /* Slightly reduced volume */
    border-radius: 12px;
    font-family: 'Montserrat', sans-serif;
    font-size: 18px;
    /* Slightly reduced font */
    font-weight: 800;
    letter-spacing: 6px;
    /* Reduced tracking */
    display: none;
    /* Controlled by JS */
    align-items: center;
    gap: 18px;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(25px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    /* Muted shadow */
    text-shadow: none;
    /* Removed neon text shadow */
}

#admin-trigger svg {
    width: 32px;
    height: 32px;
    stroke-width: 2.5;
}

#admin-trigger:hover {
    background: var(--accent-color);
    color: black;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 10px 30px rgba(235, 137, 33, 0.2);
}

#admin-trigger svg {
    opacity: 0.8;
}

.header-logo {
    font-family: 'Playfair Display', serif;
    font-size: 42px; /* Reduced from 52px */
    font-weight: 900;
    letter-spacing: 12px; /* Reduced tracking */
    color: white;
    margin-bottom: 15px; /* Reduced from 20px */
    text-transform: uppercase;
    margin-top: -10px; /* Pulling it even higher */
}

.header-logo span {
    color: var(--accent-color);
    font-weight: 300;
}

.header-status {
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 6px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    position: relative;
    display: inline-block;
    padding: 0 40px;
    /* Buffer for lines */
}

.header-status::before,
.header-status::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40px;
    height: 1px;
    background: rgba(235, 137, 33, 0.3);
}

.header-status::before {
    left: -10px;
}

.header-status::after {
    right: -10px;
}

#catalog-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.catalog-card {
    width: 280px; /* Locked size for consistent 4-column math */
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 24px; /* Back to original */
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.catalog-card:hover {
    transform: translateY(-8px);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.catalog-cover {
    aspect-ratio: 1/1.414;
    background: #1a1a1a;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px; /* Back to original */
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transition: transform 0.4s ease;
}

.catalog-card:hover .catalog-cover {
    transform: scale(1.02);
}

.cat-gloss {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%, rgba(0, 0, 0, 0.1) 100%);
    z-index: 2;
}

.cat-fold {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(225deg, transparent 50%, rgba(255, 255, 255, 0.05) 50%);
    border-radius: 0 0 0 4px;
    z-index: 3;
}

/* --- CATALOG MANAGEMENT ACTION BAR (V345) --- */
.cat-management {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    z-index: 10;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.catalog-card:hover .cat-management {
    opacity: 1;
    transform: translateY(0);
}

.cat-icon-btn {
    width: 36px;
    height: 36px;
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.cat-icon-btn:hover {
    transform: scale(1.1);
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: black;
}

.cat-icon-btn.delete:hover {
    background: #ff453a;
    border-color: #ff453a;
    color: white;
}

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

.catalog-info h4 {
    font-family: 'Montserrat', sans-serif;
    font-size: 13px; /* Back to original */
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
}

/* --- VIEWPORT --- */
/* --- V274: BULLET-PROOF VIEWPORT SAFETY --- */
#viewport {
    display: none;
    /* Sovereign Guard: Hidden until active */
    position: fixed !important;
    inset: 0 !important;
    background: #000 !important;
    z-index: 1000 !important;
}

/* Only show viewport if explicitly requested by JS */
body.is-viewing-catalog #viewport {
    display: block !important;
}

#zoom-viewport {
    position: fixed !important;
    inset: 0 !important;
    background: transparent;
    z-index: 1000;
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
    /* Managed by JS for top-bar */
    pointer-events: auto !important;
    /* V292: Restoration of clickability */
    overflow: visible !important;
}

#zoom-content {
    position: relative !important;
    z-index: 1010;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    flex-shrink: 0;
}

#flipbook-container {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

#flipbook {
    position: relative !important;
    margin: 0 auto;
}

.turn-viewport {
    overflow: visible !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.turn-wrapper,
.turnjs-wrapper {
    margin: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

.page {
    background: transparent;
    background-size: 100% 100% !important;
}

.page canvas,
.page img {
    width: 100%;
    height: 100%;
    display: block;
}

/* V207.2: Unified Zoom Toggle Icon Support */
.zoom-icon circle,
.zoom-icon line {
    stroke: currentColor;
}

.zoom-minus {
    display: block;
}

.zoom-plus {
    display: block;
}

/* --- V224: APP BAR SYSTEM --- */
.app-bar {
    position: fixed;
    left: 0;
    width: 100%;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(30px);
    z-index: 9999 !important;
    display: flex;
    align-items: center;
    padding: 0 40px;
    box-sizing: border-box;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-bar.top {
    top: 0;
    height: 42px;
    border-bottom: 1px solid rgba(235, 137, 33, 0.1);
    justify-content: space-between;
    padding: 0 20px;
    position: relative;
}

.top-bar-center-logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.top-bar-emblem-img {
    height: 24px;
    width: auto;
    object-fit: contain;
}

.app-bar.bottom {
    bottom: 0;
    height: 48px;
    border-top: 1px solid rgba(235, 137, 33, 0.1);
    justify-content: center;
    padding: 0 20px;
}

body.is-loading .app-bar {
    display: none;
}

/* --- NAVIGATION & CONTROLS --- */
#controls {
    display: flex;
    align-items: center;
    gap: 24px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

#controls button {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-color);
    color: black;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    touch-action: manipulation;
}

/* V1640: Invisible hit-area expansion for touch safety without visual overflow */
#controls button::after {
    content: '';
    position: absolute;
    top: -10px;
    bottom: -10px;
    left: -8px;
    right: -8px;
}

#controls button:active {
    transform: scale(0.9);
}

#page-display {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    margin: 0 15px;
    color: white;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

/* --- V221: SEARCH WRAPPER & BOX --- */
#search-wrapper {
    margin: 0;
}

#search-box {
    display: flex;
    align-items: center;
    background: #000;
    border: 1px solid rgba(235, 137, 33, 0.3);
    padding: 3px 10px;
    border-radius: 50px;
    gap: 6px;
    cursor: text;
    transition: all 0.3s ease;
    width: fit-content; /* V1655: Prevent expansion */
}

#search-icon {
    display: flex;
    align-items: center;
    color: var(--accent-color);
}

#global-search-input {
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    width: 80px;
    transition: all 0.3s ease;
}

#global-search-input:focus {
    width: 180px;
}

#global-search-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.top-nav-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 6px 14px;
    border-radius: 50px;
    font-family: 'Montserrat', sans-serif;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-glass:hover {
    background: var(--accent-color) !important;
    border-color: var(--accent-color);
    color: black;
}

.btn-fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    border: none;
    color: black;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-fullscreen:hover {
    transform: scale(1.1);
}

.fs-icon-exit {
    display: none;
}

.is-fullscreen .fs-icon-enter {
    display: none;
}

.is-fullscreen .fs-icon-exit {
    display: block;
}

/* V1455: Adaptive Side Navigation (Desktop: Elegant | Kiosk: Mega) */
.side-nav-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 96px;
    height: 150px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(20px);
    border: 1px solid var(--accent-color);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
    opacity: 1 !important;
}

/* Mega-Size Override strictly for Kiosk/Touch */
body.is-touch .side-nav-btn {
    width: 144px;
    height: 225px;
    background: rgba(10, 10, 10, 0.95);
    border-width: 3px;
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.side-nav-btn svg {
    width: 48px;
    height: 48px;
    transition: transform 0.2s ease;
}

/* Mega-Icon Override for Kiosk/Touch */
body.is-touch .side-nav-btn svg {
    width: 72px;
    height: 72px;
}

.side-nav-btn.is-active {
    display: flex;
}

.side-nav-btn:hover {
    background: rgba(235, 137, 33, 0.2);
    border-color: white;
}

#side-nav-prev {
    left: 0;
    border-radius: 0 50px 50px 0;
}

#side-nav-next {
    right: 0;
    border-radius: 50px 0 0 50px;
}

/* --- ADMIN --- */
#admin-trigger {
    background: rgba(235, 137, 33, 0.1);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 14px;
    border-radius: 50px;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    transition: all 0.3s;
}

#admin-trigger:hover {
    background: var(--accent-color);
    color: black;
}

.modal-wrapper {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    z-index: 20000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-hidden {
    display: none !important;
}

.modal-active {
    display: flex !important;
}

.modal-container {
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 480px;
    max-width: 90vw;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 60px 20px 60px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
}

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

.modal-header h3 {
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--accent-color);
}

/* --- SEARCH PANEL --- */
#search-panel {
    position: fixed;
    top: 42px !important;
    bottom: 0 !important;
    height: auto !important;
    left: 0;
    width: 320px;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 5000;
    padding: 30px;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s ease;
}

#search-panel.modal-hidden {
    transform: translateX(-100%);
    display: flex !important;
}

.search-header {
    position: relative;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

.search-header h3 {
    font-size: 14px;
    letter-spacing: 2px;
    opacity: 0.9;
    margin: 0 0 5px 0;
}

#search-results-info {
    font-size: 11px;
    opacity: 0.5;
}

#search-panel-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 32px;
    height: 32px;
    background: #ff3b30;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
    z-index: 100;
}

#search-panel-close:hover {
    background: #ff453a;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 15px rgba(255, 59, 48, 0.5);
}

#search-results-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 20px;
}

.search-result-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.search-result-item:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--accent-color);
}

/* --- ADMIN PANEL POLISH (V343) --- */
#admin-panel .modal-header {
    position: relative;
    padding-bottom: 20px;
}

#admin-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: #ff3b30;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
    z-index: 100;
}

#admin-close:hover {
    background: #ff453a;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 15px rgba(255, 59, 48, 0.5);
}

/* --- V1050: REFINED UPLOAD FLOW STYLES --- */
.upload-dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.02);
}

.upload-dropzone:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-color);
}

.upload-dropzone.is-attached {
    border-color: #34c759;
    background: rgba(52, 199, 89, 0.05);
    border-style: solid;
}

#confirm-upload-btn {
    background: #34c759;
    color: white;
    padding: 18px;
    border-radius: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 30px rgba(52, 199, 89, 0.2);
}

#confirm-upload-btn:hover {
    background: #30b353;
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(52, 199, 89, 0.3);
}

#new-catalog-name:focus {
    border-color: var(--accent-color) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 0 20px rgba(235, 137, 33, 0.1);
}

/* --- CUSTOM DIALOG STYLES (V347) --- */
#custom-dialog .modal-container {
    border: 1px solid rgba(235, 137, 33, 0.3);
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.8), 0 0 30px rgba(235, 137, 33, 0.1);
    background: rgba(15, 15, 15, 0.98);
    backdrop-filter: blur(40px);
    border-radius: 16px;
    padding: 30px;
}

#dialog-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: #ff3b30;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
    z-index: 100;
}

#dialog-close:hover {
    background: #ff453a;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 15px rgba(255, 59, 48, 0.5);
}

#custom-dialog .modal-header h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--accent-color);
    margin: 0;
}

#dialog-msg {
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    margin: 20px 0;
    line-height: 1.6;
}

#dialog-input {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    padding: 14px !important;
    border-radius: 10px !important;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    color: white;
    transition: all 0.3s ease;
}

#dialog-input:focus {
    border-color: var(--accent-color) !important;
    background: rgba(255, 255, 255, 0.07) !important;
    box-shadow: 0 0 15px rgba(235, 137, 33, 0.2);
}

.dialog-actions {
    margin-top: 30px;
}

.dialog-actions button {
    padding: 12px 24px !important;
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 800;
    border-radius: 8px !important;
}

#dialog-confirm {
    background: var(--accent-color) !important;
    box-shadow: 0 4px 15px rgba(235, 137, 33, 0.3);
}

#dialog-confirm:hover {
    background: white !important;
    transform: translateY(-2px) scale(1.02);
}

#dialog-cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
}

#dialog-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.res-page {
    font-family: 'Montserrat', sans-serif;
    font-size: 10px;
    font-weight: 800;
    color: var(--accent-color);
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.res-snippet {
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    line-height: 1.5;
    opacity: 0.7;
}

.res-snippet strong {
    color: white;
    background: rgba(212, 175, 55, 0.3);
    padding: 0 2px;
}

/* --- VIRTUAL KEYBOARD --- */
#virtual-keyboard {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    max-width: 95vw;
    background: rgba(10, 10, 10, 0.75);
    backdrop-filter: blur(30px);
    z-index: 10000;
    padding: 24px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 20px rgba(255,255,255,0.02);
}

/* V220: Balanced Mobile Keyboard Scaling */
@media (max-width: 600px) {
    #virtual-keyboard {
        padding: 10px 6px !important;
        bottom: 8px !important;
        border-radius: 16px !important;
        transform: translateX(-50%) scale(0.96) !important;
        transform-origin: bottom center;
        max-width: 98vw !important;
    }
    .kb-row {
        gap: 3px !important;
        margin-bottom: 5px !important;
    }
    .kb-btn {
        padding: 12px 4px !important;
        min-width: 26px !important; /* Balanced for 12-key rows */
        font-size: 13px !important;
        border-radius: 6px !important;
    }
    .kb-btn.action {
        min-width: 45px !important;
        font-size: 10px !important;
    }
    .kb-btn.primary {
        min-width: 75px !important;
        font-size: 12px !important;
        gap: 5px !important;
    }
    .kb-btn svg {
        width: 15px !important;
        height: 15px !important;
    }
    .keyboard-footer {
        gap: 5px !important;
        margin-top: 10px !important;
    }
    .kb-btn-close {
        min-width: 45px !important;
        font-size: 22px !important;
    }
}

/* V230: Critical Landscape Optimization for Mobile */
@media (orientation: landscape) and (max-height: 500px) {
    #virtual-keyboard {
        padding: 5px 10px !important;
        bottom: 2px !important;
        transform: translateX(-50%) !important; /* Removed scaling to restore touch accuracy */
        width: 98vw !important;
        max-width: 900px !important;
    }
    .kb-row {
        margin-bottom: 3px !important;
        gap: 4px !important;
    }
    .kb-btn {
        padding: 5px 8px !important; /* Very short height, but preserved width */
        min-width: 35px !important;
        height: 34px !important;
        font-size: 15px !important;
    }
    .keyboard-footer {
        margin-top: 3px !important;
        gap: 6px !important;
    }
    .kb-btn.action, .kb-btn.primary {
        height: 34px !important;
        padding: 0 10px !important;
    }
}

.keyboard-hidden {
    transform: translate(-50%, 150%);
    opacity: 0;
    pointer-events: none;
}

.keyboard-inner {
    max-width: 1000px;
    margin: 0 auto;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.kb-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 15px;
    min-width: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.kb-btn:active {
    background: var(--accent-color);
    color: black;
    transform: scale(0.95);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

.kb-btn.action {
    background: rgba(255, 255, 255, 0.1);
    min-width: 80px;
}

.kb-btn.primary {
    background: var(--accent-color);
    color: black;
    min-width: 140px;
    gap: 10px;
    font-weight: 800;
    letter-spacing: 1px;
}

.kb-btn-close {
    background: #ff3b30 !important;
    color: white !important; 
    font-size: 28px !important;
    font-weight: 900 !important;
    min-width: 60px !important;
    box-shadow: 0 4px 15px rgba(255, 59, 48, 0.4);
}

.kb-btn-close:hover {
    background: #ff453a !important;
    transform: scale(1.05);
}

.keyboard-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 15px;
}

#drop-zone:hover {
    opacity: 1;
    border-color: var(--accent-color);
    background: rgba(212, 175, 55, 0.05);
}

/* V1637: Admin Auth Modal Premium Redesign */
.auth-modal {
    max-width: 400px !important;
    background: rgba(20, 20, 20, 0.95) !important;
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8);
    border-radius: 20px !important;
}

.auth-modal .modal-header h3 {
    font-weight: 800;
    letter-spacing: 2px;
    font-size: 13px;
    color: var(--accent-color);
}

.auth-input-group {
    padding: 30px 10px;
    text-align: center;
}

.auth-input-group p {
    font-size: 13px;
    opacity: 0.6;
    margin-bottom: 25px;
    letter-spacing: 0.5px;
    font-weight: 500;
}

#admin-password-input {
    width: 90%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 20px;
    border-radius: 14px;
    text-align: center;
    font-size: 24px;
    letter-spacing: 8px;
    outline: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#admin-password-input:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 4px rgba(235, 137, 33, 0.1);
}

#admin-login-btn {
    height: 54px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-color), #f7b733);
    color: black;
    font-weight: 800;
    letter-spacing: 1.5px;
    font-size: 13px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(235, 137, 33, 0.2);
}

#admin-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(235, 137, 33, 0.3);
    background: linear-gradient(135deg, #f7b733, var(--accent-color));
}

#admin-login-btn:active {
    transform: scale(0.98);
}

#auth-return-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-decoration: none;
    transition: all 0.3s;
}

#auth-return-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* --- FULLSCREEN --- */
.fs-icon-exit {
    display: none;
}

body.is-fullscreen .fs-icon-enter {
    display: none;
}

body.is-fullscreen .fs-icon-exit {
    display: block;
}

/* V1665: Fullscreen Hardening for Mobile */
@media (max-width: 1024px) {
    body.is-fullscreen #bottom-bar {
        background: rgba(10, 10, 10, 0.6) !important; /* Higher transparency in FS */
        backdrop-filter: blur(10px);
    }
}

/* V1514: Comprehensive Mobile & Tablet Hardening (Under 1024px) */
@media (max-width: 1024px) {
    #catalog-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
        padding: 10px !important;
    }

    .library-header {
        flex-direction: column;
        gap: 12px;
        padding-top: 80px;
    }

    .brand-logo, .header-logo { 
        font-size: 24px !important;
        letter-spacing: 4px !important;
    }
    
    #top-bar { 
        padding: 0 15px; 
    }
    
    .top-nav-controls {
        width: 100%;
        justify-content: space-between;
        gap: 0 !important;
    }

    /* V1650: Aggressive Search Shrink for Mobile Portrait */
    #global-search-input {
        width: 65px !important; 
        font-size: 10px !important;
        letter-spacing: 0.5px !important;
    }
    #global-search-input:focus {
        width: 110px !important;
        max-width: 35vw;
    }
    #search-box {
        padding: 2px 8px !important;
        gap: 4px !important;
    }

    #controls {
        position: fixed !important;
        bottom: 20px !important;
        width: 96vw !important;
        left: 2vw !important;
        padding: 8px 16px !important; /* Slightly increased side padding */
        gap: 16px !important; /* Increased gap to prevent hit-area overlap */
        z-index: 3000; 
        background: rgba(10, 10, 10, 0.9) !important;
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 50px;
        justify-content: center !important;
        pointer-events: auto !important;
    }

    #bottom-bar.app-bar.bottom {
        background: transparent !important;
        border: none !important;
        pointer-events: none;
    }

    .btn-glass {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .btn-glass span { display: none; }

    .side-nav-btn {
        display: flex !important;
        width: 44px !important;
        height: 70px !important;
        border-radius: 4px;
        background: rgba(0, 0, 0, 0.4) !important;
    }

    .side-nav-btn svg {
        width: 24px !important;
        height: 24px !important;
    }

    #side-nav-prev { border-radius: 0 12px 12px 0; }
    #side-nav-next { border-radius: 12px 0 0 12px; }

    #flipbook-container {
        margin-top: 10px;
    }
}

@media (max-width: 600px) {
    #catalog-grid {
        grid-template-columns: 1fr !important;
    }

    .brand-logo {
        font-size: 22px !important;
        letter-spacing: 2px !important;
    }

    #zoom-in, #zoom-out {
        display: none !important;
    }

    #controls {
        flex-wrap: nowrap !important;
        justify-content: center;
        height: auto;
        padding: 8px 8px !important;
        gap: 6px !important;
    }

    #controls .control-group {
        gap: 6px !important;
    }

    #page-display {
        margin: 0 2px !important;
        padding: 6px 4px !important;
        font-size: 11px !important;
        min-width: 85px !important; /* V1645: Locked width to prevent layout jump on multi-page text */
        text-align: center;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #close-catalog {
        width: 44px;
        height: 44px;
        top: 10px;
        right: 10px;
    }

    /* Floating pill → bottom-bar içine al (controls static) */
    #bottom-bar.app-bar.bottom {
        height: auto !important;
        min-height: 60px !important;
        background: rgba(8, 8, 8, 0.97) !important;
        border-top: 1px solid rgba(235, 137, 33, 0.2) !important;
        pointer-events: auto !important;
        padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #controls {
        position: static !important;
        bottom: auto !important;
        left: auto !important;
        width: auto !important;
        background: transparent !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: auto !important;
    }

    #controls button {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        flex-shrink: 0 !important;
    }

    /* Yan nav butonları — ince şerit */
    .side-nav-btn {
        width: 34px !important;
        height: 54px !important;
        background: rgba(0, 0, 0, 0.5) !important;
        border-width: 1px !important;
    }

    .side-nav-btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    #side-nav-prev { border-radius: 0 8px 8px 0 !important; }
    #side-nav-next { border-radius: 8px 0 0 8px !important; }
}

/* V912: Search Inline Validation */
.search-error-msg {
    color: #ff453a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 3px;
    text-align: center;
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.search-error-msg.is-visible {
    opacity: 1;
    height: 14px;
    margin-top: 3px;
}

/* V1637: Admin Header Group & Quick Logout - Stacked Right */
.admin-header-group {
    position: absolute;
    top: 15px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    z-index: 1000;
}

.btn-logout {
    background: rgba(220, 53, 69, 0.1); 
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #ff6b6b;
    padding: 10px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    letter-spacing: 1.5px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.btn-logout:hover {
    background: rgba(220, 53, 69, 0.15);
    border-color: #ff6b6b;
    transform: translateY(-2px);
}
