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

body {
    background: linear-gradient(to bottom, #1e3a8a, #a855f7, #ec4899);
    color: #e2e8f0;
    font-family: 'Inter', sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#teleprompter {
    flex: 1;
    overflow-y: auto;
    padding: 5%;
    margin: 5rem 1rem 1rem;
    scrollbar-width: none;
    z-index: 1;
}

#teleprompter::-webkit-scrollbar {
    display: none;
}

#scriptContent {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.settings-panel {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 20;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease;
}

.settings-panel.bottom {
    top: auto;
    bottom: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
}

.settings-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
}

.position-toggle {
    position: absolute;
    right: 10px;
    top: -40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 21;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-height: 35px; /* Consistent with functional buttons */
}

.settings-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

.setting {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 140px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-group {
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
    align-items: center;
}

.status {
    font-size: 0.9rem;
    opacity: 0.9;
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    width: 100%;
}

input[type="number"],
input[type="range"],
textarea {
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(74, 85, 104, 0.5);
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s;
    flex: 1;
    min-width: 60px;
}

input[type="number"]:focus,
input[type="range"]:focus,
textarea:focus {
    outline: none;
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.3);
}

input[type="range"] {
    width: 100px;
}

label {
    font-size: 0.85rem;
    color: rgba(226, 232, 240, 0.8);
}

.functional-btn, a {
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: fit-content;
    min-height: 35px;
}

.functional-btn:hover, a:hover {
    background: #6366f1;
    transform: translateY(-1px);
}

.functional-btn:active, a:active {
    transform: translateY(0);
}

.functional-btn:disabled {
    background: #6b7280;
    cursor: not-allowed;
    transform: none;
}

#startBtn.active, #recordVideoBtn.active, #recordAudioBtn.active {
    background: #dc2626;
}

#startBtn.active:hover, #recordVideoBtn.active:hover, #recordAudioBtn.active:hover {
    background: #ef4444;
}

#pauseBtn.active {
    background: #dc2626;
}

#pauseBtn.active:hover {
    background: #ef4444;
}

#fontSizeValue {
    min-width: 3rem;
    text-align: center;
}

.highlight {
    border-radius: 4px;
    padding: 2px 4px;
    transition: all 0.2s;
}

.mobile-icon {
    display: inline-block;
    font-size: 1.2rem;
    margin-right: 0.25rem;
}

.btn-text {
    display: inline; /* Visible on desktop */
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1e293b;
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: #e2e8f0;
}

.modal-content textarea {
    width: 100%;
    min-height: 200px;
    margin-bottom: 1rem;
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(74, 85, 104, 0.5);
    border-radius: 8px;
    padding: 1rem;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

#videoPreview {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    border: 2px solid rgba(74, 85, 104, 0.5);
    border-radius: 8px;
    display: none;
    z-index: 1000;
    background: #000;
}

#audioPreview {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    width: 200px;
    height: 50px;
    border: 2px solid rgba(74, 85, 104, 0.5);
    border-radius: 8px;
    z-index: 1000;
    background: #000;
}

#browser-warning {
    display: none;
    background: #7f1d1d;
    color: #fee2e2;
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    position: fixed;
    top: 5.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    max-width: 90%;
}

#focusContainer {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    text-align: center;
}

#focusWords {
    display: none;
    min-width: 200px;
    padding: 1rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    font-size: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#exitFocusBtn {
    margin-top: 1rem;
    display: none;
    background: #dc2626;
}

#exitFocusBtn:hover {
    background: #ef4444;
}

.color-options {
    display: flex;
    flex-direction: row; /* Изменено с column на row */
    align-items: center;
    gap: 0.5rem; /* Увеличим промежуток между кнопками */
}

.color-options label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #e2e8f0;
    margin-right: 0.5rem; /* Добавим отступ справа от label */
    white-space: nowrap; /* Предотвращаем перенос текста */
}

.color-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%; /* Круглая форма */
    border: 2px solid rgba(255, 255, 255, 0.3);
    background-color: var(--bg-color);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    flex-shrink: 0; /* Предотвращаем сжатие кнопок */
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #ffffff;
}

.color-btn.selected {
    border-color: #ffffff;
    transform: scale(1.2);
}

input[type="color"] {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    min-height: 0; /* Exclude from functional button height */
}

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

input[type="color"]::-moz-color-swatch {
    border-radius: 50%;
    border: none;
}

:fullscreen #teleprompter,
:-webkit-full-screen #teleprompter {
    margin: 6rem 1rem 4rem;
    padding: 1rem;
    max-height: calc(100vh - 10rem);
}

:fullscreen .settings-panel,
:-webkit-full-screen .settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    transform: none;
    z-index: 20;
}

:fullscreen .buttons,
:-webkit-full-screen .buttons {
    justify-content: center;
    gap: 0.75rem;
}

:fullscreen #browser-warning,
:-webkit-full-screen #browser-warning {
    top: 6rem;
    z-index: 30;
}

:fullscreen #videoPreview,
:-webkit-full-screen #videoPreview {
    top: 80px;
    right: 20px;
}

:fullscreen #audioPreview,
:-webkit-full-screen #audioPreview {
    top: 80px;
    left: 20px;
}

@media (max-width: 768px) {
    .settings-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.75rem;
        top: auto;
        bottom: 0;
        transform: translateY(0);
    }

    .settings-panel.top {
        top: 0;
        bottom: auto;
    }

    .position-toggle {
        top: auto;
        bottom: -40px;
        right: 10px;
    }

    .settings-panel.top .position-toggle {
        top: -40px;
        bottom: auto;
    }

    .settings-controls {
        flex-direction: column;
        gap: 0.75rem;
    }

    .settings-group {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        width: 100%;
        gap: 0.75rem;
    }

    .setting {
        flex-direction: column;
        flex: 1;
        min-width: 120px;
    }

    .status-group {
        flex-direction: row;
        align-items: center;
        width: 100%;
        gap: 0.5rem;
        justify-content: center;
    }

    .buttons {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .functional-btn, a {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
        min-height: 35px; /* Functional buttons height */
    }

    .btn-text {
        display: none; /* Hide text on mobile */
    }

    #teleprompter {
        margin-top: 1rem;
        margin-bottom: 6rem;
    }

    .settings-panel.top + #teleprompter {
        margin-top: 6rem;
        margin-bottom: 1rem;
    }

    #browser-warning {
        top: auto;
        bottom: 6.5rem;
    }

    .settings-panel.top ~ #browser-warning {
        top: 5rem;
        bottom: auto;
    }

    #videoPreview {
        width: 120px;
        height: 90px;
        top: 10px;
        right: 10px;
    }

    #audioPreview {
        width: 120px;
        height: 40px;
        top: 10px;
        left: 10px;
    }

    :fullscreen #teleprompter,
    :-webkit-full-screen #teleprompter {
        margin: 5rem 0.5rem 3rem;
        padding: 0.5rem;
    }

    :fullscreen .settings-panel,
    :-webkit-full-screen .settings-panel {
        padding: 0.5rem;
    }

    :fullscreen #videoPreview,
    :-webkit-full-screen #videoPreview {
        top: 60px;
        right: 10px;
        width: 100px;
        height: 75px;
    }

    :fullscreen #audioPreview,
    :-webkit-full-screen #audioPreview {
        top: 60px;
        left: 10px;
        width: 100px;
        height: 35px;
    }

    .color-options label {
        font-size: 0.8rem;
    }

    .color-btn {
        width: 28px;
        height: 28px;
    }

    input[type="color"] {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .setting {
        min-width: 100px;
    }

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

    .buttons {
        gap: 0.25rem;
    }

    .functional-btn, a {
        padding: 0.2rem 0.5rem;
        font-size: 0.75rem;
        min-height: 35px; /* Functional buttons height */
    }

    .color-options label {
        font-size: 0.75rem;
    }
}
.color-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background-color: currentColor; /* Use inline style background-color */
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    aspect-ratio: 1 / 1; /* Ensure square shape */
    min-height: 0; /* Exclude from functional button height */
    box-sizing: content-box; /* Prevent padding from affecting size */
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #ffffff;
}

.color-btn.selected {
    border-color: #ffffff;
    transform: scale(1.2);
}

input[type="color"] {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    aspect-ratio: 1 / 1; /* Ensure square shape */
    min-height: 0; /* Exclude from functional button height */
    overflow: hidden; /* Hide any overflow from swatch */
}

input[type="color"]::-webkit-color-swatch {
    border-radius: 50%;
    border: none;
    padding: 0;
}

input[type="color"]::-moz-color-swatch {
    border-radius: 50%;
    border: none;
    padding: 0;
}

input[type="color"]::-ms-color-swatch {
    border-radius: 50%;
    border: none;
    padding: 0;
}

@media (max-width: 768px) {
    .color-options {
        gap: 0.4rem;
    }
    
    .color-btn {
        width: 28px;
        height: 28px;
    }
    
    .color-options label {
        font-size: 0.8rem;
    }
}