* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;

    --bg: #0d1117;
    --panel: #111820;
    --panel2: #0a1016;
    --border: #30363d;
    --soft: #242c35;
    --text: #e6edf3;
    --muted: #8b949e;

    --green: #3fb950;
    --yellow: #e3b341;
    --blue: #58a6ff;
    --red: #f85149;
    --purple: #bc8cff;
}

html,
body {
    min-height: 100%;
    margin: 0;

    background:
        linear-gradient(rgba(5, 9, 13, 0.48), rgba(5, 9, 13, 0.48)),
        url("/assets/bricks/bricks-workshop-background.png") center top / cover fixed no-repeat,
        var(--bg);

    color: var(--text);
}

body {
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

.bricks-shell {
    width: min(1380px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 50px;
}

/* =========================================================
   HERO
   ========================================================= */

.collection-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;

    padding: 26px 0 20px;
}

.eyebrow {
    color: var(--yellow);

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.collection-hero h1 {
    margin: 7px 0 8px;

    font-size: clamp(2.2rem, 6vw, 4.8rem);
    line-height: 0.95;
}

.collection-hero p {
    max-width: 760px;
    margin: 0;

    color: #9ca7b2;
    line-height: 1.6;
}

.home-link {
    color: #98a3ad;
    text-decoration: none;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.72rem;
}

.home-link:hover {
    color: var(--yellow);
}

/* =========================================================
   COLLECTION STATS
   ========================================================= */

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

    margin: 12px 0 18px;
}

.stats-grid article {
    padding: 16px;

    background: var(--panel);

    border: 1px solid var(--border);
    border-radius: 10px;
}

.stats-grid span {
    display: block;

    color: #6f7a85;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.63rem;
    letter-spacing: 0.08em;
}

.stats-grid strong {
    display: block;
    margin-top: 5px;

    font-size: 1.6rem;
}

/* =========================================================
   TABS
   ========================================================= */

.collection-tabs {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;

    margin-bottom: 13px;
}

.tab {
    min-height: 40px;
    padding: 7px 12px;

    color: #8f99a3;
    background: #10161d;

    border: 1px solid #2a323b;
    border-radius: 7px;

    cursor: pointer;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.68rem;
}

.tab.active {
    color: #fff3c4;
    border-color: #8b6e27;
    background: rgba(227, 179, 65, 0.1);
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* =========================================================
   TOOLBAR
   ========================================================= */

.toolbar {
    display: grid;
    grid-template-columns:
        minmax(220px, 1.5fr)
        repeat(3, minmax(130px, 0.55fr))
        auto;

    gap: 10px;
    align-items: end;

    padding: 14px;

    background: #0f161d;

    border: 1px solid var(--soft);
    border-radius: 10px;
}

.toolbar label {
    display: grid;
    gap: 6px;

    color: #7d8791;
    font-size: 0.65rem;
}

.toolbar input,
.toolbar select,
.toolbar button {
    min-height: 42px;
    width: 100%;

    padding: 8px 10px;

    color: #d7dfe7;
    background: #080d12;

    border: 1px solid #2d3640;
    border-radius: 7px;

    font: inherit;
}

.toolbar button {
    width: auto;

    color: #fff3c4;

    border-color: #665522;

    cursor: pointer;
}

/* =========================================================
   PROTOTYPE NOTICE
   ========================================================= */

.prototype-banner {
    margin: 12px 0;
    padding: 10px 12px;

    color: #a6976a;
    background: rgba(227, 179, 65, 0.06);

    border: 1px solid rgba(227, 179, 65, 0.2);
    border-radius: 8px;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.65rem;
}

/* =========================================================
   COLLECTION GRID
   ========================================================= */

.collection-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(225px, 1fr));

    gap: 14px;
}

.set-card {
    overflow: hidden;

    background: #111820;

    border: 1px solid #2b333d;
    border-radius: 11px;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        border-color 0.15s ease;
}

.set-card:hover {
    transform: translateY(-3px);
    border-color: #6f5a2c;
}

/*
 * Fixed image area keeps every collection card aligned.
 * Full-size imagery is still available from the detail view.
 */
.set-image {
    width: 100%;
    height: 220px;

    display: grid;
    place-items: center;

    padding: 13px;

    background: #f6f7f8;

    overflow: hidden;
}

.set-image img {
    width: 100%;
    height: 100%;

    object-fit: contain;
    object-position: center;

    display: block;
}

.set-copy {
    padding: 13px;
}

.set-number {
    color: #8e99a4;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.65rem;
}

.set-copy h3 {
    margin: 5px 0 8px;
    font-size: 1rem;
}

.set-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;

    color: #87919b;
    font-size: 0.7rem;
}

/* =========================================================
   BADGES
   ========================================================= */

.badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;

    margin-top: 11px;
}

.badge {
    padding: 4px 6px;

    color: #9faab4;

    border: 1px solid #39434d;
    border-radius: 999px;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.57rem;
}

.badge.sealed {
    color: #ffca70;
    border-color: #695126;
}

.badge.built {
    color: #75d884;
    border-color: #315c38;
}

.badge.light {
    color: #8cc8ff;
    border-color: #345b78;
}

.empty-state {
    padding: 32px;

    color: #7d8791;
    text-align: center;
}

/* =========================================================
   STATS VIEW
   ========================================================= */

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

.panel {
    overflow: hidden;

    background: #0f161d;

    border: 1px solid var(--soft);
    border-radius: 10px;
}

.panel.wide {
    grid-column: 1 / -1;
}

.panel-heading {
    padding: 10px 12px;

    color: #7d8791;
    background: #111820;

    border-bottom: 1px solid var(--soft);

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.66rem;
}

.ascii-panel {
    margin: 0;
    padding: 15px;

    overflow: auto;

    color: #cfd8e0;
    background: #05090d;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 12px;
    line-height: 1.45;
}

.ranking-list {
    padding: 10px;
}

.rank-row {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;

    padding: 9px;

    color: #aab4bd;

    border-bottom: 1px solid #242d36;

    font-size: 0.72rem;
}

.rank-row:last-child {
    border-bottom: 0;
}

.rank-row b {
    color: #e3b341;
}

/* =========================================================
   BRICKSHELL
   ========================================================= */

.terminal-window {
    overflow: hidden;

    background: #05090d;

    border: 1px solid #30363d;
    border-radius: 11px;
}

.terminal-titlebar {
    height: 46px;

    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;

    padding: 0 14px;

    color: #8d98a3;
    background: #161b22;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.7rem;
}

.window-buttons {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;

    border-radius: 50%;
}

.dot.red {
    background: #ff5f57;
}

.dot.yellow {
    background: #febc2e;
}

.dot.green {
    background: #28c840;
}

.terminal-ready {
    justify-self: end;
    color: #3fb950;
}

.terminal-output {
    min-height: 470px;
    max-height: 650px;

    overflow: auto;

    padding: 15px;

    color: #d3dde5;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 12px;
    line-height: 1.5;
}

.terminal-line {
    white-space: pre-wrap;
}

.terminal-command {
    margin-top: 8px;
    color: #e3b341;
}

.terminal-muted {
    color: #6e7883;
}

.terminal-green {
    color: #56d364;
}

.terminal-input-row {
    display: flex;
    gap: 8px;
    align-items: center;

    padding: 10px 14px;

    color: #e3b341;
    background: #081016;

    border-top: 1px solid #202832;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.72rem;
}

.terminal-input-row input {
    flex: 1;
    min-width: 0;

    color: #edf4f8;
    background: transparent;

    border: 0;
    outline: 0;

    font: inherit;
}

.quick-commands {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;

    padding: 9px 10px;

    background: #0b1218;
    border-top: 1px solid #1d252d;
}

.quick-commands button {
    min-height: 32px;
    padding: 5px 8px;

    color: #929da7;
    background: #111820;

    border: 1px solid #30363d;
    border-radius: 6px;

    cursor: pointer;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.62rem;
}

/* =========================================================
   SET DETAIL DIALOG
   ========================================================= */

.set-dialog {
    width: min(800px, calc(100% - 28px));

    padding: 0;

    color: #e6edf3;
    background: #10171e;

    border: 1px solid #30363d;
    border-radius: 12px;
}

.set-dialog::backdrop {
    background: rgba(0, 0, 0, 0.75);
}

.dialog-close {
    position: absolute;
    top: 10px;
    right: 12px;

    width: 36px;
    height: 36px;

    color: #bcc5ce;
    background: #111820;

    border: 1px solid #30363d;
    border-radius: 50%;

    cursor: pointer;

    font-size: 1.3rem;
}

.detail-grid {
    display: grid;
    grid-template-columns:
        minmax(220px, 0.8fr)
        minmax(0, 1.2fr);

    gap: 20px;

    padding: 24px;
}

.detail-image {
    display: grid;
    place-items: center;

    min-height: 260px;

    padding: 15px;

    background: #f6f7f8;
    border-radius: 9px;
}

.detail-image img {
    max-width: 100%;
    max-height: 360px;

    object-fit: contain;
}

.detail-copy h2 {
    margin: 0 40px 4px 0;
}

.detail-kicker {
    color: #e3b341;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 0.68rem;
}

.detail-table {
    display: grid;
    gap: 8px;

    margin-top: 18px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;

    padding-bottom: 7px;

    color: #8f9aa4;

    border-bottom: 1px solid #28313a;

    font-size: 0.76rem;
}

.detail-row strong {
    color: #dce4ea;
}

.external-link {
    display: inline-block;

    margin-top: 16px;

    color: #58a6ff;
    text-decoration: none;

    font-size: 0.72rem;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {
    .toolbar {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .search-field {
        grid-column: 1 / -1;
    }

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

@media (max-width: 650px) {
    .bricks-shell {
        width: min(100% - 18px, 1380px);
        padding-top: 18px;
    }

    .collection-hero {
        flex-direction: column;
    }

    .toolbar,
    .stats-layout {
        grid-template-columns: 1fr;
    }

    .panel.wide {
        grid-column: auto;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .terminal-input-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}
