@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

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

:root {
    --fg: #0a0a0a;
    --fg-dim: #666;
    --fg-muted: #999;
    --bg: #f9f9f9;
    --bg-card: #fff;
    --border: #e5e5e5;
    --border-dark: #ccc;
    --accent: #0a0a0a;
    --accent-light: #f0f0f0;
    --cta: #ff0000;
    --cta-hover: #cc0000;
    --success: #16a34a;
    --warn: #d97706;
    --radius: 8px;
    --transition: 0.15s ease;
    --header-bg: #fff;
    --verdict-bg: #f5f5f5;
    --verdict-color: #0a0a0a;
    --intel-h3-color: #888;
    --body-text: #222;
    --quote-border: #333;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    --btn-primary-bg: #0a0a0a;
    --btn-primary-fg: #fff;
    --info-bg: #fff8e1;
    --info-text: #854d0e;
    --info-border: #fde68a;
}

[data-theme="dark"] {
    --fg: #f1f1f1;
    --fg-dim: #aaa;
    --fg-muted: #717171;
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --border: #272727;
    --border-dark: #3f3f3f;
    --accent: #f1f1f1;
    --accent-light: #272727;
    --cta: #ff0000;
    --cta-hover: #cc0000;
    --success: #22c55e;
    --warn: #f59e0b;
    --header-bg: #0f0f0f;
    --verdict-bg: #1f1f1f;
    --verdict-color: #f1f1f1;
    --intel-h3-color: #717171;
    --body-text: #d0d0d0;
    --quote-border: #aaa;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    --btn-primary-bg: #f1f1f1;
    --btn-primary-fg: #0a0a0a;
    --info-bg: #2d2610;
    --info-text: #fde68a;
    --info-border: #715510;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--fg);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── HEADER ────────────────────────────────────────────────── */
#app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-yt {
    color: #ff0000;
    font-size: 18px;
    line-height: 1;
}

.btn-theme {
    background: none;
    border: 1px solid var(--border-dark);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 16px;
    color: var(--fg-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    padding: 0;
    flex-shrink: 0;
}

.btn-theme:hover {
    background: var(--accent-light);
    color: var(--fg);
}

#app-title {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.02em;
}

#app-title.clickable {
    cursor: pointer;
}

#app-title.clickable:hover {
    opacity: 0.6;
}

#app-status {
    font-size: 12px;
    color: var(--fg-muted);
}

#app-status.status-busy::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--warn);
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 1s ease-in-out infinite;
}

#app-status.status-done::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 6px;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ─── VIEWS ─────────────────────────────────────────────────── */
.view {
    display: none;
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.view.active {
    display: block;
}

/* ─── SEARCH VIEW ────────────────────────────────────────────── */
.search-container {
    max-width: 560px;
}

.search-container h1 {
    font-size: 28px;
    font-weight: 300;
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
    color: var(--fg);
}

.search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;
}

#searchInput {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: var(--bg-card);
    color: var(--fg);
    transition: border-color var(--transition);
}

#searchInput:focus {
    border-color: var(--accent);
}

button {
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
    border: none;
}

#searchBtn {
    padding: 10px 20px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-fg);
    font-weight: 500;
}

#searchBtn:hover {
    opacity: 0.8;
}

#searchBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.filter-row {
    display: flex;
    gap: 1.5rem;
    color: var(--fg-muted);
    font-size: 13px;
}

.filter-row label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-row select {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 6px;
    background: var(--bg-card);
    font-family: inherit;
    font-size: 13px;
    color: var(--fg);
    outline: none;
}

/* ─── RESULTS VIEW ───────────────────────────────────────────── */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.section-label {
    font-weight: 600;
    font-size: 15px;
    margin-right: 8px;
}

.selection-count {
    font-size: 13px;
    color: var(--fg-muted);
}

.btn-cta {
    padding: 9px 18px;
    background: var(--cta);
    color: #fff;
    font-weight: 500;
    font-size: 14px;
}

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

.btn-cta.disabled {
    background: var(--border-dark);
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── VIDEO GRID ─────────────────────────────────────────────── */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.video-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    position: relative;
}

.video-card:hover {
    border-color: var(--border-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.video-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.video-card .check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity var(--transition);
}

.video-card.selected .check {
    opacity: 1;
}

.video-thumb {
    position: relative;
    aspect-ratio: 16/9;
    background: var(--border);
}

.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 3px;
}

.video-meta {
    padding: 10px 12px;
}

.video-meta h3 {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-channel {
    font-size: 12px;
    color: var(--fg-muted);
    margin-bottom: 4px;
}

.video-stats {
    font-size: 11px;
    color: var(--fg-muted);
    display: flex;
    gap: 10px;
}

/* ─── PROGRESS VIEW ──────────────────────────────────────────── */
.progress-container {
    max-width: 480px;
    margin: 4rem auto;
}

.progress-title {
    font-size: 20px;
    font-weight: 300;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.step:last-child {
    border-bottom: none;
}

.step-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.step.pending .step-icon {
    color: var(--fg-muted);
}

.step.active .step-icon {
    color: var(--warn);
    animation: pulse 1s infinite;
}

.step.done .step-icon {
    color: var(--success);
}

.step.error .step-icon {
    color: #dc2626;
}

.step-label {
    font-size: 14px;
    font-weight: 500;
}

.step-detail {
    font-size: 12px;
    color: var(--fg-muted);
    margin-top: 2px;
}

.step.pending .step-label {
    color: var(--fg-muted);
}

.step.active .step-label {
    color: var(--fg);
}

.step.done .step-label {
    color: var(--fg);
}

.progress-note {
    margin-top: 2rem;
    font-size: 12px;
    color: var(--info-text);
    padding: 10px;
    background: var(--info-bg);
    border-radius: var(--radius);
    border: 1px solid var(--info-border);
}

/* ─── PLAYBOOK VIEW ──────────────────────────────────────────── */
.playbook-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.btn-ghost {
    background: none;
    color: var(--fg-dim);
    padding: 6px 10px;
    font-size: 13px;
    border: none;
}

.btn-ghost:hover {
    background: var(--accent-light);
    color: var(--fg);
}

.btn-outline {
    background: none;
    border: 1px solid var(--border-dark);
    padding: 6px 14px;
    font-size: 13px;
    color: var(--fg);
}

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

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

.playbook-body {
    max-width: 720px;
}

/* ─── REPORT CONTENT ─────────────────────────────────────────── */
.report-header {
    margin-bottom: 3rem;
}

.report-header h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.report-subhead {
    font-size: 13px;
    color: var(--fg-muted);
}

.report-toc {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 3rem;
}

.report-toc h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-muted);
    margin-bottom: 0.75rem;
}

.report-toc ol {
    padding-left: 1.25rem;
}

.report-toc li {
    font-size: 13px;
    margin-bottom: 4px;
}

.report-toc a {
    color: var(--fg);
    text-decoration: none;
}

.report-toc a:hover {
    text-decoration: underline;
}

.source-section {
    margin-bottom: 4rem;
    padding-bottom: 2rem;
    border-bottom: 2px dashed var(--border);
}

.source-heading {
    margin-bottom: 1rem;
}

.source-num {
    display: inline-block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--btn-primary-fg);
    background: var(--btn-primary-bg);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    margin-bottom: 10px;
}

.source-heading h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: var(--fg);
}

.source-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    font-size: 13px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-muted);
}

.meta-val {
    color: var(--fg);
    font-weight: 500;
}

.meta-val a {
    color: var(--cta);
    text-decoration: none;
}

.meta-val a:hover {
    text-decoration: underline;
}

/* CARDS */
.report-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.report-card h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--intel-h3-color);
    font-weight: 700;
    margin-bottom: 1.25rem;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.report-card p,
.report-card .body-text {
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--body-text);
}

/* Quotes */
.quotes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quote-item {
    padding: 12px 16px;
    border-left: 3px solid var(--quote-border);
    background: var(--bg-card);
}

.quote-text {
    font-style: italic;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 4px;
}

.quote-sig {
    font-size: 12px;
    color: var(--fg-muted);
}

/* Key Points & Practical Applications lists */
.key-points-list {
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.key-points-list li {
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--body-text);
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.faq-q {
    font-weight: 600;
    font-size: 14.5px;
    margin-bottom: 4px;
    color: var(--fg);
}

.faq-a {
    font-size: 14.5px;
    color: var(--body-text);
    line-height: 1.7;
}

/* Verdict */
.verdict-block {
    margin-top: 1.5rem;
    padding: 14px 16px;
    background: var(--verdict-bg);
    color: var(--verdict-color);
    border: 1px solid var(--border-dark);
    border-left: 4px solid var(--cta);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.65;
}

.source-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4rem 0;
}