:root {
    --bg: #0d1117;
    --bg-elevated: #161b22;
    --border: #2a3140;
    --text: #e6edf3;
    --text-muted: #9aa5b1;
    --accent: #f0c419;
    --accent-dark: #b98f00;
    --success: #3fb950;
    --danger: #f85149;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* ---------- Auth pages ---------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 380px;
}

.auth-card h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin: 0 0 20px;
    font-size: 0.9rem;
}

.auth-card form { display: flex; flex-direction: column; gap: 6px; }

.auth-card label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.auth-card input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 0.95rem;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-card button {
    margin-top: 18px;
    background: var(--accent);
    color: #1a1a1a;
    border: none;
    border-radius: 8px;
    padding: 11px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}

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

.switch-link {
    margin-top: 18px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin: 0 0 8px;
}

.alert-error {
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid rgba(248, 81, 73, 0.4);
    color: #ffb4ae;
}

.alert-success {
    background: rgba(63, 185, 80, 0.12);
    border: 1px solid rgba(63, 185, 80, 0.4);
    color: #9be8a5;
}

/* ---------- App layout ---------- */
.top-bar {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
}

.top-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.top-bar h1 {
    font-size: 1.15rem;
    margin: 0;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-ghost {
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ---------- Progress ---------- */
.progress-panel { margin-bottom: 26px; }

.progress-text {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.progress-text strong { color: var(--text); }

.progress-bar {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent));
    transition: width 0.35s ease;
}

.progress-hint {
    margin: 10px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Grid / cards ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.card.is-owned {
    border-color: var(--success);
    box-shadow: 0 0 0 1px rgba(63, 185, 80, 0.35);
}

.card.is-upcoming { opacity: 0.85; }

.card-image {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}

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

.badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-upcoming {
    background: rgba(240, 196, 25, 0.15);
    color: var(--accent);
    border: 1px solid rgba(240, 196, 25, 0.5);
}

.badge-complete {
    background: rgba(63, 185, 80, 0.18);
    color: var(--success);
    border: 1px solid rgba(63, 185, 80, 0.5);
}

.card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.card-code {
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    font-weight: 700;
}

.card-title {
    margin: 0;
    font-size: 1.05rem;
}

.card-desc {
    margin: 4px 0 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    flex: 1;
}

.card-meta {
    list-style: none;
    padding: 0;
    margin: 0 0 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.card-link {
    display: flex;
    flex-direction: column;
    flex: 1;
    color: inherit;
    text-decoration: none;
}

.card-link:hover .card-title { color: var(--accent); }

.view-cards-hint {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
}

.card-footer {
    padding: 10px 16px 16px;
    border-top: 1px solid var(--border);
}

.mini-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mini-progress-bar {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    height: 7px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dark), var(--success));
    transition: width 0.35s ease;
}

.mini-progress-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.no-cards-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ---------- Set detail page ---------- */
.plain-link { color: inherit; text-decoration: none; }
.plain-link:hover { color: var(--accent); }

.back-link {
    display: inline-block;
    margin-bottom: 18px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
}

.back-link:hover { color: var(--accent); }

.set-header {
    display: flex;
    gap: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.set-header-img {
    width: 320px;
    max-width: 100%;
    height: 180px;
    object-fit: cover;
    flex-shrink: 0;
}

.set-header-info {
    padding: 18px 20px 18px 0;
    flex: 1;
    min-width: 240px;
}

.set-header-info h2 { margin: 2px 0 6px; }

/* ---------- Filters ---------- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}

.filters-bar input[type="text"],
.filters-bar select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 9px 12px;
    font-size: 0.85rem;
}

.filters-bar input[type="text"] {
    flex: 1;
    min-width: 180px;
}

.filters-bar button {
    background: var(--accent);
    color: #1a1a1a;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.results-count {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0 0 14px;
}

/* ---------- Card gallery ---------- */
.card-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.card-item .card-footer { padding: 8px 12px 12px; }
.card-item .card-body { padding: 10px 12px; gap: 3px; }

.card-image-tall {
    aspect-ratio: 5 / 7;
    background: #000;
}

.card-title-sm { font-size: 0.9rem; line-height: 1.25; }
.card-desc-sm { font-size: 0.75rem; margin: 2px 0; }

.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--bg-elevated);
}

.badge-rarity {
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(2px);
}

.card-image-btn {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
}

.card-image-btn img { transition: transform 0.2s ease, filter 0.2s ease; }
.card-image-btn:hover img { transform: scale(1.03); filter: brightness(1.05); }

/* ---------- Variant list (Normal, Foil, Hyperspace...) ---------- */
.variant-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.variant-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid transparent;
}

.variant-row-owned {
    background: rgba(63, 185, 80, 0.1);
    border-color: rgba(63, 185, 80, 0.3);
}

.variant-label-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    text-decoration: underline dotted;
    text-decoration-color: var(--text-muted);
    text-underline-offset: 3px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.variant-label-btn:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ---------- Quantity stepper ---------- */
.qty-stepper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover { border-color: var(--accent); color: var(--accent); }
.qty-btn:active { transform: scale(0.94); }

.qty-input {
    width: 38px;
    text-align: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
    padding: 4px 2px;
    -moz-appearance: textfield;
}

.qty-input:focus { outline: none; border-color: var(--accent); }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 4, 8, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
}

.modal-overlay[hidden] { display: none; }

body.modal-open { overflow: hidden; }

.modal-content {
    position: relative;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 24px;
}

.modal-img {
    max-width: 320px;
    width: 100%;
    border-radius: 10px;
    align-self: start;
}

.modal-info { flex: 1; min-width: 220px; }
.modal-info h3 { margin: 0 0 8px; font-size: 1.2rem; }

.modal-meta {
    color: var(--accent);
    font-size: 0.85rem;
    margin: 0 0 12px;
    font-weight: 600;
}

.modal-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-line;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Export / import ---------- */
.container-narrow {
    max-width: 680px;
}

.actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
}

.upload-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin: 18px 0;
}

.upload-form input[type="file"] {
    flex: 1;
    min-width: 200px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.import-summary { margin-top: 24px; }

.import-issue-title {
    margin: 16px 0 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.import-issue-list {
    margin: 0 0 10px;
    padding-left: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
