:root {
    --bg-color: #000000;
    /* Fixed as requested */
    --text-color: #ffffff;
    --primary-color: #3b82f6;
    --toolbar-bg: rgba(30, 30, 30, 0.95);
    --toolbar-border: #333;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- Editor --- */
#editor-container {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 0;
    /* Remove padding here, managing in children */
    max-width: 100%;
    /* Full width for header */
    margin: 0;
    background-color: #1a1a1a;
}

#app-header {
    width: 100%;
    background-color: #333;
    /* Grey background */
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #444;
}

.header-logo {
    height: 40px;
    width: auto;
}

.header-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #eee;
}

#editor-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    height: 100%;
    /* Fill sidebar height */
    overflow-y: auto;
    min-width: 0;
    /* Important for flex child with overflow */
}

#main-layout {
    display: flex;
    flex: 1;
    height: calc(100vh - 61px);
    /* Header is approx 61px */
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: 320px;
    background: #222;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1rem;
    color: #ccc;
    font-weight: 600;
}

#new-script-btn {
    background: var(--primary-color);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#script-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.script-item {
    padding: 10px;
    background: #2a2a2a;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.script-item:hover {
    background: #333;
    border-color: #555;
}

.script-item.active {
    background: #2d3b55;
    border-color: var(--primary-color);
}

.script-item.over {
    border: 1px dashed #666;
    background: #333;
}

.script-item.dragging {
    opacity: 0.4;
}

.script-name {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

.delete-script-btn {
    background: transparent;
    border: none;
    color: #666;
    padding: 4px;
    font-size: 0.8rem;
}

.delete-script-btn:hover {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.empty-state {
    color: #666;
    text-align: center;
    font-size: 0.9rem;
    margin-top: 20px;
    font-style: italic;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #333;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    /* Allow buttons to wrap if needed */
    justify-content: center;
}

.secondary-btn {
    flex: 1;
    background: #333;
    font-size: 1.2rem;
    /* Larger for icons */
    padding: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Header Controls */
.header-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

#script-title {
    background: #222;
    border: 1px solid #444;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    width: 250px;
}

.action-btn {
    background: #2d8a4e;
    /* Green for Save */
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
}

.action-btn:hover {
    background: #247340;
}

#share-prompter-btn,
#open-window-btn {
    background: #6269e9;
    border-color: #4a51e6;
}

#share-prompter-btn:hover,
#open-window-btn:hover {
    background: #4a51e6;
}

#editor-container.active {
    display: flex;
}

header {
    margin-bottom: 1rem;
    text-align: center;
}

.editor-toolbar {
    background: #2a2a2a;
    padding: 10px;
    border-radius: 8px 8px 0 0;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.toolbar-label {
    font-size: 0.9rem;
    color: #aaa;
}

.color-palette {
    display: flex;
    gap: 5px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: #fff;
}

#text-editor {
    flex: 1;
    background: #222;
    border: 1px solid #333;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 20px;
    font-size: 1.2rem;
    line-height: 1.6;
    overflow-y: auto;
    outline: none;
    min-height: 200px;
    word-break: break-word;
    overflow-wrap: break-word;
}

#text-editor:empty:before {
    content: attr(placeholder);
    color: #555;
}

.primary-btn {
    margin-top: 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    align-self: center;
    transition: background 0.2s;
}

.primary-btn:hover {
    background-color: #2563eb;
}

/* --- Teleprompter --- */
#prompter-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index: 100;
}

#prompter-container.active {
    display: block;
}

/* Toolbar */
#toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--toolbar-bg);
    border-top: 1px solid var(--toolbar-border);
    padding: 10px 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 1000;
    transition: opacity 0.3s;
}

#toolbar.hidden {
    opacity: 0;
    pointer-events: none;
    /* Ensure clicks pass through if hidden */
}

#toolbar:hover {
    opacity: 1;
    pointer-events: auto;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    border-right: 1px solid #444;
}

.toolbar-group:last-child {
    border-right: none;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.8rem;
}

button {
    background: #333;
    color: white;
    border: 1px solid #444;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

button:hover {
    background: #444;
}

button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

input[type="range"] {
    width: 80px;
    cursor: pointer;
}

/* Marker */
#marker-arrow {
    position: fixed;
    left: 10px;
    top: 30%;
    width: 0;
    height: 0;
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
    border-left: 30px solid white;
    transform: translateY(-50%);
    z-index: 500;
    opacity: 0.7;
    pointer-events: none;
}

/* Scrolling Content */
#prompter-display {
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: auto;
    transform-origin: center center;
    cursor: default;
    /* Default cursor for empty areas */
}

/* Scrollbar Styling */
#prompter-display::-webkit-scrollbar {
    width: 12px;
}

#prompter-display::-webkit-scrollbar-track {
    background: #111;
}

#prompter-display::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 6px;
}

#prompter-display::-webkit-scrollbar-thumb:hover {
    background: #666;
}

#scrolling-content {
    min-height: auto;
    /* Changed from 150% since we use margins now */
    margin: 30vh 0 50vh 0;
    /* Use margin for spacing so cursor doesn't trigger on it */
    padding: 0 5%;

    font-size: 60px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    outline: none;
    cursor: text;
    /* Only text area gets text cursor */
}

/* Help and Share Modals */
/* ── Modales existantes ─────────────────────────────────────────────────── */
#help-modal,
#share-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #222;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 20px;
    z-index: 2000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

#help-modal.hidden,
#share-modal.hidden {
    display: none;
}

.help-content h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.help-content ul {
    list-style: none;
    margin-bottom: 20px;
}

.help-content li {
    margin-bottom: 10px;
    font-size: 1rem;
}

#close-help-btn {
    width: 100%;
    padding: 8px;
    background: #444;
    border: none;
}

#close-help-btn:hover {
    background: #555;
}

/* Mobile Fullscreen Button */
#mobile-fullscreen-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid white;
    padding: 10px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
}

#mobile-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}