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

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    padding: 20px 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

.header-text h1 {
    font-size: 2rem;
    margin-bottom: 4px;
}

.subtitle {
    opacity: 0.9;
    font-size: 1rem;
}

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

.help-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.help-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

/* 房间信息栏 */
.room-bar {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.room-label {
    font-weight: 500;
    color: var(--text-light);
}

.room-code {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    background: var(--primary);
    color: white;
    padding: 6px 16px;
    border-radius: 8px;
}

.connection-status {
    font-size: 0.85rem;
    color: var(--text-light);
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 12px;
}

.room-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.room-actions input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    text-transform: uppercase;
    width: 100px;
}

.room-actions input:focus {
    outline: none;
    border-color: var(--primary);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .room-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .room-info, .room-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text);
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn .icon {
    font-size: 1.1rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

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

/* 文件夹选择器 */
.folder-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    min-width: 120px;
}

.folder-select:focus {
    outline: none;
    border-color: var(--primary);
}

.preview-area {
    margin-top: 16px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.preview-area img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
}

.preview-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.status {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: var(--danger);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.video-preview {
    margin-top: 16px;
    width: 100%;
    max-height: 180px;
    border-radius: 8px;
    background: #000;
}

.recording-save {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

/* 文件夹管理 */
.folder-manager {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.folder-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.folder-item:hover {
    border-color: var(--primary);
}

.folder-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.folder-item .delete-folder {
    padding: 2px 6px;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 4px;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.8rem;
}

.folder-item .delete-folder:hover {
    background: var(--danger);
    color: white;
}

.folder-create {
    display: flex;
    gap: 8px;
}

.folder-create input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}

.folder-create input:focus {
    outline: none;
    border-color: var(--primary);
}

/* 文件列表 */
.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.file-folder-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#currentFolderName {
    font-weight: 600;
    font-size: 1.1rem;
}

.file-count {
    color: var(--text-light);
    font-size: 0.9rem;
}

.file-list {
    max-height: 450px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.file-item:hover {
    background: var(--bg);
}

.file-icon {
    font-size: 2rem;
    margin-right: 12px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

.file-actions {
    display: flex;
    gap: 6px;
}

.file-actions button {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.file-actions .download-btn {
    background: var(--primary);
    color: white;
}

.file-actions .delete-btn {
    background: var(--danger);
    color: white;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 28px;
    background: var(--text);
    color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.hidden {
    display: none !important;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 550px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.modal-header h2 {
    font-size: 1.2rem;
}

.close-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.4rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(85vh - 76px);
}

.modal-body section {
    margin-bottom: 20px;
}

.modal-body section:last-child {
    margin-bottom: 0;
}

.modal-body h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--primary);
}

.modal-body ul {
    list-style: none;
    padding: 0;
}

.modal-body li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

.modal-body li:last-child {
    border-bottom: none;
}

.modal-body code {
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--danger);
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* 设置按钮 */
.settings-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

/* 快捷键列表 */
.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-action {
    font-weight: 500;
    color: var(--text);
}

.shortcut-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    min-width: 140px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    justify-content: center;
}

.shortcut-input:hover {
    border-color: var(--primary);
}

.shortcut-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.shortcut-input.recording {
    border-color: var(--warning);
    background: #fffbeb;
    animation: flashBorder 0.5s infinite;
}

@keyframes flashBorder {
    0%, 100% { border-color: var(--warning); }
    50% { border-color: #fbbf24; }
}

.shortcut-input .key-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    background: var(--primary);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
}

.shortcut-input .key-badge kbd {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    font-size: 0.85em;
    margin-left: 2px;
}

.shortcut-input.empty {
    color: var(--text-light);
    font-style: italic;
}

.shortcut-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-light);
    text-align: center;
}

.shortcut-reset {
    margin-top: 20px;
    text-align: center;
}

/* 区域选择覆盖层 */
.region-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    cursor: crosshair;
}

.region-overlay canvas {
    position: absolute;
    top: 0;
    left: 0;
}

.selection-info {
    position: fixed;
    padding: 8px 14px;
    background: var(--text);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: 'Monaco', 'Consolas', monospace;
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.15s;
}

.selection-info.visible {
    opacity: 1;
}

.selection-hint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 28px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 10px;
    font-size: 1rem;
    pointer-events: none;
    z-index: 10000;
}
