:root {
    --bg: #f7f3ea;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --ink: #172121;
    --muted: #5e6a6a;
    --line: rgba(23, 33, 33, 0.1);
    --brand: #7a1f1f;
    --brand-dark: #4b1010;
    --accent: #d8aa2a;
    --success: #1f7a52;
    --danger: #a42a2a;
    --shadow: 0 24px 60px rgba(70, 47, 21, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(216, 170, 42, 0.25), transparent 32%),
        linear-gradient(180deg, #fcfaf5 0%, var(--bg) 100%);
}

body.modal-open {
    overflow: hidden;
}

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

button,
input {
    font: inherit;
}

.wrap {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(14px);
    background:
        linear-gradient(135deg, rgba(75, 16, 16, 0.98), rgba(122, 31, 31, 0.96)),
        linear-gradient(90deg, rgba(216, 170, 42, 0.12), transparent 40%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 40px rgba(75, 16, 16, 0.22);
}

/* Keep header contents flush to the left edge of the viewport
   without affecting other centered `.wrap` sections. */
.site-header > .wrap {
    width: 100%;
    max-width: none;
    margin: 0;
    padding-left: 1rem;
    padding-right: 1rem;
}

.site-header .header-inner {
    justify-content: flex-start;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 88px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.95rem;
    color: #fff7ee;
}

.brand-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.24));
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.brand-subtitle {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(255, 247, 238, 0.78);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-button,
.primary-button {
    border: 0;
    cursor: pointer;
    color: white;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    border-radius: 999px;
    padding: 0.8rem 1.3rem;
    box-shadow: var(--shadow);
}

.danger-button {
    border: 0;
    cursor: pointer;
    color: white;
    background: linear-gradient(135deg, #a42a2a, #6f1212);
    border-radius: 999px;
    padding: 0.8rem 1.3rem;
    box-shadow: var(--shadow);
}

.hero {
    padding: 4.5rem 0 2rem;
    min-height: calc(100vh - 88px);
}

.hero-grid,
.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
    gap: 2rem;
}

.hero .wrap {
    width: min(1440px, calc(100% - 1rem));
}

.hero-grid > div:first-child {
    max-width: 760px;
}

.hero-grid > div:last-child {
    justify-self: end;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.76rem;
    color: var(--brand);
    margin-bottom: 0.75rem;
}

h1,
h2 {
    margin-top: 0;
    line-height: 1.05;
}

h1 {
    font-size: clamp(2.8rem, 4.8vw, 5.2rem);
    margin-bottom: 1rem;
}

.hero-copy,
.section-copy {
    color: var(--muted);
    line-height: 1.7;
}

.panel,
.stats-card,
.summary-card,
.result-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.panel,
.result-card {
    padding: 1.5rem;
}

.stats-card,
.summary-card {
    display: inline-flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.25rem;
    margin-top: 1rem;
}

.stats-card strong,
.summary-card strong {
    font-size: 1.8rem;
}

.search-panel {
    align-self: start;
}

.stack-form {
    display: grid;
    gap: 0.85rem;
}

.search-mode-group {
    margin: 0;
    padding: 0;
    border: 0;
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-mode-group legend {
    width: 100%;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.search-mode-option {
    flex: 1 1 0;
    max-width: 220px;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    justify-content: center;
}

.search-mode-option input {
    margin: 0;
    /* Use maroon brand for the radio accent color */
    accent-color: var(--brand);
}

/* Fallback: ensure native radio inputs use brand accent where supported */
input[type="radio"] {
    accent-color: var(--brand);
}

.search-field-group {
    display: grid;
    gap: 0.85rem;
}

.stack-form input[type="text"],
.stack-form input[type="email"],
.stack-form input[type="password"],
.stack-form input[type="file"] {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    border-radius: 16px;
    padding: 0.95rem 1rem;
}

.flash-stack {
    padding-top: 1rem;
}

.flash {
    border-radius: 18px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}

.flash-success {
    background: rgba(31, 122, 82, 0.12);
    color: var(--success);
}

.flash-error {
    background: rgba(164, 42, 42, 0.12);
    color: var(--danger);
}

.search-help {
    color: var(--muted);
    line-height: 1.6;
    margin: 1rem 0 0;
}

.search-feedback {
    min-height: 1.5rem;
    margin-top: 0.9rem;
    font-weight: 600;
}

.search-feedback.info {
    color: var(--muted);
}

.search-feedback.success {
    color: var(--success);
}

.search-feedback.error {
    color: var(--danger);
}

.result-section,
.admin-shell,
.auth-shell {
    padding-bottom: 3rem;
}

.hidden {
    display: none;
}

.result-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.result-modal.hidden {
    display: none;
}

.result-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(23, 33, 33, 0.48);
    backdrop-filter: blur(8px);
}

.confetti-layer {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    bottom: 8%;
    border-radius: 999px;
    opacity: 0.95;
    transform: translate3d(0, 0, 0) rotate(0deg);
    transform-origin: center center;
    animation:
        confetti-burst var(--confetti-duration, 3s) cubic-bezier(0.16, 0.84, 0.28, 1) var(--confetti-delay, 0s) forwards,
        confetti-spin calc(var(--confetti-duration, 3s) * 0.75) linear var(--confetti-delay, 0s) forwards;
}

@keyframes confetti-burst {
    0% {
        transform: translate3d(0, 0, 0) rotate(0deg);
        opacity: 1;
    }

    18% {
        opacity: 1;
    }

    100% {
        transform: translate3d(var(--confetti-travel-x, 0), var(--confetti-travel-y, -60vh), 0) rotate(var(--confetti-rotate, 360deg));
        opacity: 0;
    }
}

.confetti-piece--left {
    transform-origin: left bottom;
}

.confetti-piece--right {
    transform-origin: right bottom;
}

@keyframes confetti-spin {
    0% {
        filter: saturate(1);
    }

    50% {
        filter: saturate(1.2);
    }

    100% {
        filter: saturate(1);
    }
}

.result-modal-card {
    position: relative;
    z-index: 2;
    width: min(1280px, calc(100vw - 3rem));
    min-height: min(72vh, 720px);
    max-height: min(90vh, 980px);
    overflow-y: auto;
    background: rgba(255, 252, 247, 0.98);
}

/* Make modal card a column flex container so the message can expand */
.result-modal-card {
    display: flex;
    flex-direction: column;
}

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

.result-modal-topbar .eyebrow {
    margin-bottom: 0;
}

.modal-close-button {
    border: 0;
    background: transparent;
    color: var(--ink);
    border-radius: 0;
    padding: 0.15rem 0.25rem;
    cursor: pointer;
    font-weight: 800;
    font-size: 1.8rem;
    line-height: 1;
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
}

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

.status-pill {
    background: rgba(216, 170, 42, 0.18);
    color: var(--brand-dark);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 400px;
    /* allow container queries to respond to the pill's inline size */
    container-type: inline-size;
    padding: 0.75rem 1.5rem;
    font-weight: 700;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    font-size: clamp(1.05rem, 1.8vw, 1.4rem);
    line-height: 1.05;
    text-transform: none;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 20px rgba(75, 16, 16, 0.06);
}

/* Adjust text size and spacing depending on the pill's own width */
@container (min-width: 400px) {
    .status-pill {
        font-size: 1.6rem;
        padding: 0.95rem 2rem;
        font-weight: 800;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        background: rgba(216, 170, 42, 0.24);
        border: 1px solid rgba(75, 16, 16, 0.06);
    }
}

@container (max-width: 399px) {
    .status-pill {
        font-size: 1rem;
        padding: 0.6rem 1rem;
        font-weight: 700;
    }
}

.result-message {
    padding: 1rem 1.1rem;
    border-radius: 20px;
    background: rgba(23, 33, 33, 0.04);
    color: var(--ink);
    line-height: 1.6;
    white-space: pre-line;
}

.result-actions {
    /* empty placeholder removed previously; kept minimal layout rules if needed */
    display: block;
}

/* Let the message area grow to fill remaining vertical space */
.result-message {
    flex: 1 1 auto;
    margin-bottom: 0;
    /* make bottom corners rounded and top corners flush with header */
    border-radius: 0 0 20px 20px;
}

.result-message--disqualified {
    justify-content: center;
}

.result-message a {
    color: var(--brand);
    font-weight: 800;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.18em;
    background: rgba(216, 170, 42, 0.22);
    padding: 0 0.25rem;
    border-radius: 0.35rem;
}

.result-message a:hover,
.result-message a:focus-visible {
    color: var(--brand-dark);
    background: rgba(216, 170, 42, 0.32);
}

/* Styled heading used for congratulation messages inside result modal */
.congrats-heading {
    /* Increased so the single "Congratulations!" stands out more */
    font-size: clamp(2rem, 4.4vw, 3.2rem);
    margin: 0 0 0.65rem 0;
    font-weight: 800;
    color: var(--brand-dark);
    letter-spacing: 0.01em;
    text-shadow: 0 6px 20px rgba(75,16,16,0.06);
}

.congrats-subtext {
    color: var(--muted);
    font-weight: 600;
}

.privacy-note {
    margin-top: 0.6rem;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

@media (min-width: 861px) {
    .result-message {
        /* Larger type to better fill modal whitespace */
        font-size: clamp(1.2rem, 1.6vw + 0.6rem, 1.6rem);
        line-height: 1.65;
        padding: 1.2rem 2rem 2rem 2rem;
        /* align content to the top so the heading sits higher */
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 1.05rem;
    }

    .result-message--disqualified {
        justify-content: center;
    }

    .result-message p {
        margin: 0;
    }

    /* Desktop-only separators for result modal */
    .result-header {
        /* keep spacing but add a stronger divider */
        padding-bottom: 1rem;
        margin-bottom: 1rem;
        border-bottom: 2px solid var(--brand);
        align-items: center;
    }

    /* vertical separator between name block and status pill (removed) */
    .result-header > div {
        padding-right: 1rem;
        margin-right: 0.75rem;
        border-right: none; /* separator removed */
    }

    /* give the status pill some separation */
    .result-header .status-pill {
        margin-left: 0.5rem;
    }
}

.meta-label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.remarks-box,
.note-box {
    padding: 1rem 1.1rem;
    border-radius: 20px;
    background: rgba(23, 33, 33, 0.04);
}

.admin-shell {
    padding-top: 2rem;
}

.danger-panel {
    border-color: rgba(164, 42, 42, 0.25);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(164, 42, 42, 0.05));
}

.admin-heading {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

.summary-strip {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

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

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

th,
td {
    text-align: left;
    padding: 0.9rem 0.6rem;
    border-bottom: 1px solid var(--line);
}

.auth-shell {
    padding-top: 4rem;
}

.auth-panel {
    max-width: 520px;
    margin: 0 auto;
}

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

    .hero {
        padding: 2.5rem 0 1.5rem;
        min-height: auto;
    }

    .hero .wrap {
        width: calc(100% - 1rem);
    }

    .hero-grid > div:first-child,
    .hero-grid > div:last-child {
        max-width: none;
        justify-self: stretch;
    }

    .search-panel {
        width: 100%;
    }

    .search-mode-group {
        flex-direction: column;
        align-items: stretch;
    }

    .search-mode-option {
        max-width: none;
        width: 100%;
        justify-content: flex-start;
    }

    .header-inner,
    .result-header {
        flex-direction: column;
        align-items: start;
    }

    .site-header > .wrap {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .header-inner {
        min-height: 68px;
    }

    .brand {
        gap: 0.7rem;
        align-items: center;
    }

    .brand-logo {
        width: 44px;
        height: 44px;
    }

    .brand-copy {
        gap: 0.08rem;
        min-width: 0;
    }

    .brand-title {
        font-size: 1rem;
        line-height: 1.15;
        letter-spacing: 0.01em;
    }

    h1 {
        font-size: clamp(2.1rem, 8vw, 2.8rem);
    }

    .result-modal {
        padding: 0.75rem;
    }

    .result-modal-card {
        width: calc(100vw - 1.5rem);
        min-height: auto;
        max-height: calc(100vh - 1.5rem);
        padding: 1.2rem;
    }

    /* Make the status pill fill the modal width on mobile */
    .result-header .status-pill {
        width: 100%;
        max-width: none;
        min-width: 0;
        align-self: stretch;
        justify-content: center;
        margin-top: 0.6rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .result-modal-topbar {
        flex-direction: row;
        align-items: center;
    }

    .result-header {
        gap: 0.85rem;
    }

    .result-message {
        padding: 0.9rem 1rem;
        flex: initial;
        border-radius: 20px;
    }

    .result-actions {
        justify-content: stretch;
    }

    .result-download-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .brand-subtitle {
        display: none;
    }

    .site-header > .wrap {
        display: flex;
        align-items: center;
        min-height: 56px;
    }

    .header-inner {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        min-height: auto;
        width: 100%;
    }

    .site-header > .wrap {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }

    .brand {
        width: 100%;
        gap: 0.5rem;
        align-items: center;
    }

    .brand-logo {
        width: 38px;
        height: 38px;
    }

    .brand-title {
        font-size: 0.88rem;
        line-height: 1.1;
        letter-spacing: 0;
        display: block;
        max-width: 100%;
    }

    .brand-copy {
        min-width: 0;
        flex: 1;
    }

    .hero {
        padding-top: 1.75rem;
    }

    .wrap {
        width: calc(100% - 1rem);
    }

    h1 {
        font-size: 2rem;
    }

    .panel,
    .result-card {
        padding: 1.1rem;
    }

    .search-mode-option {
        padding: 0.8rem 1rem;
    }

    .modal-close-button {
        font-size: 1.5rem;
        padding: 0.1rem 0.2rem;
    }

    .status-pill {
        /* smaller but still readable on very small screens */
        min-width: 260px;
        padding: 0.45rem 0.9rem;
        font-size: 0.95rem;
    }
}
