/* ==========================================================================
   TRACE & WRITE - CUSTOM WRITING SHEET GENERATOR
   DESIGN ALIGNED WITH COCO GAMES (PLAYFUL TACTILE SYSTEM)
   ========================================================================== */

:root {
    /* Color Palette */
    --color-bg: #e0f2fe; /* Light sky blue */
    --color-text-dark: #0f172a; /* Slate 900 */
    --color-text-muted: #475569; /* Slate 600 */
    --color-card-bg: #ffffff;
    --color-border: #0f172a;
    
    /* Playful Theme Accents */
    --color-green: #80c41c;
    --color-green-shadow: #5c9310;
    --color-green-bg: #f4fbe7;
    
    --color-yellow: #f59e0b;
    --color-yellow-shadow: #b45309;
    --color-yellow-bg: #fffbeb;
    
    --color-pink: #ec4899;
    --color-pink-shadow: #be185d;
    --color-pink-bg: #fdf2f8;
    
    --color-purple: #8b5cf6;
    --color-purple-shadow: #6d28d9;
    --color-purple-bg: #f5f3ff;

    --color-blue: #2563eb;
    --color-blue-shadow: #1d4ed8;
    --color-blue-bg: #eff6ff;

    /* Fonts */
    --font-ui: 'Fredoka', system-ui, -apple-system, sans-serif;
    --font-text: 'Outfit', system-ui, -apple-system, sans-serif;
    
    /* Animation / Transition */
    --transition-tactile: all 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ==========================================================================
   1. GLOBAL STYLES & RESET
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-text);
    background-color: var(--color-bg);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    color: var(--color-text-dark);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#app-container {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Helper Utilities */
.hide {
    display: none !important;
}

/* Buttons */
.btn {
    font-family: var(--font-ui);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 12px;
    border: 3px solid var(--color-border);
    cursor: pointer;
    transition: var(--transition-tactile);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    text-decoration: none;
}

.btn:active {
    transform: translateY(4px);
}

.btn-primary {
    background-color: var(--color-green);
    color: white;
    box-shadow: 0 6px 0 var(--color-green-shadow);
}
.btn-primary:hover {
    background-color: #8cd820;
    box-shadow: 0 4px 0 var(--color-green-shadow);
    transform: translateY(2px);
}
.btn-primary:active {
    box-shadow: 0 0px 0 var(--color-green-shadow);
}

.btn-secondary {
    background-color: var(--color-yellow);
    color: white;
    box-shadow: 0 6px 0 var(--color-yellow-shadow);
}
.btn-secondary:hover {
    background-color: #fbbf24;
    box-shadow: 0 4px 0 var(--color-yellow-shadow);
    transform: translateY(2px);
}
.btn-secondary:active {
    box-shadow: 0 0px 0 var(--color-yellow-shadow);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.25rem;
}

.btn-md {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-width: 2px;
    box-shadow: 0 3px 0 var(--color-border);
}
.btn-sm:hover {
    transform: translateY(1px);
    box-shadow: 0 2px 0 var(--color-border);
}
.btn-sm:active {
    transform: translateY(3px);
    box-shadow: 0 0px 0 var(--color-border);
}

/* ==========================================================================
   2. PRODUCT LANDING VIEW
   ========================================================================== */
.view-panel {
    display: none;
    flex-grow: 1;
    width: 100%;
}

.view-panel.active-view {
    display: flex;
    flex-direction: column;
}

/* Landing Header */
.landing-header {
    text-align: center;
    padding: 3rem 1.5rem 1rem;
}

.brand-badge {
    display: inline-block;
    background: var(--color-blue);
    color: white;
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0.5rem 1.25rem;
    border-radius: 50px;
    border: 3px solid var(--color-border);
    box-shadow: 0 4px 0 var(--color-border);
    margin-bottom: 1.5rem;
    transform: rotate(-2deg);
}

.logo-title {
    font-family: var(--font-ui);
    font-size: 4rem;
    font-weight: 700;
    color: var(--color-text-dark);
    text-shadow: 0 4px 0 #ffffff;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.logo-subtitle {
    font-size: 1.3rem;
    color: var(--color-text-muted);
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
}

/* Content & Hero layout */
.landing-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

.hero-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    align-items: center;
}

@media (max-width: 900px) {
    .hero-section {
        grid-template-columns: 1fr;
    }
}

.hero-info h2 {
    font-family: var(--font-ui);
    font-size: 2.25rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

.hero-info p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--color-text-muted);
    margin-bottom: 2.5rem;
}

/* Demo Showcase Card */
.hero-demo-card {
    background: var(--color-card-bg);
    border: 3px solid var(--color-border);
    border-radius: 20px;
    box-shadow: 8px 8px 0px var(--color-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.demo-card-header {
    background: #f1f5f9;
    border-bottom: 3px solid var(--color-border);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.demo-card-header .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
}
.demo-card-header .dot.red { background: #f87171; }
.demo-card-header .dot.yellow { background: #fbbf24; }
.demo-card-header .dot.green { background: #4ade80; }

.demo-label {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.85rem;
    margin-left: 10px;
    text-transform: uppercase;
}

.demo-card-body {
    padding: 1.5rem;
    background: #f8fafc;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.demo-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-ui);
    font-weight: 600;
}

.demo-select {
    padding: 0.4rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--color-border);
    font-family: var(--font-text);
    font-weight: 600;
}

.demo-preview-sheet {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    min-height: 250px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.demo-header-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #94a3b8;
    font-family: var(--font-ui);
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 0.5rem;
}

/* Feature Grid Cards */
.features-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.75rem;
}

.feature-card {
    background: var(--color-card-bg);
    border: 3px solid var(--color-border);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    transition: var(--transition-tactile);
}

.feature-card:hover {
    transform: translateY(-4px);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-family: var(--font-ui);
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
}

.feature-card p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Feature specific card border colors */
.feature-card.f-green { box-shadow: 6px 6px 0px var(--color-green-shadow); border-color: var(--color-green-shadow); }
.feature-card.f-yellow { box-shadow: 6px 6px 0px var(--color-yellow-shadow); border-color: var(--color-yellow-shadow); }
.feature-card.f-pink { box-shadow: 6px 6px 0px var(--color-pink-shadow); border-color: var(--color-pink-shadow); }
.feature-card.f-purple { box-shadow: 6px 6px 0px var(--color-purple-shadow); border-color: var(--color-purple-shadow); }

/* Landing Footer */
.landing-footer {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-muted);
    border-top: 3px solid rgba(15, 23, 42, 0.05);
    margin-top: 4rem;
    font-size: 0.9rem;
}

/* ==========================================================================
   3. WORKSPACE EDITOR LAYOUT
   ========================================================================== */
.workspace-header {
    background: white;
    border-bottom: 3px solid var(--color-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.workspace-header h2 {
    font-family: var(--font-ui);
    font-size: 1.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.workspace-layout {
    display: flex;
    flex-grow: 1;
    height: calc(100vh - 65px); /* Header offset */
    overflow: hidden;
}

@media (max-width: 800px) {
    .workspace-layout {
        flex-direction: column;
        height: auto;
    }
}

/* Sidebar Controls */
.controls-panel {
    width: 380px;
    background: #f8fafc;
    border-right: 3px solid var(--color-border);
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-shrink: 0;
}

@media (max-width: 800px) {
    .controls-panel {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 3px solid var(--color-border);
    }
}

.control-group {
    background: white;
    border: 3px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 4px 4px 0px var(--color-border);
}

.control-group h3 {
    font-family: var(--font-ui);
    font-size: 1.05rem;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    color: var(--color-text-dark);
}

.input-wrapper {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-wrapper:last-child {
    margin-bottom: 0;
}

.input-wrapper label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrapper input[type="text"],
.input-wrapper select,
.input-wrapper textarea {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 2px solid var(--color-border);
    font-family: var(--font-text);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-dark);
    outline: none;
    width: 100%;
    transition: var(--transition-tactile);
}

.input-wrapper input[type="text"]:focus,
.input-wrapper select:focus,
.input-wrapper textarea:focus {
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Radio Tile Selector */
.radio-tile-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.radio-tile {
    display: flex;
    align-items: center;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    background: white;
    transition: var(--transition-tactile);
    font-size: 0.9rem;
    font-weight: 600;
}

.radio-tile input[type="radio"] {
    margin-right: 10px;
    accent-color: var(--color-blue);
}

.radio-tile:hover {
    background: var(--color-blue-bg);
}

.radio-tile input[type="radio"]:checked + .tile-label {
    color: var(--color-blue);
}

/* Vocabulary Selection Box */
.vocab-items-box {
    border: 2px solid var(--color-border);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
    margin-top: 0.5rem;
}

.vocab-box-actions {
    background: #e2e8f0;
    padding: 0.4rem 0.75rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid var(--color-border);
}

.btn-text {
    background: none;
    border: none;
    color: var(--color-blue);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
}
.btn-text:hover {
    text-decoration: underline;
}

.checkboxes-list {
    max-height: 180px;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkboxes-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.checkboxes-list input[type="checkbox"] {
    accent-color: var(--color-green);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Prominent Generate Button */
.btn-generate-prominent {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.85rem 1.25rem;
    font-size: 1.1rem;
    background-color: var(--color-green);
    color: white;
    box-shadow: 0 5px 0 var(--color-green-shadow);
    border: 3px solid var(--color-border);
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-ui);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-tactile);
}
.btn-generate-prominent:hover {
    background-color: #8cd820;
    box-shadow: 0 3px 0 var(--color-green-shadow);
    transform: translateY(2px);
}
.btn-generate-prominent:active {
    box-shadow: 0 0px 0 var(--color-green-shadow);
    transform: translateY(5px);
}

/* Custom Words Manager */
.custom-words-manager {
    border: 2px solid var(--color-border);
    border-radius: 8px;
    background: #f8fafc;
    padding: 0.75rem;
    margin-top: 0.5rem;
}

.custom-words-input-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    margin-bottom: 8px;
}

.custom-words-input-row input {
    flex: 1;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    border: 2px solid var(--color-border);
    font-size: 0.9rem;
    font-family: var(--font-text);
}

.custom-chips-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.custom-chips-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 140px;
    overflow-y: auto;
    padding: 6px;
    background: white;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    min-height: 48px;
    align-content: flex-start;
}

.word-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--color-blue-bg);
    border: 1.5px solid var(--color-blue);
    color: var(--color-text-dark);
    border-radius: 16px;
    padding: 2px 8px 2px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 1px 1px 0px rgba(0,0,0,0.1);
    animation: chipPop 0.15s ease-out;
}

@keyframes chipPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.btn-chip-remove {
    background: none;
    border: none;
    color: #ef4444;
    font-weight: bold;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
.btn-chip-remove:hover {
    color: #b91c1c;
    transform: scale(1.2);
}

.custom-words-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
}

.bulk-paste-details {
    margin-top: 10px;
    border-top: 1px dashed #cbd5e1;
    padding-top: 6px;
}
.bulk-paste-details summary {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-blue);
    cursor: pointer;
}
.bulk-paste-body {
    margin-top: 6px;
}
.bulk-paste-body textarea {
    width: 100%;
    border-radius: 6px;
    border: 2px solid var(--color-border);
    padding: 6px;
    font-size: 0.85rem;
    font-family: var(--font-text);
}

/* Range Sliders */
.slider-wrapper {
    margin-bottom: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-header label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.slider-badge {
    background: var(--color-blue-bg);
    color: var(--color-blue);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1.5px solid var(--color-blue);
    font-family: var(--font-ui);
}

.custom-range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: #e2e8f0;
    outline: none;
    border: 2px solid var(--color-border);
    transition: var(--transition-tactile);
}

.custom-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-green);
    border: 2px solid var(--color-border);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: var(--transition-tactile);
}

.custom-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: #8cd820;
}

.custom-range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-green);
    border: 2px solid var(--color-border);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Font Size Custom Controls */
.font-size-header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.num-input-sm {
    width: 54px;
    padding: 2px 4px;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--color-border);
    border-radius: 6px;
    font-family: var(--font-ui);
}

.font-size-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: 0.8rem;
}

.safe-max-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
    border: 1px solid #f59e0b;
}

.btn-auto-fit {
    font-size: 0.75rem;
    color: var(--color-blue);
    cursor: pointer;
    font-weight: 700;
    background: none;
    border: none;
}
.btn-auto-fit:hover {
    text-decoration: underline;
}

.preset-pills {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.pill-btn {
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1.5px solid var(--color-border);
    background: white;
    cursor: pointer;
    transition: var(--transition-tactile);
}
.pill-btn:hover {
    background: var(--color-blue-bg);
}
.pill-btn.active {
    background: var(--color-blue);
    color: white;
    border-color: var(--color-blue);
}

/* Sliders / Toggles */
.checkbox-row {
    margin-top: 0.75rem;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    background-color: #cbd5e1;
    border-radius: 20px;
    border: 2px solid var(--color-border);
    transition: .3s;
}

.toggle-container input {
    display: none;
}

.toggle-container input:checked + .toggle-slider {
    background-color: var(--color-green);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: var(--color-border);
    border-radius: 50%;
    transition: .3s;
}

.toggle-container input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background-color: white;
}

/* ==========================================================================
   4. LIVE CANVAS PREVIEW AREA
   ========================================================================== */
.preview-area {
    flex-grow: 1;
    background: #cbd5e1; /* Slate board background */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-toolbar {
    background: #0f172a;
    color: white;
    padding: 0.5rem 1.5rem;
    font-size: 0.85rem;
    font-family: var(--font-ui);
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

.preview-zoom-container {
    flex-grow: 1;
    overflow: auto;
    padding: 2.5rem 1.5rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Canvas Wrapper containing physical US Letter pages */
#preview-canvas-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
    transform-origin: top center;
}

/* ==========================================================================
   5. SHEET SPECIFIC STYLES (COMMON FOR PREVIEW & PRINT)
   ========================================================================== */
.print-page {
    background: white;
    width: 8.5in;
    height: 11in;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: relative;
    color: #000;
}

/* Margins styles mapping to controls */
.print-page.margin-standard { padding: 0.75in; }
.print-page.margin-narrow { padding: 0.5in; }
.print-page.margin-wide { padding: 1.0in; }

.print-page-header {
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.print-page-header h2 {
    font-size: 24px;
    font-weight: 700;
    text-transform: capitalize;
    color: #000;
    margin: 0;
}

.print-page-fields {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-family: monospace;
    color: #555;
    margin-top: 4px;
}

/* Grid system for practice rows layout */
.print-page-content {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr; /* Default 1 column */
    gap: 25px;
    align-content: start;
}

.print-page-content.cols-2 {
    grid-template-columns: 1fr 1fr;
    column-gap: 40px;
    row-gap: 30px;
}

/* Practice block containing label + guidelines list */
.practice-word-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.practice-word-block.full-width {
    grid-column: span 2;
}

/* Word label for guidance */
.practice-word-label {
    font-family: var(--font-ui);
    font-size: 13px;
    color: #64748b;
    margin-bottom: 2px;
    text-transform: capitalize;
}

/* Practice fonts configurations */
.font-courier-prime { font-family: 'Courier Prime', Courier, monospace; }
.font-roboto-mono { font-family: 'Roboto Mono', monospace; }
.font-system-mono { font-family: monospace; }

/* Font size configurations - fallback classes & dynamic support */
.font-size-sm .char-segment { font-size: 28px; }
.font-size-md .char-segment { font-size: 36px; }
.font-size-lg .char-segment { font-size: 44px; }
.font-size-xl .char-segment { font-size: 56px; }

/* Tracing Line / Practice Character Layout */
.practice-line-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
}

/* Character Segment (The foundational grid block) */
.char-segment {
    display: inline-flex;
    width: 0.95em;
    height: 1.35em;
    justify-content: center;
    align-items: center;
    font-weight: 400;
    position: relative;
    box-sizing: border-box;
    font-size: var(--char-font-size, 36px);
    margin-right: var(--char-letter-gap, 4px); /* Dynamic character gap */
}

/* Spaced out letter styling */
.spaced-letters .char-segment {
    margin-right: 12px;
}

/* Spaces inside sentences should not render guides */
.char-segment.char-space {
    border: none !important;
    background: none !important;
}

/* Text Render Mode styles applied to characters */
.text-solid .char-segment {
    color: #000 !important;
}

.text-gray .char-segment {
    color: rgba(100, 116, 139, var(--trace-opacity-val, 0.4)) !important;
}

.text-outline .char-segment {
    color: transparent !important;
    -webkit-text-stroke: 1.5px #94a3b8; /* Hollow bounds */
}

/* All-Box Faint Tracing Styles */
.trace-repeat-row .char-segment {
    color: rgba(100, 116, 139, var(--trace-opacity-val, 0.4)) !important;
}

.text-outline .trace-repeat-row .char-segment {
    color: transparent !important;
    -webkit-text-stroke: 1.2px rgba(100, 116, 139, var(--trace-opacity-val, 0.4));
}

@media print {
    .trace-repeat-row .char-segment {
        color: #cbd5e1 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .text-outline .trace-repeat-row .char-segment {
        color: transparent !important;
        -webkit-text-stroke: 1.2px #cbd5e1 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ==========================================================================
   CHARACTER GUIDELINES DESIGN (BROKEN SEGMENT RENDERING)
   ========================================================================== */

/* 1. Broken Underlines (One underline per letter - default) */
.guide-underline .char-segment {
    border-bottom: 2.5px solid #94a3b8;
}

/* 2. Primary Lined (Top solid, dotted midline, bottom baseline) */
.guide-primary .char-segment {
    background-image: 
        linear-gradient(to bottom, #94a3b8 1px, transparent 1px), /* top solid */
        linear-gradient(to right, #cbd5e1 50%, transparent 50%), /* middle dashed midline */
        linear-gradient(to bottom, #fda4af 2.5px, transparent 2.5px); /* bottom solid pink baseline */
    background-position: 
        0 15%, 
        0 50%, 
        0 85%;
    background-size: 
        100% 1px, 
        8px 1px, 
        100% 2.5px;
    background-repeat: repeat-x;
}

/* 3. Character Box Outlines */
.guide-boxes .char-segment {
    border: 2px dashed #94a3b8;
    border-radius: 6px;
}

/* 4. Guide None */
.guide-none .char-segment {
    border: none;
    background: none;
}

/* Practice lines rows vertical offset */
.practice-word-block .guide-lines-list {
    display: flex;
    flex-direction: column;
    gap: var(--practice-row-gap, 15px); /* Dynamic vertical gap between practice rows */
}

/* Page numbers inside sheets */
.print-page-footer {
    position: absolute;
    bottom: 0.4in;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    font-family: monospace;
}

/* ==========================================================================
   6. PRINT ONLY WORKSPACE CONTAINER
   ========================================================================== */
.print-only {
    display: none;
}

/* ==========================================================================
   7. SHARE & DOWNLOAD MODAL STYLES
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border: 3px solid var(--color-border);
    border-radius: 20px;
    box-shadow: 8px 8px 0px var(--color-border);
    width: 90%;
    max-width: 650px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: modalBounce 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes modalBounce {
    0% { transform: scale(0.9) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.modal-header h2 {
    font-family: var(--font-ui);
    font-size: 1.4rem;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    font-weight: 700;
    color: var(--color-text-muted);
}
.modal-close-btn:hover {
    color: var(--color-text-dark);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* Options Grid */
.share-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 520px) {
    .share-options-grid {
        grid-template-columns: 1fr;
    }
}

.share-option-card {
    background: #f8fafc;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: var(--transition-tactile);
}

.share-option-card:hover {
    background: #eff6ff;
    transform: translateY(-2px);
}

.share-option-card .share-icon {
    font-size: 2rem;
}

.share-option-card h4 {
    font-family: var(--font-ui);
    font-size: 1rem;
    margin: 4px 0 2px;
}

.share-option-card p {
    font-size: 0.8rem;
    line-height: 1.35;
    margin-bottom: 8px;
    color: var(--color-text-muted);
    flex-grow: 1;
}

/* Link Display box */
.share-link-display {
    background: var(--color-blue-bg);
    border: 2px solid var(--color-border);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 5px;
}

.share-link-display label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.copy-link-row {
    display: flex;
    gap: 10px;
}

.copy-link-row input {
    flex-grow: 1;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 2px solid var(--color-border);
    font-family: monospace;
    font-size: 0.8rem;
    outline: none;
}

/* ==========================================================================
   8. CSS PRINT STYLE MEDIA QUERY (CRITICAL RULES - FIXES BLANK PREVIEW)
   ========================================================================== */
@media print {
    /* Hide screen-only containers (leaving html/body visible) */
    #app-container, #particle-canvas, .no-print, .modal-overlay {
        display: none !important;
    }
    
    /* Reset margins and dimensions for default printer */
    html, body {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: 100% !important;
        overflow: visible !important;
    }
    
    /* Make sure printer sheet root is visible and resets margins */
    .print-only, #print-sheet-root {
        display: block !important;
        background: transparent !important;
    }
    
    .print-page {
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        page-break-after: always !important;
        page-break-inside: avoid !important;
        width: 8.5in !important;
        height: 11in !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
    }

    .print-page:last-child {
        page-break-after: avoid !important;
    }

    /* Force background gradients / colors to print exactly */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Brand Badge Link */
.brand-badge-link {
    text-decoration: none;
    display: inline-block;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.brand-badge-link:hover {
    transform: translateY(-2px);
    opacity: 0.92;
}
