/* ==========================================================================
   Magic Collection theme: "the binder"
   A dark slate binder cover (sidebar, binder pages), cool light paper for
   everything else, and a gold foil accent used sparingly. The card images
   carry the color; the interface stays quiet around them.
   ========================================================================== */

:root {
    --binder: #1E2B30;
    --binder-raised: #2A3B41;
    --binder-text: #E6EBE6;
    --binder-muted: #9FB0AE;
    --page: #EDEFEA;
    --surface: #FFFFFF;
    --surface-sunk: #F5F6F3;
    --ink: #172024;
    --muted: #5B666A;
    --line: #D5DAD5;
    --foil: #C9A227;
    --foil-ink: #7A5E12;
    --foil-on-dark: #E9C964;
    --danger: #A33A2A;

    /* The five Magic colors (plus colorless) */
    --mana-w: #F4EDCF;
    --mana-u: #A7D1EC;
    --mana-b: #BCB0A9;
    --mana-r: #EFA387;
    --mana-g: #98D0AA;
    --mana-c: #D9D6D2;

    --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-card: "Spectral", Georgia, "Times New Roman", serif;

    --radius-sm: 4px;
    --radius: 8px;
    --card-radius: 4.5% / 3.2%; /* the rounded corners of a real card */

    /* Bootstrap overrides */
    --bs-body-font-family: var(--font-ui);
    --bs-body-font-size: 0.9375rem;
    --bs-body-line-height: 1.55;
    --bs-body-bg: var(--page);
    --bs-body-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-border-color: var(--line);
    --bs-link-color: var(--binder);
    --bs-link-color-rgb: 30, 43, 48;
    --bs-link-hover-color: #0F181B;
    --bs-link-hover-color-rgb: 15, 24, 27;
    --bs-focus-ring-color: rgba(201, 162, 39, 0.45);
}

body {
    background: var(--page);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .card-name {
    font-family: var(--font-card);
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.005em;
}

h1 { font-size: 2rem; line-height: 1.15; margin: 0; }
h2 { font-size: 1.375rem; line-height: 1.25; margin: 0; }
h1:focus { outline: none; }

a { text-underline-offset: 0.15em; }

.num, .price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.loading { color: var(--muted); padding: 2rem 0; }

/* Small section heading set in the UI face */
.h-small {
    font-family: var(--font-ui);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    margin: 0 0 0.75rem;
}

:focus-visible {
    outline: 2px solid var(--foil);
    outline-offset: 2px;
}

/* ---------- Bootstrap components, re-skinned ---------- */

.btn {
    border-radius: var(--radius-sm);
    background-image: none;
    font-weight: 500;
}

.btn-primary {
    --bs-btn-color: var(--binder-text);
    --bs-btn-bg: var(--binder);
    --bs-btn-border-color: var(--binder);
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: var(--binder-raised);
    --bs-btn-hover-border-color: var(--binder-raised);
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: #121B1E;
    --bs-btn-active-border-color: #121B1E;
    --bs-btn-disabled-color: var(--binder-text);
    --bs-btn-disabled-bg: var(--binder);
    --bs-btn-disabled-border-color: var(--binder);
    --bs-btn-focus-shadow-rgb: 201, 162, 39;
}

.btn-outline-secondary {
    --bs-btn-color: var(--ink);
    --bs-btn-border-color: #C3CAC4;
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-bg: #E3E7E2;
    --bs-btn-hover-border-color: #B3BBB4;
    --bs-btn-active-color: var(--ink);
    --bs-btn-active-bg: #D8DDD7;
    --bs-btn-active-border-color: #B3BBB4;
    --bs-btn-focus-shadow-rgb: 201, 162, 39;
}

.btn-outline-danger {
    --bs-btn-color: var(--danger);
    --bs-btn-border-color: #E2B8AF;
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: var(--danger);
    --bs-btn-hover-border-color: var(--danger);
    --bs-btn-active-bg: #8A2F22;
    --bs-btn-active-border-color: #8A2F22;
}

.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #8A2F22;
    --bs-btn-hover-border-color: #8A2F22;
    --bs-btn-active-bg: #742619;
    --bs-btn-active-border-color: #742619;
}

.form-control,
.form-select {
    border-color: #C9CFC9;
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--ink);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--foil);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.25);
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.form-check-input:checked {
    background-color: var(--binder);
    border-color: var(--binder);
}

.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--binder);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    cursor: pointer;
}

.link-button:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* ---------- App shell: binder-cover sidebar + page ---------- */

.shell {
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
    min-height: 100vh;
    /* keeps the binder color under the sidebar on very long pages */
    background: linear-gradient(90deg, var(--binder) 0 224px, transparent 224px);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem 1rem;
    background: var(--binder);
    color: var(--binder-text);
}

.brand {
    padding: 0 0.5rem;
    font-family: var(--font-card);
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.15;
    color: var(--binder-text);
    text-decoration: none;
}

.brand:hover { color: #FFFFFF; }

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.side-link {
    display: block;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--binder-muted);
    font-weight: 500;
    text-decoration: none;
}

.side-link:hover {
    color: var(--binder-text);
    background: rgba(255, 255, 255, 0.05);
}

.side-link.active {
    color: var(--binder-text);
    background: var(--binder-raised);
    border-left-color: var(--foil);
}

.side-add {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--foil);
    color: #231A02;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}

.side-add:hover,
.side-add.active {
    background: #D9B53F;
    color: #231A02;
}

.side-user {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.side-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-logout {
    padding: 0.25rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--binder-text);
    font-size: 0.8125rem;
}

.side-logout:hover { background: rgba(255, 255, 255, 0.08); }

.main-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.main {
    flex: 1;
    width: 100%;
    max-width: 1440px;
    padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem;
}

.site-footer {
    padding: 1rem clamp(1rem, 3vw, 2.5rem) 1.5rem;
    color: var(--muted);
    font-size: 0.75rem;
}

.site-footer a { color: inherit; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; background: none; }

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .side-nav { flex-direction: row; flex-wrap: wrap; }

    .side-link {
        border-left: 0;
        border-bottom: 3px solid transparent;
        border-radius: 0;
    }

    .side-link.active { border-bottom-color: var(--foil); background: none; }

    .side-user {
        margin-top: 0;
        margin-left: auto;
        padding-top: 0;
        border-top: 0;
    }
}

/* ---------- Page heading, panels, notices ---------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-sub {
    max-width: 65ch;
    margin: 0.4rem 0 0;
    color: var(--muted);
}

.panel {
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid;
    border-radius: var(--radius-sm);
}

.notice .btn-close { margin-left: auto; }
.notice-ok { background: #E4EFE6; border-color: #B9D3BF; color: #1D3B26; }
.notice-error { background: #F6E3DF; border-color: #E2B8AF; color: #6E2418; }

.empty-state {
    max-width: 34rem;
    padding: 3rem 0;
}

.empty-state p {
    margin: 0.75rem 0 1.5rem;
    color: var(--muted);
}

/* ---------- Small tags ---------- */

.foil-tag {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: linear-gradient(115deg, #F3DE8A, #F7F2DC 45%, #CFE3F5 70%, #F3DE8A);
    color: #4B3A08;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.format-tag {
    display: inline-block;
    padding: 0.05rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.rarity { white-space: nowrap; }

.rarity::before {
    content: "";
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    background: currentColor;
    vertical-align: 0.05em;
}

.rarity-common { color: #3C4448; }
.rarity-uncommon { color: #5F7886; }
.rarity-rare { color: #9C7A16; }
.rarity-mythic { color: #B8492A; }
.rarity-special,
.rarity-bonus { color: #7A4FB0; }

/* ---------- Dashboard ---------- */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 2rem;
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--line);
}

.hero-title {
    max-width: 15ch;
    font-size: clamp(2.1rem, 4.2vw, 3.25rem);
    line-height: 1.08;
}

.hero-sub {
    max-width: 52ch;
    margin: 1rem 0 0;
    font-size: 1.0625rem;
}

.hero-meta {
    max-width: 60ch;
    margin: 0.75rem 0 0;
    color: var(--muted);
    font-size: 0.875rem;
}

/* The five most valuable cards, fanned out like a hand */
.hand {
    --hand-w: clamp(104px, 11vw, 158px);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    min-height: calc(var(--hand-w) * 1.6);
    padding: 1rem 0 0.5rem;
}

.hand-card {
    width: var(--hand-w);
    aspect-ratio: 63 / 88;
    border-radius: var(--card-radius);
    background: #CBD1CB;
    box-shadow: 0 10px 26px rgba(23, 32, 36, 0.28);
    transform-origin: 50% 150%;
    transform: rotate(calc(var(--a) * 1deg)) translateY(calc(var(--lift) * 1px));
}

.hand-card + .hand-card { margin-left: calc(var(--hand-w) * -0.56); }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.top-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: rank;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.top-item {
    counter-increment: rank;
    display: grid;
    grid-template-columns: 1.5rem 36px minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 0.85rem;
    padding: 0.55rem 1rem;
    border-top: 1px solid var(--line);
}

.top-item:first-child { border-top: 0; }

.top-item::before {
    content: counter(rank);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.top-thumb {
    width: 36px;
    aspect-ratio: 63 / 88;
    border-radius: var(--card-radius);
    object-fit: cover;
    background: #DDE1DC;
}

.top-name { min-width: 0; }
.top-name .card-name { display: block; font-size: 1.0625rem; line-height: 1.25; }
.top-set { display: block; color: var(--muted); font-size: 0.8125rem; }
.top-qty { color: var(--muted); font-variant-numeric: tabular-nums; }
.top-item .price { font-weight: 600; }

@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; }
    .hand { --hand-w: 92px; order: -1; }
    .top-item { grid-template-columns: 1.5rem 36px minmax(0, 1fr) auto; }
    .top-foil,
    .top-qty { display: none; }
}

/* ---------- Collection: toolbar ---------- */

.view-toggle {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid #C3CAC4;
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.view-toggle button {
    padding: 0.4rem 1rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 500;
}

.view-toggle button.active {
    background: var(--binder);
    color: var(--binder-text);
}

.head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.export { position: relative; }

.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.export-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 50;
    width: 310px;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(23, 32, 36, 0.18);
}

.export-format {
    display: flex;
    overflow: hidden;
    margin: 0.15rem 0.15rem 0.5rem;
    border: 1px solid #C3CAC4;
    border-radius: var(--radius-sm);
}

.export-format button {
    flex: 1;
    padding: 0.35rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 500;
}

.export-format button.active {
    background: var(--binder);
    color: var(--binder-text);
}

.export-item {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink);
    text-align: left;
}

.export-item:hover,
.export-item:focus-visible { background: #EEF1EC; }

@media (max-width: 600px) {
    .export-menu {
        right: auto;
        left: 0;
        width: min(310px, calc(100vw - 2rem));
    }
}

.toolbar {
    margin-bottom: 1.25rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.toolbar-row.more {
    align-items: flex-end;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.toolbar .search { flex: 1 1 260px; min-width: 200px; }
.toolbar .compact { flex: 0 0 auto; width: auto; }
.field { display: flex; flex-direction: column; }
.field .form-control,
.field .form-select { min-width: 8rem; }
.field-narrow .form-control { width: 7rem; min-width: 0; }

.mana-chips { display: flex; gap: 0.35rem; }

.mana-chip {
    --chip: var(--mana-c);
    display: inline-grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: 2px solid var(--chip);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.8125rem;
    font-weight: 600;
}

.mana-chip:hover { background: color-mix(in srgb, var(--chip) 40%, white); }

.mana-chip.on {
    background: var(--chip);
    border-color: var(--ink);
}

.mana-w { --chip: var(--mana-w); }
.mana-u { --chip: var(--mana-u); }
.mana-b { --chip: var(--mana-b); }
.mana-r { --chip: var(--mana-r); }
.mana-g { --chip: var(--mana-g); }
.mana-c { --chip: var(--mana-c); }

/* ---------- Collection: binder pages ---------- */

.binder {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 1.4rem 1rem;
    padding: clamp(1rem, 2vw, 1.5rem);
    border-radius: var(--radius);
    background: var(--binder);
}

.pocket {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--binder-text);
    text-align: left;
    cursor: pointer;
}

.pocket:focus-visible {
    outline: 2px solid var(--foil);
    outline-offset: 4px;
    border-radius: 6px;
}

.pocket-card {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 63 / 88;
    border-radius: var(--card-radius);
    background: var(--binder-raised);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.pocket-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pocket:hover .pocket-card { box-shadow: 0 0 0 2px var(--foil); }

.pocket-noimg {
    display: grid;
    place-items: center;
    height: 100%;
    padding: 1rem;
    font-family: var(--font-card);
    text-align: center;
}

/* Foil cards get a light, static shimmer across the card */
.pocket.is-foil .pocket-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg,
        transparent 22%,
        rgba(255, 255, 255, 0.26) 40%,
        rgba(165, 208, 255, 0.22) 50%,
        rgba(255, 228, 150, 0.2) 60%,
        transparent 78%);
    mix-blend-mode: screen;
    pointer-events: none;
}

.pocket-qty {
    position: absolute;
    right: 0.45rem;
    bottom: 0.45rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: rgba(23, 32, 36, 0.88);
    color: #FFFFFF;
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.pocket-card .foil-tag {
    position: absolute;
    left: 0.45rem;
    bottom: 0.45rem;
}

.pocket-caption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    min-width: 0;
}

.pocket-name {
    overflow: hidden;
    font-family: var(--font-card);
    font-size: 0.9375rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pocket-price {
    color: var(--foil-on-dark);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pocket-deck {
    margin-top: -0.3rem;
    color: var(--binder-muted);
    font-size: 0.75rem;
}

.show-more { margin-top: 1.25rem; }

@media (max-width: 600px) {
    .binder {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem 0.75rem;
        padding: 0.75rem;
    }

    .pocket-name { font-size: 0.875rem; }
}

/* ---------- Collection: list view ---------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

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

.card-table th {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface-sunk);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.card-table td {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--line);
    vertical-align: middle;
}

.card-table tbody tr:first-child td { border-top: 0; }
.card-table tbody tr:hover td { background: #F7F8F5; }
.card-table .num { text-align: right; }
.card-table .card-name {
    font-family: var(--font-card);
    font-size: 1rem;
    color: var(--ink);
    text-align: left;
    text-decoration: none;
}

.card-table .card-name:hover { text-decoration: underline; }
.card-table .type-line { color: var(--muted); font-size: 0.8125rem; }

.thumb {
    display: block;
    width: 34px;
    aspect-ratio: 63 / 88;
    border-radius: var(--card-radius);
    object-fit: cover;
    background: #DDE1DC;
}

/* ---------- Card drawer ---------- */

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(23, 32, 36, 0.45);
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    width: min(440px, 100vw);
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--surface);
    box-shadow: -12px 0 32px rgba(23, 32, 36, 0.25);
    animation: drawer-in 0.2s ease-out;
}

.drawer:focus { outline: none; }

@keyframes drawer-in {
    from { transform: translateX(24px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.drawer-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    font-size: 1.25rem;
    line-height: 1;
}

.drawer-close:hover { background: var(--surface-sunk); }

.drawer-img {
    display: block;
    width: 220px;
    max-width: 72%;
    margin: 0.5rem auto 1.25rem;
    border-radius: var(--card-radius);
    box-shadow: 0 8px 24px rgba(23, 32, 36, 0.25);
}

.drawer .card-name { font-size: 1.5rem; }
.drawer-type { margin: 0.2rem 0 0; color: var(--muted); }

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1.25rem;
    margin: 1.25rem 0;
    font-size: 0.875rem;
}

.facts dt { color: var(--muted); font-weight: 500; }
.facts dd { margin: 0; }

.drawer-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
}

/* ---------- Add card ---------- */

.search-hero {
    max-width: 640px;
    margin-bottom: 1.75rem;
}

.search-box { position: relative; }

.search-hero .form-control {
    padding: 0.75rem 1rem;
    font-size: 1.125rem;
}

.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 360px;
    overflow-y: auto;
    padding: 0.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(23, 32, 36, 0.16);
}

.suggestions button {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink);
    font-family: var(--font-card);
    font-size: 1.0625rem;
    text-align: left;
}

.suggestions button:hover,
.suggestions button:focus-visible { background: #EEF1EC; }

.suggestions .suggestion-printing {
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-family: var(--font-ui);
    font-size: 0.9375rem;
}

.suggestions .suggestion-printing:only-child {
    margin-bottom: 0;
    border-bottom: 0;
}

.search-hint {
    max-width: 60ch;
    margin-top: 0.5rem;
    color: var(--muted);
}

.search-hint kbd {
    padding: 0.05rem 0.4rem;
    border: 1px solid #C3CAC4;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: none;
    color: var(--ink);
    font-size: 0.8125rem;
}

.h-small .link-button { margin-left: 0.35rem; font-weight: 500; }

.add-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    align-items: start;
    gap: 1.75rem;
}

.printings {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
    gap: 0.75rem;
}

.printing {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.4rem;
    border: 2px solid transparent;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.75rem;
    text-align: left;
}

.printing:hover { border-color: var(--line); }

.printing img {
    width: 100%;
    aspect-ratio: 63 / 88;
    border-radius: var(--card-radius);
    object-fit: cover;
    background: #E3E7E2;
}

.printing.selected {
    border-color: var(--foil);
    background: #FBF6E6;
}

.printing-set { font-weight: 600; }
.printing-price { color: var(--muted); font-variant-numeric: tabular-nums; }

.add-panel {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}

.add-preview {
    display: block;
    width: 100%;
    max-width: 200px;
    margin: 0 auto 1.25rem;
    border-radius: var(--card-radius);
    box-shadow: 0 8px 24px rgba(23, 32, 36, 0.22);
}

.add-panel .card-name { font-size: 1.5rem; }
.add-set { margin: 0.2rem 0 0; color: var(--muted); }

.price-pair {
    display: flex;
    gap: 2rem;
    margin: 1rem 0 1.25rem;
}

.price-pair dt {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.price-pair dd {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 1000px) {
    .add-layout { grid-template-columns: 1fr; }
    .add-panel { position: static; order: -1; max-height: none; }
}

/* ---------- Decks ---------- */

.deck-form {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.7fr) minmax(0, 1.6fr) auto;
    align-items: end;
    gap: 0.75rem;
}

.deck-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.deck-row {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.5fr) 6rem 7rem 14rem;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--line);
}

.deck-row:first-child { border-top: 0; }
.deck-row.editing { grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.7fr) minmax(0, 1.6fr) auto; background: var(--surface-sunk); }

.deck-name {
    font-family: var(--font-card);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
}

.deck-name:hover { text-decoration: underline; }
.deck-main .format-tag { margin-left: 0.5rem; vertical-align: 0.15em; }
.deck-notes { color: var(--muted); font-size: 0.875rem; }
.deck-stat { text-align: right; }
.deck-stat .muted { font-size: 0.8125rem; }
.deck-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.deck-actions .btn { white-space: nowrap; }

@media (max-width: 860px) {
    .deck-form,
    .deck-row.editing { grid-template-columns: 1fr; }
    .deck-row { grid-template-columns: minmax(0, 1fr) auto; }
    .deck-notes,
    .deck-actions { grid-column: 1 / -1; justify-content: flex-start; }
    .deck-stat { text-align: left; }
}

/* ---------- Login & registration ---------- */

.auth-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    background: var(--binder);
}

.auth-brand {
    margin-bottom: 1.25rem;
    color: var(--binder-text);
    font-family: var(--font-card);
    font-size: 1.625rem;
    font-weight: 600;
}

.auth-card {
    width: min(400px, 100%);
    padding: 2rem;
    border-radius: var(--radius);
    background: var(--surface);
}

.auth-card h1 { font-size: 1.625rem; margin-bottom: 1.25rem; }
.auth-switch { margin: 1.25rem 0 0; color: var(--muted); font-size: 0.875rem; text-align: center; }

.auth-footer {
    max-width: 44ch;
    margin-top: 1.5rem;
    color: var(--binder-muted);
    font-size: 0.75rem;
    text-align: center;
}

.auth-footer a { color: var(--binder-text); }

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
    .drawer { animation: none; }
}

/* ---------- Blazor error bar ---------- */

#blazor-error-ui {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1100;
    display: none;
    width: 100%;
    padding: 0.6rem 1.25rem 0.7rem;
    background: #FFF6D6;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    cursor: pointer;
}
