* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #22c55e;
    --success-dark: #16a34a;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --secondary: #6b7280;
    --telegram: #2196F3;
    --telegram-dark: #1976D2;
    --bg-dark: #1a1a1a;
    --bg-light: #f5f5f5;
    --border: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
}

html, body { height: 100%; background: var(--bg-dark); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* ===== TABS ===== */
.mobile-tabs { display: none; }

/* ===== LAYOUT ===== */
.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100vh;
    padding: 20px;
}

/* ===== EDITOR PANEL ===== */
.editor-panel {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    padding: 20px;
    overflow: hidden;
    height: 100%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    flex-shrink: 0;
}

.header h1 { font-size: 24px; font-weight: 700; }

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

.editor-controls {
    background: var(--bg-light);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.control-row label { white-space: nowrap; min-width: 100px; }

.slider { flex: 1; cursor: pointer; }

.text-editor {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 15px;
    font-family: 'Courier New', monospace;
    resize: none;
    margin-bottom: 12px;
    color: var(--text-primary);
    min-height: 0;
}

.editor-footer { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ===== DISPLAY PANEL ===== */
.display-panel {
    display: block;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    height: 100%;
}

/* Камера на весь фон */
.camera-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    z-index: 1;
}

/* Контейнер скроллящегося текста */
.teleprompter-wrap {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
}

.teleprompter-text {
    position: absolute;
    width: 100%;
    padding: 24px;
    color: white;
    font-size: 48px;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0,0,0,0.9), 0 0 30px rgba(0,0,0,0.7);
    word-break: break-word;
    will-change: transform;
    top: 0;
    left: 0;
}

/* Кнопки поверх */
.controls-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    pointer-events: all;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}

.bottom-controls {
    display: flex;
    gap: 10px;
    padding: 16px;
    pointer-events: all;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
}

.recording-status {
    color: white;
    font-size: 13px;
    font-weight: 600;
    background: rgba(0,0,0,0.4);
    padding: 6px 12px;
    border-radius: 20px;
}

.recording-status.active {
    background: rgba(239,68,68,0.7);
}

.icon-btn {
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

/* Превью видео после записи */
.video-preview-panel {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: #111;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
}

.video-preview-panel video {
    width: 100%;
    border-radius: 8px;
    background: #000;
    margin-bottom: 12px;
}

.video-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.video-actions .btn { flex: 1; }

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    touch-action: manipulation;
}

.btn-small { padding: 7px 11px; font-size: 12px; }
.btn-large { padding: 16px 20px; font-size: 16px; flex: 1; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-telegram { background: var(--telegram); color: white; }

@media (hover: hover) {
    .btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
    .btn-success:hover:not(:disabled) { background: var(--success-dark); }
    .btn-danger:hover:not(:disabled) { background: var(--danger-dark); }
    .btn-telegram:hover:not(:disabled) { background: var(--telegram-dark); }
}

.btn:active:not(:disabled) { transform: scale(0.96); }

/* ===== NOTICES ===== */
.bot-notice {
    background: rgba(34,197,94,0.15);
    border: 1px solid var(--success);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--success);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.telegram-status {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}
.telegram-status.sending { background: rgba(33,150,243,0.1); color: var(--telegram); border: 1px solid var(--telegram); }
.telegram-status.success { background: rgba(34,197,94,0.1); color: var(--success); border: 1px solid var(--success); }
.telegram-status.error { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid var(--danger); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--secondary); border-radius: 4px; }

.mobile-only { display: none; }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    html, body { overflow: hidden; height: 100%; height: 100dvh; }

    .mobile-tabs {
        display: flex;
        position: fixed;
        top: 0; left: 0; right: 0;
        z-index: 200;
        background: #111;
        border-bottom: 2px solid #333;
        height: 52px;
    }

    .tab-btn {
        flex: 1;
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        color: #888;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
        touch-action: manipulation;
    }

    .tab-btn.active { color: white; border-bottom-color: var(--primary); }

    .container {
        display: block;
        height: calc(100dvh - 52px);
        margin-top: 52px;
        padding: 0;
        gap: 0;
    }

    .editor-panel,
    .display-panel {
        display: none !important;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    #tab-editor.active  { display: flex   !important; padding: 16px; }
    #tab-display.active { display: block  !important; }

    .text-editor { font-size: 16px; min-height: 120px; }

    .header h1 { font-size: 20px; }

    .editor-footer { gap: 8px; }
    .editor-footer .btn { flex: 1; font-size: 13px; }

    .mobile-only { display: flex !important; }

    .teleprompter-text { font-size: 36px; padding: 16px; }

    .bottom-controls { padding: 12px; gap: 8px; }
    .btn-large { padding: 16px 10px; font-size: 15px; }
}
