:root {
    --bg-color: #1a1a1e;
    --shadow-light: #25252b;
    --shadow-dark: #0f0f11;
    --accent-color: #a78bfa;
    --accent-glow: rgba(167, 139, 250, 0.45);
    --text-color: #e0e0e0;
    --danger-color: #ff6b6b;
    --ok-color: #7CFFB2;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.header {
    width: 100%;
    padding: 16px;
    text-align: center;
    box-shadow: 0 5px 15px var(--shadow-dark);
    z-index: 10;
}

h1 {
    margin: 0;
    font-weight: 300;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-glow);
}

.video-container {
    width: 94%;
    max-width: 560px;
    margin-top: 14px;
    border-radius: 20px;
    padding: 10px;
    background: var(--bg-color);
    box-shadow: 10px 10px 20px var(--shadow-dark),
               -10px -10px 20px var(--shadow-light);
    position: relative;
}

#videoElement {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 15px;
    background-color: #000;
    transform: scaleX(-1);
    display: block;
    object-fit: cover;
}

#videoElement.environment { transform: scaleX(1); }
#videoElement.camera-off { visibility: hidden; }

.camera-placeholder {
    position: absolute;
    inset: 10px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #050507;
    color: var(--accent-color);
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: inset 5px 5px 12px #000,
                inset -5px -5px 12px rgba(255,255,255,0.04);
}
.camera-placeholder.hidden { display: none; }

.overlay {
    position: absolute;
    inset: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    border-radius: 15px;
    pointer-events: none;
}

.rec-badge, .mode-badge {
    position: absolute;
    top: 20px;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
}
.rec-badge { right: 20px; color: var(--danger-color); display: none; }
.rec-badge.active { display: inline-block; animation: pulse 1s infinite; }
.mode-badge { left: 20px; color: var(--accent-color); }

@keyframes pulse { 50% { opacity: 0.4; } }

.presets, .modes, .controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 94%;
    max-width: 560px;
    margin-top: 14px;
}

.presets .preset {
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 12px;
}

.modes .mode {
    flex: 1;
    padding: 12px 8px;
    font-size: 14px;
}
.modes .mode.active {
    color: var(--accent-color);
    background: var(--bg-color);
    border-color: var(--accent-color);
    box-shadow: inset 3px 3px 8px var(--shadow-dark),
                inset -3px -3px 8px var(--shadow-light);
}

button {
    padding: 14px 20px;
    border: 1.5px solid transparent;
    border-radius: 15px;
    background: var(--bg-color);
    color: var(--accent-color);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 5px 5px 10px var(--shadow-dark),
               -5px -5px 10px var(--shadow-light);
    transition: all 0.15s ease;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    flex-shrink: 0;
}

.presets .preset .btn-icon { width: 16px; height: 16px; }

button:active {
    box-shadow: inset 3px 3px 8px var(--shadow-dark),
                inset -3px -3px 8px var(--shadow-light);
    border-color: var(--accent-color);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

button.recording, button.running {
    color: var(--accent-color);
    background: var(--bg-color);
    border-color: var(--accent-color);
    box-shadow: inset 3px 3px 8px var(--shadow-dark),
                inset -3px -3px 8px var(--shadow-light);
    text-shadow: 0 0 8px var(--accent-glow);
}

.status-panel {
    width: 94%;
    max-width: 560px;
    min-height: 160px;
    max-height: 40vh;
    margin: 16px 0 24px;
    border-radius: 20px;
    padding: 16px;
    background: var(--bg-color);
    box-shadow: inset 5px 5px 10px var(--shadow-dark),
                inset -5px -5px 10px var(--shadow-light);
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
}

.status-line {
    margin-bottom: 10px;
    border-bottom: 1px solid var(--shadow-light);
    padding-bottom: 6px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.status-line img {
    width: 56px; height: 42px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
}
.status-line.alert { color: var(--danger-color); }
.status-line.ok { color: var(--ok-color); }
.status-line .time { color: #888; margin-right: 6px; flex-shrink: 0; }

.modal {
    display: none;
    position: fixed;
    z-index: 100;
    inset: 0;
    background-color: rgba(0,0,0,0.8);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-color);
    padding: 24px;
    border-radius: 20px;
    width: 90%;
    max-width: 420px;
    box-shadow: 10px 10px 20px var(--shadow-dark),
               -10px -10px 20px var(--shadow-light);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-content input {
    padding: 12px;
    border-radius: 10px;
    border: none;
    background: var(--bg-color);
    color: var(--text-color);
    box-shadow: inset 3px 3px 6px var(--shadow-dark),
                inset -3px -3px 6px var(--shadow-light);
    outline: none;
    font-size: 14px;
}

.lbl { font-size: 12px; color: #999; margin-top: 4px; }

#activePrompt {
    color: var(--accent-color);
    font-weight: 500;
    text-align: center;
    margin-top: 10px;
    font-style: italic;
    font-size: 14px;
    padding: 0 14px;
}

.media-preview {
    width: 94%;
    max-width: 560px;
    margin-top: 14px;
    border-radius: 20px;
    padding: 10px;
    background: var(--bg-color);
    box-shadow: inset 5px 5px 10px var(--shadow-dark),
                inset -5px -5px 10px var(--shadow-light);
    position: relative;
}
.media-preview img, .media-preview video {
    width: 100%;
    border-radius: 12px;
    display: block;
}
#previewDoc {
    padding: 30px 20px;
    text-align: center;
    color: var(--accent-color);
}
#previewDoc .doc-icon { font-size: 60px; margin-bottom: 10px; }

.report-panel {
    width: 94%;
    max-width: 560px;
    margin-top: 14px;
    border-radius: 20px;
    padding: 14px 18px;
    background: var(--bg-color);
    box-shadow: 6px 6px 14px var(--shadow-dark),
                -6px -6px 14px var(--shadow-light);
    font-size: 14px;
    line-height: 1.5;
}
.report-title {
    color: var(--accent-color);
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}
#reportBody { color: var(--text-color); white-space: pre-wrap; }
.report-stats {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.report-stats .chip {
    padding: 4px 10px; border-radius: 10px;
    background: var(--shadow-light); color: var(--accent-color);
    font-size: 12px; font-weight: 600;
}
.modes .mode { min-width: 0; }

.tasks-panel {
    width: 94%;
    max-width: 560px;
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.tasks-panel .tasks-label {
    font-size: 12px;
    color: #888;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    width: 100%;
    margin-bottom: 2px;
}
.task-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    border-radius: 12px;
    background: var(--bg-color);
    color: var(--accent-color);
    border: 1.5px solid var(--accent-color);
    font-size: 13px;
    max-width: 100%;
}
.task-chip .task-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}
.task-chip .task-remove {
    all: unset;
    cursor: pointer;
    color: var(--accent-color);
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.8;
}
.task-chip .task-remove:hover { opacity: 1; }
.tasks-empty {
    font-size: 13px;
    color: #666;
    font-style: italic;
}

.color-slider-wrap {
    width: 94%;
    max-width: 560px;
    margin: 14px 0 24px;
    padding: 0 4px;
}

#colorSlider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg,
        #ffffff 0%,
        #ff4d4d 30%,
        #a855f7 70%,
        #000000 100%);
    outline: none;
    cursor: pointer;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.45),
                inset -2px -2px 4px rgba(255,255,255,0.06);
}

#colorSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    border: 2px solid var(--bg-color);
    box-shadow: 0 0 10px var(--accent-glow);
    margin-top: -1px;
}

#colorSlider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    border: 2px solid var(--bg-color);
    box-shadow: 0 0 10px var(--accent-glow);
}