:root {
    --bg:            #0d0b14;
    --surface:       #13111d;
    --surface-2:     #1a1726;
    --surface-3:     #211e30;
    --border:        rgba(255,255,255,0.07);
    --border-mid:    rgba(255,255,255,0.13);

    --gold:          #c9a84c;
    --gold-light:    #e0bc6a;
    --gold-dim:      rgba(201,168,76,0.15);
    --gold-border:   rgba(201,168,76,0.35);

    --red:           #b83030;
    --red-light:     #e05040;
    --red-dim:       rgba(184,48,48,0.18);
    --red-border:    rgba(184,48,48,0.38);

    --green:         #259a54;
    --green-light:   #38c76d;
    --green-dim:     rgba(37,154,84,0.18);
    --green-border:  rgba(37,154,84,0.38);

    --blue:          #2e5a96;
    --blue-light:    #5a8fd4;
    --blue-dim:      rgba(46,90,150,0.18);
    --blue-border:   rgba(46,90,150,0.38);

    --purple:        #6a42a8;
    --purple-light:  #9468d8;
    --purple-dim:    rgba(106,66,168,0.2);
    --purple-border: rgba(106,66,168,0.4);

    --text:          #ddd8f0;
    --text-muted:    #6e688a;
    --text-dim:      #3c3858;

    --radius:        6px;
    --radius-sm:     4px;
}

/* ── Reset & Base ─────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ── Top Bar ────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    font-family: 'Cinzel', serif;
    font-size: 1.05em;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.topbar-divider {
    width: 1px;
    height: 22px;
    background: var(--border-mid);
    flex-shrink: 0;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82em;
    color: var(--text-muted);
}

.topbar-status strong { color: var(--gold-light); font-weight: 600; }

.topbar-badge {
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 0.78em;
    font-weight: 600;
    border: 1px solid;
    letter-spacing: 0.04em;
}
.topbar-badge.combat  { background: var(--red-dim);  color: var(--red-light);  border-color: var(--red-border); }
.topbar-badge.idle    { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }

/* ── Toolbar ────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 20px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar-group { display: flex; align-items: center; gap: 3px; }

.toolbar-sep {
    width: 1px;
    height: 24px;
    background: var(--border-mid);
    margin: 0 8px;
    flex-shrink: 0;
}

.toolbar-label {
    font-size: 0.68em;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    padding: 0 5px;
    font-weight: 600;
}

/* ── Toolbar Buttons ────────────────────── */
.tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.tb-btn:hover   { opacity: 0.82; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.tb-btn:active  { opacity: 1; box-shadow: none; }

.tb-btn.tb-gold    { background: var(--gold-dim);   color: var(--gold-light);  border-color: var(--gold-border); }
.tb-btn.tb-success { background: var(--green-dim);  color: var(--green-light); border-color: var(--green-border); }
.tb-btn.tb-danger  { background: var(--red-dim);    color: var(--red-light);   border-color: var(--red-border); }
.tb-btn.tb-primary { background: var(--blue-dim);   color: var(--blue-light);  border-color: var(--blue-border); }
.tb-btn.tb-muted   { background: transparent;       color: var(--text-muted);  border-color: var(--border); }
.tb-btn.tb-muted:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-mid); }

/* Legacy button classes used in modal */
button { cursor: pointer; transition: opacity 0.15s; }
.btn-primary { padding: 7px 14px; border-radius: var(--radius-sm); font-family: 'Inter', system-ui, sans-serif; font-size: 12px; font-weight: 500; border: 1px solid var(--blue-border);  background: var(--blue-dim);  color: var(--blue-light);  }
.btn-success  { padding: 7px 14px; border-radius: var(--radius-sm); font-family: 'Inter', system-ui, sans-serif; font-size: 12px; font-weight: 500; border: 1px solid var(--green-border); background: var(--green-dim); color: var(--green-light); }
.btn-danger   { padding: 7px 14px; border-radius: var(--radius-sm); font-family: 'Inter', system-ui, sans-serif; font-size: 12px; font-weight: 500; border: 1px solid var(--red-border);   background: var(--red-dim);   color: var(--red-light);   }
.btn-warning  { padding: 7px 14px; border-radius: var(--radius-sm); font-family: 'Inter', system-ui, sans-serif; font-size: 12px; font-weight: 500; border: 1px solid var(--gold-border);  background: var(--gold-dim);  color: var(--gold-light);  }
.btn-primary:hover, .btn-success:hover, .btn-danger:hover, .btn-warning:hover { opacity: 0.8; }

/* ── Main Content ───────────────────────── */
.main-content {
    padding: 14px 20px 30px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Combatant List ─────────────────────── */
.combatants-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ── Card ───────────────────────────────── */
.combatant-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid transparent;
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.combatant-card.player { border-left-color: var(--green); }
.combatant-card.enemy  { border-left-color: var(--red); }
.combatant-card.active {
    border-color: var(--gold-border);
    border-left-color: var(--gold);
    background: var(--surface-2);
    box-shadow: 0 0 0 1px var(--gold-dim), 0 4px 20px rgba(0,0,0,0.35);
}

/* ── Card Header Row ────────────────────── */
.c-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    flex-wrap: wrap;
}

.c-init {
    font-family: 'Cinzel', serif;
    font-size: 1.3em;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 30px;
    text-align: center;
    flex-shrink: 0;
}
.combatant-card.active .c-init { color: var(--gold); }

.c-name {
    font-family: 'Cinzel', serif;
    font-size: 0.98em;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.combatant-card.active .c-name { color: var(--gold-light); }

.clickable {
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 2px 5px;
}
.clickable:hover { background: rgba(255,255,255,0.05); }

/* ── HP Block ───────────────────────────── */
.c-hp-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 190px;
    flex: 2;
}

.c-hp-row {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.c-hp-cur  { font-size: 1.2em; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.c-hp-sep  { color: var(--text-dim); font-size: 0.9em; }
.c-hp-max  { font-size: 0.88em; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.c-hp-lbl  { font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); margin-left: 3px; }

.c-temp {
    font-size: 0.75em;
    padding: 1px 6px;
    background: rgba(90,190,255,0.1);
    color: #7dd4f8;
    border: 1px solid rgba(90,190,255,0.2);
    border-radius: 10px;
    margin-left: 4px;
}

/* ── HP Bar ─────────────────────────────── */
.hp-bar {
    width: 100%;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    overflow: hidden;
}
.hp-fill {
    height: 100%;
    transition: width 0.35s ease, background 0.35s ease;
    border-radius: 2px;
    background: var(--green);
}
.hp-fill.medium { background: #b87820; }
.hp-fill.low    { background: var(--red); }

/* ── HP Buttons ─────────────────────────── */
.c-hp-btns { display: flex; gap: 3px; }

.hpb {
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity 0.15s;
}
.hpb:hover { opacity: 0.78; }
.hpb-dmg  { background: var(--red-dim);    color: var(--red-light);   border-color: var(--red-border); }
.hpb-heal { background: var(--green-dim);  color: var(--green-light); border-color: var(--green-border); }
.hpb-set  { background: var(--surface-3);  color: var(--text-muted);  border-color: var(--border-mid); }

/* ── Stat Chips ─────────────────────────── */
.c-stats { display: flex; gap: 5px; flex-shrink: 0; }

.c-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    min-width: 42px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.c-stat:hover { border-color: var(--border-mid); }
.c-stat-lbl { font-size: 0.6em; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-dim); font-weight: 600; }
.c-stat-val { font-size: 1.07em; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.c-stat-val .unit { font-size: 0.6em; color: var(--text-dim); }

/* ── Card Action Buttons ────────────────── */
.c-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; flex-shrink: 0; }

.c-btn {
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    transition: opacity 0.15s, background 0.15s;
    white-space: nowrap;
}
.c-btn:hover      { background: var(--surface-3); color: var(--text); border-color: var(--border-mid); }
.c-btn-del        { color: var(--red-light); border-color: var(--red-border); }
.c-btn-del:hover  { background: var(--red-dim); }

/* ── Card Body ──────────────────────────── */
.c-body {
    border-top: 1px solid var(--border);
    padding: 8px 14px 10px;
    background: rgba(0,0,0,0.12);
}

.c-body-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.c-sec { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.c-sec-notes { flex: 1; min-width: 160px; }

.c-sec-lbl {
    font-size: 0.62em;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    font-weight: 600;
}

.c-empty { color: var(--text-dim); font-size: 0.85em; }

/* ── Conditions ─────────────────────────── */
.conditions { display: flex; flex-wrap: wrap; gap: 4px; }

.condition-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: var(--red-dim);
    border: 1px solid var(--red-border);
    color: #f0a0a0;
    font-size: 0.76em;
    font-weight: 500;
}
.condition-badge .duration {
    background: rgba(0,0,0,0.3);
    padding: 0 4px;
    border-radius: 8px;
    font-size: 0.85em;
}
.condition-badge button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    font-size: 0.9em;
    opacity: 0.6;
    line-height: 1;
}
.condition-badge button:hover { opacity: 1; }

/* ── Spell Slots ────────────────────────── */
.spell-slots  { display: flex; flex-wrap: wrap; gap: 5px; }

.spell-level {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    background: var(--purple-dim);
    border: 1px solid var(--purple-border);
    border-radius: var(--radius-sm);
}
.spell-lvl-label { font-size: 0.7em; color: var(--purple-light); font-weight: 600; white-space: nowrap; }
.spell-count     { font-size: 0.68em; color: var(--text-muted); }
.spell-dots      { display: flex; gap: 3px; }

.spell-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(106,66,168,0.3);
    cursor: pointer;
    transition: all 0.15s;
}
.spell-dot.used {
    background: var(--purple);
    border-color: var(--purple-light);
    box-shadow: 0 0 5px rgba(106,66,168,0.45);
}

/* ── Legendary Actions ──────────────────── */
.legendary-slots { display: flex; flex-direction: column; gap: 4px; }
.legendary-row   { display: flex; gap: 4px; flex-wrap: wrap; }

.legendary-dot {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--gold-border);
    cursor: pointer;
    transition: all 0.15s;
}
.legendary-dot:hover { border-color: var(--gold-light); }
.legendary-dot.la-avail {
    background: var(--gold);
    border-color: var(--gold-light);
    box-shadow: 0 0 5px rgba(201,168,76,0.45);
}

.legendary-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.la-count { font-size: 0.76em; color: var(--gold-light); font-weight: 600; }
.la-regen { font-size: 0.68em; color: var(--text-muted); }

/* ── Reaction ───────────────────────────── */
.c-btn-reaction-avail { color: var(--green-light) !important; border-color: var(--green-border) !important; }
.c-btn-reaction-avail:hover { background: var(--green-dim) !important; }
.c-btn-reaction-used  { color: var(--red-light) !important; border-color: var(--red-border) !important; }
.c-btn-reaction-used:hover  { background: var(--red-dim) !important; }

/* ── Notes ──────────────────────────────── */
.c-notes {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.84em;
    resize: none;
    min-height: 26px;
    padding: 2px 0;
    font-family: 'Inter', system-ui, sans-serif;
    font-style: italic;
}
.c-notes:focus { outline: none; border-bottom-color: var(--gold-border); color: var(--text); }

/* ── Modal ──────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal.active { display: flex; }

.modal-content {
    background: var(--surface-2);
    padding: 24px 28px;
    border-radius: var(--radius);
    max-width: 480px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-mid);
    border-top: 2px solid var(--gold);
    box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}

.modal-content h2 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 1.1em;
    letter-spacing: 0.07em;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ── Form ───────────────────────────────── */
.form-group { margin-bottom: 13px; }

label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.11em;
}

input, select {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-mid);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-family: 'Inter', system-ui, sans-serif;
    transition: border-color 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--gold-border); }
select option { background: var(--surface-2); }

.checkbox-group  { display: flex; gap: 14px; flex-wrap: wrap; }
.checkbox-item   { display: flex; align-items: center; gap: 6px; font-size: 0.88em; color: var(--text); }
.checkbox-item input[type="checkbox"] { width: auto; accent-color: var(--gold); }