:root {
    color-scheme: light;
    --bg: #f7f8fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #647084;
    --line: #dce2ec;
    --accent: #1b66d2;
    --accent-dark: #144fa4;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

.wrap {
    width: min(1040px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.center {
    min-height: 100vh;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: 32px 16px;
}

.brand {
    font-size: clamp(48px, 9vw, 88px);
    font-weight: 700;
    letter-spacing: 0;
    margin: 0;
}

.subtitle {
    color: var(--muted);
    font-size: 22px;
    margin: 0 0 32px;
}

.search-form {
    width: min(900px, 100%);
    display: flex;
    gap: 10px;
}

.search-form input[type="search"] {
    flex: 1 1 360px;
}

.search-form select {
    flex: 0 1 260px;
}

input[type="search"],
input[type="text"],
input[type="file"],
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 17px;
    padding: 14px 16px;
}

button,
.button {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 650;
    min-height: 48px;
    padding: 0 20px;
    text-decoration: none;
    white-space: nowrap;
}

button:hover,
.button:hover {
    background: var(--accent-dark);
}

.button-danger {
    background: #b42318;
    min-height: 36px;
    padding: 0 12px;
}

.button-danger:hover {
    background: #8f1c14;
}

.links {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0;
}

.panel,
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.stack {
    display: grid;
    gap: 16px;
}

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

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.admin-wrap {
    width: min(1180px, calc(100% - 32px));
}

.admin-hero {
    background:
        linear-gradient(135deg, rgba(27, 102, 210, 0.12), rgba(36, 151, 124, 0.12)),
        var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
    margin-bottom: 18px;
    padding: 28px;
}

.admin-hero h1 {
    font-size: clamp(34px, 6vw, 64px);
    line-height: 1;
    margin: 0 0 12px;
}

.admin-hero p {
    color: var(--muted);
    font-size: 18px;
    margin: 0;
}

.eyebrow {
    color: var(--accent) !important;
    font-size: 13px !important;
    font-weight: 750;
    letter-spacing: 0.08em;
    margin-bottom: 10px !important;
    text-transform: uppercase;
}

.admin-search {
    align-self: end;
    display: flex;
    gap: 10px;
}

.quick-actions {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    margin-bottom: 18px;
}

.action-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: grid;
    gap: 8px;
    min-height: 150px;
    padding: 18px;
    text-decoration: none;
}

.action-card:hover {
    border-color: rgba(27, 102, 210, 0.45);
    box-shadow: 0 14px 34px rgba(23, 32, 51, 0.08);
}

.action-card span {
    color: var(--accent);
    font-size: 13px;
    font-weight: 750;
    text-transform: uppercase;
}

.action-card strong {
    font-size: 20px;
    line-height: 1.2;
}

.action-card small,
.book-row small,
.search-row small {
    color: var(--muted);
}

.primary-action {
    background: #172033;
    border-color: #172033;
    color: #fff;
}

.primary-action span,
.primary-action small {
    color: #d7e6ff;
}

.metric-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
}

.metric strong {
    font-size: 36px;
    line-height: 1;
}

.admin-columns {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.section-head {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-head h2 {
    margin: 0;
}

.book-list,
.search-list {
    display: grid;
    gap: 10px;
}

.book-row,
.search-row {
    align-items: center;
    background: #f7f8fb;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 14px;
    text-decoration: none;
}

.book-row:hover,
.search-row:hover {
    border-color: var(--line);
}

.book-row span,
.search-row span {
    display: grid;
    gap: 2px;
}

.book-row em {
    color: var(--muted);
    font-style: normal;
    text-align: right;
    white-space: nowrap;
}

.result-title {
    margin: 0 0 8px;
    font-size: 18px;
}

.snippet {
    margin: 0 0 12px;
}

.result-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 18px;
}

.result-card:hover {
    border-color: rgba(27, 102, 210, 0.35);
}

.result-meta {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 14px;
    gap: 8px;
}

.result-meta span:first-child {
    color: var(--text);
    font-size: 17px;
    font-weight: 750;
}

.result-meta span + span::before {
    content: "/";
    color: #9aa5b5;
    margin-right: 8px;
}

.result-snippet {
    font-size: 18px;
    line-height: 1.65;
    margin: 0;
}

mark {
    background: #fff1a8;
    border-radius: 4px;
    color: inherit;
    padding: 0 3px;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 14px;
}

.empty-state {
    background: var(--panel);
    border: 1px dashed #bdc7d6;
    border-radius: 8px;
    margin-top: 18px;
    padding: 28px;
    text-align: center;
}

.empty-state h2 {
    margin: 0 0 8px;
}

.empty-state p {
    color: var(--muted);
    margin: 0 0 18px;
}

.page-block {
    border-top: 1px solid var(--line);
    padding-top: 18px;
    margin-top: 18px;
}

pre {
    background: #f2f4f8;
    border-radius: 6px;
    overflow: auto;
    padding: 14px;
    white-space: pre-wrap;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

@media (max-width: 640px) {
    .search-form,
    .topbar,
    .admin-search {
        flex-direction: column;
        align-items: stretch;
    }

    button,
    .button {
        width: 100%;
    }
}

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

    .quick-actions,
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .quick-actions,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .book-row,
    .search-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .book-row em {
        text-align: left;
    }
}
