@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

/* --- High-Fidelity Tooltip System --- */
[data-tooltip] { position: relative; }
[data-tooltip]::before, [data-tooltip]::after {
    position: absolute; left: 50%; transform: translateX(-50%) translateY(10px);
    opacity: 0; visibility: hidden; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; z-index: 9999;
}
[data-tooltip]::before {
    content: attr(data-tooltip); bottom: calc(100% + 12px); width: max-content; max-width: 200px;
    padding: 8px 14px; background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(8px);
    color: white; font-size: 11px; font-weight: 700; font-family: 'Poppins', sans-serif;
    text-transform: uppercase; letter-spacing: 0.05em; border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); text-align: center; border: 1px solid rgba(255, 255, 255, 0.1);
}
[data-tooltip]::after {
    content: ''; bottom: calc(100% + 4px); border: 6px solid transparent; border-top-color: rgba(15, 23, 42, 0.95);
}
[data-tooltip]:hover::before, [data-tooltip]:hover::after { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

[data-tooltip-pos="bottom"]::before { top: calc(100% + 12px); bottom: auto; }
[data-tooltip-pos="bottom"]::after { top: calc(100% + 4px); bottom: auto; border-top-color: transparent; border-bottom-color: rgba(15, 23, 42, 0.95); }

:root {
    scroll-behavior: smooth;
    --paper: #ffffff;
    --ink: #0f172a;
    --accent: #6366f1;
    --accent-dark: #4f46e5;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --line: rgba(226, 232, 240, 0.8);
    --muted: #64748b;
    --panel: rgba(255, 255, 255, 0.82);
    --panel-border: rgba(255, 255, 255, 0.7);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.03);
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.08);
    --soft: #f8fafc;
    --soft-strong: #f1f5f9;
    --bg-page: #f8fafc;
    --input-bg: #fff;
    --input-border: #e2e8f0;
    --card-bg: #fff;
    --card-border: var(--line);
    --btn-subtle-bg: #fff;
    --btn-subtle-border: #e2e8f0;
    --btn-subtle-text: #475569;
    --radial-glow-1: rgba(99, 102, 241, 0.08);
    --radial-glow-2: rgba(168, 85, 247, 0.08);
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --topbar-bg: rgba(255, 255, 255, 0.85);
    --topbar-text: var(--ink);
    --topbar-label: var(--muted);
}

[data-theme="dark"] {
    --paper: #1e293b;
    --ink: #f1f5f9;
    --accent: #818cf8;
    --accent-dark: #6366f1;
    --accent-light: #a5b4fc;
    --accent-glow: rgba(129, 140, 248, 0.4);
    --accent-gradient: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    --accent-gradient-hover: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --line: rgba(255, 255, 255, 0.08);
    --muted: #94a3b8;
    --panel: rgba(30, 41, 59, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.4);
    --soft: rgba(255, 255, 255, 0.04);
    --soft-strong: rgba(255, 255, 255, 0.08);
    --bg-page: #0f172a;
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(30, 41, 59, 0.5);
    --card-border: rgba(255, 255, 255, 0.1);
    --btn-subtle-bg: rgba(255, 255, 255, 0.06);
    --btn-subtle-border: rgba(255, 255, 255, 0.1);
    --btn-subtle-text: #e2e8f0;
    --radial-glow-1: rgba(99, 102, 241, 0.18);
    --radial-glow-2: rgba(168, 85, 247, 0.18);
    --topbar-bg: rgba(15, 23, 42, 0.85);
    --topbar-text: #fff;
    --topbar-label: rgba(255, 255, 255, 0.7);
}

* {

    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background-color: var(--bg-page);
    background-image:
        radial-gradient(circle at 10% 0%, var(--radial-glow-1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, var(--radial-glow-2) 0%, transparent 40%);
    background-attachment: fixed;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: grid;
    grid-template-rows: 50px 1fr;
    min-height: 100vh;
}

h1,
h2,
h3,
h4 {
    font-family: 'Poppins', sans-serif;
    margin-top: 0;
    letter-spacing: -0.04em;
    color: var(--ink);
    line-height: 1.2;
}

h1 {
    font-size: 40px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    padding-bottom: 0.1em;
    filter: drop-shadow(0 4px 12px var(--accent-glow));
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 18px;
    font-weight: 700;
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

.container {
    width: min(1200px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 0;
}

/* Force Reset for Professional Views (Studio & Management) */
body:has(.canva-shell, .hero, .grid.two) .container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

body:has(.canva-shell, .hero, .grid.two) main.container {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    grid-row: 2;
    /* Explicitly second row */
}

/* Full Bleed Editor Override */
.page-editor.canva-shell {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
    overflow-x: hidden !important;
}

.hero,
.panel {
    background: var(--panel);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Premium Entrance Animations */
.animate-fade-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1), transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-fade-in {
    opacity: 0;
    transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-scale-in {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1), transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-fade-up.visible,
.animate-fade-in.visible,
.animate-scale-in.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.delay-100 {
    transition-delay: 100ms;
}

.delay-200 {
    transition-delay: 200ms;
}

.delay-300 {
    transition-delay: 300ms;
}

.delay-400 {
    transition-delay: 400ms;
}

.delay-500 {
    transition-delay: 500ms;
}

.hero {
    min-height: 55vh;
    padding: 2.5rem 2rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.75rem;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, var(--radial-glow-1), transparent 70%);
    pointer-events: none;
}

.panel {
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
}

.grid,
.stack,
.book-grid,
.page-list,
.preview-grid {
    display: grid;
    gap: 1.25rem;
}

/* Professional Page Sequencer & Reordering Hub */
.page-thumb-list {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 2rem !important;
    padding: 1.5rem 0.5rem !important;
    min-height: 320px;
    align-items: flex-start !important;
}

.page-thumb-card {
    flex: 0 0 220px !important;
    width: 220px !important;
    min-height: 280px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    cursor: grab;
}

.page-thumb-card:active {
    cursor: grabbing;
}

.page-thumb-card.add-page-card {
    cursor: pointer;
    border: 2px dashed var(--accent-glow);
    background: rgba(99, 102, 241, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.page-thumb-card.add-page-card:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--accent);
}

.page-thumb-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--accent-light);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Sortable.js Visual Feedback */
.sortable-ghost {
    opacity: 0.3 !important;
    background: var(--soft-strong) !important;
    border: 2px dashed var(--accent) !important;
    transform: scale(0.95);
}

.sortable-chosen {
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.25) !important;
    border-color: var(--accent) !important;
    z-index: 1000;
}

.sortable-drag {
    cursor: grabbing !important;
    transform: rotate(2deg) scale(1.05) !important;
}

.page-thumb-preview {
    height: 180px;
    background: var(--soft);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.page-thumb-meta {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.page-thumb-overlay {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: all 0.3s ease;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-thumb-card:hover .page-thumb-overlay {
    opacity: 1;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
}

/* Refined Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3rem;
}

.header-title-block h2 {
    font-size: 26px;
    margin: 0;
    letter-spacing: -0.02em;
}

.header-divider {
    height: 1px;
    flex: 1;
    background: var(--line);
    margin: 0 2.5rem;
    opacity: 0.5;
}

.stat-badge {
    background: var(--ink);
    color: var(--paper);
    padding: 0.65rem 1.4rem;
    border-radius: 14px;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Dashboard Refinements */
.stat-card {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--card-border);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.1);
    border-color: var(--accent-glow);
}

.book-card {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.12);
}

.book-card:hover .book-card-cover img {
    transform: scale(1.08);
}

.book-card-cover {
    overflow: hidden;
    position: relative;
    border-radius: 12px;
}

.book-card-cover img {
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.button[href*="action=book-edit"] {
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: all 0.3s ease;
}

.button[href*="action=book-edit"]:hover {
    box-shadow: 0 8px 24px var(--accent-glow);
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* Page Indicator for Dashboard */
.pages-indicator {
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent);
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}

/* --- Dashboard UI Components --- */
.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-size: clamp(12px, 0.85vw, 14px);
    font-weight: 600;
    color: var(--ink);
    padding: 0.35rem 0.75rem;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 9px;
    transition: all 0.2s ease;
}

.file-item:hover {
    background: var(--paper);
    border-color: var(--accent-glow);
    transform: translateY(-1px);
}

.file-item .icon {
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.file-item .label {
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

/* Editor Specifics */
.canva-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 100vh;
    box-sizing: border-box;
}

.canva-topbar {
    width: 100% !important;
    max-width: 100% !important;
    height: 52px !important;
    min-height: 52px !important;
    background: var(--paper) !important;
    border-bottom: 1px solid var(--line) !important;
    position: sticky;
    top: 50px;
    /* Match the 50px global nav */
    left: 0;
    right: 0;
    z-index: 2200;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    padding: 0 1.5rem !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}


.canva-topbar::-webkit-scrollbar {
    display: none;
}

.canva-topbar-sections {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    gap: 16px !important;
}

.canva-brand {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    height: 100% !important;
}

.topbar-left-zone,
.topbar-center-zone,
.topbar-right-zone {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    gap: 12px !important;
    flex-shrink: 0 !important;
}

.topbar-center-zone {
    justify-content: center !important;
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
}

.center-content-orchestrator {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 16px !important;
    width: 100% !important;
}

/* Stable Sticky Formatting Panel (Strictly Attached) */
.text-toolbar {
    position: sticky !important;
    top: 5px !important;
    left: auto !important;
    transform: none !important;
    z-index: 10 !important;
    flex-direction: row !important;
    width: auto !important;
    max-width: 98% !important;
    height: 48px !important;
    padding: 0 16px !important;
    margin: 0 auto 15px !important;
    background: #ffffff !important;
    border: 1px solid #dddddd !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    animation: none !important;
    transition: none !important;
}

.text-toolbar .hub-label {
    display: flex !important;
    align-items: center !important;
    flex-direction: row !important;
    gap: 8px !important;
    padding-right: 12px !important;
    border-right: 1px solid #eeeeee !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-right: 12px !important;
    text-align: left !important;
    white-space: nowrap !important;
}

.text-toolbar .hub-icon {
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
}

.text-toolbar select.toolbar-select {
    width: auto !important;
    min-width: 100px !important;
    height: 36px !important;
    padding: 0 8px !important;
    font-size: 13px !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 500 !important;
    color: #0f172a !important; /* Explicit deep indigo */
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    display: inline-block !important;
    appearance: menulist !important; /* Force native dropdown arrow and text rendering */
    -webkit-appearance: menulist !important;
}

.text-toolbar select.toolbar-select option {
    background: #ffffff !important;
    color: #0f172a !important;
}

.text-toolbar .size-control-group {
    flex-direction: row !important;
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
}

.text-toolbar .size-control-group input {
    width: 50px !important;
    border-top: 1px solid #d1d5db !important;
    border-bottom: 1px solid #d1d5db !important;
    border-left: none !important;
    border-right: none !important;
    height: 36px !important;
    text-align: center !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    font-size: 13px !important;
    background: #fff !important;
}

.text-toolbar .size-control-group .toolbar-btn.mini {
    width: 36px !important;
    height: 36px !important;
    background: #f1f5f9 !important;
    border: 1px solid #d1d5db !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    color: #0f172a !important;
}

.text-toolbar .style-toggle-group {
    flex-direction: row !important;
    gap: 6px !important;
}

.text-toolbar .toolbar-divider.mini {
    width: 1px !important;
    height: 24px !important;
    background: #eee !important;
    margin: 0 10px !important;
}

.text-toolbar[hidden] {
    display: none !important;
}

[data-theme="dark"] .text-toolbar select.toolbar-select,
[data-theme="dark"] .text-toolbar .size-control-group input {
    background: #0f172a !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

/* Elite Block Selection */
.editor-block.selected {
    box-shadow: 0 0 0 2px var(--accent), 0 12px 32px rgba(99, 102, 241, 0.25) !important;
    z-index: 1000 !important;
}

.editor-block.selected .editor-block-tag {
    background: var(--accent-gradient);
    color: white;
    transform: translateY(-100%) scale(1.05);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.editor-block-tag {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 10px;
    font-weight: 800;
    color: var(--muted);
    background: var(--soft-strong);
    padding: 2px 8px;
    border-radius: 6px 6px 0 0;
    transform: translateY(-100%);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.editor-block-frame {
    width: 100%;
    height: 100%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    overflow: hidden;
}

.editor-block:hover .editor-block-frame {
    border-color: var(--accent-light);
    background: rgba(99, 102, 241, 0.02);
}

.editor-block.selected .editor-block-frame {
    border-color: var(--accent);
    background: white;
}

.resize-handle {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid var(--accent);
    border-radius: 50%;
    cursor: nwse-resize;
    display: none;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.editor-block.selected .resize-handle {
    display: block;
    animation: bounceIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.resize-handle:hover {
    transform: scale(1.2);
    background: var(--accent);
    border-color: white;
}

.resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    transform: translate(-60%, -60%) rotate(0deg);
}

.resize-handle:hover::after {
    border-color: white;
}

.canva-topbar-fields {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 16px !important;
    height: 100% !important;
}

.canva-topbar-fields .field-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    height: 100% !important;
}

.canva-topbar-fields label {
    font-size: 10px !important;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    margin: 0 !important;
}

.canva-topbar-fields input {
    height: 32px !important;
    padding: 0 10px !important;
    border-radius: 6px !important;
    border: 1px solid var(--line) !important;
    background: #f8fafc !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    transition: all 0.2s;
}

.canva-topbar-fields input:focus {
    background: white !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-glow) !important;
}

.creation-tools,
.action-tools-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.canva-brand {
    display: flex;
    flex-direction: column;
}

.canva-brand strong {
    font-size: 13px !important;
    font-weight: 800;
    color: var(--text);
    display: block;
    line-height: 1;
    white-space: nowrap;
}

.canva-brand .hint {
    font-size: 9px !important;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.canva-topbar .toolbar-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    background: transparent;
    border: none !important;
    cursor: pointer !important;
    color: var(--ink) !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.canva-topbar .toolbar-btn:hover {
    background: var(--soft-strong) !important;
    transform: translateY(-2px) !important;
    color: var(--accent) !important;
}

.canva-topbar .toolbar-btn:active {
    transform: translateY(0) !important;
}

.canva-topbar .toolbar-btn.active,
.canva-topbar .toolbar-btn.active-menu {
    background: rgba(99, 102, 241, 0.12) !important;
    color: var(--accent) !important;
    box-shadow: 0 0 0 1px var(--accent-glow), 0 8px 20px var(--accent-glow) !important;
}

.canva-topbar .toolbar-btn.active svg,
.canva-topbar .toolbar-btn.active-menu svg {
    stroke: var(--accent) !important;
}

.dropdown-content.show {
    display: block !important;
    animation: dropdownPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

@keyframes dropdownPop {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.canva-topbar-fields input {
    height: 34px !important;
    padding: 0 10px !important;
    border-radius: 6px !important;
    border: 1px solid var(--line) !important;
    background: white !important;
    font-size: 13px !important;
    font-weight: 600 !important;
}

.canva-topbar-actions {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.canva-topbar .button {
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    white-space: nowrap !important;
}

.button.primary {
    background: var(--accent) !important;
    color: white !important;
    font-weight: 800 !important;
    padding: 0 1.25rem !important;
    height: 40px !important;
    border: none !important;
}

.button.compact {
    padding: 0 0.8rem !important;
    height: 40px !important;
}

.layout-tools .toolbar-btn {
    width: 38px;
    padding: 0;
    font-size: 16px;
}

.layout-tools .toolbar-btn[data-tool-action="toggle-safe"] {
    color: #f59e0b;
}

.layout-tools .toolbar-btn[data-tool-action="toggle-grid"] {
    color: #3b82f6;
}

.layout-tools .toolbar-btn[data-tool-action="bring-front"] {
    color: #10b981;
}

.layout-tools .toolbar-btn[data-tool-action="send-back"] {
    color: #8b5cf6;
}

.sidebar-shortcuts .toolbar-btn span {
    font-size: 12px;
}

.canva-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 0.5rem;
}

.canva-topbar-actions .button.subtle {
    height: 40px;
    padding: 0 16px;
    font-weight: 700;
}

.canva-topbar-actions .button:not(.subtle) {
    height: 40px;
    padding: 0 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    box-shadow: 0 4px 12px var(--accent-glow);
    font-weight: 700;
    border: none;
}

.sidebar-shortcuts {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 12px);
    right: -10px;
    min-width: 300px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.02);
    z-index: 2500;
    padding: 1rem;
    border-radius: 16px;
    animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown-content.preview-dropdown {
    width: 380px !important;
    max-width: 90vw !important;
    padding: 24px !important;
    right: -12px !important;
    left: auto !important;
}

.final-preview-shell {
    width: 100%;
    height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.03);
    border-radius: 12px;
    position: relative;
    border: 1px solid var(--line);
}

.final-preview-shell .a5-page {
    transform: scale(0.6);
    transform-origin: center center;
    box-shadow: 0 30px 60px -12px rgba(15, 23, 42, 0.25), 0 18px 36px -18px rgba(0, 0, 0, 0.3) !important;
    margin: 0 !important;
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    margin-left: -210px !important;
    /* Half of 420px */
    margin-top: -297px !important;
    /* Half of 594px */
}

.dropdown-content::after {
    content: '';
    position: absolute;
    top: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: white;
    border-left: 1px solid var(--panel-border);
    border-top: 1px solid var(--panel-border);
    transform: rotate(45deg);
    z-index: 10;
}

.canva-body.layout-full {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

.canva-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .canva-body {
        grid-template-columns: 1fr;
    }

    .canva-rightbar {
        order: 2;
        width: 100% !important;
        position: static !important;
    }

    .canva-stage-area {
        order: 1;
    }
}

@media (max-width: 768px) {
    .topbar-center-zone {
        display: none !important;
        /* Hide metadata fields on very small screens to favor tools */
    }

    .canva-topbar-sections {
        padding: 0 1rem;
    }

    .canva-stage-card {
        padding: 1.5rem 1rem;
    }

    .brand-glyph {
        display: none;
    }
}

/* Left Tools Ribbon */
.tool-rail {
    position: sticky;
    top: 5rem;
    padding: 1rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    background: var(--input-bg);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.tool-rail-head {
    margin-bottom: 1.25rem;
    text-align: center;
}

.tool-button {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 1rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--input-bg);
    color: var(--ink);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    box-shadow: var(--shadow-sm);
}

.tool-button:hover,
.tool-button.active {
    background: var(--soft-strong);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Stage Area */
.canva-stage-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background-color: var(--soft);
    background-image:
        radial-gradient(circle at 2px 2px, var(--line) 1px, transparent 0);
    background-size: 32px 32px;
    padding-top: 1rem;
}

.canva-stage-card {
    width: 100%;
    padding: 3rem 1.5rem;
    border: none;
    border-radius: 24px;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 80vh;
}

@media (max-width: 640px) {
    .canva-stage-card {
        padding: 1rem 0.5rem;
    }

    .a5-page {
        box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.2);
    }
}

.editor-stage-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.25rem;
    padding: 0.6rem 1.25rem;
    background: var(--input-bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
    z-index: 5;
}

.editor-stage {
    width: 600px;
    max-width: 100%;
    margin: 0 auto;
    box-shadow: 0 40px 100px -20px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.editor-stage:hover {
    transform: scale(1.02);
    box-shadow: 0 50px 120px -20px rgba(15, 23, 42, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* Right Inspector Panel */
.canva-rightbar .canva-panel {
    background: var(--input-bg);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.panel-head h3 {
    margin: 0;
    color: var(--ink);
}

.selected-layer-inspector {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.6);
}

/* Forms & Inputs */
label {
    display: grid;
    gap: 0.4rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--soft);
    color: var(--ink);
    border: 2px solid transparent;
    border-radius: 12px;
    box-shadow: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 0.5;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    background: var(--paper);
    border-color: var(--accent-light);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 18px;
    border: 0;
    border-radius: 10px;
    background: var(--accent-gradient);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px -2px rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
    gap: 8px;
}

.button::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 20px 30px -10px rgba(99, 102, 241, 0.5);
}

.button:hover::after {
    opacity: 1;
}

.button:active {
    transform: translateY(-1px) scale(0.98);
}

.button.subtle {
    background: var(--btn-subtle-bg);
    color: var(--btn-subtle-text);
    border: 1px solid var(--btn-subtle-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    padding: 8px 16px;
}

.button.subtle:hover {
    background: var(--soft-strong);
    color: var(--ink);
    border-color: var(--muted);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.button.danger {
    background: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.button.danger:hover {
    background: #dc2626;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

/* Layer List */
.layer-list {
    display: grid;
    gap: 0.6rem;
}

.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--ink);
    cursor: pointer;
    font-family: "Inter", sans-serif;
    font-weight: 500;
    transition: all 0.2s ease;
}

.layer-item:hover {
    background: var(--soft);
    border-color: var(--muted);
}

.layer-item.active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
    color: var(--accent-dark);
}

/* Scoped Page Sequencer (Editor Bottom Strip) */
#page-drag-wrapper {
  width: 100%;
  overflow: hidden;
  margin-top: 10px;
}

#page-drag-wrapper .canva-page-strip {
  display: flex !important;
  gap: 16px !important;
  align-items: flex-start !important;
  overflow-x: auto !important;
  padding: 10px 5px !important;
  flex-wrap: nowrap !important;
}

#page-drag-wrapper .canva-page-chip {
  width: 120px !important;
  min-width: 120px !important;
  flex-shrink: 0 !important;
  cursor: grab !important;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

#page-drag-wrapper .canva-page-chip:active {
  cursor: grabbing !important;
}

#page-drag-wrapper .canva-page-add {
  min-width: 120px !important;
  flex-shrink: 0 !important;
  pointer-events: auto !important;
}

/* Sortable Visual Markers */
#page-drag-wrapper .sortable-ghost {
    opacity: 0.3 !important;
    transform: scale(0.9) !important;
    background: var(--soft-strong) !important;
    border: 1px dashed var(--accent) !important;
}

#page-drag-wrapper .sortable-chosen {
    box-shadow: 0 20px 40px rgba(0,0,0,0.15) !important;
    border-color: var(--accent) !important;
    z-index: 5000 !important;
}

/* Base Styles Refinement */
.canva-bottom-strip {
    display: grid;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    background: var(--input-bg);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-sm);
    margin-top: 0;
}

.canva-page-strip {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.canva-page-strip::-webkit-scrollbar {
    height: 8px;
}

.canva-page-strip::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.canva-page-chip {
    flex: 0 0 130px;
    display: grid;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid transparent;
    border-radius: 20px;
    background: var(--paper);
    border: 1px solid var(--panel-border);
    text-decoration: none;
    color: var(--ink);
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.canva-page-chip:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.canva-page-chip.active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.03);
}

.canva-page-chip-thumb .a5-page {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.canva-page-add {
    flex: 0 0 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s;
}

.canva-page-add:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent);
}

/* Preview Grid for Online Reader */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.preview-grid>div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.preview-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    background: var(--soft-strong);
    padding: 0.35rem 1rem;
    border-radius: 99px;
}

.preview-grid .a5-page {
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.2), 0 10px 20px -5px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.preview-grid .a5-page:hover {
    transform: scale(1.02) translateY(-10px);
}

/* Books Grid */
.book-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .book-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.book-card {
    padding: 0;
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.book-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-light);
}

.book-card-cover {
    height: 160px;
    width: 100%;
    position: relative;
    overflow: hidden;
    background: var(--soft-strong);
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-card:hover .book-card-cover img {
    transform: scale(1.1);
}

.book-card-content {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.book-card h3 {
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
    color: var(--ink);
    letter-spacing: -0.03em;
}

.book-card-author {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

.book-card-description {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 1.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.text-balance {
    text-wrap: balance;
}

.book-card .actions {
    margin-top: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

/* Single Stripe Suite Legacy Cleanup */
.formatting-toolbar {
    display: none !important;
}

.formatting-toolbar::-webkit-scrollbar {
    display: none;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--line);
    margin: 0 4px;
    flex-shrink: 0;
}

.toolbar-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 70px;
    white-space: nowrap;
}

.toolbar-select {
    height: 34px !important;
    padding: 0 28px 0 10px !important;
    font-size: 13px;
    font-weight: 700;
    border-radius: 6px !important;
    background-color: white !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    border: 1px solid var(--line) !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    cursor: pointer;
    line-height: 1;
    color: var(--ink);
}

.toolbar-select.font-select {
    width: 130px;
}

.toolbar-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    border: 1px solid var(--line) !important;
    background: white !important;
    color: #475569 !important;
    cursor: pointer !important;
    padding: 0 !important;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.toolbar-btn:hover {
    background: white !important;
    color: var(--accent) !important;
    border-color: var(--accent-light) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.toolbar-btn.active {
    background: var(--accent-gradient) !important;
    color: white !important;
    border-color: var(--accent) !important;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.toolbar-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

.toolbar-input {
    height: 32px;
    padding: 0 8px !important;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px !important;
    background-color: var(--soft) !important;
    border: 1px solid var(--line) !important;
}

.toolbar-input.size-input {
    width: 48px !important;
    height: 30px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    text-align: center;
    background: #f1f5f9 !important;
    color: var(--ink) !important;
    border: 1px solid var(--line) !important;
    border-radius: 8px !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-picker-wrapper {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--line), 0 2px 8px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.toolbar-color {
    width: 200%;
    height: 200%;
    margin: -50%;
    padding: 0;
    border: none;
    cursor: pointer;
    background: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.toolbar-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    flex-shrink: 0;
}

.toolbar-btn:hover {
    background: var(--soft-strong);
    border-color: var(--line);
    color: var(--accent);
    transform: translateY(-1px);
}

.toolbar-btn.active {
    background: rgba(99, 102, 241, 0.12) !important;
    color: var(--accent) !important;
}

input[type="color"] {
    width: 32px;
    height: 32px;
    padding: 0 !important;
    border: 1px solid var(--line) !important;
    border-radius: 6px !important;
    cursor: pointer;
    background: transparent !important;
    overflow: hidden;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
}

@media (max-width: 768px) {
    .formatting-toolbar {
        height: auto;
        min-height: 48px;
        padding: 8px;
        flex-wrap: wrap;
        gap: 8px;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Core Canvas / A5 Layout */
.canva-stage-card .a5-page {
    width: min(98%, 1200px) !important;
    aspect-ratio: 210 / 297;
    height: auto !important;
    background: var(--paper);
    position: relative;
    border: 1px solid #ddd;
    box-shadow: none !important;
    transform: none !important;
}

/* Elite Page Edge Reflection */
.a5-page::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    z-index: 100;
    pointer-events: none;
}

.safe-area {
    position: absolute;
    inset: 6%;
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    pointer-events: none;
    z-index: 10;
}

/* Block Styles */
.editor-block {
    position: absolute;
    z-index: 2;
    min-width: 5%;
    min-height: 5%;
    cursor: move;
}

.editor-block-frame {
    position: relative;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-block:hover .editor-block-frame {
    border-color: rgba(99, 102, 241, 0.4);
}

.editor-block.selected .editor-block-frame {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.03);
    box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-lg);
}

.editor-block-tag {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    font-size: 10px;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    pointer-events: none;
    background: var(--paper);
    padding: 2px 8px;
    border-radius: 99px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--accent-glow);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 20;
}

.editor-block:hover .editor-block-tag,
.editor-block.selected .editor-block-tag {
    opacity: 1;
    transform: translateY(0);
}

.resize-handle {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: nwse-resize;
    display: none;
}

.editor-block:hover .resize-handle,
.editor-block.selected .resize-handle {
    display: block !important;
}

.resize-handle:hover {
    transform: scale(1.2);
}

.editor-block-frame .page-image,
.editor-block-frame .page-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.page-image {
    width: 100%;
    height: 100%;
    object-fit: scale-down;
    background: var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'%3E%3C/circle%3E%3Cpolyline points='21 15 16 10 5 21'%3E%3C/polyline%3E%3C/svg%3E") no-repeat center;
    background-size: 32px;
    image-rendering: -webkit-optimize-contrast;
    transition: transform 0.3s ease;
    border-radius: inherit;
}

/* For small icons/placeholders, don't upscale beyond natural size into blurry mess */
.editor-block-image .page-image {
    object-fit: scale-down;
}

.page-image:not([src]),
.page-image[src=""] {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Cpath stroke-dasharray='3 3' d='M8 8h8v8H8z'/%3E%3C/svg%3E") no-repeat center;
    background-size: 24px;
    opacity: 0.5;
}

.page-text {
    white-space: pre-wrap;
    line-height: 1.4;
    padding: 0.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.align-left {
    text-align: left;
    justify-content: flex-start;
}

.align-center {
    text-align: center;
    justify-content: center;
    align-items: center;
}

.align-right {
    text-align: right;
    justify-content: flex-end;
    align-items: flex-end;
}

.editor-text-content {
    outline: none;
    cursor: text;
}

/* Checkboxes */
.check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 4px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Utilities */
.glass {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .glass {
    background: rgba(15, 23, 42, 0.65);
    border-color: rgba(255, 255, 255, 0.08);
}

.gradient-text {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #6366f1 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: shine 4s linear infinite;
}

@keyframes shine {
    to {
        background-position: 200% center;
    }
}

.shadow-premium {
    box-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.12);
}

.hidden-block-inputs {
    display: none !important;
}

.inspector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.inspector-actions {
    display: flex;
    gap: 0.4rem;
    margin: 0.25rem 0;
}

.final-preview-shell {
    padding: 1rem;
    border-radius: 12px;
    background: var(--soft-strong);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.final-preview {
    width: 220px;
    flex-shrink: 0;
}

.final-preview .a5-page {
    width: 100%;
    aspect-ratio: 148 / 210;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    pointer-events: none;
    transform: none !important;
}

/* Animations */
.panel,
.canva-topbar,
.tool-rail,
.canva-rightbar .canva-panel {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

@keyframes breathe {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.4;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.5;
    }
}

.animate-fade-up {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-scale {
    animation: scaleIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

.animate-pulse-slow {
    animation: breathe 8s ease-in-out infinite;
}

.delay-100 {
    animation-delay: 0.1s;
}

.delay-200 {
    animation-delay: 0.2s;
}

.delay-300 {
    animation-delay: 0.3s;
}

.delay-400 {
    animation-delay: 0.4s;
}

.delay-500 {
    animation-delay: 0.5s;
}



/* A5 Preview Grid Enhancements */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 3rem 2rem;
    padding: 1rem;
}

.preview-label {
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.preview-grid>div>.a5-page {
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin: 0 auto;
}

.preview-grid>div:hover .a5-page {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.1);
    border-color: var(--muted);
}

/* Booklet Print Setup */
.print-body {
    background: var(--bg-page);
}

.print-toolbar {
    position: sticky;
    top: 0;
    z-index: 200;
    padding: 1.25rem 2rem;
    background: var(--input-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.print-toolbar h1 {
    margin: 0;
    font-size: 1.5rem;
}

.print-toolbar p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.print-sheet {
    position: relative;
    width: 297mm;
    height: 210mm;
    margin: 2rem auto;
    padding: 0;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    page-break-after: always;
    overflow: hidden;
}

.sheet-meta {
    position: absolute;
    top: 4mm;
    left: 4mm;
    font-size: 9px;
    font-weight: 700;
    color: var(--slate);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 10;
}

.sheet-row {
    display: grid;
    grid-template-columns: 148.5mm 148.5mm;
    width: 297mm;
    height: 210mm;
}

.sheet-row>div {
    position: relative;
    width: 148.5mm;
    height: 210mm;
    padding: 4mm;
    display: flex;
    justify-content: center;
    align-items: center;
    border-right: 1px dashed rgba(0, 0, 0, 0.1);
}

.sheet-row>div:last-child {
    border-right: none;
}

.sheet-row>div .preview-label {
    position: absolute;
    margin: 0;
    font-size: 8px;
    font-weight: 700;
    color: var(--slate);
    opacity: 0.6;
    white-space: nowrap;
    z-index: 10;
}

/* Left page: gutter is on the right */
.sheet-row>div:first-child .preview-label {
    right: 2px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

/* Right page: gutter is on the left */
.sheet-row>div:last-child .preview-label {
    left: 2px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
}

.sheet-row .a5-page {
    width: 140.5mm;
    height: 202mm;
    aspect-ratio: auto;
    border: 1px solid #e3e3e3;
    pointer-events: none;
}

/* Print Overrides & Imposition Fixes */
@media print {
    @page {
        size: A4 landscape;
        margin: 0;
    }

    html,
    body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 297mm;
        height: 210mm;
    }

    .no-print {
        display: none !important;
    }

    .print-sheet {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: 297mm !important;
        height: 210mm !important;
        page-break-after: always;
        page-break-inside: avoid;
    }
}

.export-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    text-decoration: none;
    color: var(--ink);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.export-btn:hover {
    border-color: var(--accent-light);
    transform: translateX(6px);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.1);
    background: var(--soft);
}

.export-btn .icon-box {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--soft-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.export-btn:hover .icon-box {
    background: var(--accent-gradient);
    color: white;
    transform: scale(1.1) rotate(-5deg);
}

.export-btn:hover .icon-box {
    background: rgba(99, 102, 241, 0.1);
}

.export-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.export-text strong {
    font-size: 1.05rem;
    color: var(--ink);
    font-weight: 600;
}

.export-text span {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Page Thumbnail List */
.page-thumb-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.page-thumb-card {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--paper);
    box-shadow: var(--shadow-sm);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.page-thumb-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-light);
}

.page-thumb-preview {
    aspect-ratio: 148 / 210;
    width: 100%;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-page);
    border: 1px solid var(--line);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    padding: 1rem;
}

.page-thumb-preview .a5-page {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.page-thumb-meta {
    padding: 0.25rem 0.5rem 0.5rem;
}

.page-thumb-meta strong {
    font-size: 1.15rem;
    color: var(--ink);
    margin-bottom: 0.2rem;
    display: block;
}

.page-thumb-meta p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.page-thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.page-thumb-preview:hover .page-thumb-overlay {
    opacity: 1;
}

.page-thumb-preview .a5-page {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.page-thumb-meta {
    padding: 0.5rem 0.25rem;
}

.page-thumb-actions {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-thumb-actions .button {
    flex: 1;
    min-height: 40px;
    padding: 0 1rem;
}

/* Grid Guides */
.grid-guide,
.center-guide {
    position: absolute;
    pointer-events: none;
    z-index: 1;
    background: rgba(99, 102, 241, 0.15);
}

.grid-guide-v1,
.grid-guide-v2 {
    top: 0;
    bottom: 0;
    width: 1px;
}

.grid-guide-v1 {
    left: 33.33%;
}

.grid-guide-v2 {
    left: 66.66%;
}

.grid-guide-h1,
.grid-guide-h2 {
    left: 0;
    right: 0;
    height: 1px;
}

.grid-guide-h1 {
    top: 33.33%;
}

.grid-guide-h2 {
    top: 66.66%;
}

.center-guide {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: rgba(99, 102, 241, 0.3);
    border-left: 1px dashed rgba(255, 255, 255, 0.5);
}

.editor-stage.hide-safe .safe-area,
.editor-stage.hide-grid .grid-guide,
.editor-stage.hide-grid .center-guide {
    display: none;
}

/* Thumbnails */
.thumbnail-canvas {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.02));
}

.thumb-text-block {
    position: absolute;
    display: grid;
    gap: 4px;
    padding: 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    overflow: hidden;
}

.thumb-text-bar {
    display: block;
    height: 6px;
    border-radius: 999px;
    background: rgba(17, 17, 17, 0.18);
}

.thumb-text-bar.w-100 {
    width: 100%;
}

.thumb-text-bar.w-85 {
    width: 85%;
}

.thumb-text-bar.w-65 {
    width: 65%;
}

.canva-body.layout-full {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
}

.canva-stage-area {
    padding-top: 1rem !important;
    /* Managed by toolbars height/margins */
}

.editor-stage {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding: 1.5rem 1rem 4rem 1rem !important;
    /* Significant reduction in whitespace */
    min-height: calc(100vh - 120px) !important;
    width: 100% !important;
    background-color: #f1f5f9 !important;
    background-image:
        radial-gradient(circle at center, rgba(255, 255, 255, 0.8) 0%, transparent 70%),
        linear-gradient(rgba(203, 213, 225, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(203, 213, 225, 0.2) 1px, transparent 1px) !important;
    background-size: 100% 100%, 30px 30px, 30px 30px !important;
    position: relative;
    overflow: hidden;
}

.a5-page {
    position: relative !important;
    width: 100%;
    height: auto;
    aspect-ratio: 210 / 297;
    background: var(--paper);
    border: 1px solid #ddd;
    box-shadow: none !important;
    overflow: visible;
    transition: none;
    outline: none;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    transform: none !important;
}

.a5-page:hover {
    box-shadow: none !important;
    transform: none !important;
}

.safe-area {
    position: absolute;
    inset: 12.5mm;
    border: 1.5px dashed var(--accent);
    /* More visible sapphire */
    opacity: 0.3;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.3s ease;
}

.hide-safe .safe-area {
    opacity: 0;
}

/* Laptops & Tablets (1200px and below) */
@media (max-width: 1200px) {
    .container {
        width: calc(100% - 3rem);
    }

    .canva-body {
        grid-template-columns: minmax(0, 1fr) 300px;
    }

    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 1024px) {
    .canva-topbar {
        height: auto;
        padding: 0.75rem;
        flex-direction: column;
        gap: 1rem;
        top: 0;
        border-radius: 0;
    }

    .topbar-section-group {
        width: 100%;
        justify-content: space-between;
        gap: 1rem;
    }

    .canva-stage-note {
        margin-top: 1rem;
        font-size: 11px;
        font-weight: 600;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        opacity: 0.4;
        text-align: center;
        pointer-events: none;
    }

    z-index: 10;
}

.tool-rail-head {
    display: none;
}

.tool-button {
    flex: 0 0 auto;
    width: 100px;
    margin-bottom: 0;
}

.page-thumb-list {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
}

/* Average Mobiles (768px and below) */
@media (max-width: 768px) {
    body {
        background-size: 150% 150%;
    }

    .container {
        width: calc(100% - 2rem);
        padding: 1.5rem 0;
    }

    .hero h1 {
        font-size: 2.25rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .canva-topbar-actions {
        width: 100%;
        justify-content: stretch;
    }

    .canva-topbar-actions .button {
        flex: 1;
    }

    .canva-bottom-strip {
        padding: 1rem;
        border-radius: 16px;
    }

    .button {
        min-height: 44px;
        padding: 0 1.25rem;
        font-size: 0.9rem;
    }

    .panel {
        padding: 1.25rem 1.5rem;
    }
}

/* Small Mobiles (480px and below) */
@media (max-width: 480px) {
    :root {
        --radius: 12px;
        --radius-lg: 16px;
    }

    .container {
        width: calc(100% - 1.5rem);
    }

    .hero {
        padding: 2.5rem 1.25rem;
        border-radius: 20px;
    }

    .hero h1 {
        font-size: 1.85rem;
    }

    .book-card-cover {
        height: 160px;
    }

    .book-card-content {
        padding: 1.25rem;
    }

    .canva-shell {
        padding: 0.75rem;
    }

    /* Ensure the A5 canvas scales to fit mobile screen */
    .editor-stage-wrap {
        width: 100%;
        overflow-x: auto;
        display: flex;
        justify-content: flex-start;
        padding-bottom: 1rem;
    }

    .editor-stage {
        min-width: 600px;
        /* Force minimum width to keep layout readable, allow horizontal scroll */
        transform: scale(0.65);
        /* Optional: scale down visually */
        transform-origin: top left;
    }

    /* Alternatively, responsive scaling which is more modern: */
    .canva-stage-card {
        padding: 1rem 0.5rem;
    }

    .inspector-grid {
        grid-template-columns: 1fr;
    }

    .preview-grid {
        grid-template-columns: 1fr;
    }
}

/* Extra Tight (360px and below) */
@media (max-width: 1100px) {
    .topbar-center-zone {
        transform: scale(0.9);
        margin: 0 -10px;
    }
}

@media (max-width: 860px) {
    .canva-brand {
        display: none;
    }
}

@media (max-width: 640px) {
    .dashboard-stats {
        flex-wrap: wrap;
    }

    .stat-card {
        flex: 1 1 140px;
    }
}


@keyframes glow {
    0% {
        filter: hue-rotate(0deg) drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
    }

    50% {
        filter: hue-rotate(15deg) drop-shadow(0 0 25px rgba(168, 85, 247, 0.7));
    }

    100% {
        filter: hue-rotate(0deg) drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
    }
}

h1 {
    animation: glow 6s infinite ease-in-out;
}

@keyframes float {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-15px) rotate(2deg);
    }

    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

.animate-float {
    animation: float 8s ease-in-out infinite;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.delay-100 {
    animation-delay: 0.1s;
}

.delay-200 {
    animation-delay: 0.2s;
}

.delay-300 {
    animation-delay: 0.3s;
}

.delay-400 {
    animation-delay: 0.4s;
}

.delay-500 {
    animation-delay: 0.5s;
}

.shadow-premium {
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1), 0 10px 20px -5px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    position: relative;
}


/* Toast System Style */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 9999;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    opacity: 0;
}

.toast-container.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast {
    background: #111;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 240px;
}

.toast-success {
    border-left: 4px solid var(--accent);
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-icon {
    font-weight: bold;
}

/* Loader Spinners */
.loader-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin-loader 0.8s linear infinite;
    display: inline-block;
}

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

[data-theme="dark"] .toast {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--line);
}


/* Global Viewport Reset & Lock */
* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden !important;
    position: relative;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    /* Firefox: Ensure slim scrollbar */
}

/* Premium Minimal Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    border: 3px solid transparent;
    background-clip: content-box;
    transition: background 0.3s ease;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
    background-clip: content-box;
}

/* Scroll Reveal Classes */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* --- High-Fidelity Print Folio Engine --- */
.no-screen { display: none !important; }

@media print {
    @page { size: A4 portrait; margin: 0; }
    body { background: white !important; margin: 0; padding: 0; display: block !important; width: 100% !important; height: auto !important; overflow: visible !important; color-adjust: exact; -webkit-print-color-adjust: exact; }
    
    .site-nav, .canva-topbar, .canva-brand, .toolbar-divider, .creation-tools, .center-content-orchestrator,
    .action-tools-group, .canva-topbar-actions, .toolbar-dock-station, .active-formatting-hub,
    .canva-pages-rail, .canva-bottom-strip, .inspector-rail, .button, .badge, .hint, 
    .resize-handle, .safe-area, .grid-guide, .center-guide, .canva-stage-note,
    .editor-block-tag, .layers-rail, .layer-list, .dropdown, .toast-container,
    .page-number-telemetry, .resize-handle { 
        display: none !important; 
    }
    
    .editor-block.selected .editor-block-frame {
        border-color: transparent !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    
    .no-screen { display: flex !important; }
    
    .canva-shell { margin: 0 !important; padding: 0 !important; display: block !important; border: none !important; box-shadow: none !important; transform: none !important; min-height: 0 !important; }
    .canva-body, .canva-stage-area { display: block !important; border: none !important; height: auto !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
    
    .canva-stage-card { width: 210mm; height: 297mm; display: flex !important; flex-direction: column !important; padding: 12mm 20mm !important; border: none !important; box-shadow: none !important; box-sizing: border-box !important; position: relative !important; background: white !important; margin: 0 auto !important; }
    
    .print-facsimile-wrapper { width: 100%; height: 100%; display: flex; flex-direction: column; position: relative; }
    
    .facsimile-header { width: 100%; border-bottom: 2px solid #0f172a; padding-bottom: 5mm; margin-bottom: 8mm; flex-shrink: 0; }
    .facsimile-title { font-family: 'Georgia', serif !important; font-size: 20pt !important; font-weight: 800 !important; text-align: center !important; color: #0f172a !important; margin: 0 !important; text-transform: uppercase !important; letter-spacing: 0.1em !important; width: 100% !important; line-height: 1 !important; }
    
    .editor-stage { margin: 0 auto !important; position: relative !important; border: none !important; box-shadow: none !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; width: 148.5mm !important; height: 210mm !important; transform: scale(1.08) !important; transform-origin: top center !important; background-image: none !important; background-color: white !important; flex: 1; }
    
    .facsimile-footer { position: absolute; bottom: 0; left: 0; right: 0; height: 10mm; display: flex !important; align-items: center; justify-content: center; font-family: 'Georgia', serif !important; font-size: 11pt !important; font-weight: 600 !important; color: #64748b !important; border-top: 1px solid #e2e8f0; }
    
    .page-text, .editor-text-content, .editor-block-text { font-family: 'Georgia', serif !important; text-align: justify !important; line-height: 1.8 !important; padding: 0 !important; }
    .align-left { text-align: justify !important; }
}

/* Global Responsiveness Dispatch */
@media (max-width: 1024px) {
    .hero { flex-direction: column !important; text-align: center !important; gap: 2rem !important; }
    .hero .header-actions, .hero > div:last-child { justify-content: center !important; }
    .grid.two { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
    .site-nav .container { padding: 0 1rem !important; }
    .site-nav .brand-glyph + div span:last-child { display: none !important; } /* Hide Institutional Portal text */
    .site-nav .button.subtle:not(#theme-toggle) { display: none; } /* Dashboard button hidden, use Logo */
    
    .panel { padding: 1.5rem !important; }
    .export-btn { flex-direction: column; text-align: center; }
    .page-thumb-list { justify-content: center !important; }
    
    .canva-topbar { padding: 0.5rem 1rem !important; flex-wrap: wrap; height: auto !important; gap: 0.5rem; justify-content: center; }
    .canva-topbar > div { flex-wrap: wrap; justify-content: center; width: 100%; gap: 0.5rem; }
    .canva-body { flex-direction: column !important; height: auto !important; }
    .tool-rail { width: 100% !important; height: 50px !important; flex-direction: row !important; border-bottom: 1px solid var(--line); border-right: none !important; position: sticky; top: 0; z-index: 1001; }
    .canva-stage-area { height: 70vh !important; }
}

@media (max-width: 480px) {
    .site-nav { height: auto !important; padding: 0.5rem 0; }
    .site-nav .container { flex-direction: column; gap: 0.75rem; }
    .hero h1 { font-size: 2rem !important; }
    .button { width: 100%; justify-content: center; }
}


/* Dashboard Delete Hover */
.book-card-cover:hover .delete-form {
    opacity: 1 !important;
}

/* Hero Interactivity */
.hero-interaction-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
    transform: translate(-50%, -50%);
    opacity: 0.15;
    z-index: -1;
    filter: blur(60px);
    transition: opacity 0.5s ease;
}

/* Bottom Page Nav Chips */
.canva-bottom-strip {
    padding: 1.5rem 2rem;
    background: white;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.canva-page-strip {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.canva-page-chip {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-decoration: none;
    transition: all 0.3s ease;
    width: 140px;
    flex-shrink: 0;
}

.canva-page-chip-thumb {
    width: 100%;
    aspect-ratio: 148 / 210;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.canva-page-chip.active .canva-page-chip-thumb {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    transform: translateY(-4px);
}

.canva-page-chip-meta {
    display: flex;
    flex-direction: column;
}

.canva-page-chip-meta strong {
    font-size: 13px;
    color: var(--ink);
}

.canva-page-chip.active .canva-page-chip-meta strong {
    color: var(--accent);
}

.canva-page-chip-meta small {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sortable Grid Aesthetics */
.draggable-item {
    cursor: grab;
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s cubic-bezier(0.2, 0, 0, 1) !important;
}

.draggable-item:active {
    cursor: grabbing;
}

.sortable-ghost {
    opacity: 0.3;
    transform: scale(0.95);
    filter: grayscale(1) blur(2px);
    border: 2px dashed var(--accent) !important;
}

.sortable-chosen {
    background: var(--soft) !important;
}

.sortable-drag {
    opacity: 0.9 !important;
    transform: scale(1.05) rotate(2deg) !important;
    box-shadow: 0 30px 60px -12px rgba(50, 50, 93, 0.25), 0 18px 36px -18px rgba(0, 0, 0, 0.3) !important;
    cursor: grabbing !important;
    z-index: 9999;
}

/* --- High-Fidelity Responsive Navigation --- */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 2500;
    height: auto;
    min-height: 50px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0 !important;
    background: var(--topbar-bg) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 0.25rem 0;
}

.site-nav .nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
    gap: 0.75rem;
}

.nav-branding {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.brand-glyph {
    width: 34px;
    height: 34px;
    background: var(--accent-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    line-height: 1;
}

.brand-subtitle {
    font-size: 9px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.theme-btn {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 9px;
    font-size: 1rem;
    background: var(--soft);
}

.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--line);
    margin: 0 0.25rem;
}

.nav-btn, .login-btn {
    font-size: 12px;
    height: 36px;
    min-height: 36px;
    padding: 0 1rem;
    border-radius: 9px;
    font-weight: 700;
}

.logout-btn {
    font-size: 12px;
    height: 36px;
    min-height: 36px;
    padding: 0 1rem;
    border-radius: 9px;
    background: #ef4444;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
    font-weight: 700;
    color: white !important;
}

@media (max-width: 600px) {
    .site-nav .nav-wrapper {
        padding: 0.5rem 1rem;
        justify-content: space-between;
    }
    
    .brand-subtitle {
        display: none;
    }
    
    .nav-actions {
        gap: 0.5rem;
    }
    
    .nav-divider {
        display: none;
    }
    
    .nav-btn, .logout-btn, .login-btn {
        padding: 0 0.75rem;
    }
}

@media (max-width: 480px) {
    .site-nav .nav-wrapper {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .nav-btn, .logout-btn, .login-btn {
        padding: 0 0.6rem;
        font-size: 11px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 36px;
    }

    .brand-glyph {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .nav-branding {
        min-width: 0;
        gap: 0.5rem;
    }

    .brand-name {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .theme-btn {
        width: 32px;
        height: 32px;
        min-height: 32px;
        font-size: 0.9rem;
    }
}