:root {
    --primary: #4f46e5;
    --success: #22c55e;
    --danger: #ef4444;
    --bg: #f9fafb;
    --text: #1f2937;
    --card: #ffffff;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --text: #f9fafb;
    --card: #1e293b;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    padding: 0.75rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    border-radius: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--border);
    transform: rotate(20deg);
}

/* Main Recording Section */
.main-recording-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 6px var(--shadow);
}

/* Preview Container */
.preview-container {
    margin-bottom: 0.75rem;
}

.preview {
    width: 100%;
    max-height: min(200px, 30vh);
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 0.375rem;
    position: relative;
    overflow: hidden;
}

.preview video {
    width: 100%;
    height: 100%;
    border-radius: 0.5rem;
}

/* Preview overlays */
.preview.with-frame {
    padding: var(--frame-size, 30px);
    background: linear-gradient(to bottom, var(--frame-color-1, #4f46e5), var(--frame-color-2, #9333ea));
}

.preview.with-label .preview-label {
    position: absolute;
    bottom: calc(var(--frame-size, 0px) + 20px);
    right: calc(var(--frame-size, 0px) + 20px);
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    z-index: 10;
}

.preview.with-icon .preview-icon {
    position: absolute;
    bottom: calc(var(--frame-size, 0px) + 60px);
    right: calc(var(--frame-size, 0px) + 20px);
    width: 64px;
    height: 64px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 10;
}

/* Recording Controls */
.recording-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.record-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--danger);
    border: 3px solid var(--card);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow), 0 0 0 0 rgba(239, 68, 68, 0.7);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 40px var(--shadow);
}

.record-btn:active {
    transform: scale(0.98);
}

.record-btn.recording {
    animation: blink-red 1.5s infinite;
}

@keyframes blink-red {
    0%, 100% {
        background: var(--danger);
        box-shadow: 0 10px 30px var(--shadow), 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        background: #dc2626;
        box-shadow: 0 10px 40px rgba(239, 68, 68, 0.6), 0 0 0 20px rgba(239, 68, 68, 0);
    }
}

.btn-stop {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px var(--shadow);
}

.btn-stop:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

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

.timer {
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--danger);
    text-align: center;
}

/* Recording Options */
.recording-options {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
}

.recording-options h3 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--text);
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.option-item label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.text-input {
    flex: 1;
    min-width: 150px;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    background: var(--card);
    color: var(--text);
    font-size: 0.8rem;
    transition: all 0.2s;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.file-input {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text);
}

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

.color-picker {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    background: transparent;
}

.color-picker::-webkit-color-swatch {
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 0;
}

.range-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 120px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.flex-align-center {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.frame-size-label,
.opacity-label {
    font-size: 0.75rem;
    min-width: 32px;
}

/* Status */
.status {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--text);
    opacity: 0.8;
}

/* Gallery Section */
.gallery-section {
    margin-top: 0.75rem;
}

.gallery-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.downloads {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.no-downloads {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.5rem;
    color: var(--text);
    opacity: 0.6;
    font-size: 0.9rem;
}

.download-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px var(--shadow);
}

.download-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px var(--shadow);
}

.download-button {
    display: block;
    width: 100%;
    padding: 0.6rem;
    background: var(--card);
    border: none;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.8rem;
}

.download-button:hover {
    background: var(--bg);
}

.delete-button {
    width: 100%;
    padding: 0.5rem;
    background: var(--danger);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.delete-button:hover {
    background: #dc2626;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: #333;
    color: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    font-size: 0.95rem;
    max-width: 350px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: #f59e0b;
}

.toast-info {
    background: var(--primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .record-btn {
        width: 150px;
        height: 150px;
        font-size: 1rem;
    }

    .timer {
        font-size: 1.5rem;
    }

    .downloads {
        grid-template-columns: 1fr;
    }

    .main-recording-section {
        padding: 1rem;
    }

    .option-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
