* {
    box-sizing: border-box;
}

:root {
    --bg: #f7f8fb;
    --surface: #ffffff;
    --surface-alt: #f2f4f8;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --success: #15803d;
    --danger: #dc2626;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    --radius-xl: 26px;
    --radius-lg: 20px;
    --radius-md: 14px;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Sans Arabic", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-shell {
    width: min(1440px, calc(100% - 36px));
    margin: 0 auto;
    padding: 18px 0 56px;
}

.page-shell-detail {
    padding-top: 20px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
}

.brand-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #dbeafe, #fde68a);
    color: var(--primary-dark);
    font-size: 0.9rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 30px;
    color: var(--muted);
    font-weight: 500;
}

.topbar-nav a:hover {
    color: var(--text);
}

.nav-moon {
    font-size: 1.25rem;
    color: var(--text);
}

.eyebrow {
    display: inline-block;
    color: var(--muted);
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.api-inline-panel,
.filter-panel,
.channel-card,
.detail-panel,
.metric-tile,
.empty-state,
.flash-message {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.api-inline-panel {
    display: grid;
    grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.5fr);
    gap: 18px;
    align-items: center;
    margin-top: 26px;
    padding: 22px;
    border-radius: var(--radius-xl);
}

.api-inline-copy h2,
.detail-copy h1,
.section-head h2 {
    margin: 8px 0 0;
    font-family: "Space Grotesk", sans-serif;
}

.api-inline-copy h2 {
    font-size: clamp(1.4rem, 2.4vw, 2rem);
}

.api-inline-copy p,
.detail-copy p,
.channel-profile p,
.channel-description,
.detail-video-card p,
.detail-video-card small,
.similar-card span {
    color: var(--muted);
}

.api-inline-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 14px;
    align-items: end;
}

.discovery-shell {
    margin-top: 26px;
}

.powered-by {
    text-align: right;
    color: #94a3b8;
    font-size: 0.95rem;
    margin-bottom: 18px;
}

.discovery-header {
    text-align: center;
    margin-bottom: 18px;
}

.discovery-header h1 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(2.3rem, 4vw, 3.2rem);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.title-icon {
    font-size: 0.8em;
    color: #64748b;
}

.launch-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0 auto 18px;
    max-width: 860px;
    flex-wrap: wrap;
}

.launch-stack {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.search-field-launch {
    flex: 1 1 620px;
}

.search-field-main {
    flex: 1 1 100%;
    max-width: 760px;
}

.launch-panel-secondary {
    max-width: 860px;
    opacity: 0.88;
}

.launch-panel-primary {
    margin-top: 16px;
    margin-bottom: 22px;
}

.launch-select select {
    min-width: 150px;
}

.btn-start-search {
    min-width: 180px;
}

.process-log {
    margin: 0 auto 18px;
    max-width: 980px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    color: #334155;
    font: 500 0.9rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: pre-wrap;
    box-shadow: var(--shadow);
}

.result-status {
    max-width: 980px;
    margin: 0 auto 18px;
    padding: 14px 18px;
    border-radius: 16px;
}

.result-status-loading {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
}

.result-status-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.flash-message {
    margin: 18px 0 0;
    padding: 14px 18px;
    border-radius: 16px;
}

.flash-message-success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: var(--success);
}

.flash-message-error {
    border-color: #fecaca;
    background: #fef2f2;
    color: var(--danger);
}

.filter-panel {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.search-field {
    flex: 1 1 420px;
}

.search-field input,
.field input,
.field select,
.compact-field select {
    width: 100%;
    min-height: 50px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
}

.search-field input {
    min-height: 54px;
}

.compact-field {
    min-width: 170px;
}

.compact-field span,
.field span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.field small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.82rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 0 18px;
    border-radius: 14px;
    border: 1px solid transparent;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-primary {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

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

.btn-secondary {
    background: #fff;
    border-color: var(--line-strong);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-alt);
}

.quick-actions,
.active-filters,
.topic-list,
.card-actions,
.pagination,
.modal-actions,
.similar-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.quick-actions {
    justify-content: center;
    margin-top: 16px;
}

.pill-button,
.filter-chip,
.bookmark-button {
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text);
    border-radius: 999px;
    padding: 9px 14px;
    cursor: pointer;
}

.active-filters {
    margin-top: 16px;
}

.active-filters-centered {
    justify-content: center;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
}

.filter-chip span {
    color: var(--muted);
    font-size: 0.82rem;
}

.filter-panel-compact {
    max-width: 980px;
    margin: 0 auto;
}

.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.toolbar-select select {
    min-height: 52px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: #475569;
    font: inherit;
}

.toolbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: #64748b;
    cursor: pointer;
    font-size: 1.15rem;
}

.toolbar-bookmark {
    font-size: 1rem;
}

.search-field-compact {
    flex: 0 1 300px;
}

.compact-field-inline {
    min-width: 230px;
}

.compact-field-inline span {
    display: inline-block;
    margin: 0 10px 0 0;
    vertical-align: middle;
}

.compact-field-inline select {
    width: 170px;
    display: inline-block;
    min-height: 52px;
    vertical-align: middle;
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: 10px 0 18px;
}

.section-head h2 {
    font-size: clamp(1.5rem, 2.8vw, 2.2rem);
}

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

.channel-card {
    display: grid;
    gap: 18px;
    padding: 20px;
    border-radius: 22px;
    border-color: #e5e7eb;
    position: relative;
}

.card-head,
.channel-profile,
.signal-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.channel-profile {
    justify-content: flex-start;
}

.channel-badge {
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.channel-badge.is-faceless {
    color: #166534;
    background: #dcfce7;
}

.channel-badge.is-face {
    color: #991b1b;
    background: #fee2e2;
}

.bookmark-button {
    min-width: 72px;
}

.bookmark-button.is-bookmarked {
    color: #fff;
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.channel-avatar,
.detail-avatar,
.similar-card img {
    object-fit: cover;
}

.channel-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 1px solid var(--line);
}

.detail-avatar {
    width: 100%;
    min-height: 280px;
    border-radius: 24px;
}

.channel-profile h3,
.detail-video-card h3,
.similar-card strong {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.2rem;
}

.channel-profile h3 {
    font-size: 1.2rem;
}

.stats-strip {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stats-strip div {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.stats-strip span,
.signal-row span {
    color: var(--muted);
    font-size: 0.82rem;
}

.stats-strip strong,
.signal-row strong {
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.95rem;
}

.signal-row {
    gap: 12px;
}

.monetize-mark {
    position: absolute;
    top: 104px;
    right: 24px;
    color: #16a34a;
    font-size: 1.6rem;
    font-weight: 700;
}

.signal-bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: #e2e8f0;
}

.signal-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #60a5fa, #1d4ed8);
}

.channel-description {
    line-height: 1.7;
}

.topic-list span {
    border-radius: 999px;
    padding: 7px 11px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: 0.82rem;
}

.recent-videos-label {
    color: #64748b;
    font-size: 0.95rem;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.video-grid-dual {
    gap: 12px;
}

.video-grid a {
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid var(--line);
}

.video-grid img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.video-card-mini {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
}

.video-card-mini span {
    padding: 0 2px 10px;
    color: #475569;
    font-size: 0.82rem;
}

.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.empty-state {
    padding: 34px;
    border-radius: 22px;
    text-align: center;
}

.pagination {
    justify-content: center;
    align-items: center;
    margin-top: 26px;
}

.pagination .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    padding: 24px;
    background: rgba(15, 23, 42, 0.28);
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal.is-open {
    display: flex;
}

.modal-card {
    width: min(820px, 100%);
    max-height: 88vh;
    overflow: auto;
    border-radius: 24px;
    padding: 22px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}

.modal-close {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text);
    font-size: 1.35rem;
    cursor: pointer;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.detail-hero {
    display: grid;
    grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
    gap: 20px;
    margin-top: 18px;
}

.detail-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
    gap: 18px;
    margin-top: 22px;
}

.detail-panel {
    padding: 22px;
    border-radius: 22px;
}

.detail-video-list {
    display: grid;
    gap: 14px;
}

.detail-video-card,
.similar-card {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 14px;
    padding: 12px;
    border-radius: 16px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.detail-video-card img,
.similar-card img {
    width: 100%;
    height: 102px;
    object-fit: cover;
    border-radius: 12px;
}

.similar-card {
    align-items: center;
    grid-template-columns: 82px minmax(0, 1fr);
}

.back-link {
    display: inline-flex;
    margin-bottom: 16px;
    color: var(--primary-dark);
    font-weight: 600;
}

@media (max-width: 1180px) {
    .api-inline-panel,
    .detail-hero,
    .detail-columns {
        grid-template-columns: 1fr;
    }

    .api-inline-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .topbar,
    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

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

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

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 18px, 100%);
    }

    .topbar-nav,
    .card-actions {
        width: 100%;
    }

    .btn,
    .search-field,
    .compact-field,
    .search-field-launch,
    .detail-video-card,
    .similar-card {
        width: 100%;
    }

    .detail-video-card,
    .similar-card {
        grid-template-columns: 1fr;
    }

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

    .toolbar-row,
    .card-actions,
    .api-inline-form {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .compact-field-inline {
        width: 100%;
    }

    .compact-field-inline span,
    .compact-field-inline select {
        width: 100%;
        display: block;
    }
}
