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

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            min-height: 100vh;
            color: #e0e0e0;
            overflow-x: hidden;
        }

        /* Magical Library Background */
        .library-bg {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background:
                radial-gradient(ellipse at 20% 20%, rgba(255, 180, 50, 0.15) 0%, transparent 40%),
                radial-gradient(ellipse at 80% 30%, rgba(255, 150, 50, 0.1) 0%, transparent 35%),
                radial-gradient(ellipse at 50% 80%, rgba(100, 50, 20, 0.2) 0%, transparent 50%),
                linear-gradient(180deg, #1a0a05 0%, #2d1810 30%, #1a0f0a 70%, #0d0705 100%);
            z-index: -2;
        }

        /* Wood desk texture overlay */
        .desk-surface {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background:
                repeating-linear-gradient(
                    90deg,
                    transparent,
                    transparent 100px,
                    rgba(0,0,0,0.03) 100px,
                    rgba(0,0,0,0.03) 102px
                ),
                repeating-linear-gradient(
                    0deg,
                    transparent,
                    rgba(60, 30, 15, 0.1) 2px,
                    transparent 4px
                );
            z-index: -1;
            pointer-events: none;
        }

        /* Floating particles */
        .particles {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 100;
            overflow: hidden;
        }

        .particle {
            position: absolute;
            width: 3px;
            height: 3px;
            background: rgba(255, 200, 100, 0.6);
            border-radius: 50%;
            animation: float 8s infinite ease-in-out;
            box-shadow: 0 0 6px rgba(255, 180, 80, 0.8);
        }

        @keyframes float {
            0%, 100% { transform: translateY(0) translateX(0); opacity: 0; }
            10% { opacity: 1; }
            90% { opacity: 1; }
            100% { transform: translateY(-100vh) translateX(50px); opacity: 0; }
        }

        /* Candle glow effect */
        .candle-glow {
            position: fixed;
            width: 300px;
            height: 300px;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(255, 180, 80, 0.3) 0%, transparent 70%);
            pointer-events: none;
            animation: flicker 3s infinite ease-in-out;
        }

        .candle-glow.left {
            top: 10%;
            left: -50px;
        }

        .candle-glow.right {
            top: 5%;
            right: -50px;
        }

        @keyframes flicker {
            0%, 100% { opacity: 0.8; transform: scale(1); }
            25% { opacity: 1; transform: scale(1.05); }
            50% { opacity: 0.7; transform: scale(0.98); }
            75% { opacity: 0.9; transform: scale(1.02); }
        }

        .container {
            max-width: 1500px;
            margin: 0 auto;
            padding: 20px;
            position: relative;
            z-index: 1;
        }

        /* Back link */
        .back-link {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            color: #c9a86c;
            text-decoration: none;
            font-family: 'MedievalSharp', cursive;
            font-size: 0.95em;
            padding: 8px 16px;
            border: 1px solid rgba(201, 168, 108, 0.3);
            border-radius: 4px;
            background: rgba(0, 0, 0, 0.3);
            transition: all 0.3s ease;
            margin-bottom: 15px;
        }

        .back-link:hover {
            color: #ffd700;
            border-color: rgba(255, 215, 0, 0.5);
            background: rgba(0, 0, 0, 0.5);
            text-shadow: 0 0 10px rgba(255, 200, 100, 0.5);
        }

        .back-link .arrow {
            font-size: 0.8em;
        }

        /* Header */
        header {
            text-align: center;
            margin-bottom: 30px;
            position: relative;
        }

        h1 {
            font-family: 'MedievalSharp', cursive;
            font-size: 2.8em;
            color: #ffd700;
            text-shadow:
                0 0 10px rgba(255, 200, 100, 0.5),
                0 0 20px rgba(255, 150, 50, 0.3),
                2px 2px 4px rgba(0,0,0,0.8);
            letter-spacing: 3px;
        }

        .subtitle {
            font-family: 'Dancing Script', cursive;
            font-size: 1.3em;
            color: #c9a86c;
            margin-top: 5px;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        }

        /* Main workspace */
        .workspace {
            display: flex;
            gap: 30px;
            justify-content: center;
            align-items: flex-start;
            flex-wrap: wrap;
        }


        .control-group {
            margin-bottom: 22px;
        }

        .control-group h3 {
            font-family: 'MedievalSharp', cursive;
            margin-bottom: 12px;
            color: #ffd700;
            font-size: 1.1em;
            border-bottom: 1px solid rgba(255, 215, 0, 0.3);
            padding-bottom: 5px;
            text-shadow: 0 0 5px rgba(255, 200, 100, 0.3);
        }

        /* Template Selection */
        .template-options {
            display: flex;
            gap: 8px;
            margin-bottom: 8px;
        }

        .template-option {
            flex: 1;
            padding: 10px 8px;
            background: rgba(60, 40, 20, 0.6);
            border: 2px solid rgba(139, 105, 20, 0.4);
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            color: #c9a86c;
            font-size: 0.8em;
        }

        .template-option:hover {
            background: rgba(80, 50, 25, 0.8);
            border-color: rgba(255, 215, 0, 0.5);
        }

        .template-option.selected {
            border-color: #ffd700;
            background: rgba(100, 60, 30, 0.8);
            box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
            color: #ffd700;
        }

        /* Paper Size Selection */
        .size-options {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
        }

        .size-option {
            padding: 10px 8px;
            background: rgba(60, 40, 20, 0.6);
            border: 2px solid rgba(139, 105, 20, 0.4);
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            color: #c9a86c;
            font-size: 0.85em;
        }

        .size-option:hover {
            background: rgba(80, 50, 25, 0.8);
            border-color: rgba(255, 215, 0, 0.5);
        }

        .size-option.selected {
            border-color: #ffd700;
            background: rgba(100, 60, 30, 0.8);
            box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
            color: #ffd700;
        }

        .size-option .dimensions {
            font-size: 0.75em;
        }

        /* Size manual input */
        .size-manual-input {
            margin-bottom: 12px;
            padding-bottom: 12px;
            border-bottom: 1px solid rgba(255, 215, 0, 0.2);
        }

        .size-input-row {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .size-input-row label {
            color: #c9a86c;
            font-size: 0.85em;
        }

        .size-input-row input[type="number"] {
            width: 65px;
            padding: 6px 8px;
            background: rgba(60, 40, 20, 0.8);
            border: 1px solid rgba(139, 105, 20, 0.5);
            border-radius: 4px;
            color: #e8dcc0;
            font-size: 0.85em;
            text-align: center;
        }

        .size-input-row input[type="number"]:focus {
            border-color: rgba(255, 215, 0, 0.6);
            outline: none;
        }

        .size-input-row button {
            padding: 6px 12px;
            background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
            border: none;
            border-radius: 4px;
            color: #1a0f0a;
            font-size: 0.8em;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .size-input-row button:hover {
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
        }

        /* Size category headers */
        .size-category {
            font-family: 'MedievalSharp', cursive;
            font-size: 0.75em;
            color: rgba(255, 215, 0, 0.7);
            text-transform: uppercase;
            letter-spacing: 1px;
            padding: 8px 0 4px 0;
            margin-top: 8px;
            opacity: 0.7;
            margin-top: 2px;
        }

        /* Paper Selection */
        .paper-options {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
        }

        .paper-option {
            width: 100%;
            height: 50px;
            border: 2px solid transparent;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .paper-option:hover {
            transform: scale(1.05);
        }

        .paper-option.selected {
            border-color: #ffd700;
            box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
        }

        .paper-option span {
            position: absolute;
            bottom: 2px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 0.6em;
            background: rgba(0, 0, 0, 0.8);
            padding: 1px 4px;
            border-radius: 2px;
            white-space: nowrap;
        }

        /* Paper background previews */
        .paper-scroll { background: linear-gradient(180deg, #d4a574 0%, #f5deb3 50%, #d4a574 100%); }
        .paper-papyrus { background: linear-gradient(135deg, #c9b896 0%, #d4c4a8 100%); }
        .paper-parchment { background: linear-gradient(135deg, #f4e4bc 0%, #dcc48c 100%); }
        .paper-aged { background: linear-gradient(135deg, #d4b896 0%, #b8946a 100%); }
        .paper-vellum { background: linear-gradient(135deg, #faf6e8 0%, #e8dcc0 100%); }
        .paper-dark { background: linear-gradient(135deg, #4a3c2a 0%, #2d2418 100%); }
        .paper-dotmatrix {
            background: repeating-linear-gradient(
                0deg,
                #f8f8f0,
                #f8f8f0 6px,
                rgba(200, 230, 200, 0.4) 6px,
                rgba(200, 230, 200, 0.4) 12px
            );
        }
        .paper-blueprint { background: linear-gradient(135deg, #234b6e 0%, #1a3250 100%); }
        .paper-congressional { background: linear-gradient(180deg, #fffef8 0%, #f8f7f0 100%); }
        .paper-graph {
            background: #ffffff;
            background-image:
                linear-gradient(rgba(180, 210, 240, 0.6) 1px, transparent 1px),
                linear-gradient(90deg, rgba(180, 210, 240, 0.6) 1px, transparent 1px);
            background-size: 8px 8px;
        }
        .paper-hex {
            background: #fffef5;
        }
        .paper-legalpad {
            background: linear-gradient(180deg, #ffffc0 0%, #ffff99 50%, #ffffc0 100%);
        }

        /* Font Selection */
        .font-options {
            display: flex;
            flex-direction: column;
            gap: 6px;
            max-height: 160px;
            overflow-y: auto;
            padding-right: 5px;
        }

        .font-options::-webkit-scrollbar {
            width: 6px;
        }

        .font-options::-webkit-scrollbar-track {
            background: rgba(60, 40, 20, 0.5);
            border-radius: 3px;
        }

        .font-options::-webkit-scrollbar-thumb {
            background: rgba(255, 215, 0, 0.5);
            border-radius: 3px;
        }

        .font-option {
            padding: 8px 12px;
            background: rgba(244, 228, 188, 0.9);
            border: 2px solid transparent;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s ease;
            color: #2d1b0e;
            font-size: 0.95em;
        }

        .font-option:hover {
            background: rgba(244, 228, 188, 1);
        }

        .font-option.selected {
            border-color: #ffd700;
            box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
        }

        /* Font category legend */
        .font-legend {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-bottom: 8px;
            padding: 6px 8px;
            background: rgba(45, 27, 14, 0.3);
            border-radius: 4px;
            font-size: 0.75em;
        }

        .font-legend-item {
            display: flex;
            align-items: center;
            gap: 4px;
            color: #c9a86c;
        }

        .font-legend .dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
        }

        .font-legend .dot.fantasy {
            background: #d4af37;
        }

        .font-legend .dot.dotmatrix {
            background: #4a7c4e;
        }

        .font-legend .dot.blueprint {
            background: #4a90d9;
        }

        .font-legend .dot.congressional {
            background: #000080;
        }

        /* Font category indicators */
        .font-option.font-cat-fantasy {
            border-left: 4px solid #d4af37;
        }

        .font-option.font-cat-dotmatrix {
            border-left: 4px solid #4a7c4e;
        }

        .font-option.font-cat-blueprint {
            border-left: 4px solid #4a90d9;
        }

        .font-option.font-cat-congressional {
            border-left: 4px solid #000080;
        }

        /* Ink Colors */
        .ink-options {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .ink-option {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid rgba(255, 255, 255, 0.2);
            transition: all 0.3s ease;
            position: relative;
        }

        .ink-option:hover {
            transform: scale(1.15);
            border-color: rgba(255, 255, 255, 0.5);
        }

        .ink-option.selected {
            border-color: #fff;
            box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
        }

        /* Slider styling */
        .slider-container {
            margin-top: 8px;
        }

        .slider-container input[type="range"] {
            width: 100%;
            height: 6px;
            border-radius: 3px;
            background: rgba(60, 40, 20, 0.8);
            outline: none;
            cursor: pointer;
            -webkit-appearance: none;
        }

        .slider-container input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
            cursor: pointer;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
        }

        .slider-value {
            text-align: center;
            margin-top: 5px;
            color: #c9a86c;
            font-size: 0.9em;
        }

        /* Image Upload */
        .image-upload-btn {
            width: 100%;
            padding: 12px;
            background: rgba(60, 40, 20, 0.6);
            border: 2px dashed rgba(139, 105, 20, 0.6);
            border-radius: 5px;
            color: #c9a86c;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            font-size: 0.9em;
        }

        .image-upload-btn:hover {
            background: rgba(80, 50, 25, 0.8);
            border-color: rgba(255, 215, 0, 0.5);
        }

        .image-upload-btn.has-image {
            border-style: solid;
            border-color: #ffd700;
        }

        #imageInput {
            display: none;
        }

        .image-preview {
            margin-top: 10px;
            position: relative;
        }

        .image-preview img {
            max-width: 100%;
            max-height: 80px;
            border-radius: 4px;
            border: 1px solid rgba(139, 105, 20, 0.4);
        }

        .image-controls {
            margin-top: 10px;
            display: none;
        }

        .image-controls.visible {
            display: block;
        }

        .image-control-row {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 8px;
        }

        .image-control-row label {
            font-size: 0.8em;
            color: #c9a86c;
            min-width: 50px;
        }

        .image-control-row input[type="range"] {
            flex: 1;
            height: 4px;
            border-radius: 2px;
            background: rgba(60, 40, 20, 0.8);
            outline: none;
            cursor: pointer;
            -webkit-appearance: none;
        }

        .image-control-row input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
            cursor: pointer;
        }

        .remove-image-btn {
            width: 100%;
            padding: 8px;
            margin-top: 8px;
            background: rgba(139, 50, 50, 0.6);
            border: 1px solid rgba(180, 80, 80, 0.5);
            border-radius: 4px;
            color: #e0a0a0;
            cursor: pointer;
            font-size: 0.8em;
            transition: all 0.3s ease;
        }

        .remove-image-btn:hover {
            background: rgba(160, 60, 60, 0.8);
        }

        .image-drag-hint {
            font-size: 0.75em;
            color: rgba(200, 180, 140, 0.7);
            text-align: center;
            padding: 6px 0;
            font-style: italic;
        }

        /* Template Image Upload */
        .template-image-upload {
            width: 100%;
        }

        .template-image-btn {
            display: block;
            width: 100%;
            padding: 10px;
            background: rgba(60, 40, 20, 0.6);
            border: 2px dashed rgba(139, 105, 20, 0.6);
            border-radius: 5px;
            color: #c9a86c;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            font-size: 0.85em;
        }

        .template-image-btn:hover {
            background: rgba(80, 50, 25, 0.8);
            border-color: rgba(255, 215, 0, 0.5);
        }

        .template-image-btn.has-image {
            border-style: solid;
            border-color: #4a90d9;
        }

        .template-image-hint {
            font-size: 0.7em;
            color: rgba(200, 180, 140, 0.6);
            text-align: center;
            padding: 4px 0;
            font-style: italic;
        }

        .template-image-preview {
            margin-top: 8px;
            position: relative;
            text-align: center;
        }

        .template-image-preview img {
            max-width: 100%;
            max-height: 100px;
            border-radius: 4px;
            border: 1px solid rgba(74, 144, 217, 0.5);
        }

        .remove-template-image {
            position: absolute;
            top: -6px;
            right: -6px;
            width: 20px;
            height: 20px;
            background: rgba(139, 50, 50, 0.9);
            border: none;
            border-radius: 50%;
            color: #fff;
            cursor: pointer;
            font-size: 14px;
            line-height: 18px;
            text-align: center;
        }

        .remove-template-image:hover {
            background: rgba(180, 60, 60, 1);
        }

        /* Embellish Controls (Stamps & Seals) */
        .embellish-section {
            margin-bottom: 10px;
        }

        .embellish-toggle {
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            color: #c9a86c;
            font-size: 0.9em;
            margin-bottom: 8px;
        }

        .embellish-toggle input[type="checkbox"] {
            width: 16px;
            height: 16px;
            accent-color: #ffd700;
        }

        .embellish-controls {
            display: none;
            padding: 10px;
            background: rgba(45, 27, 14, 0.4);
            border-radius: 5px;
            margin-top: 8px;
        }

        .embellish-controls.visible {
            display: block;
        }

        .embellish-row {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
        }

        .embellish-row label {
            min-width: 60px;
            font-size: 0.8em;
            color: #c9a86c;
        }

        .embellish-input {
            flex: 1;
            padding: 6px 10px;
            background: rgba(60, 40, 20, 0.8);
            border: 1px solid rgba(139, 105, 20, 0.5);
            border-radius: 4px;
            color: #f4e4bc;
            font-size: 0.85em;
        }

        .embellish-input:focus {
            outline: none;
            border-color: #ffd700;
        }

        .embellish-row input[type="range"] {
            flex: 1;
            height: 4px;
            border-radius: 2px;
            background: rgba(60, 40, 20, 0.8);
            outline: none;
            cursor: pointer;
            -webkit-appearance: none;
        }

        .embellish-row input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
            cursor: pointer;
        }

        .stamp-colors, .seal-colors {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }

        .stamp-color, .seal-color {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.2s ease;
        }

        .stamp-color:hover, .seal-color:hover {
            transform: scale(1.15);
        }

        .stamp-color.selected, .seal-color.selected {
            border-color: #ffd700;
            box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
        }

        .seal-symbols {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }

        .seal-symbol {
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(60, 40, 20, 0.6);
            border: 2px solid rgba(139, 105, 20, 0.4);
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.2s ease;
        }

        .seal-symbol:hover {
            background: rgba(80, 50, 25, 0.8);
            border-color: rgba(255, 215, 0, 0.5);
        }

        .seal-symbol.selected {
            border-color: #ffd700;
            background: rgba(100, 60, 30, 0.8);
            box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
        }

        .embellish-hint {
            font-size: 0.7em;
            color: rgba(200, 180, 140, 0.6);
            text-align: center;
            font-style: italic;
            margin-top: 5px;
        }

        /* Export Button */
        .export-btn {
            width: 100%;
            padding: 14px;
            margin-top: 15px;
            background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
            border: none;
            border-radius: 5px;
            font-family: 'MedievalSharp', cursive;
            font-size: 1.1em;
            font-weight: bold;
            color: #1a0f0a;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 2px;
            box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
        }

        .export-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 25px rgba(255, 215, 0, 0.5);
        }

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

        /* Page counter */
        .page-info {
            text-align: center;
            margin-top: 10px;
            color: #c9a86c;
            font-size: 0.9em;
            font-family: 'MedievalSharp', cursive;
        }

        /* Template field inputs */
        .template-fields {
            display: flex;
            flex-direction: column;
            gap: 15px;
            max-height: 200px;
            overflow-y: auto;
            padding-right: 5px;
        }

        .template-fields::-webkit-scrollbar {
            width: 6px;
        }

        .template-fields::-webkit-scrollbar-track {
            background: rgba(60, 40, 20, 0.5);
            border-radius: 3px;
        }

        .template-fields::-webkit-scrollbar-thumb {
            background: rgba(255, 215, 0, 0.5);
            border-radius: 3px;
        }

        .template-field {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .template-field.has-textarea {
            flex: 1;
            min-height: 120px;
        }

        .template-field label {
            font-size: 0.85em;
            color: #c9a86c;
            font-family: 'MedievalSharp', cursive;
            flex-shrink: 0;
        }

        .template-field input,
        .template-field textarea {
            width: 100%;
            padding: 10px 12px;
            background: rgba(60, 40, 20, 0.6);
            border: 1px solid rgba(139, 105, 20, 0.4);
            border-radius: 4px;
            color: #e8dcc0;
            font-size: 0.95em;
            outline: none;
            transition: border-color 0.3s ease;
            line-height: 1.5;
        }

        .template-field input:focus,
        .template-field textarea:focus {
            border-color: rgba(255, 215, 0, 0.6);
        }

        .template-field textarea {
            flex: 1;
            min-height: 100px;
            resize: none;
        }

        .template-field input::placeholder,
        .template-field textarea::placeholder {
            color: rgba(200, 180, 140, 0.5);
        }

        .template-field-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .field-size-control {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .field-size-control input[type="range"] {
            width: 50px;
            height: 4px;
            border-radius: 2px;
            background: rgba(60, 40, 20, 0.8);
            outline: none;
            cursor: pointer;
            -webkit-appearance: none;
        }

        .field-size-control input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
            cursor: pointer;
        }

        .field-size-value {
            font-size: 0.7em;
            color: rgba(200, 180, 140, 0.8);
            min-width: 24px;
            text-align: right;
        }

        /* Desk Area - where the paper sits */
        .desk-area {
            position: relative;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            padding: 40px;
            min-height: 500px;
        }

        /* Desk surface under paper */
        .desk-mat {
            background:
                linear-gradient(135deg, #2a1a10 0%, #1f140a 50%, #150d07 100%);
            padding: 30px;
            border-radius: 5px;
            box-shadow:
                inset 0 0 50px rgba(0, 0, 0, 0.5),
                0 15px 50px rgba(0, 0, 0, 0.6);
            border: 2px solid #3d2817;
            position: relative;
            min-width: 500px;
            min-height: 400px;
        }

        /* Decorative corner elements */
        .desk-mat::before,
        .desk-mat::after {
            content: '';
            position: absolute;
            width: 40px;
            height: 40px;
            border: 2px solid rgba(139, 105, 20, 0.4);
        }

        .desk-mat::before {
            top: 10px;
            left: 10px;
            border-right: none;
            border-bottom: none;
        }

        .desk-mat::after {
            bottom: 10px;
            right: 10px;
            border-left: none;
            border-top: none;
        }

        /* Pages container - stacked papers */
        .pages-container {
            position: relative;
            cursor: text;
        }

        .page-canvas {
            display: block;
            position: absolute;
            top: 0;
            left: 0;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
            transition: transform 0.3s ease;
        }

        .page-canvas:first-child {
            position: relative;
        }

        .page-canvas.dragging-image {
            cursor: grabbing !important;
        }

        .page-canvas.can-drag-image {
            cursor: grab;
        }

        /* Hidden textarea for input */
        #hiddenInput {
            position: absolute;
            left: -9999px;
            top: 0;
        }

        /* Quill decoration */
        .quill-decoration {
            position: absolute;
            top: -20px;
            right: -60px;
            font-size: 3em;
            transform: rotate(45deg);
            opacity: 0.7;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
            z-index: 50;
        }

        /* ===== NEW LAYOUT STYLES ===== */

        /* Style Bar - horizontal bar at top */
        .style-bar {
            display: flex;
            justify-content: center;
            gap: 5px;
            padding: 15px 20px;
            background: linear-gradient(180deg, #2d1810 0%, #1f140a 100%);
            border-bottom: 2px solid #5a3d2a;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
            flex-wrap: wrap;
        }

        /* Style dropdown container */
        .style-dropdown {
            position: relative;
        }

        /* Style dropdown trigger button */
        .style-trigger {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 16px;
            background: rgba(60, 40, 20, 0.6);
            border: 2px solid rgba(139, 105, 20, 0.4);
            border-radius: 5px;
            color: #c9a86c;
            font-family: 'MedievalSharp', cursive;
            font-size: 0.95em;
            cursor: pointer;
            transition: all 0.3s ease;
            white-space: nowrap;
        }

        .style-trigger:hover {
            background: rgba(80, 50, 25, 0.8);
            border-color: rgba(255, 215, 0, 0.5);
            color: #ffd700;
        }

        .style-trigger .arrow {
            font-size: 0.7em;
            transition: transform 0.3s ease;
        }

        .style-dropdown:hover .style-trigger .arrow {
            transform: rotate(180deg);
        }

        /* Dropdown panel */
        .style-panel {
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            margin-top: 8px;
            padding: 15px;
            background: linear-gradient(135deg, #3d2817 0%, #2a1a0f 50%, #1f140a 100%);
            border: 2px solid #5a3d2a;
            border-radius: 5px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px #8b6914;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
            z-index: 1000;
            min-width: 200px;
        }

        .style-dropdown:hover .style-panel {
            opacity: 1;
            visibility: visible;
        }

        /* Panel content styling */
        .style-panel h4 {
            font-family: 'MedievalSharp', cursive;
            color: #ffd700;
            font-size: 0.95em;
            margin-bottom: 10px;
            padding-bottom: 5px;
            border-bottom: 1px solid rgba(255, 215, 0, 0.3);
            text-shadow: 0 0 5px rgba(255, 200, 100, 0.3);
        }

        /* Size panel specific */
        .style-panel .size-options {
            grid-template-columns: repeat(2, 1fr);
            gap: 6px;
        }

        .style-panel .size-option {
            padding: 8px 6px;
            font-size: 0.8em;
        }

        /* Paper panel specific */
        .style-panel .paper-options {
            grid-template-columns: repeat(3, 1fr);
            gap: 6px;
            width: 180px;
        }

        .style-panel .paper-option {
            height: 45px;
        }

        /* Font panel specific */
        .style-panel .font-options {
            max-height: 250px;
            width: 220px;
        }

        .style-panel .font-option {
            padding: 6px 10px;
            font-size: 0.9em;
        }

        /* Ink panel specific */
        .style-panel .ink-options {
            width: 180px;
            gap: 6px;
        }

        /* Image panel specific */
        .style-panel .image-upload-btn {
            font-size: 0.85em;
            padding: 10px;
        }

        .style-panel .image-controls {
            margin-top: 10px;
        }

        .style-panel .image-control-row label {
            font-size: 0.75em;
        }

        .style-panel .image-preview img {
            max-height: 60px;
        }

        /* Vertical template options in dropdown */
        .template-options-vertical {
            display: flex;
            flex-direction: column;
            gap: 6px;
            min-width: 160px;
        }

        .template-options-vertical .template-option {
            padding: 10px 14px;
            background: rgba(60, 40, 20, 0.6);
            border: 2px solid rgba(139, 105, 20, 0.4);
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            color: #c9a86c;
            font-size: 0.9em;
        }

        .template-options-vertical .template-option:hover {
            background: rgba(80, 50, 25, 0.8);
            border-color: rgba(255, 215, 0, 0.5);
        }

        .template-options-vertical .template-option.selected {
            border-color: #ffd700;
            background: rgba(100, 60, 30, 0.8);
            box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
            color: #ffd700;
        }

        /* Two-column template layout */
        .template-columns {
            display: flex;
            gap: 15px;
        }

        .template-column {
            display: flex;
            flex-direction: column;
            gap: 6px;
            min-width: 150px;
        }

        .template-column .template-option {
            padding: 8px 12px;
            background: rgba(60, 40, 20, 0.6);
            border: 2px solid rgba(139, 105, 20, 0.4);
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            color: #c9a86c;
            font-size: 0.85em;
            white-space: nowrap;
        }

        .template-column .template-option:hover {
            background: rgba(80, 50, 25, 0.8);
            border-color: rgba(255, 215, 0, 0.5);
        }

        .template-column .template-option.selected {
            border-color: #ffd700;
            background: rgba(100, 60, 30, 0.8);
            box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
            color: #ffd700;
        }

        /* Document category headers */
        .template-category {
            font-family: 'MedievalSharp', cursive;
            font-size: 0.75em;
            color: rgba(255, 215, 0, 0.7);
            text-transform: uppercase;
            letter-spacing: 1px;
            padding: 8px 0 4px 0;
            margin-top: 8px;
            border-top: 1px solid rgba(255, 215, 0, 0.2);
        }

        .template-category:first-child {
            margin-top: 0;
            border-top: none;
            padding-top: 0;
        }

        /* Category-specific styling for template options */
        .template-option.cat-fantasy {
            border-left: 3px solid #ffd700;
        }

        .template-option.cat-dotmatrix {
            border-left: 3px solid #90EE90;
            font-family: 'Courier Prime', monospace;
        }

        .template-option.cat-blueprint {
            border-left: 3px solid #87CEEB;
        }

        .template-option.cat-congressional {
            border-left: 3px solid #000080;
            font-family: 'Libre Baskerville', serif;
        }

        /* Nav Export Button */
        .nav-export-btn {
            padding: 10px 20px;
            background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
            border: none;
            border-radius: 5px;
            font-family: 'MedievalSharp', cursive;
            font-size: 0.95em;
            font-weight: bold;
            color: #1a0f0a;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
            box-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
        }

        .nav-export-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(255, 215, 0, 0.5);
        }

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

        /* Main workspace - left/right split */
        .workspace {
            display: flex;
            gap: 15px;
            justify-content: center;
            align-items: flex-start;
            padding: 20px;
            max-width: 1500px;
            margin: 0 auto;
            position: relative;
            z-index: 1;
        }

        /* Left panel - Content (sticky, viewport height) */
        .content-panel {
            background: linear-gradient(135deg, #3d2817 0%, #2a1a0f 50%, #1f140a 100%);
            border-radius: 5px;
            padding: 20px;
            width: 350px;
            min-width: 320px;
            border: 3px solid #5a3d2a;
            box-shadow: inset 0 0 30px rgba(0,0,0,0.5), 0 10px 40px rgba(0,0,0,0.6), 0 0 0 1px #8b6914;
            position: sticky;
            top: 20px;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            height: calc(100vh - 40px);
            overflow: hidden;
        }

        .content-panel::before {
            content: '';
            position: absolute;
            top: 5px;
            left: 5px;
            right: 5px;
            bottom: 5px;
            border: 1px solid rgba(139, 105, 20, 0.3);
            border-radius: 3px;
            pointer-events: none;
        }

        .content-panel .control-group {
            flex: 1;
            display: flex;
            flex-direction: column;
            margin-bottom: 0;
            overflow: hidden;
        }

        /* Template fields expanded to fill panel */
        .content-panel .template-fields {
            flex: 1;
            max-height: none;
            min-height: 200px;
            overflow-y: auto;
        }

        /* Scroll to top button */
        .scroll-to-top {
            position: fixed;
            bottom: 30px;
            right: 30px;
            width: 50px;
            height: 50px;
            background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
            border: none;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4), 0 0 0 2px rgba(139, 105, 20, 0.5);
            opacity: 0;
            visibility: hidden;
            transform: translateY(20px);
            transition: all 0.3s ease;
            z-index: 1000;
        }

        .scroll-to-top.visible {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

        .scroll-to-top:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 25px rgba(255, 215, 0, 0.6), 0 0 0 2px rgba(139, 105, 20, 0.7);
        }

        .scroll-to-top::before {
            content: '';
            width: 12px;
            height: 12px;
            border-left: 3px solid #1a0f0a;
            border-top: 3px solid #1a0f0a;
            transform: rotate(45deg) translateY(3px);
        }

        /* Right panel - Render */
        .render-panel {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: flex-start;
        }

        .render-panel .desk-area {
            padding: 20px;
            padding-left: 0;
            min-height: auto;
            display: flex;
            align-items: flex-start;
            justify-content: flex-start;
        }

        .render-panel .desk-mat {
            min-width: auto;
            min-height: auto;
            padding: 20px;
        }

        .render-panel .page-info {
            margin-top: 10px;
        }

        /* Responsive */
        @media (max-width: 1100px) {
            .workspace {
                flex-direction: column;
                align-items: center;
            }

            .content-panel {
                position: relative;
                top: 0;
                width: 100%;
                max-width: 600px;
                height: auto;
                min-height: 400px;
            }

            .content-panel .template-fields {
                min-height: 250px;
            }

            .scroll-to-top {
                bottom: 20px;
                right: 20px;
                width: 44px;
                height: 44px;
            }

            .style-bar {
                padding: 10px;
                gap: 4px;
            }

            .style-trigger {
                padding: 8px 12px;
                font-size: 0.85em;
            }

            .nav-export-btn {
                padding: 8px 14px;
                font-size: 0.85em;
            }

            .desk-mat {
                padding: 20px;
                min-width: auto;
            }
        }

        @media (max-width: 600px) {
            .style-panel {
                position: fixed;
                top: auto;
                bottom: 0;
                left: 0;
                right: 0;
                transform: none;
                margin: 0;
                border-radius: 10px 10px 0 0;
                max-height: 60vh;
                overflow-y: auto;
            }

            .style-trigger span:first-child {
                display: none;
            }

            .style-trigger .arrow {
                display: none;
            }

            .style-trigger::before {
                font-size: 1.2em;
            }
        }
