:root {
    --bg: #f4efe7;
    --bg-strong: #eadcc8;
    --panel: rgba(255, 248, 240, 0.8);
    --panel-border: rgba(74, 46, 20, 0.12);
    --text: #1f1a17;
    --muted: #6d6258;
    --accent: #bf5a36;
    --accent-strong: #9f401e;
    --accent-soft: rgba(191, 90, 54, 0.14);
    --success: #266b52;
    --warning: #9a6a18;
    --error: #a53a2f;
    --shadow: 0 24px 80px rgba(87, 54, 24, 0.14);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --mono: "IBM Plex Mono", monospace;
    --sans: "Space Grotesk", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(191, 90, 54, 0.22), transparent 28%),
        radial-gradient(circle at top right, rgba(38, 107, 82, 0.18), transparent 26%),
        linear-gradient(180deg, #f8f1e8 0%, var(--bg) 48%, #efe5d7 100%);
    color: var(--text);
    font-family: var(--sans);
}

a {
    color: inherit;
}

code,
pre,
input,
textarea,
button {
    font: inherit;
}

.page-shell {
    position: relative;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

.page-glow {
    position: fixed;
    width: 360px;
    height: 360px;
    border-radius: 999px;
    filter: blur(56px);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

.page-glow-left {
    top: -80px;
    left: -80px;
    background: rgba(191, 90, 54, 0.28);
}

.page-glow-right {
    top: 10vh;
    right: -100px;
    background: rgba(38, 107, 82, 0.22);
}

.site-header,
.page-stack,
.preview-dialog {
    position: relative;
    z-index: 1;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 14px 18px;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: rgba(255, 249, 242, 0.72);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.brand {
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
}

.site-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.site-nav a {
    padding: 10px 14px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.site-nav a:hover,
.site-nav a.is-active {
    background: rgba(31, 26, 23, 0.08);
    color: var(--text);
    transform: translateY(-1px);
}

.page-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.hero,
.panel {
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
    gap: 24px;
    padding: 28px;
    background: linear-gradient(135deg, rgba(255, 250, 245, 0.92), rgba(244, 230, 210, 0.78));
}

.hero-home {
    min-height: 320px;
}

.hero-search {
    grid-template-columns: 1fr;
}

.eyebrow,
.section-kicker,
.status-chip-label,
.result-date,
.results-count,
.preview-meta,
.form-note,
.notice,
.log-line-meta,
.log-placeholder {
    font-family: var(--mono);
}

.eyebrow,
.section-kicker {
    margin: 0 0 12px;
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.hero h1,
.panel h2,
.preview-header h3 {
    margin: 0;
    line-height: 1;
}

.hero h1 {
    max-width: 12ch;
    font-size: clamp(2.5rem, 5vw, 5rem);
}

.hero-search h1 {
    max-width: 14ch;
}

.hero-text {
    max-width: 62ch;
    margin: 18px 0 0;
    font-size: 1.02rem;
    line-height: 1.65;
    color: var(--muted);
}

.hero-text code {
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: rgba(31, 26, 23, 0.08);
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.hero-status {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    padding: 22px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(31, 26, 23, 0.08);
}

.status-chip {
    display: inline-flex;
    flex-direction: column;
    gap: 8px;
}

.status-chip strong {
    font-size: 2rem;
}

[data-state="running"] {
    color: var(--success);
}

[data-state="idle"] {
    color: var(--warning);
}

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

.panel {
    padding: 24px;
    background: var(--panel);
    backdrop-filter: blur(10px);
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    margin-bottom: 20px;
}

.inline-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.panel h2 {
    font-size: 1.75rem;
}

.two-column {
    display: grid;
    grid-template-columns: minmax(320px, 1.1fr) minmax(280px, 0.9fr);
    gap: 24px;
    align-items: start;
}

.crawl-form,
.search-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.crawl-form label,
.search-form {
    width: 100%;
}

.crawl-form span {
    display: block;
    margin-bottom: 8px;
    font-size: 0.92rem;
    font-weight: 500;
}

textarea,
input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(31, 26, 23, 0.12);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.76);
    color: var(--text);
    transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

textarea {
    min-height: 132px;
    resize: vertical;
}

textarea:focus,
input:focus {
    outline: none;
    border-color: rgba(191, 90, 54, 0.6);
    box-shadow: 0 0 0 4px rgba(191, 90, 54, 0.12);
}

.crawl-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.crawl-actions,
.result-actions,
.result-meta,
.results-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.primary-button,
.secondary-button,
.inline-button {
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    font-weight: 700;
    text-decoration: none;
}

.primary-button {
    background: var(--accent);
    color: #fff7f3;
}

.primary-button:hover,
.secondary-button:hover,
.inline-button:hover {
    transform: translateY(-1px);
}

.secondary-button {
    background: rgba(31, 26, 23, 0.08);
    color: var(--text);
}

.inline-button {
    padding: 0;
    background: transparent;
    color: var(--accent-strong);
    font-weight: 600;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

.form-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.notice {
    margin: 20px 0 0;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    background: rgba(31, 26, 23, 0.06);
    color: var(--text);
}

.notice[data-tone="success"] {
    background: rgba(38, 107, 82, 0.12);
    color: var(--success);
}

.notice[data-tone="error"] {
    background: rgba(165, 58, 47, 0.12);
    color: var(--error);
}

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

.compact-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
    min-height: 132px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(243, 230, 212, 0.62));
    border: 1px solid rgba(31, 26, 23, 0.08);
}

.stat-card span {
    display: block;
    margin-bottom: 24px;
    color: var(--muted);
}

.stat-card strong {
    font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 22px;
}

.results-empty {
    padding: 24px;
    border: 1px dashed rgba(31, 26, 23, 0.16);
    border-radius: var(--radius-lg);
    color: var(--muted);
    background: rgba(255, 255, 255, 0.44);
}

.results-list {
    display: grid;
    gap: 16px;
}

.result-card {
    padding: 20px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(31, 26, 23, 0.08);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px rgba(87, 54, 24, 0.12);
}

.result-meta {
    margin-bottom: 10px;
    align-items: baseline;
    flex-wrap: wrap;
}

.result-url,
.inline-link {
    color: var(--accent-strong);
    text-decoration: none;
}

.result-url {
    font-size: 0.85rem;
    word-break: break-all;
}

.result-date,
.results-count,
.preview-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.result-title {
    margin: 0 0 10px;
    font-size: 1.28rem;
}

.result-title a {
    text-decoration: none;
}

.result-desc,
.result-excerpt {
    margin: 0;
    line-height: 1.6;
}

.result-desc {
    color: #413931;
}

.result-excerpt {
    margin-top: 10px;
    color: var(--muted);
}

.result-actions {
    margin-top: 16px;
    justify-content: flex-start;
}

.log-console {
    display: grid;
    gap: 10px;
    min-height: 260px;
    max-height: 480px;
    overflow: auto;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: #1d1713;
    color: #f8efe5;
    border: 1px solid rgba(31, 26, 23, 0.18);
}

.log-line {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 12px;
    align-items: start;
    font-family: var(--mono);
    font-size: 0.84rem;
    line-height: 1.55;
}

.log-line-meta {
    color: #c3b3a0;
}

.log-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.log-level-info {
    background: rgba(92, 165, 255, 0.18);
    color: #96c6ff;
}

.log-level-warn {
    background: rgba(255, 189, 89, 0.16);
    color: #ffd58b;
}

.log-level-error {
    background: rgba(255, 110, 110, 0.16);
    color: #ffadad;
}

.log-placeholder {
    margin: 0;
    color: #c3b3a0;
}

.preview-dialog {
    width: min(880px, calc(100vw - 32px));
    border: 1px solid rgba(31, 26, 23, 0.1);
    border-radius: var(--radius-xl);
    padding: 0;
    box-shadow: var(--shadow);
    background: #fffaf5;
}

.preview-dialog::backdrop {
    background: rgba(31, 26, 23, 0.42);
    backdrop-filter: blur(3px);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: start;
    padding: 22px 22px 0;
}

.preview-content {
    margin: 0;
    padding: 22px;
    max-height: 62vh;
    overflow: auto;
    white-space: pre-wrap;
    line-height: 1.6;
    color: #2a241f;
    font-family: var(--mono);
    font-size: 0.9rem;
}

@media (max-width: 1024px) {
    .hero,
    .two-column {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .page-shell {
        padding: 18px 14px 36px;
    }

    .site-header,
    .hero,
    .panel {
        padding: 18px;
    }

    .site-header,
    .crawl-grid,
    .stats-grid,
    .compact-stats,
    .search-form {
        grid-template-columns: 1fr;
    }

    .site-header,
    .panel-heading,
    .crawl-actions,
    .result-meta,
    .result-actions,
    .preview-header {
        flex-direction: column;
        align-items: stretch;
    }

    .site-nav {
        width: 100%;
    }

    .site-nav a {
        flex: 1;
        text-align: center;
    }

    .hero h1 {
        max-width: none;
    }

    .log-line {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
