/**
 * Estilos visuales y sistema de diseño (Professional Workstation UI)
 *
 * Copyright (c) 2024-2026 Ruben Caramutti / PuntoGAP
 * Licensed under MIT License
 *
 * Este archivo es parte del proyecto PDF2AUDIO, Aplicación TTS web profesional para convertir documentos PDF en audio con controles personalizados y sincronizacion de texto en tiempo real.
 *
 * @author Ruben Caramutti
 * @project PDF2AUDIO
 * @repository https://github.com/tuknqn/PDF2AUDIO
 * @created 2026-02-12
 *
 */

:root {
    --bg-deep: #020203;
    --bg-surface: #070709;
    --bg-card: rgba(15, 15, 22, 0.45);
    --accent: #0066ff;
    --accent-glow: rgba(0, 102, 255, 0.2);
    --accent-vibrant: #4d9dff;
    --text-primary: #ffffff;
    --text-secondary: #a1a1b5;
    --border: rgba(255, 255, 255, 0.06);
    --radius-lg: 32px;
    --radius-md: 20px;
    --radius-sm: 14px;
    --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    --shadow-premium: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 30px 80px rgba(0, 0, 0, 0.8);
    --glass-bg: rgba(8, 8, 12, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] {
    --bg-deep: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.6);
    --accent: #1155cc;
    --accent-glow: rgba(17, 85, 204, 0.08);
    --accent-vibrant: #3b82f6;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border: rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 0 0 1px rgba(0, 0, 0, 0.01), 0 20px 50px rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.06);
}

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

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    background-image:
        radial-gradient(circle at 0% 0%, var(--accent-glow) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, var(--accent-glow) 0%, transparent 50%);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 60px 40px;
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    gap: 32px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

header {
    grid-column: 1 / -1;
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    padding: 16px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
}

.title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.title-group h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--accent-vibrant) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

.app-tagline {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    opacity: 0.8;
}

.badge-version {
    background: var(--accent-glow);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid var(--accent-glow);
    margin-left: 10px;
    vertical-align: middle;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-theme {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    font-size: 0.85rem;
    padding: 10px 20px;
}

.btn-secondary:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

/* --- Main Content Area --- */
.main-column {
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0;
    order: 2;
    /* Center */
}

.panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-premium);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.7);
}

/* --- Sidebar (Engineer Console) --- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: calc(100vh - 120px);
    position: sticky;
    top: 40px;
    order: 1;
    /* Left side */
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-premium);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    overflow: hidden;
}

.scrollable-controls {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px 20px 4px;
    /* Added padding to prevent clipping hover effects */
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.scrollable-controls::-webkit-scrollbar {
    width: 4px;
}

.scrollable-controls::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.section-title i {
    color: var(--accent);
    font-size: 0.9rem;
}

/* --- Control Groups --- */
.control-block {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 18px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    transition: var(--transition-fast);
}

.control-block:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.03);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--accent-glow);
    transform: translateY(-3px);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.control-header label {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.value-display {
    font-family: 'Outfit', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(0, 85, 255, 0.12);
    padding: 3px 10px;
    border-radius: 6px;
    min-width: 50px;
    text-align: center;
    border: 1px solid rgba(0, 85, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.smart-feature-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.feature-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

/* --- Reader Area --- */
.reader-hud {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.hud-item {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.hud-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.hud-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.current-text-container {
    min-height: 480px;
    max-height: 600px;
    font-family: 'Fraunces', serif;
    font-size: 1.35rem;
    line-height: 1.8;
    color: var(--text-secondary);
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 48px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
}

.highlighted-text {
    color: var(--text-primary);
    font-weight: 600;
    padding: 4px 8px;
    background: var(--accent-glow);
    border-radius: 4px;
    display: inline;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    transition: var(--transition);
}

@keyframes highlightIn {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

.context-text {
    opacity: 0.35;
    transition: var(--transition);
}

/* --- Controls Bar --- */
.playback-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    margin-top: -1px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Buttons --- */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.95rem;
}

.btn:hover:not(:disabled) {
    background: var(--border);
    transform: translateY(-2px);
    border-color: var(--text-secondary);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.btn:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-circle {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    padding: 0;
    font-size: 1.25rem;
}

.btn-large {
    width: 68px;
    height: 68px;
    font-size: 1.5rem;
}

/* --- Quantum Well (Drop Area) --- */
.drop-zone {
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 80px 40px;
    text-align: center;
    background: var(--bg-card);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    position: relative;
    overflow: hidden;
}

/* Liquid Light Border */
.drop-zone::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, var(--accent), transparent) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: destination-out;
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0.15;
    transition: var(--transition);
    pointer-events: none;
}

.drop-zone.active::after {
    opacity: 1;
    background: linear-gradient(90deg, transparent, var(--accent), var(--accent-vibrant), transparent) border-box;
    animation: borderRotate 2s linear infinite;
}

@keyframes borderRotate {
    0% {
        filter: hue-rotate(0deg);
    }

    100% {
        filter: hue-rotate(360deg);
    }
}

.quantum-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.drop-zone i {
    font-size: 3.5rem;
    color: var(--accent);
    filter: drop-shadow(0 0 20px var(--accent-glow));
    z-index: 1;
}

.drop-zone .content-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.drop-zone.active {
    background: radial-gradient(circle at center, rgba(0, 85, 255, 0.15) 0%, transparent 70%);
    transform: scale(0.98);
}

/* Ripple Effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: var(--accent-glow);
    transform: scale(0);
    animation: rippleEffect 0.8s ease-out;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* --- Spectral Visualizer --- */
.visualizer-container {
    width: 100%;
    height: 120px;
    margin-bottom: 24px;
    position: relative;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
}

#spectralCanvas {
    width: 100%;
    height: 100%;
    filter: blur(1px);
}

/* --- Text Editor --- */
.editor-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-surface);
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 40px;
    visibility: hidden;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: inherit;
}

.editor-overlay.visible {
    display: flex !important;
    /* Force flex to override global utilities */
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

textarea {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 24px;
    font-family: 'Fraunces', serif;
    /* Matching the reader's elegant font */
    font-size: 1.15rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    margin-bottom: 24px;
    width: 100%;
    min-height: 500px;
    /* Force more visible lines */
    box-shadow: inset 0 2px 15px rgba(0, 0, 0, 0.05);
    transition: var(--transition-fast);
}

textarea:focus {
    border-color: var(--accent);
    background: var(--bg-surface);
    box-shadow: inset 0 2px 20px var(--accent-glow);
}

.editor-overlay textarea {
    flex: 1;
}

/* --- Sliders --- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 10px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5), 0 0 0 4px var(--bg-deep);
    transition: var(--transition);
}

input[type="range"]:hover::-webkit-slider-thumb {
    background: var(--accent);
    transform: scale(1.1);
}

/* --- Select --- */
select {
    background: var(--bg-deep);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius-md);
    width: 100%;
    font-family: inherit;
    outline: none;
}

/* --- Status --- */
#status-message {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 32px;
    border-radius: 50px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    font-weight: 500;
    display: none;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: translate(-50%, 20px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.status-success {
    border-color: #10b981;
    color: #10b981;
}

.status-error {
    border-color: #ef4444;
    color: #ef4444;
}

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: var(--border);
    margin-top: 12px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.1s linear;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* --- New Utility Classes for Strict CSP --- */
.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-theme {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    flex-shrink: 0;
}

.drop-zone-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.drop-zone-subtitle {
    color: var(--text-secondary);
    margin-top: 8px;
}

.btn-select-pdf {
    margin-top: 8px;
}

.file-info-panel {
    display: none;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.file-info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
}

.file-info-header>div:first-child {
    flex: 1;
    min-width: 0;
    /* Critical: allowing the name container to shrink */
}

.info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 600;
    word-break: break-all;
    /* Critical: Prevent long filenames from pushing the layout */
    overflow-wrap: anywhere;
}

.info-label-sm {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.reader-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
}

.reader-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 24px 0;
}

.btn-sm-action {
    padding: 10px 18px;
    font-size: 0.85rem;
}

.btn-sm-primary {
    padding: 10px 24px;
    font-size: 0.85rem;
}

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

.editor-title {
    font-size: 1.5rem;
}

.btn-clean {
    padding: 8px 16px;
}

.editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.smart-feature-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.feature-label {
    font-size: 0.9rem;
}

.hygiene-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hygiene-textarea {
    height: 400px !important;
    min-height: 400px;
    font-size: 0.8rem;
    padding: 12px;
    margin-top: 8px;
}

.cite-help-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cite-help-text {
    font-size: 0.65rem;
    color: var(--text-secondary);
    padding-left: 30px;
    line-height: 1.2;
}

.persistence-note {
    font-size: 0.75rem;
    margin-bottom: 12px;
    opacity: 0.8;
}

.btn-full-width {
    width: 100%;
    justify-content: center;
}

.text-right {
    text-align: right;
}

.panel-no-padding {
    padding: 0;
}

.panel-header-padding {
    padding: 32px 32px 0 32px;
}

.text-accent {
    color: var(--accent);
}

.flex-gap-8 {
    display: flex;
    gap: 8px;
}

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

#fileInput,
#audioPlayer {
    display: none !important;
    visibility: hidden !important;
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

.checkbox-sm {
    width: 18px;
    height: 18px;
}

.flex-col-gap-8 {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.visible {
    display: block;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: var(--progress-width, 0%);
    transition: width 0.1s linear;
}

/* Additional utilities for index.html cleanup */
.control-block-accent {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.section-title-primary {
    color: var(--text-primary);
}

.btn-reset {
    width: 100%;
    justify-content: center;
    font-size: 0.8rem;
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

/* --- Library Panel (Right) --- */
.library-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: calc(100vh - 120px);
    position: sticky;
    top: 40px;
    order: 3;
    /* Right side */
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-premium);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    overflow-y: auto;
}

.library-item {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: var(--transition-fast);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

.library-item:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    transform: translateX(4px);
}

.library-item i {
    color: var(--accent);
    font-size: 1.2rem;
}

.library-item-info {
    flex: 1;
    min-width: 0;
}

.library-item-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-item-date {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

@media (max-width: 1400px) {
    .container {
        grid-template-columns: 300px 1fr;
    }

    .library-panel {
        display: none;
    }
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr 350px;
        padding: 40px 32px;
    }

    .sidebar {
        order: 2;
    }

    .main-column {
        order: 1;
    }
}

@media (max-width: 1024px) {
    .container {
        display: flex;
        flex-direction: column;
        padding: 32px 24px;
        gap: 32px;
    }

    .main-column {
        display: contents;
        /* Allows children (dropPanel, readerPanel) to be part of the container flex flow */
    }

    .sidebar,
    .main-column,
    .library-panel {
        width: 100%;
        min-width: 0;
    }

    .sidebar {
        height: auto;
        position: static;
        order: 2;
        /* Controls in the middle */
    }

    #dropPanel {
        order: 1;
        /* Drop Area first initially */
    }

    #readerPanel {
        order: 3;
        /* Reader UI lower initially */
    }

    /* Dynamic Reordering when content is loaded */
    body.app-has-content #readerPanel {
        order: 1;
        /* Reader UI jumps to top */
    }

    body.app-has-content #dropPanel {
        order: 3;
        /* Drop Area moves to bottom */
    }
}

@media (max-width: 768px) {
    .container {
        padding: 24px 16px;
    }

    .panel {
        padding: 24px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px 20px;
        display: flex;
        flex-direction: column;
    }

    .panel {
        padding: 24px 16px;
        width: 100%;
        margin-bottom: 24px;
        box-sizing: border-box;
        min-width: 0;
        overflow-x: hidden;
    }

    .drop-zone {
        padding: 40px 20px;
    }

    .current-text-container {
        padding: 24px 16px;
        font-size: 1.15rem;
        min-height: 400px;
        width: 100%;
    }

    .title-group h1 {
        font-size: 1.8rem;
    }

    .reader-hud {
        grid-template-columns: 1fr !important;
        /* Force single column on mobile */
        gap: 12px;
    }

    .hud-item {
        padding: 12px;
    }

    .playback-strip {
        gap: 8px;
        padding: 16px 8px;
        flex-wrap: wrap;
        /* Allow buttons to wrap on very narrow screens */
    }

    .btn {
        padding: 10px 16px;
    }

    .btn-circle {
        width: 48px;
        height: 48px;
    }

    .btn-large {
        width: 60px;
        height: 60px;
    }
}