/* ── Spellcasting Section ────────────────────────────────── */

.details-section {
    margin: 16px 0;
    padding: 16px;
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    border-left: 3px solid rgba(201,168,76,0.4);
}

.section-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #c9a84c;
    margin-bottom: 14px;
}

/* ── Recalc Button ───────────────────────────────────────── */

.btn-recalc {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.8rem;
    background: rgba(201,168,76,0.1);
    color: #c9a84c;
    border: 1px solid rgba(201,168,76,0.3);
    border-radius: 4px;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.2s;
}
.btn-recalc:hover { background: rgba(201,168,76,0.25); }

/* ── Custom spell badge ──────────────────────────────────── */
.spell-custom-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 2px 6px;
    background: rgba(142, 68, 173, 0.2);
    color: #9b59b6;
    border: 1px solid rgba(142, 68, 173, 0.4);
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Login ──────────────────────────────────────────────── */
#login-screen {
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}
.login-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.login-card h1 {
    font-size: 1.5rem;
    text-align: center;
    color: var(--clr-accent);
}
#login-form { display: flex; flex-direction: column; gap: 1rem; }

/* ── Seat selection ─────────────────────────────────────── */
#seat-screen {
    padding: 1.5rem;
    align-items: center;
    gap: 1.5rem;
}
.seat-header { text-align: center; }
.seat-header h2 { font-size: 1.4rem; }
.seat-hint { color: var(--clr-muted); font-size: .9rem; margin-top: .25rem; }

.seat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
    width: 100%;
    max-width: 360px;
}
.seat-btn {
    aspect-ratio: 1;
    background: var(--clr-surface);
    border: 2px solid var(--clr-border);
    border-radius: var(--radius);
    color: var(--clr-text);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.seat-btn:hover:not(:disabled) { border-color: var(--clr-accent); background: #1f2b4a; }
.seat-btn.mine { border-color: var(--clr-success); background: #1b3a1e; }
.seat-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Sheet header / tabs ────────────────────────────────── */
.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    font-weight: 600;
    font-size: 1.05rem;
}

.tab-nav {
    display: flex;
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-surface);
}
.tab-btn {
    flex: 1;
    padding: .7rem .5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--clr-muted);
    font-size: .9rem;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--clr-text); border-bottom-color: var(--clr-accent); }

.tab-panel { padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1rem; }
.tab-panel.hidden { display: none; }

/* ── Quick Stats tab ────────────────────────────────────── */
.stat-row.big {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}
.stat-label { font-size: .75rem; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .08em; }

.hp-editor {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.hp-btn {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.5rem;
    border-radius: 50%;
    border: 2px solid var(--clr-border);
    background: var(--clr-bg);
    color: var(--clr-text);
    cursor: pointer;
    line-height: 1;
    transition: border-color .15s;
}
.hp-btn:hover { border-color: var(--clr-accent); }
.hp-value { font-size: 2.5rem; font-weight: 700; min-width: 2.5rem; text-align: center; }
.hp-sep   { font-size: 1.5rem; color: var(--clr-muted); }
.hp-max   { font-size: 1.25rem; color: var(--clr-muted); }

.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}
.quick-stat {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: .75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; }
.gold-editor { display: flex; align-items: center; gap: .5rem; }
.gold-editor .hp-btn { width: 2rem; height: 2rem; font-size: 1.1rem; }
.gold-editor .stat-value { font-size: 1.4rem; }

/* ── Full Sheet tab ─────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .9rem;
}
.form-grid .full-width { grid-column: 1 / -1; }

/* ── Theme: current preview row ─────────────────────────── */
.theme-current-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.theme-thumb {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    border: 2px solid var(--clr-border);
    background-size: cover;
    background-position: center;
    background-color: var(--clr-surface);
    flex-shrink: 0;
}
.theme-thumb.empty { background-color: var(--clr-bg); }
.theme-name { font-size: .88rem; color: var(--clr-muted); }

/* ── Theme: picker modal ─────────────────────────────────── */
#theme-modal { align-items: center; padding: 1rem; }
.theme-modal-card {
    border-radius: var(--radius);
    max-width: 560px;
    max-height: 78dvh;
}
.theme-groups { display: flex; flex-direction: column; gap: 1.25rem; }
.theme-group-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--clr-muted);
    margin-bottom: .45rem;
}
.theme-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.theme-swatch-pick {
    width: 76px;
    height: 76px;
    border-radius: var(--radius);
    border: 3px solid var(--clr-border);
    background-size: cover;
    background-position: center;
    background-color: var(--clr-surface);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: border-color .15s, transform .1s;
}
.theme-swatch-pick:hover  { border-color: rgba(255,255,255,.4); transform: scale(1.06); }
.theme-swatch-pick.active { border-color: var(--clr-accent); }
.theme-swatch-badge {
    position: absolute;
    bottom: 3px;
    right: 4px;
    font-size: .65rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,.9);
    line-height: 1;
}

/* ── Notes tab ──────────────────────────────────────────── */
#notes-field {
    width: 100%;
    min-height: 60dvh;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    color: var(--clr-text);
    padding: .75rem;
    font-size: 1rem;
    resize: vertical;
    font-family: var(--font);
    line-height: 1.6;
}
#notes-field:focus { outline: none; border-color: var(--clr-accent); }

/* ── Avatar upload ──────────────────────────────────────── */
.avatar-upload-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--clr-border);
}
.avatar-wrap { flex-shrink: 0; }

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--clr-border);
    display: block;
}
.avatar-placeholder {
    background: var(--clr-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--clr-muted);
}

.avatar-actions {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.avatar-label { cursor: pointer; display: inline-block; text-align: center; }
.upload-status { font-size: .78rem; color: var(--clr-muted); }

/* ── Toast notifications ─────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(.5rem);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: .55rem 1.25rem;
    font-size: .875rem;
    z-index: 999;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    white-space: nowrap;
}
.toast.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.toast-success { border-color: var(--clr-success); color: var(--clr-success); }
.toast.toast-error   { border-color: var(--clr-danger);  color: var(--clr-danger); }

/* ── Seat grid (V2 style) ───────────────────────────────── */
.seat-option {
    background: var(--clr-surface);
    border: 2px solid var(--clr-border);
    border-radius: var(--radius);
    color: var(--clr-text);
    padding: .75rem .5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.seat-option:hover:not(.taken) { border-color: var(--clr-accent); background: #1f2b4a; }
.seat-option.mine    { border-color: var(--clr-success); background: #1b3a1e; }
.seat-option.taken   { opacity: .4; cursor: not-allowed; }
.seat-num    { font-size: 1.4rem; font-weight: 700; }
.seat-status { font-size: .7rem; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Tab nav — scrollable for 6 tabs ───────────────────── */
.tab-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn { flex: 0 0 auto; min-width: 56px; white-space: nowrap; font-size: .82rem; }

/* ── Death save pips ────────────────────────────────────── */
.death-pip-row { display: flex; gap: .3rem; justify-content: center; }
.death-pip {
    width: 1.1rem; height: 1.1rem;
    border-radius: 50%;
    border: 2px solid var(--clr-muted);
    background: transparent;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
    transition: background .1s, border-color .1s;
}
.death-pip.filled { background: var(--clr-accent); border-color: var(--clr-accent); }

/* ── Tab 2: Ability Scores ──────────────────────────────── */
.scores-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem 0;
}
.prof-display { font-size: .85rem; color: var(--clr-muted); }
.prof-val     { font-weight: 700; color: var(--clr-text); font-size: 1rem; margin-left: .35rem; }

.insp-toggle {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    cursor: pointer;
    color: var(--clr-muted);
}
.insp-toggle input { accent-color: var(--clr-accent); width: 1rem; height: 1rem; }

.scores-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .6rem;
}
.score-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: .65rem .4rem .5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
}
.score-abbr { font-size: .7rem; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .06em; }
.score-mod  { font-size: 1.55rem; font-weight: 700; min-width: 2.5rem; text-align: center; }
.score-input {
    width: 3rem; text-align: center;
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: 4px;
    color: var(--clr-text);
    font-size: .95rem; padding: .2rem;
}
.save-row {
    display: flex; align-items: center; gap: .25rem;
    cursor: pointer; font-size: .72rem; color: var(--clr-muted);
    margin-top: .1rem;
}
.save-check  { accent-color: var(--clr-accent); width: .85rem; height: .85rem; }
.save-mod    { font-weight: 600; color: var(--clr-text); }
.save-lbl    { color: var(--clr-muted); }

/* ── Tab 3: Skills ──────────────────────────────────────── */
.skills-list { display: flex; flex-direction: column; gap: .1rem; }

.skill-row {
    display: flex; align-items: center; gap: .55rem;
    padding: .55rem .6rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .1s;
}
.skill-row:hover { background: var(--clr-surface); }

.skill-dot {
    width: .7rem; height: .7rem; border-radius: 50%;
    border: 2px solid var(--clr-muted);
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
}
.skill-dot.proficient { background: var(--clr-accent); border-color: var(--clr-accent); }
.skill-dot.expertise  {
    background: var(--clr-accent);
    border: 3px solid var(--clr-text);
    box-shadow: 0 0 0 2px var(--clr-accent);
}

.skill-name { flex: 1; font-size: .9rem; }
.skill-abbr { font-size: .7rem; color: var(--clr-muted); width: 2rem; text-align: right; }
.skill-mod  { font-size: .9rem; font-weight: 600; width: 2rem; text-align: right; }

.btn-exp {
    font-size: .65rem; font-weight: 700;
    padding: .1rem .35rem;
    border-radius: 3px;
    border: 1px solid var(--clr-border);
    background: transparent; color: var(--clr-muted);
    cursor: pointer; transition: all .1s;
}
.btn-exp.active { border-color: var(--clr-accent); color: var(--clr-accent); background: #1a2f5a; }

/* ── Spell override toggle (Details tab) ────────────────── */
.spell-override-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-weight: 600;
}
.spell-override-row input[type="checkbox"] { width: 1.1rem; height: 1.1rem; cursor: pointer; }
.spell-override-label { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.spell-override-label input[type="checkbox"] { width: auto; flex-shrink: 0; }
.form-hint { font-size: .78rem; color: var(--clr-muted); margin: .25rem 0 0; line-height: 1.4; }

/* ── Non-caster message (Spells tab) ────────────────────── */
.no-spells-message {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--clr-muted);
    font-style: italic;
    line-height: 1.7;
}
.no-spells-message a { color: var(--clr-accent); cursor: pointer; text-decoration: underline; }

/* ── Tab 4: Spell slots ─────────────────────────────────── */
.slot-tracker { display: flex; flex-direction: column; gap: .45rem; }

.slot-tracker-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 .1rem .2rem;
}
.slot-tracker-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--clr-muted);
}
.btn-long-rest {
    padding: .25rem .75rem;
    font-size: .75rem;
    background: rgba(241,196,15,.12);
    color: #f1c40f;
    border: 1px solid rgba(241,196,15,.3);
    border-radius: 20px;
    cursor: pointer;
    transition: background .15s;
}
.btn-long-rest:hover { background: rgba(241,196,15,.22); }

.slot-row {
    display: flex; align-items: center; gap: .6rem;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: .5rem .75rem;
}
.slot-lbl   { font-size: .75rem; color: var(--clr-muted); min-width: 2.25rem; }
.slot-pips  { display: flex; gap: .3rem; flex: 1; flex-wrap: wrap; }
.slot-count { font-size: .75rem; color: var(--clr-muted); min-width: 2.5rem; text-align: right; }

.slot-pip {
    width: 1.25rem; height: 1.25rem;
    border-radius: 50%;
    border: 2px solid var(--clr-border);
    background: transparent;
    cursor: pointer; padding: 0;
    touch-action: manipulation;
    transition: all .1s;
}
.slot-pip.available { background: var(--clr-accent); border-color: var(--clr-accent); }
.slot-pip.used      { border-color: var(--clr-border); }
.slot-pip:hover     { transform: scale(1.15); }

/* ── Tab 4: Spell toolbar ───────────────────────────────── */
.spell-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .25rem 0;
}
.spell-filters { display: flex; gap: .3rem; flex-wrap: wrap; }

.filter-btn {
    padding: .3rem .7rem;
    border-radius: 999px;
    border: 1px solid var(--clr-border);
    background: transparent; color: var(--clr-muted);
    font-size: .78rem; cursor: pointer;
    transition: all .15s;
}
.filter-btn.active { background: var(--clr-accent); border-color: var(--clr-accent); color: #fff; }

/* ── Tab 4: Spell list cards ────────────────────────────── */
.spell-list { display: flex; flex-direction: column; gap: .4rem; }

.spell-group-hdr {
    font-size: .7rem; color: var(--clr-muted);
    text-transform: uppercase; letter-spacing: .08em;
    margin-top: .5rem;
    padding-bottom: .2rem;
    border-bottom: 1px solid var(--clr-border);
}

.spell-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-left: 3px solid var(--clr-border);
    border-radius: var(--radius);
    padding: .55rem .75rem;
    cursor: pointer;
    transition: border-color .1s;
}
.spell-card:hover        { border-left-color: var(--clr-accent); }
.spell-card.prepared     { border-left-color: #c9a84c; background: rgba(201,168,76,.05); }

.spell-row-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

.spell-prep-btn {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: none;
    background: transparent;
    font-size: .95rem;
    line-height: 1;
    cursor: pointer;
    color: rgba(201,168,76,.35);
    transition: color .15s, transform .15s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.spell-prep-btn.active   { color: #c9a84c; }
.spell-prep-btn:hover    { transform: scale(1.2); color: #c9a84c; }
.spell-name    { font-weight: 600; font-size: .95rem; }
.spell-badges  { display: flex; gap: .25rem; }
.badge-c, .badge-r {
    font-size: .62rem; font-weight: 700;
    padding: .05rem .3rem;
    border-radius: 3px;
}
.badge-c { background: #3a2070; color: #c9a8f0; }
.badge-r { background: #1e3a20; color: #7fb88a; }
.spell-meta  { font-size: .75rem; color: var(--clr-muted); margin-top: .15rem; }

/* ── Tab 4: Spell search panel ──────────────────────────── */
.spell-search-panel {
    position: fixed; inset: 0;
    background: var(--clr-bg);
    z-index: 100;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.spell-search-panel.hidden { display: none; }

.search-header {
    display: flex; gap: .5rem; align-items: center;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-surface);
}
.search-header input[type=search] {
    flex: 1;
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    color: var(--clr-text);
    padding: .45rem .75rem;
    font-size: 1rem;
}
.search-filters {
    display: flex; gap: .5rem;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-surface);
}
.search-filters select {
    flex: 1;
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    color: var(--clr-text);
    padding: .35rem .5rem;
    font-size: .85rem;
}
.spell-search-results {
    flex: 1; overflow-y: auto;
    padding: .75rem 1rem;
    display: flex; flex-direction: column; gap: .4rem;
}
.search-result {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .55rem .75rem;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
}
.search-result-info { display: flex; flex-direction: column; gap: .1rem; flex: 1; }
.btn-sm.added { opacity: .5; }

/* ── Tab 4: Spell modal ─────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 200;
    display: flex; align-items: flex-end; justify-content: center;
    padding: 0;
}
.modal-overlay.hidden { display: none; }

.modal-card {
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%; max-width: 520px;
    max-height: 85dvh;
    overflow-y: auto;
    padding: 1.25rem 1rem 2rem;
    position: relative;
}
.modal-close {
    position: absolute; top: .75rem; right: .75rem;
    background: none; border: none;
    color: var(--clr-muted); font-size: 1.5rem;
    cursor: pointer; line-height: 1; padding: .1rem .3rem;
}

.modal-hdr         { margin-bottom: .75rem; }
.modal-spell-name  { font-size: 1.3rem; font-weight: 700; }
.modal-spell-sub   { font-size: .85rem; color: var(--clr-muted); margin-top: .2rem; }

.spell-props { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; }
.prop-row    {
    display: flex; gap: .5rem;
    font-size: .875rem;
    border-bottom: 1px solid var(--clr-border);
    padding-bottom: .3rem;
}
.prop-row > span:first-child { color: var(--clr-muted); min-width: 7rem; flex-shrink: 0; }

.spell-desc-text {
    font-size: .875rem; line-height: 1.65;
    color: var(--clr-text);
    margin-bottom: .75rem;
}
.spell-upcast {
    font-size: .8rem; color: var(--clr-muted);
    border-top: 1px solid var(--clr-border);
    padding-top: .5rem; margin-bottom: .5rem;
}
.spell-classes { font-size: .75rem; color: var(--clr-muted); margin-bottom: .75rem; }

.modal-actions { display: flex; gap: .75rem; padding-top: .5rem; }
.btn-ghost.danger { color: var(--clr-danger); border-color: var(--clr-danger); }
.btn-ghost.danger:hover { background: rgba(220,50,50,.15); }

/* ── Tab 5: Gear ────────────────────────────────────────── */
.gear-section { display: flex; flex-direction: column; gap: .5rem; }
.gear-section-header {
    display: flex; align-items: center; justify-content: space-between;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--clr-border);
}
.gear-section-header h3 { font-size: 1rem; font-weight: 700; }

.weapon-row, .inventory-row {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .55rem .65rem;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
}
.weapon-info, .item-info { display: flex; flex-direction: column; gap: .1rem; flex: 1; }
.weapon-name, .item-name { font-weight: 600; font-size: .9rem; }
.weapon-stat, .item-meta { font-size: .75rem; color: var(--clr-muted); }

.main-weapon-badge {
    color: #c9a84c;
    margin-right: .25rem;
    font-size: .85rem;
}
.weapon-magic {
    color: #c9a84c;
    font-size: .8rem;
}

.weapon-check-field {
    display: flex;
    align-items: center;
    padding-top: .25rem;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    cursor: pointer;
    font-size: .85rem;
    color: var(--clr-text);
}
.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--clr-accent);
    cursor: pointer;
}

/* ── Weapon form field groups ───────────────────────────── */
.wf-group {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.wf-group label {
    font-size: .78rem;
    color: var(--clr-muted);
    font-weight: 500;
}
.wf-group input,
.wf-group select,
.wf-group textarea {
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    color: var(--clr-text);
    padding: .4rem .55rem;
    font-size: .875rem;
    width: 100%;
    box-sizing: border-box;
}
.wf-group input:focus,
.wf-group select:focus,
.wf-group textarea:focus { outline: none; border-color: var(--clr-accent); }
.wf-group textarea { resize: vertical; line-height: 1.5; }

/* ── Grip toggle ────────────────────────────────────────── */
.grip-toggle {
    display: flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--clr-border);
}
.grip-btn {
    flex: 1;
    padding: .45rem .5rem;
    font-size: .82rem;
    background: var(--clr-bg);
    color: var(--clr-muted);
    border: none;
    cursor: pointer;
    transition: all .15s;
}
.grip-btn.active {
    background: rgba(201,168,76,0.18);
    color: var(--clr-accent);
    font-weight: 600;
}

/* ── Range inputs ───────────────────────────────────────── */
.range-inputs {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.range-inputs input { width: 80px; }
.range-inputs span  { color: var(--clr-muted); font-size: 1rem; }

/* ── Form hint ──────────────────────────────────────────── */
.form-hint {
    display: block;
    font-size: .72rem;
    color: var(--clr-muted);
    font-style: italic;
}

.row-actions { display: flex; gap: .35rem; }
.btn-xs {
    font-size: .72rem; padding: .2rem .5rem;
    border-radius: 4px; cursor: pointer;
    border: 1px solid var(--clr-border);
    background: transparent; color: var(--clr-muted);
    transition: all .1s; white-space: nowrap;
}
.btn-xs.btn-ghost:hover { border-color: var(--clr-accent); color: var(--clr-accent); }
.btn-xs.danger { color: var(--clr-danger); }
.btn-xs.danger:hover { border-color: var(--clr-danger); background: rgba(220,50,50,.1); }

/* ── Tab 5: Inline forms ────────────────────────────────── */
.item-form {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: .9rem .8rem;
    display: flex; flex-direction: column; gap: .75rem;
}
.item-form.hidden { display: none; }

.form-actions { display: flex; gap: .5rem; }
.btn-sm {
    padding: .35rem .75rem; font-size: .82rem;
    border-radius: var(--radius); cursor: pointer;
    border: 1px solid var(--clr-border);
    background: transparent; color: var(--clr-muted);
    transition: all .1s;
}
.btn-sm.btn-primary { background: var(--clr-accent); border-color: var(--clr-accent); color: #fff; }
.btn-sm.btn-ghost   { border-color: var(--clr-border); }
.btn-sm.btn-ghost:hover { border-color: var(--clr-accent); color: var(--clr-accent); }

/* ── Tab 5: Currency ────────────────────────────────────── */
.currency-section { margin-top: .5rem; }
.currency-section h3 {
    font-size: .8rem; color: var(--clr-muted);
    text-transform: uppercase; letter-spacing: .06em;
    margin-bottom: .5rem;
}
.currency-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem;
}
.currency-cell { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.currency-cell label { font-size: .65rem; color: var(--clr-muted); text-transform: uppercase; }
.currency-cell input {
    width: 100%; text-align: center;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 4px; color: var(--clr-text);
    padding: .3rem; font-size: .85rem;
}

/* ── Tab 6: Details layout ──────────────────────────────── */
#tab-details {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 1.5rem));
}
#tab-details .field { display: flex; flex-direction: column; gap: .25rem; }
#tab-details .field label { font-size: .78rem; color: var(--clr-muted); }
#tab-details .field label .field-unit { font-size: .68rem; opacity: .65; font-style: italic; }

#tab-details .field input,
#tab-details .field select,
#tab-details .field textarea {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    color: var(--clr-text);
    padding: .45rem .6rem;
    font-size: .9rem;
    font-family: var(--font);
    width: 100%;
}
#tab-details .field input:focus,
#tab-details .field select:focus,
#tab-details .field textarea:focus { outline: none; border-color: var(--clr-accent); }

#tab-details .field textarea { resize: vertical; line-height: 1.55; }
#tab-details .form-grid { margin-bottom: .75rem; }

/* ── Condition selector (Quick Stats tab) ───────────────── */

.condition-section {
    margin-top: 1.25rem;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
}
.condition-header {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--clr-accent);
    margin-bottom: .6rem;
}
.condition-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .6rem;
}

.condition-option input[type="radio"],
.condition-invisible-toggle input[type="checkbox"] { display: none; }

.condition-pill {
    display: inline-block;
    padding: .35rem .9rem;
    border-radius: 20px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    background: rgba(255,255,255,0.07);
    color: var(--clr-muted);
    transition: background .15s, color .15s, border-color .15s;
    user-select: none;
}

.condition-option.condition-none      input:checked ~ .condition-pill { background: #444;    color: #fff;     border-color: #888; }
.condition-option.condition-poisoned  input:checked ~ .condition-pill { background: #1a6b3a; color: #2ecc71;  border-color: #2ecc71; }
.condition-option.condition-paralyzed input:checked ~ .condition-pill { background: #6b5a00; color: #f1c40f;  border-color: #f1c40f; }
.condition-option.condition-petrified input:checked ~ .condition-pill { background: #3d4344; color: #95a5a6;  border-color: #95a5a6; }
.condition-option.condition-stunned   input:checked ~ .condition-pill { background: #6b3a00; color: #e67e22;  border-color: #e67e22; }
.condition-option.condition-unconscious input:checked ~ .condition-pill { background: #4a1010; color: #e74c3c; border-color: #922b21; }
.condition-option.condition-charmed   input:checked ~ .condition-pill { background: #6b0040; color: #e91e8c;  border-color: #e91e8c; }
.condition-option.condition-frightened input:checked ~ .condition-pill { background: #3b1a5e; color: #8e44ad; border-color: #8e44ad; }
.condition-option.condition-burning   input:checked ~ .condition-pill { background: #6b1010; color: #e74c3c;  border-color: #e74c3c; }

.condition-invisible-toggle { display: inline-block; }
.invisible-pill { border: 2px dashed #888; color: #888; }
.condition-invisible-toggle input:checked ~ .invisible-pill {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-color: #fff;
    border-style: dashed;
}

/* ── Shared muted message ───────────────────────────────── */
.muted-msg { font-size: .85rem; color: var(--clr-muted); text-align: center; padding: .75rem 0; }

/* ── Toast (updated class name) ─────────────────────────── */
.toast.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Mobile UX polish ───────────────────────────────────── */
.hp-btn { touch-action: manipulation; }

/* ── Details tab: form-group (sections outside form-grid) ── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin-bottom: .75rem;
}
.form-group label {
    font-size: .78rem;
    color: var(--clr-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.form-group input,
.form-group select {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    color: var(--clr-text);
    padding: .45rem .6rem;
    font-size: .9rem;
    font-family: var(--font);
    width: 100%;
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--clr-accent); }
.form-group input[readonly] { opacity: 0.65; cursor: default; }

/* ── Form row (side-by-side layout inside sections) ───────── */

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.form-row .form-group {
    flex: 1;
    min-width: 110px;
    margin-bottom: 0;
}

/* ── Class Features Section (Quick Stats tab) ────────────── */

.class-features-section {
    margin-top: 1.25rem;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
}

.cf-header {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #c9a84c;
    margin-bottom: 14px;
}

.class-feature {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.class-feature:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.cf-label {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #aaa;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cf-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
}

.cf-hint {
    font-size: .75rem;
    color: #666;
    font-style: italic;
}

.cf-die-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(201,168,76,0.2);
    color: #c9a84c;
    border: 1px solid rgba(201,168,76,0.4);
    border-radius: 10px;
    font-size: .75rem;
    font-weight: bold;
}

/* ── Darkvision input ────────────────────────────────────── */

.darkvision-input {
    display: flex;
    align-items: center;
    gap: 8px;
}
.darkvision-input input { width: 80px; flex-shrink: 0; }

.input-unit {
    color: #aaa;
    font-size: .9rem;
}

/* ── Passive Skills recalc button ───────────────────────── */

.btn-recalc-sm {
    padding: 3px 10px;
    font-size: .75rem;
    background: rgba(201,168,76,0.1);
    color: #c9a84c;
    border: 1px solid rgba(201,168,76,0.3);
    border-radius: 4px;
    cursor: pointer;
    margin-left: 8px;
    vertical-align: middle;
}
.btn-recalc-sm:hover { background: rgba(201,168,76,0.25); }

/* ── Calc badge (read-only auto fields) ─────────────────── */

.calc-badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: .65rem;
    background: rgba(39,174,96,0.15);
    color: #27ae60;
    border: 1px solid rgba(39,174,96,0.3);
    border-radius: 8px;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ── Long rest button small variant ─────────────────────── */

.btn-long-rest.btn-sm {
    padding: 4px 12px;
    font-size: .8rem;
    margin-top: 8px;
}

@media (max-width: 390px) {
    .hp-btn    { width: 3rem; height: 3rem; }
    .tab-btn   { font-size: .75rem; padding: .65rem .35rem; }
    .stat-value { font-size: 1.4rem; }
    .scores-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Safe area padding for header */
.sheet-header { padding-bottom: max(.75rem, env(safe-area-inset-top, .75rem)); }

/* ── TV Card visibility selector ────────────────────────── */
.vis-option input[type="radio"] { display: none; }
.vis-pill {
    display: inline-block;
    padding: .35rem .9rem;
    border-radius: 20px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    background: rgba(255,255,255,0.07);
    color: var(--clr-muted);
    transition: background .15s, color .15s, border-color .15s;
    user-select: none;
}
.vis-option input:checked ~ .vis-pill { background: #444; color: #fff; border-color: #888; }
.vis-option input[value="hidden"]:checked ~ .vis-pill { background: #3a1a1a; color: #e74c3c; border-color: #922b21; }

/* ── Spell slot max configuration ───────────────────────── */
.slot-config-section { margin-bottom: .75rem; }
.slot-config-header-row {
    display: flex;
    align-items: center;
    margin-bottom: .4rem;
}
.slot-config-label {
    font-size: .7rem;
    font-weight: 700;
    color: var(--clr-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .4rem;
}
.slot-config-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .35rem .5rem;
}
.slot-config-cell {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.slot-config-lv {
    font-size: .75rem;
    color: var(--clr-muted);
    min-width: 2rem;
    white-space: nowrap;
    margin: 0;
    font-weight: normal;
}
.slot-max-input {
    width: 3rem;
    padding: .2rem .3rem;
    font-size: .85rem;
    text-align: center;
    background: rgba(255,255,255,.08);
    color: var(--clr-text);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
}

/* ── Companions Tab ───────────────────────────────────────── */

.companion-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.companion-card:hover {
    background: rgba(201,168,76,0.08);
    border-color: rgba(201,168,76,0.2);
}

.companion-card-avatar {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.companion-card-avatar img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(201,168,76,0.4);
}

.companion-card-info {
    flex: 1;
    overflow: hidden;
}

.companion-card-name {
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 2px;
}

.companion-card-species {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.companion-type-badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.65rem;
    background: rgba(201,168,76,0.15);
    color: #c9a84c;
    border: 1px solid rgba(201,168,76,0.3);
    border-radius: 8px;
}

.companion-card-stats {
    font-size: 0.75rem;
    color: #888;
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
}

.companion-hp-bar {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.companion-hp-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.companion-hp-fill.hp-high   { background: #27ae60; }
.companion-hp-fill.hp-medium { background: #f39c12; }
.companion-hp-fill.hp-low    { background: #c0392b; }

.companion-card-arrow {
    font-size: 1.4rem;
    color: #555;
    flex-shrink: 0;
}

.btn-add-companion {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    background: transparent;
    color: #c9a84c;
    border: 2px dashed rgba(201,168,76,0.4);
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-companion:hover {
    background: rgba(201,168,76,0.08);
    border-color: rgba(201,168,76,0.7);
}

.no-companions {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

.no-companions-hint {
    font-size: 0.85rem;
    font-style: italic;
    margin-top: 6px;
}

.companion-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 16px;
}

.btn-back {
    background: transparent;
    color: #c9a84c;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 4px 0;
}

#companion-detail-title {
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
}

.btn-retire-companion {
    background: transparent;
    color: #e74c3c;
    border: 1px solid rgba(231,76,60,0.3);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
}

.companion-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.companion-avatar-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(201,168,76,0.5);
    background: #333;
}

.btn-upload-avatar {
    display: inline-block;
    padding: 6px 16px;
    font-size: 0.85rem;
    background: rgba(201,168,76,0.1);
    color: #c9a84c;
    border: 1px solid rgba(201,168,76,0.3);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-upload-avatar:hover {
    background: rgba(201,168,76,0.2);
}

.companion-form-section {
    margin-bottom: 20px;
    padding: 14px;
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
}

.companion-form-section textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    color: var(--clr-text);
    border-radius: 4px;
    padding: 8px;
    resize: vertical;
    line-height: 1.5;
}

.companion-form-section textarea:focus {
    outline: none;
    border-color: var(--clr-accent);
}

.companion-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.companion-stat-cell label {
    display: block;
    font-size: 0.75rem;
    color: #aaa;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hp-display {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hp-display input {
    width: 60px;
}

.hp-display span {
    color: #666;
}

.ability-scores-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.ability-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ability-cell label {
    font-size: 0.7rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ability-cell input {
    width: 60px;
    text-align: center;
}

.ability-mod {
    font-size: 0.9rem;
    color: #c9a84c;
    font-weight: bold;
}

.companion-save-bar {
    position: sticky;
    bottom: 0;
    padding: 12px 0;
    background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.9) 30%);
}

.btn-save-companion {
    width: 100%;
    padding: 14px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save-companion:hover    { background: #2ecc71; }
.btn-save-companion:disabled { background: #555; cursor: wait; }
