@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
    --bg: #0c0c0e;
    --surface: #151519;
    --surface-2: #1e1e24;
    --surface-3: #272730;
    --text: #f2f2f0;
    --text-muted: #8f8f96;
    --border: #2a2a32;
    --accent: #ff3b30;
    --accent-hover: #ff5e55;
    --accent-glow: rgba(255, 59, 48, 0.35);
    --live: #00e676;
    --live-glow: rgba(0, 230, 118, 0.35);
    --info: #00d4ff;
    --warning: #ffbd2e;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --font-display: 'Noto Sans SC', 'Source Han Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-body: 'Noto Sans SC', 'Source Han Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
}

body {
    background:
        radial-gradient(circle at 10% 20%, rgba(255, 59, 48, 0.06) 0%, transparent 25%),
        radial-gradient(circle at 90% 80%, rgba(0, 212, 255, 0.05) 0%, transparent 25%),
        var(--bg);
}

.app {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 24px 48px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #b71c1c);
    color: #fff;
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    box-shadow: 0 6px 20px var(--accent-glow);
}

.brand-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 32px;
    letter-spacing: 1px;
}

.brand-subtitle {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.global-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--live);
    box-shadow: 0 0 8px var(--live-glow);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: var(--accent);
}

@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(1.3); }
    100% { opacity: 1; transform: scale(1); }
}

/* Main */
.app-main {
    flex: 1;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 28px;
}

.section-title {
    margin: 0 0 18px;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 400;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

/* Form */
.add-room-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-options {
    align-items: center;
}

input[type="text"] {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-url {
    flex: 1;
    min-width: 260px;
}

.input-tags {
    flex: 0 1 240px;
    min-width: 160px;
}

/* Toggle */
.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    color: var(--text-muted);
    font-size: 14px;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    width: 42px;
    height: 24px;
    background: var(--surface-3);
    border-radius: 999px;
    position: relative;
    transition: background 0.25s;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--text);
    border-radius: 50%;
    transition: transform 0.25s;
}

.toggle input:checked + .toggle-track {
    background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
    transform: translateX(18px);
}

.toggle input:checked ~ .toggle-label {
    color: var(--text);
}

/* Buttons */
.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-record {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-stop {
    background: var(--warning);
    color: #1a1a1a;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

.btn-danger {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-danger:hover {
    background: rgba(255, 59, 48, 0.08);
}

/* Rooms grid */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.room-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: fadeIn 0.5s ease-out both;
    transition: transform 0.2s, border-color 0.2s;
}

.room-card:hover {
    transform: translateY(-3px);
    border-color: var(--surface-3);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.room-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.room-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 20px;
    line-height: 1.3;
    word-break: break-all;
}

.room-title.unknown {
    color: var(--text-muted);
}

.room-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.room-status.live {
    background: rgba(0, 230, 118, 0.12);
    color: var(--live);
    box-shadow: 0 0 10px var(--live-glow);
}

.room-status.ended {
    background: var(--surface-3);
    color: var(--text-muted);
}

.room-status.unknown {
    background: var(--surface-3);
    color: var(--text-muted);
}

.room-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.room-status.live .dot {
    animation: pulse 1.6s infinite;
}

.room-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.room-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.online-count {
    font-family: var(--font-mono);
    color: var(--info);
    font-size: 14px;
}

.room-url {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
    background: var(--surface-2);
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
}

.room-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.room-actions .spacer {
    flex: 1;
}

.recording-timer {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(255, 59, 48, 0.10);
    padding: 4px 10px;
    border-radius: 8px;
    min-width: 52px;
    text-align: center;
    letter-spacing: 0.5px;
}

.recordings {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-top: 4px;
}

.recordings-title {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recordings-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 140px;
    overflow-y: auto;
}

.recording-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

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

.recording-status {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
}

.recording-status.completed {
    background: rgba(0, 230, 118, 0.12);
    color: var(--live);
}

.recording-status.recording {
    background: rgba(255, 59, 48, 0.12);
    color: var(--accent);
}

.recording-status.failed {
    background: rgba(255, 59, 48, 0.12);
    color: var(--accent);
}

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

.recording-date {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 52px;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    border-radius: 10px;
    padding: 14px 18px;
    min-width: 260px;
    max-width: 360px;
    box-shadow: var(--shadow);
    animation: slideIn 0.35s ease-out;
    font-size: 14px;
}

.toast.error {
    border-left-color: var(--accent);
}

.toast.success {
    border-left-color: var(--live);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-header .section-title {
    margin: 0;
}

.log-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--border);
}

.log-content {
    flex: 1;
    margin: 0;
    padding: 16px 22px;
    overflow: auto;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-content .log-line {
    display: block;
    margin-bottom: 2px;
}

.log-content .log-level-INFO { color: var(--info); }
.log-content .log-level-WARNING { color: var(--warning); }
.log-content .log-level-ERROR { color: var(--accent); }
.log-content .log-level-CRITICAL { color: var(--accent); font-weight: bold; }

/* Footer */
.app-footer {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

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

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

/* Responsive */
@media (max-width: 640px) {
    .app {
        padding: 18px 14px 36px;
    }

    .brand-title {
        font-size: 24px;
    }

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

    .form-row {
        flex-direction: column;
    }

    .input-url, .input-tags {
        width: 100%;
    }
}
