/* ── RESET & BASE ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; overflow: hidden; background: #0a0a0a; color: #fff; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif; font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
#app { display: flex; flex-direction: column; height: 100vh; width: 100vw; position: relative; }

/* ── SCREEN BASE ──────────────────────────────────────────────── */
.screen { display: none; flex-direction: column; flex: 1; overflow: hidden; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); animation: fadeIn 0.25s ease; }
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── WELCOME SCREEN ───────────────────────────────────────────── */
#screen-welcome { justify-content: center; align-items: center; text-align: center; gap: 20px; }
.logo { font-size: 72px; line-height: 1; }
h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.tagline { color: #9ca3af; font-size: 16px; line-height: 1.6; }
.small-note { color: #6b7280; font-size: 13px; text-align: center; }

/* ── BUTTONS ──────────────────────────────────────────────────── */
.button-group { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
.btn { width: 100%; padding: 14px 20px; border: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.15s; -webkit-tap-highlight-color: transparent; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:active { background: #2563eb; transform: scale(0.98); }
.btn-secondary { background: #1f2937; color: #fff; }
.btn-secondary:active { background: #374151; transform: scale(0.98); }
.btn-danger { background: #7f1d1d; color: #fecaca; }
.btn-danger:active { background: #991b1b; }
.btn-small { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 8px; }

/* ── INPUTS ───────────────────────────────────────────────────── */
.input, .seed-input { width: 100%; padding: 12px 14px; background: #111827; border: 1px solid #374151; border-radius: 10px; color: #fff; font-size: 16px; font-family: inherit; outline: none; margin-bottom: 12px; }
.input:focus, .seed-input:focus { border-color: #3b82f6; }
.seed-input { font-family: 'SF Mono', Menlo, monospace; font-size: 15px; line-height: 1.6; resize: none; }

/* ── SEED PHRASE ──────────────────────────────────────────────── */
.seed-box { background: #111827; border: 1px solid #374151; border-radius: 12px; padding: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-family: 'SF Mono', Menlo, monospace; font-size: 15px; text-align: center; }
.seed-box span { background: #1f2937; padding: 8px 4px; border-radius: 6px; }
.warning { color: #fca5a5; font-size: 14px; line-height: 1.5; text-align: center; }

/* ── RECORD SCREEN ────────────────────────────────────────────── */
#screen-record { padding: 0; position: relative; flex-direction: column; }
.camera-container { flex: 1; position: relative; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#camera-preview { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-overlay { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; }
.timer { font-size: 18px; font-weight: 600; background: rgba(0,0,0,0.6); padding: 6px 14px; border-radius: 8px; align-self: center; }
.permission-msg { background: rgba(0,0,0,0.8); padding: 12px 20px; border-radius: 12px; text-align: center; font-size: 14px; }

/* Record controls */
.record-controls { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 0 40px; background: #0a0a0a; }
.record-btn { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.record-ring { width: 56px; height: 56px; background: #ef4444; border-radius: 50%; transition: all 0.2s; }
.record-btn.recording .record-ring { width: 28px; height: 28px; border-radius: 4px; background: #ef4444; }
.record-hint { color: #9ca3af; font-size: 13px; }

/* Stats bar */
.stats-bar { display: flex; justify-content: space-between; padding: 8px 16px; background: #111827; font-size: 12px; color: #9ca3af; }
.stats-bar .mono { font-family: 'SF Mono', monospace; }

/* ── GALLERY SCREEN ───────────────────────────────────────────── */
.screen-header { padding: 16px 0 8px; border-bottom: 1px solid #1f2937; margin-bottom: 12px; }
.screen-header h2 { font-size: 22px; font-weight: 700; }
.screen-header p { color: #9ca3af; font-size: 14px; }

.video-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.video-card { display: flex; gap: 14px; padding: 14px 4px; border-bottom: 1px solid #1f2937; cursor: pointer; }
.video-card:active { background: #1f2937; }
.video-thumb { width: 80px; height: 100px; background: #1f2937; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-thumb .no-thumb { font-size: 24px; }
.video-info { flex: 1; min-width: 0; }
.video-title { font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-meta { color: #9ca3af; font-size: 13px; line-height: 1.5; }
.video-status { font-size: 12px; padding: 2px 8px; border-radius: 4px; display: inline-block; margin-top: 4px; }
.status-local { background: #1e3a5f; color: #93c5fd; }
.status-uploaded { background: #064e3b; color: #6ee7b7; }
.status-pending { background: #451a03; color: #fcd34d; }
.status-failed { background: #450a0a; color: #fca5a5; }

/* ── QUEUE SCREEN ─────────────────────────────────────────────── */
.queue-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.queue-item { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid #1f2937; }
.queue-item .progress-bar { height: 4px; background: #1f2937; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.queue-item .progress-fill { height: 100%; background: #3b82f6; border-radius: 2px; transition: width 0.3s; }

/* ── SETTINGS ─────────────────────────────────────────────────── */
.settings-group { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid #1f2937; }
.settings-group h3 { font-size: 14px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.relay-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.relay-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #111827; border-radius: 8px; font-size: 14px; }
.relay-row .url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relay-row .btn-text { color: #ef4444; background: none; border: none; font-size: 12px; cursor: pointer; padding: 4px 8px; }
.add-row { display: flex; gap: 8px; }
.add-row .input { flex: 1; margin-bottom: 0; }
.code { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; word-break: break-all; color: #9ca3af; background: #111827; padding: 10px; border-radius: 8px; margin-bottom: 10px; }

/* ── VIDEO DETAIL ─────────────────────────────────────────────── */
#screen-video-detail { padding: 0; }
.video-detail-player { width: 100%; max-height: 60vh; background: #000; }
.video-detail-player video { width: 100%; height: auto; max-height: 60vh; object-fit: contain; }
.video-detail-info { padding: 16px; }
.video-detail-info h3 { font-size: 18px; margin-bottom: 8px; }
.video-detail-info p { color: #9ca3af; font-size: 14px; margin-bottom: 6px; }
.video-detail-actions { display: flex; gap: 8px; padding: 0 16px 20px; }
.video-detail-actions .btn { flex: 1; }

/* ── BOTTOM NAV ───────────────────────────────────────────────── */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); background: rgba(10,10,10,0.95); backdrop-filter: blur(10px); border-top: 1px solid #1f2937; z-index: 100; }
.bottom-nav.hidden { display: none; }
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; color: #6b7280; font-size: 11px; cursor: pointer; padding: 4px 12px; }
.nav-btn span { font-size: 20px; }
.nav-btn:active { color: #fff; }

/* ── UTILITIES ────────────────────────────────────────────────── */
.hidden { display: none !important; }
.error { color: #fca5a5; font-size: 14px; text-align: center; margin-top: 8px; }
.mono { font-family: 'SF Mono', Menlo, monospace; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 2px; }

/* iOS overscroll fix */
body { overscroll-behavior-y: none; }
