/* ── Theme ────────────────────────────────────────────────────────────────
   Dark, parchment-and-iron. Class colours are the only strong hues in the
   interface, so a sheet can be read by colour the way the game itself is. */

:root {
    --bg: #0e0e13;
    --bg-raised: #171720;
    --bg-raised-2: #1e1e2a;
    --bg-input: #12121a;
    --line: #2c2c3b;
    --line-strong: #3d3d52;
    --text: #ded9d0;
    --text-dim: #9b95a6;
    --text-faint: #6f6a7c;
    --gold: #d9b356;
    --gold-bright: #f2dfa0;
    --danger: #d9534f;
    --success: #63b76c;
    --warn: #d9a441;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 6px 20px rgb(0 0 0 / 45%);
    --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: var(--serif);
    color: var(--gold-bright);
    font-weight: 600;
    margin: 0 0 .6rem;
    letter-spacing: .3px;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); text-decoration: underline; }

p { margin: 0 0 .8rem; }

code, .mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: .88em; }

/* ── Shell ──────────────────────────────────────────────────────────────── */

.page { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: linear-gradient(180deg, #14141d, #0d0d13);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
}

.brand {
    padding: 1.1rem 1.1rem .9rem;
    border-bottom: 1px solid var(--line);
}

.brand-title {
    font-family: var(--serif);
    font-size: 1.15rem;
    color: var(--gold-bright);
    display: block;
    line-height: 1.2;
}

.brand-sub { font-size: .74rem; color: var(--text-faint); letter-spacing: 1.4px; text-transform: uppercase; }

.nav-list { list-style: none; margin: 0; padding: .6rem 0; flex: 1 1 auto; overflow-y: auto; }

.nav-list li { margin: 0; }

.nav-section {
    padding: 1rem 1.1rem .35rem;
    font-size: .68rem;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--text-faint);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem 1.1rem;
    color: var(--text-dim);
    border-left: 3px solid transparent;
    font-size: .93rem;
}

.nav-link:hover { background: #1a1a25; color: var(--text); text-decoration: none; }

.nav-link.active {
    background: #1d1d2a;
    color: var(--gold-bright);
    border-left-color: var(--gold);
}

.nav-icon { width: 18px; text-align: center; opacity: .85; }

.sidebar-foot { padding: .7rem 1.1rem; border-top: 1px solid var(--line); font-size: .74rem; color: var(--text-faint); }

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

.content { padding: 1.6rem 2rem 4rem; max-width: 1400px; width: 100%; }

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

.page-head .lead { color: var(--text-dim); margin: 0; max-width: 70ch; }

/* ── Surfaces ───────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.1rem;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    flex-wrap: wrap;
    margin-bottom: .8rem;
}

.card-head h2, .card-head h3 { margin: 0; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: .85rem; }
.small { font-size: .85rem; }
.right { margin-left: auto; }
.row-flex { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.grid { display: grid; gap: 1rem; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--bg-raised-2);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: .42rem .85rem;
    font-size: .88rem;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, border-color .12s;
}

.btn:hover:not(:disabled) { background: #262636; border-color: var(--gold); color: var(--gold-bright); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: linear-gradient(180deg, #a4832e, #7d631f); border-color: #c8a13d; color: #1a1508; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #c19a37, #96762a); color: #120e04; }

.btn-danger { border-color: #6b2f2f; color: #e29a97; }
.btn-danger:hover:not(:disabled) { background: #3a1c1c; border-color: var(--danger); color: #ffb9b6; }

.btn-sm { padding: .22rem .5rem; font-size: .8rem; }
.btn-icon { padding: .25rem .45rem; line-height: 1; }

/* ── Forms ──────────────────────────────────────────────────────────────── */

label, .label { display: block; font-size: .8rem; color: var(--text-dim); margin-bottom: .2rem; letter-spacing: .3px; }

input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: .4rem .55rem;
    font-family: inherit;
    font-size: .9rem;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgb(217 179 86 / 18%); }

textarea { resize: vertical; min-height: 90px; line-height: 1.45; }

select option { background: var(--bg-input); }

.field { margin-bottom: .7rem; }
.field-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 160px; margin-bottom: .7rem; }

input[type=checkbox] { width: auto; accent-color: var(--gold); }

.check { display: flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--text); }
.check label { margin: 0; color: inherit; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

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

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

th {
    text-align: left;
    font-weight: 600;
    font-size: .74rem;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--text-faint);
    border-bottom: 1px solid var(--line-strong);
    padding: .4rem .55rem;
    white-space: nowrap;
}

td { padding: .4rem .55rem; border-bottom: 1px solid var(--line); vertical-align: middle; }

tbody tr:hover { background: #1b1b26; }

tbody tr:last-child td { border-bottom: none; }

/* Eight columns of controls squeeze the selects until "Group 1" reads "Grou"; the wrapper scrolls, so let them breathe. */
.review-table select { min-width: 7rem; }

/* ── Chips and badges ───────────────────────────────────────────────────── */

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--bg-raised-2);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: .12rem .55rem;
    font-size: .8rem;
    white-space: nowrap;
}

.player-chip { font-weight: 600; }

.class-icon { width: 20px; height: 20px; border-radius: 5px; flex: 0 0 auto; }

.spec-icon {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    flex: 0 0 auto;
    border: 1px solid #000;
    box-shadow: 0 0 0 1px var(--line-strong);
}

.spec-icon.lg { width: 30px; height: 30px; border-radius: 7px; }
.class-icon.lg { width: 30px; height: 30px; border-radius: 8px; }
.role-icon { width: 16px; height: 16px; opacity: .9; flex: 0 0 auto; }

.marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: .8rem;
    line-height: 1;
    background: #0b0b10;
    border: 1px solid var(--line-strong);
}

.pill {
    display: inline-block;
    border-radius: 999px;
    padding: .05rem .5rem;
    font-size: .72rem;
    letter-spacing: .5px;
    text-transform: uppercase;
    border: 1px solid var(--line-strong);
    color: var(--text-dim);
}

.pill-tier { border-color: #5d4a1c; color: var(--gold); }

/* ── Alerts ─────────────────────────────────────────────────────────────── */

.alert { border-radius: var(--radius-sm); padding: .55rem .8rem; margin-bottom: .9rem; border: 1px solid; font-size: .9rem; }
.alert-error { background: #2b1414; border-color: #6b2f2f; color: #f0aeab; }
.alert-ok { background: #14241a; border-color: #2f6b3b; color: #a8dfb2; }
.alert-info { background: #141a24; border-color: #2f4a6b; color: #a8c6df; }
.alert-warn { background: #241f14; border-color: #6b562f; color: #dfcda8; }

/* ── Raid cards ─────────────────────────────────────────────────────────── */

.raid-card {
    display: block;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    transition: border-color .15s, transform .15s;
}

.raid-card:hover { border-color: var(--gold); text-decoration: none; transform: translateY(-2px); }

.raid-banner { width: 100%; aspect-ratio: 800 / 260; object-fit: cover; display: block; background: #0b0b10; }

.raid-card-body { padding: .75rem .9rem .9rem; }

.raid-card-body h3 { margin: 0 0 .25rem; }

/* ── Encounter sheet ────────────────────────────────────────────────────── */

.assignment-group { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; background: var(--bg-raised); }

.assignment-group > header {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .6rem .9rem;
    background: linear-gradient(180deg, #20202c, #1a1a24);
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
}

.assignment-group > header h3 { margin: 0; font-size: 1.02rem; }

.assignment-group .group-body { padding: .5rem .9rem .8rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }

.gallery figure { margin: 0; background: var(--bg-raised-2); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }

.gallery img { width: 100%; display: block; cursor: zoom-in; background: #0b0b10; }

.gallery figcaption { padding: .4rem .55rem; font-size: .8rem; color: var(--text-dim); }

.lightbox {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 85%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 2rem;
    cursor: zoom-out;
}

.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); box-shadow: var(--shadow); }

/* ── Composition board ──────────────────────────────────────────────────── */

.comp-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .8rem; }

.comp-group { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-raised); }

.comp-group header { padding: .35rem .6rem; border-bottom: 1px solid var(--line); font-size: .78rem; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); }

.comp-slot { display: flex; align-items: center; gap: .4rem; padding: .25rem .45rem; border-bottom: 1px solid #22222e; }

.comp-slot:last-child { border-bottom: none; }

.comp-slot select { font-size: .82rem; padding: .2rem .35rem; }

/* ── Import review ──────────────────────────────────────────────────────── */

.confidence-bar { display: inline-block; width: 48px; height: 6px; border-radius: 3px; background: #2a2a38; overflow: hidden; vertical-align: middle; }
.confidence-bar > span { display: block; height: 100%; }

.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line-strong); vertical-align: middle; }

.preview-shot { max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); }

.drop-zone {
    border: 2px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 1.4rem;
    text-align: center;
    color: var(--text-dim);
    background: #12121a;
}

.drop-zone:hover { border-color: var(--gold); }

/* ── Misc ───────────────────────────────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--line-strong);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: -2px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.stat-row { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.stat { min-width: 92px; }
.stat .value { font-family: var(--serif); font-size: 1.7rem; color: var(--gold-bright); line-height: 1.1; }
.stat .label { font-size: .72rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-faint); }

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

#blazor-error-ui {
    background: #2b1414;
    border-top: 1px solid #6b2f2f;
    color: #f0aeab;
    bottom: 0;
    display: none;
    left: 0;
    padding: .6rem 1.2rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

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

/* ── Print ──────────────────────────────────────────────────────────────── */

@media print {
    .sidebar, .no-print, .btn { display: none !important; }
    body, html { background: #fff; color: #111; }
    .card, .assignment-group { border-color: #bbb; background: #fff; break-inside: avoid; }
    .assignment-group > header { background: #eee; }
    h1, h2, h3 { color: #111; }
    a { color: #111; }
    td, th { border-color: #ccc; color: #111; }
    .content { padding: 0; }
}

@media (max-width: 860px) {
    .page { flex-direction: column; }
    .sidebar { width: 100%; flex: 0 0 auto; }
    .nav-list { display: flex; flex-wrap: wrap; padding: .3rem; }
    .nav-section { display: none; }
    .content { padding: 1rem; }
}
