/* Screen Recorder — 99aupairs */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 8px;
}

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

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

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
header h1 { font-size: 1.25rem; font-weight: 600; }
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.back-link { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--text); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 500; cursor: pointer;
    text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-text { background: none; color: var(--text-muted); }
.btn-text:hover { color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* Main */
main { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Login */
.login-container {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 24px;
}
.login-card {
    background: var(--card-bg); border-radius: 12px;
    padding: 48px 40px; max-width: 400px; width: 100%;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08); text-align: center;
}
.login-card h1 { margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-muted); margin-bottom: 24px; }
.login-card input {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 1rem; margin-bottom: 16px;
}
.login-card button {
    width: 100%; padding: 12px; background: var(--primary); color: white;
    border: none; border-radius: var(--radius); font-size: 1rem;
    font-weight: 500; cursor: pointer;
}
.login-card button:hover { background: var(--primary-hover); }
.error-msg {
    background: #fef2f2; color: var(--danger); padding: 10px;
    border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem;
}

/* Dashboard grid */
.empty-state {
    text-align: center; padding: 80px 24px; color: var(--text-muted);
}
.empty-state h2 { color: var(--text); margin-bottom: 8px; }
.empty-state .btn { margin-top: 16px; }

.recordings-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}
.recording-card {
    background: var(--card-bg); border-radius: var(--radius);
    overflow: hidden; border: 1px solid var(--border);
    transition: box-shadow 0.15s;
}
.recording-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.card-thumb {
    display: block; position: relative; aspect-ratio: 16/9;
    background: #1e293b; overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; color: #94a3b8;
}
.duration {
    position: absolute; bottom: 8px; right: 8px;
    background: rgba(0,0,0,0.75); color: white;
    padding: 2px 6px; border-radius: 4px; font-size: 0.75rem;
}

.card-info { padding: 12px 16px; }
.card-title {
    font-weight: 600; color: var(--text); text-decoration: none;
    display: block; margin-bottom: 4px;
}
.card-title:hover { color: var(--primary); }
.card-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; }
.card-actions { display: flex; gap: 6px; }

/* Record page */
.record-container { max-width: 720px; margin: 0 auto; }
.record-section { text-align: center; }

.setup-form {
    text-align: left; max-width: 400px; margin: 0 auto 24px;
}
.setup-form label {
    display: block; font-weight: 500; margin-bottom: 4px; margin-top: 12px;
}
.setup-form input {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.95rem;
}

.record-options {
    margin-bottom: 24px;
}
.option-label {
    display: flex; align-items: center; gap: 8px;
    justify-content: center; font-size: 0.9rem; color: var(--text-muted);
}

/* Recording state */
.recording-indicator {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; margin-bottom: 16px; font-size: 1.5rem; font-weight: 600;
}
.rec-dot {
    width: 14px; height: 14px; background: var(--danger);
    border-radius: 50%; animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#preview {
    width: 100%; max-height: 400px; border-radius: var(--radius);
    background: #000; margin-bottom: 16px;
}
.recording-controls { display: flex; gap: 12px; justify-content: center; }

/* Upload progress */
.upload-progress { padding: 60px 0; }
.spinner {
    width: 40px; height: 40px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar {
    width: 300px; height: 6px; background: var(--border);
    border-radius: 3px; margin: 16px auto 0; overflow: hidden;
}
#progress-fill {
    width: 0; height: 100%; background: var(--primary);
    transition: width 0.3s;
}

/* Done state */
.done-card {
    padding: 40px; background: var(--card-bg); border-radius: 12px;
    max-width: 500px; margin: 0 auto;
}
.done-card h2 { margin: 16px 0; }
.share-link {
    display: flex; gap: 8px; margin: 20px 0;
}
.share-link input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.9rem; background: var(--bg);
}
.done-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.ai-note { color: var(--text-muted); font-size: 0.8rem; margin-top: 16px; }

/* Watch page */
.watch-layout {
    display: grid; grid-template-columns: 1fr 320px; gap: 24px;
    max-width: 1200px;
}
@media (max-width: 900px) {
    .watch-layout { grid-template-columns: 1fr; }
}

.video-wrapper {
    border-radius: var(--radius); overflow: hidden; background: #000;
}
.video-wrapper video { width: 100%; display: block; }

.watch-meta {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0; font-size: 0.85rem; color: var(--text-muted);
}
.author { font-weight: 500; color: var(--text); }

.summary-section, .transcript-section {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 16px 20px; margin-top: 16px; border: 1px solid var(--border);
}
.summary-section h3, .transcript-section h3 {
    font-size: 0.9rem; margin-bottom: 8px; color: var(--text-muted);
}
.transcript-content { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.6; }

/* Comments */
.watch-sidebar {
    background: var(--card-bg); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 16px; height: fit-content;
}
.watch-sidebar h3 { margin-bottom: 16px; font-size: 0.95rem; }

.comment-form { margin-bottom: 20px; }
.comment-form input, .comment-form textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 8px;
    font-family: inherit;
}
.comment-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.comment-form .btn { margin-top: 4px; }

.comment {
    padding: 10px 0; border-top: 1px solid var(--border);
}
.comment-header {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.8rem; margin-bottom: 4px;
}
.comment-header strong { font-size: 0.85rem; }
.comment-ts {
    color: var(--primary); text-decoration: none; font-weight: 500;
}
.comment-time { color: var(--text-muted); }
.comment p { font-size: 0.9rem; line-height: 1.4; }



/* =========================================
   SHARED: badges, processing status bars
   ========================================= */

.header-actions { display: flex; align-items: center; gap: 10px; }

.step-badge {
    background: #dbeafe; color: var(--primary);
    font-size: 0.8rem; font-weight: 600;
    padding: 4px 12px; border-radius: 20px; white-space: nowrap;
}

.processing-card {
    background: #fff; border-radius: 16px; padding: 48px 56px;
    text-align: center; box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}

.guide-status-box {
    background: #f8fafc; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; margin: 16px 0; text-align: left;
}
.status-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 0.9rem; }
.status-spinner {
    width: 14px; height: 14px; border: 2px solid #e5e7eb;
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite; flex-shrink: 0; display: inline-block;
}
.status-ok { color: #22c55e; font-weight: 700; width: 14px; text-align: center; flex-shrink: 0; }
.proc-progress-wrap {
    width: 100%; height: 8px; background: var(--border);
    border-radius: 4px; overflow: hidden; margin: 8px 0;
}
.proc-progress-bar {
    width: 0%; height: 100%; background: var(--primary);
    border-radius: 4px; transition: width 0.6s ease;
}

/* =========================================
   GUIDE EDITOR — Scribe-style layout
   ========================================= */

html, body.ge-body { height: 100%; overflow: hidden; }
body.ge-body {
    display: flex; flex-direction: column;
    background: #f1f5f9;
}

/* ── Top bar ── */
.ge-topbar {
    flex-shrink: 0; display: flex; align-items: center; gap: 12px;
    height: 56px; padding: 0 20px;
    background: #fff; border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); z-index: 100;
}
.ge-back {
    display: flex; align-items: center; gap: 4px;
    font-size: 0.85rem; color: var(--text-muted); text-decoration: none;
    white-space: nowrap;
}
.ge-back:hover { color: var(--text); }
.ge-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }
.ge-title {
    font-size: 0.95rem; font-weight: 600;
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ge-topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ge-topbar-right .btn.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ── Pending state ── */
.ge-pending {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 16px;
    color: var(--text-muted);
}

/* ── Three-column layout ── */
.ge-layout {
    flex: 1; display: flex; overflow: hidden; position: relative;
}

/* ── Left sidebar ── */
.ge-sidebar {
    width: 260px; flex-shrink: 0;
    background: #fff; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
}
.ge-sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 10px;
    font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ge-select-all-wrap {
    display: flex; align-items: center; gap: 5px;
    font-weight: 400; cursor: pointer;
    accent-color: var(--primary);
}

.ge-sidebar-steps {
    flex: 1; overflow-y: auto; padding: 8px 0;
}
.ge-sidebar-step {
    display: flex; align-items: center; gap: 7px;
    padding: 7px 12px; text-decoration: none;
    color: var(--text); font-size: 0.82rem; line-height: 1.4;
    border-left: 3px solid transparent;
    transition: background 0.1s, border-color 0.1s;
    cursor: pointer;
}
.ge-sidebar-step:hover { background: #f8fafc; }
.ge-sidebar-step.active { background: #eff6ff; border-left-color: var(--primary); }
.ge-sidebar-step.ge-sb-checked { background: #eff6ff; }
.ge-sb-cb {
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
    width: 14px; height: 14px;
}
.ge-sb-del {
    display: flex;
    flex-shrink: 0;
    background: none; border: none;
    color: #94a3b8; cursor: pointer;
    padding: 2px 4px; border-radius: 4px;
    line-height: 0;
    transition: color 0.15s, background 0.15s;
}
.ge-sb-del:hover { color: var(--danger); background: #fef2f2; }
.ge-snum {
    flex-shrink: 0; width: 20px; height: 20px;
    background: #f1f5f9; color: #475569;
    border-radius: 5px; display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700; margin-top: 1px;
}
.ge-sidebar-step.active .ge-snum { background: #dbeafe; color: var(--primary); }
.ge-stitle {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ge-sts {
    flex-shrink: 0; font-size: 0.72rem; color: var(--text-muted);
    background: #f1f5f9; padding: 1px 6px; border-radius: 10px;
    margin-top: 1px;
}

.ge-sidebar-footer {
    flex-shrink: 0; padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 6px;
}

/* ── Main document ── */
.ge-document {
    flex: 1; overflow-y: auto;
    padding: 32px 0 140px;
    background: #f1f5f9;
}

/* Step cards */
.ge-step {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    margin: 0 auto 20px;
    max-width: 820px;
    overflow: hidden;
    transition: box-shadow 0.2s;
    scroll-margin-top: 80px;
}
.ge-step:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1), 0 8px 24px rgba(0,0,0,0.06); }
.ge-step.ge-selected { outline: 2px solid var(--primary); }

.ge-step-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid #f1f5f9;
}
.ge-cb { accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.ge-step-num {
    flex-shrink: 0; width: 28px; height: 28px;
    background: #eff6ff; color: var(--primary);
    border-radius: 8px; display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700;
}
.ge-step-title-input {
    flex: 1; min-width: 0;
    border: none; outline: none; background: transparent;
    font-size: 0.95rem; font-weight: 600; color: var(--text);
    font-family: inherit;
    padding: 3px 6px; border-radius: 6px;
}
.ge-step-title-input:focus { background: #f8fafc; }
.ge-step-title-input::placeholder { color: #cbd5e1; font-weight: 400; }

.ge-ts-btn {
    display: inline-flex; align-items: center; gap: 5px;
    background: none; border: 1px solid #e2e8f0;
    color: var(--primary); font-size: 0.78rem; font-weight: 600;
    padding: 3px 10px; border-radius: 20px; cursor: pointer;
    white-space: nowrap; transition: all 0.15s; flex-shrink: 0;
}
.ge-ts-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.ge-del-btn {
    background: none; border: 1px solid #e2e8f0;
    color: #64748b; font-size: 0.78rem; font-weight: 500;
    cursor: pointer; padding: 4px 10px; border-radius: 6px;
    display: flex; align-items: center; gap: 5px; flex-shrink: 0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.ge-del-btn:hover { color: var(--danger); background: #fef2f2; border-color: #fca5a5; }

/* Screenshot */
.ge-screenshot-wrap { background: #f8fafc; line-height: 0; border-bottom: 1px solid #e2e8f0; }
.ge-screenshot {
    width: 100%; display: block; height: auto;
}
.ge-no-screenshot {
    padding: 28px; text-align: center;
    color: #94a3b8; font-size: 0.85rem;
    background: #f8fafc; border-bottom: 1px solid #f1f5f9;
}

/* Description textarea */
.ge-desc-wrap { padding: 14px 18px 18px; }
.ge-desc {
    width: 100%; border: none; outline: none;
    background: transparent; font-family: inherit;
    font-size: 0.95rem; line-height: 1.7; color: var(--text);
    resize: none; overflow: hidden; min-height: 32px;
    padding: 4px 0;
}
.ge-desc::placeholder { color: #94a3b8; font-style: italic; }

/* Empty state */
.ge-empty {
    text-align: center; padding: 80px 24px; color: var(--text-muted);
    max-width: 820px; margin: 0 auto;
}
.ge-empty h3 { color: var(--text); font-size: 1.1rem; margin: 12px 0 8px; }

/* ── Right panels (video + transcript) ── */
.ge-video-panel, .ge-transcript-panel {
    width: 0; overflow: hidden; flex-shrink: 0;
    background: #1e293b;
    transition: width 0.3s ease;
    display: flex; flex-direction: column;
}
.ge-video-panel.ge-panel-open { width: 360px; }

.ge-transcript-panel { background: #fff; border-left: 1px solid var(--border); }
.ge-transcript-panel.ge-panel-open { width: 400px; }

.ge-video-inner, .ge-transcript-inner {
    padding: 16px; height: 100%; overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px;
    min-width: 0;
}
.ge-vp-header, .ge-tp-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.ge-vp-label { font-size: 0.8rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.ge-video-inner video { width: 100%; border-radius: 8px; background: #000; display: block; }

.ge-tp-header h3 { font-size: 0.95rem; font-weight: 600; }
.ge-transcript-area {
    flex: 1; min-height: 200px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.82rem; line-height: 1.8; background: #fafafa;
    resize: none; transition: border-color 0.15s;
}
.ge-transcript-area:focus { outline: none; border-color: var(--primary); background: #fff; }
.ge-tp-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ge-saved-msg { font-size: 0.82rem; color: #22c55e; font-weight: 500; display: none; }

/* ── Sticky bottom bar ── */
.ge-bottom-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,0.96); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    display: flex; align-items: center; justify-content: center;
    gap: 16px; z-index: 90;
}

/* ── Overlay ── */
.ge-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,0.65); backdrop-filter: blur(2px);
    z-index: 200; align-items: center; justify-content: center;
}
.ge-overlay.active { display: flex; }

@media (max-width: 900px) {
    .ge-sidebar { display: none; }
    .ge-video-panel.ge-panel-open,
    .ge-transcript-panel.ge-panel-open {
        position: fixed; inset: 0; width: 100%; z-index: 150;
    }
}
