/* --- Design Tokens --- */
:root {
    --bg-color: #000000;
    --text-main: #FFFFFF;
    --text-dim: #888888;

    --surface: #000000;
    --surface-container: #111111;
    --surface-hover: #1A1A1A;
    --surface-glass: rgba(15, 15, 15, 0.78);

    --outline: #2A2A2A;
    --accent: #FFFFFF;
    --danger: #FF3B30;

    --radius-lg: 24px;
    --radius-md: 12px;

    --font-main: 'Roboto', sans-serif;
    --font-mono: 'Space Mono', monospace;

    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
}

.ambient-glow {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.07) 0%, rgba(0,0,0,0) 60%);
    z-index: -1;
    pointer-events: none;
}

/* Wider Container for Larger Preview */
.app-container {
    width: 100%;
    max-width: 960px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

/* --- Header --- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0 1.25rem 0;
}

.home-link {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s ease;
}

.home-link:hover { opacity: 0.7; }

.logo-section h1 {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--text-dim);
    letter-spacing: -0.5px;
}

.logo-section .highlight {
    color: var(--text-main);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
    border: 1px solid var(--outline);
    padding: 6px 12px;
    border-radius: 50px;
    background: rgba(0,0,0,0.5);
}

.live-dot {
    width: 6px; height: 6px;
    background-color: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.9); }
}

/* --- Large Camera Viewport --- */
.camera-section {
    margin-bottom: 3rem;
}

.viewport-wrapper {
    background-color: var(--surface-container);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    width: 100%;
    height: 74vh;
    min-height: 500px;
    max-height: 780px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}

#cameraFeed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    transform: scaleX(-1);
    transition: filter 0.35s ease, opacity 0.35s ease, transform 0.25s ease;
}

#cameraFeed.unmirrored {
    transform: scaleX(1);
}

/* Privacy Blur & Dim */
.viewport-wrapper.privacy-active #cameraFeed {
    filter: blur(60px) brightness(0.04);
}

.privacy-curtain {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.viewport-wrapper.privacy-active .privacy-curtain {
    opacity: 1;
}

/* Flash Effect */
.flash-overlay {
    position: absolute;
    inset: 0;
    background: #FFFFFF;
    z-index: 4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease-out;
}

.flash-overlay.flash { opacity: 0.85; }

/* --- Top HUD --- */
.hud-top {
    position: relative;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
}

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

.pill {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 4px 9px;
    border-radius: 6px;
    background: var(--surface-glass);
    border: 1px solid var(--outline);
    color: var(--text-main);
    backdrop-filter: blur(8px);
}

.hdr-pill.active {
    border-color: var(--accent);
    font-weight: 700;
}

.rec-pill {
    background: rgba(255, 59, 48, 0.22);
    border-color: var(--danger);
    color: #FF6961;
    animation: pulse 1s infinite;
}

.hidden { display: none !important; }

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

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--surface-glass);
    border: 1px solid var(--outline);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    backdrop-filter: blur(8px);
    transition: all 0.2s var(--ease-spring);
}

.icon-btn span { font-size: 18px; }

.icon-btn:hover, .icon-btn.active {
    background: var(--accent);
    color: var(--bg-color);
    border-color: var(--accent);
}

/* --- Settings Drawer --- */
.settings-drawer {
    position: absolute;
    top: 60px;
    right: 16px;
    width: 260px;
    background: rgba(12, 12, 12, 0.95);
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    padding: 14px;
    z-index: 10;
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: all 0.22s var(--ease-spring);
}

.settings-drawer.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--outline);
    padding-bottom: 6px;
}

.close-drawer {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
}

.close-drawer:hover { color: var(--text-main); }
.close-drawer span { font-size: 16px; }

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-group label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-dim);
}

.setting-group select {
    background: var(--surface-container);
    color: var(--text-main);
    border: 1px solid var(--outline);
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    outline: none;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.setting-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.mic-test-box {
    border-top: 1px solid var(--outline);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    background: var(--surface-hover);
    border: 1px solid var(--outline);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover { border-color: var(--accent); }
.action-btn.testing { background: var(--accent); color: var(--bg-color); }

.audio-meter {
    height: 4px;
    background: var(--outline);
    border-radius: 4px;
    overflow: hidden;
}

.audio-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.06s linear;
}

/* --- Bottom HUD --- */
.hud-bottom {
    position: relative;
    z-index: 5;
    padding: 18px 24px;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.mode-selector {
    display: flex;
    gap: 4px;
    background: var(--surface-glass);
    padding: 3px;
    border-radius: 50px;
    border: 1px solid var(--outline);
    backdrop-filter: blur(8px);
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 5px 14px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn.active {
    background: var(--accent);
    color: var(--bg-color);
    font-weight: 700;
}

.shutter-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bar-side {
    flex: 1;
    display: flex;
    align-items: center;
}

.bar-side.right {
    justify-content: flex-end;
    gap: 12px;
}

.pill-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-glass);
    border: 1px solid var(--outline);
    color: var(--text-dim);
    padding: 7px 14px;
    border-radius: 50px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
}

.pill-toggle span.material-symbols-rounded { font-size: 16px; }

.pill-toggle.active {
    border-color: var(--accent);
    color: var(--text-main);
}

.shutter-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    background: transparent;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s var(--ease-spring);
}

.shutter-btn:hover { transform: scale(1.06); }
.shutter-btn:active { transform: scale(0.94); }

.shutter-inner {
    width: 100%;
    height: 100%;
    background: var(--accent);
    border-radius: 50%;
    transition: all 0.25s var(--ease-spring);
}

.shutter-btn.video-mode .shutter-inner { background: var(--danger); }

.shutter-btn.recording .shutter-inner {
    background: var(--danger);
    width: 52%;
    height: 52%;
    border-radius: 6px;
}

/* Snapshot Button During Video */
.snap-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-glass);
    border: 1px solid var(--accent);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s var(--ease-spring);
}

.snap-btn:hover {
    background: var(--accent);
    color: var(--bg-color);
    transform: scale(1.08);
}

.folder-tag {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
}

.folder-tag span.material-symbols-rounded { font-size: 16px; }

/* --- Uploads Log --- */
.log-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 1.5rem;
}

.log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    border-bottom: 1px solid var(--outline);
    padding-bottom: 8px;
}

.log-header span.material-symbols-rounded { font-size: 16px; }

.log-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-card {
    background-color: var(--surface-container);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 14px;
    animation: slideIn 0.35s var(--ease-spring) forwards;
    opacity: 0;
    transform: translateX(-15px);
    border: 1px solid var(--outline);
}

.log-card.success { border-color: #444; }
.log-card.error { border-color: var(--danger); border-style: dashed; }

.file-icon-box {
    width: 40px; height: 40px;
    background-color: var(--surface-hover);
    color: var(--text-main);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--outline);
    flex-shrink: 0;
}

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

.file-name {
    font-size: 0.88rem;
    font-weight: 500;
    display: block;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-status {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.progress-bar {
    height: 2px;
    background-color: var(--outline);
    margin-top: 8px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    position: absolute;
    left: 0; top: 0; height: 100%;
    background-color: var(--accent);
    width: 0%;
    transition: width 0.25s ease;
}

.progress-fill.indeterminate {
    width: 35%;
    animation: indeterminate 1.2s infinite ease-in-out;
}

@keyframes indeterminate {
    0% { left: -35%; }
    100% { left: 100%; }
}

.card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* --- Preview Modal --- */
.preview-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

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

.modal-box {
    position: relative;
    z-index: 1;
    background: var(--surface-container);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 820px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--outline);
}

.modal-filename {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.modal-body {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 75vh;
}

.modal-body img,
.modal-body video {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}

/* --- Footer --- */
footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.82rem;
    padding-bottom: 0.5rem;
}

footer a {
    color: var(--text-dim);
    text-decoration: none;
    margin: 0 4px;
}

footer a:hover {
    color: var(--text-main);
    text-decoration: underline;
}

/* --- Popout Window Mode --- */
body.pip-window {
    padding: 0;
    margin: 0;
    background: #000;
}
body.pip-window .viewport-wrapper {
    width: 100vw;
    height: 100vh;
    max-height: none;
    min-height: 0;
    border-radius: 0;
    border: none;
}

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

@media (max-width: 650px) {
    .app-container { padding: 1rem; }
    .viewport-wrapper { height: 62vh; min-height: 400px; }
    .hud-bottom { padding: 14px; }
}