:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --text: #1a2332;
    --muted: #5c6b7a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #dbe3ee;
    --error: #b91c1c;
    --radius: 12px;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--accent);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
    color: var(--text);
}

.app-header nav a {
    margin-left: 1rem;
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
}

.app-header nav a:hover {
    color: var(--accent);
}

.app-main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.app-main:has(.home-page) {
    max-width: min(1440px, calc(100vw - 4rem));
}

.app-footer {
    padding: 1rem 2rem 2rem;
    color: var(--muted);
    font-size: 0.875rem;
    text-align: center;
}

.ad-slot {
    margin: 1.5rem auto;
    max-width: 100%;
    min-height: 90px;
    overflow: hidden;
}

.ad-slot-label {
    margin: 0 0 0.35rem;
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
}

.ad-slot-home-top {
    margin-top: 0.5rem;
    margin-bottom: 1.25rem;
}

.ad-slot-home-results {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.ad-slot-footer {
    margin-top: 0;
    margin-bottom: 1rem;
    max-width: 728px;
}

.search-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem 2rem;
    margin-bottom: 2rem;
}

.hero-banner {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 1.5rem;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid #1e3d2e;
    box-shadow: 0 4px 16px rgba(26, 35, 50, 0.12);
    line-height: 0;
}

.hero-banner-img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

.home-intro {
    max-width: 52rem;
    margin: 0 auto 1rem;
    padding: 0 1rem;
    color: var(--muted);
    font-size: 0.8125rem;
    line-height: 1.45;
    text-align: center;
}

.home-intro a,
.home-intro-link {
    color: var(--accent);
    font-weight: 600;
}

.home-intro-link {
    display: inline;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.home-intro-link:hover {
    color: var(--accent-hover);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.55);
}

.modal-dialog {
    width: min(100%, 28rem);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem 1.5rem;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.modal-close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
}

.modal-close:hover {
    color: var(--text);
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.modal-field label {
    font-size: 0.875rem;
    font-weight: 600;
}

.modal-textarea {
    min-height: 6rem;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.modal-success {
    margin: 0 0 1rem;
    color: var(--text);
}

.search-hero h1 {
    margin-top: 0;
}

.search-form {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    align-items: flex-start;
}

.search-input-wrap {
    position: relative;
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.search-history-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(26, 35, 50, 0.12);
    z-index: 20;
    max-height: 280px;
    overflow-y: auto;
}

.search-history-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text);
}

.search-history-item:hover {
    background: var(--bg);
}

.search-history-query {
    font-weight: 500;
}

.search-history-filters {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.btn-saved {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    font-weight: 600;
    cursor: default;
}

.curated-notice {
    color: #1e40af;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.curated-card {
    border-color: #93c5fd;
    box-shadow: 0 0 0 1px #dbeafe;
}

.source-badge {
    display: inline-block;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.source-badge-promoted {
    background: #2563eb;
}

.source-badge-catalog {
    background: #0f766e;
}

.source-badge-search {
    background: #7c3aed;
}

.curated-badge {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.curated-badge-catalog {
    background: #0f766e;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.chip-label {
    font-size: 0.875rem;
    color: var(--muted);
    margin-right: 0.25rem;
}

.chip {
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

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

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.results-meta {
    margin-bottom: 1rem;
    color: var(--muted);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: contain;
    background: #eef2f7;
    border-bottom: 1px solid var(--border);
}

.preview-link {
    display: block;
    background: #eef2f7;
    border-bottom: 1px solid var(--border);
}

.preview-placeholder {
    aspect-ratio: 3 / 4;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef2f7;
    color: var(--muted);
    font-weight: 600;
    font-size: 1.5rem;
}

.card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.card-body h2 {
    font-size: 1rem;
    margin: 0;
    line-height: 1.3;
}

.domain-badge,
.format-badge {
    display: inline-block;
    font-size: 0.75rem;
    background: #e8eef8;
    color: var(--accent);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    width: fit-content;
    margin-right: 0.35rem;
}

.format-badge {
    background: #eef8f0;
    color: #166534;
}

.snippet,
.meta,
.source-line {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
}

.source-line {
    word-break: break-all;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

.error {
    color: var(--error);
}

.status {
    color: var(--muted);
    margin: 1rem 0;
}

.loading-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem 1rem;
    margin: 1rem 0 2rem;
}

.loading-panel .status {
    margin: 0;
    text-align: center;
}

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spinner-rotate 0.75s linear infinite;
}

@keyframes spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

.section-heading {
    margin: 2rem 0 0.75rem;
    font-size: 1.25rem;
}

.unverified-notice {
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.unverified-grid {
    margin-top: 0.5rem;
}

.unverified-card h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}

.unverified-card .unverified-actions {
    flex-wrap: wrap;
}

.review-controls {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.review-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    cursor: pointer;
}

.review-hint {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.review-count {
    font-weight: 500;
    color: var(--muted);
    font-size: 0.95rem;
}

.review-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.review-card {
    display: grid;
    grid-template-columns: minmax(200px, 1.2fr) minmax(240px, 1fr);
    gap: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

@media (max-width: 768px) {
    .review-card {
        grid-template-columns: 1fr;
    }
}

.review-preview-link {
    display: block;
}

.review-preview-img {
    width: 100%;
    max-height: min(70vh, 720px);
    object-fit: contain;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.review-preview-placeholder {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.review-card-body h2 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.review-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-danger {
    background: #b91c1c;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    font-weight: 600;
}

.btn-danger:hover {
    background: #991b1b;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
}

.btn-link {
    align-self: center;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem;
}

.exclusion-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.exclusion-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.exclusion-card h2 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
}

.admin-page {
    max-width: 28rem;
    margin: 2rem auto;
}

.admin-page h1 {
    margin-bottom: 0.5rem;
}

.admin-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.admin-remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--muted);
}

.admin-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.admin-access-denied {
    max-width: 28rem;
    margin: 2rem auto;
}
