:root {
    color-scheme: light;
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ink: #172033;
    --muted: #647084;
    --paper: #f5f6f8;
    --card: #ffffff;
    --line: #dce1e8;
    --accent: #efb42d;
    --accent-dark: #9b6900;
    --danger: #a62e3b;
    --shadow: 0 1rem 2.5rem rgb(38 48 70 / 10%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

input,
select {
    width: 100%;
    min-height: 3rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #fff;
    color: var(--ink);
}

button,
.button {
    display: inline-flex;
    min-height: 3rem;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
}

button.primary,
.button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #211600;
    font-weight: 800;
}

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

.site-header {
    position: sticky;
    z-index: 10;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4.5rem;
    padding: 0.7rem max(1rem, calc((100vw - 72rem) / 2));
    border-bottom: 1px solid var(--line);
    background: rgb(255 255 255 / 94%);
    backdrop-filter: blur(1rem);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 900;
    text-decoration: none;
}

.brand img {
    width: 2.5rem;
    height: 2.5rem;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

nav a {
    padding: 0.6rem 0.75rem;
    border-radius: 0.65rem;
    text-decoration: none;
}

nav a:hover {
    background: var(--paper);
}

.page {
    width: min(72rem, 100%);
    margin: 0 auto;
    padding: 1.25rem;
}

.hero {
    display: grid;
    grid-template-columns: 1fr minmax(12rem, 22rem);
    align-items: center;
    gap: 2rem;
    min-height: 24rem;
    padding: clamp(1.5rem, 5vw, 4rem);
    border-radius: 1.5rem;
    background:
        linear-gradient(135deg, #18243c, #2f466e);
    color: #fff;
    box-shadow: var(--shadow);
}

.hero h1,
.page-heading h1 {
    max-width: 15ch;
    margin: 0;
    font-size: clamp(2.2rem, 7vw, 4.7rem);
    line-height: 0.98;
}

.hero p {
    max-width: 42rem;
    font-size: 1.05rem;
    line-height: 1.6;
}

.hero-art {
    width: 100%;
    max-height: 20rem;
}

.eyebrow {
    margin-bottom: 0.55rem;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.page-heading {
    padding: 1.5rem 0;
}

.page-heading p {
    max-width: 48rem;
    color: var(--muted);
    line-height: 1.6;
}

.panel {
    margin-top: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: var(--card);
    box-shadow: var(--shadow);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stats article {
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: #fff;
}

.stats strong {
    display: block;
    font-size: 2rem;
}

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

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.action-card {
    min-height: 12rem;
    padding: 1.35rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: #fff;
    box-shadow: var(--shadow);
    text-decoration: none;
}

.action-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.section-heading,
.button-row,
.input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.cover-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 1rem;
}

.cover-card {
    display: grid;
    gap: 0.4rem;
    text-decoration: none;
}

.cover-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 0.5rem;
    background: var(--paper);
}

.cover-card span,
.muted,
.help,
.result-count {
    color: var(--muted);
}

.form-stack {
    display: grid;
    gap: 0.9rem;
    max-width: 48rem;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.checkbox input {
    width: auto;
    min-height: auto;
    margin-top: 0.25rem;
}

.search-checkbox {
    margin: 0;
}

.filters {
    display: grid;
    gap: 1rem;
}

.filters-main {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    align-items: end;
    gap: 0.75rem;
}

.filters-secondary {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.filter-field {
    min-width: 0;
}

.filter-search {
    min-width: min(22rem, 100%);
}

.filter-submit {
    min-width: 8rem;
}

.filter-sort {
    width: min(14rem, 100%);
}

.filters label,
.form-stack > label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 750;
}

.collection-list {
    display: grid;
    gap: 0.75rem;
}

.collection-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 1rem 0 0.75rem;
}

.view-toggle {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.collection-row {
    display: grid;
    grid-template-columns: 5rem 1fr minmax(8rem, auto);
    gap: 1rem;
    align-items: center;
    padding: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    background: #fff;
    text-decoration: none;
}

.collection-row:hover {
    border-color: var(--accent);
}

.collection-row img {
    width: 5rem;
    height: 7.5rem;
    object-fit: cover;
    border-radius: 0.4rem;
    background: var(--paper);
}

.collection-row h2 {
    margin: 0 0 0.4rem;
}

.collection-row p {
    margin: 0.25rem 0;
}

.location {
    display: grid;
    justify-items: end;
    gap: 0.3rem;
}

.location span {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: #edf0f5;
}

.collection-list-table {
    display: grid;
    gap: 0.5rem;
}

.series-groups {
    display: grid;
    gap: 1rem;
}

.series-group {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: #fff;
    box-shadow: var(--shadow);
}

.series-group-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.series-group-header h2 {
    margin: 0;
}

.series-group-header span {
    color: var(--muted);
    font-weight: 700;
}

.series-group-list {
    display: grid;
    gap: 0.5rem;
}

.series-group-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    text-decoration: none;
}

.series-group-item:hover {
    border-color: var(--accent);
}

.series-group-item strong,
.series-group-item p {
    overflow-wrap: anywhere;
}

.collection-list-header,
.collection-list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: 0.8rem 1rem;
    border-radius: 0.9rem;
}

.collection-list-header {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.collection-list-item {
    border: 1px solid var(--line);
    background: #fff;
    text-decoration: none;
}

.collection-list-item:hover {
    border-color: var(--accent);
}

.collection-list-item strong {
    overflow-wrap: anywhere;
}

.collection-boxes {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}

.collection-boxes span {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: #edf0f5;
}

.table-wrap {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.table-pill {
    display: inline-flex;
    margin: 0 0.35rem 0.35rem 0;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: #edf0f5;
}

.detail-card {
    display: grid;
    grid-template-columns: minmax(15rem, 24rem) 1fr;
    gap: clamp(1.5rem, 5vw, 4rem);
    padding: 1.5rem 0;
}

.detail-cover {
    width: 100%;
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: var(--shadow);
}

.detail-card h1 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 4rem);
    line-height: 1;
}

.lead {
    font-size: 1.15rem;
    color: var(--muted);
}

.metadata {
    display: grid;
    gap: 0.6rem;
    margin: 1.5rem 0;
}

.metadata div {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 0.75rem;
}

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

.metadata dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.copy-list {
    display: grid;
    gap: 0.5rem;
}

.copy-list div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem;
    border-radius: 0.7rem;
    background: #fff;
    border: 1px solid var(--line);
}

.camera-frame {
    position: relative;
    overflow: hidden;
    max-width: 42rem;
    aspect-ratio: 4 / 3;
    border-radius: 0.8rem;
    background: #0d1119;
}

.cover-camera-frame {
    max-width: none;
    width: 100%;
    min-height: min(74vh, 50rem);
    aspect-ratio: auto;
    height: min(74vh, 50rem);
}

.cover-camera-frame.is-captured {
    box-shadow: inset 0 0 0 3px rgb(239 180 45 / 80%);
}

#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#cover-camera-preview,
.cover-capture-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.scan-guide.cover-guide {
    inset: 4% 4%;
    border-radius: 0.75rem;
}

.cover-camera-frame.is-captured .cover-guide {
    opacity: 0;
}

.scan-guide {
    position: absolute;
    inset: 35% 8%;
    border: 3px solid var(--accent);
    border-radius: 0.45rem;
    box-shadow: 0 0 0 999px rgb(0 0 0 / 30%);
    pointer-events: none;
}

.scanner-hint {
    position: absolute;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    max-width: calc(100% - 2rem);
    padding: 0.65rem 0.85rem;
    border-radius: 999px;
    background: rgb(239 180 45 / 92%);
    color: #211600;
    font-size: 0.92rem;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 0.5rem 1.2rem rgb(0 0 0 / 25%);
}

.scan-matches {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.scan-match {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 1rem;
}

.scan-match img {
    width: 8rem;
    max-height: 12rem;
    object-fit: cover;
    border-radius: 0.5rem;
}

.result-message,
.flash {
    padding: 0.85rem 1rem;
    border-radius: 0.7rem;
    background: #edf0f5;
}

.result-message.error,
.flash.error {
    background: #fae4e7;
    color: var(--danger);
}

.result-message.loading {
    background: #fff1c6;
    color: #6d4a00;
    font-weight: 800;
}

.warning-list {
    line-height: 1.6;
}

.empty-state {
    display: grid;
    justify-items: center;
    padding: 3rem 1rem;
    text-align: center;
}

.empty-state img {
    width: min(16rem, 70%);
}

@media (max-width: 48rem) {
    .site-header {
        position: static;
        align-items: flex-start;
    }

    nav {
        justify-content: flex-end;
    }

    .brand span {
        display: none;
    }

    .hero,
    .detail-card,
    .collection-row,
    .filters-main,
    .series-group-item,
    .collection-list-header,
    .collection-list-item {
        grid-template-columns: 1fr;
    }

    .hero-art {
        display: none;
    }

    .location {
        justify-items: start;
    }

    .collection-boxes {
        justify-content: flex-start;
    }

    .input-row,
    .button-row {
        align-items: stretch;
        flex-direction: column;
    }

    .collection-row img {
        width: 6rem;
        height: 9rem;
    }

    .cover-camera-frame {
        min-height: 76vh;
        height: 76vh;
    }
}
