/* ============================================================
   Character Sheets — Dark Fantasy Theme
   Matches Erisian Codex style
   ============================================================ */

/* --- Design Tokens --- */
:root {
    --surface-base: #1a1a1e;
    --surface-raised: #22222a;
    --surface-card: #29293a;
    --surface-overlay: #32324a;
    --surface-input: #1e1e28;

    --text-primary: #e8dcc8;
    --text-secondary: #c4b699;
    --text-muted: #8a7e6b;

    --accent-red: #922610;
    --accent-red-light: #c23a1a;
    --accent-gold: #c8a84e;
    --accent-gold-dim: #9a7e38;
    --accent-green: #5a7247;
    --accent-green-bright: #7aaa67;
    --accent-blue: #4a7a9b;
    --accent-blue-bright: #6aa3cc;
    --accent-purple: #7a5a9b;

    --border: #3d3454;
    --border-hover: #574a7a;

    --font-heading: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
    --font-body: 'Trebuchet MS', Verdana, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.6);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.7);

    --top-bar-height: 56px;
    --tab-bar-height: 48px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--surface-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
}

button {
    cursor: pointer;
    font-family: var(--font-body);
}

input, select, textarea {
    font-family: var(--font-body);
}

/* --- Top Bar --- */
.cs-top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--top-bar-height);
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0 var(--space-lg);
    box-shadow: var(--shadow-md);
}

.cs-back {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--accent-gold);
    text-decoration: none;
    font-size: 0.875rem;
    font-family: var(--font-body);
    flex-shrink: 0;
    transition: color 0.15s;
}

.cs-back:hover {
    color: var(--text-primary);
}

.cs-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.2;
    text-align: center;
}

.cs-title small {
    display: block;
    font-size: 0.7rem;
    font-family: var(--font-body);
    color: var(--text-muted);
    font-weight: normal;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.cs-nav-links {
    display: flex;
    gap: var(--space-md);
    flex-shrink: 0;
}

.cs-nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.cs-nav-link:hover {
    color: var(--accent-gold);
    background: var(--surface-overlay);
}

/* --- Tab Bar --- */
.cs-tab-bar {
    position: sticky;
    top: var(--top-bar-height);
    z-index: 90;
    height: var(--tab-bar-height);
    background: var(--surface-raised);
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: stretch;
    gap: 2px;
    padding: 0 var(--space-md);
    overflow-x: auto;
    scrollbar-width: none;
}

.cs-tab-bar::-webkit-scrollbar { display: none; }

.cs-tab {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0 var(--space-md);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    flex-shrink: 0;
    position: relative;
    top: 2px; /* align border-bottom with tab-bar bottom border */
}

.cs-tab:hover {
    color: var(--text-primary);
    background: var(--surface-overlay);
}

.cs-tab--active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}

.cs-tab .cs-tab__class {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 2px;
}

.cs-tab--add {
    margin-left: auto;
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold-dim);
    border-bottom: 3px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    margin-top: 6px;
    margin-bottom: 4px;
    padding: 0 var(--space-sm);
    font-size: 0.8rem;
    top: 0;
}

.cs-tab--add:hover {
    background: var(--accent-gold);
    color: var(--surface-base);
}

.cs-tab--add svg {
    flex-shrink: 0;
}

/* --- Main --- */
.cs-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    padding-bottom: var(--space-2xl);
}

/* --- Empty State --- */
.cs-empty {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
}

.cs-empty__icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

.cs-empty__text {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.cs-empty__sub {
    font-size: 0.875rem;
}

/* --- Sheet Header --- */
.cs-sheet__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.cs-sheet__name {
    font-size: 1.75rem;
    color: var(--accent-gold);
    line-height: 1.1;
    margin-bottom: var(--space-xs);
}

.cs-sheet__meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: var(--font-body);
}

.cs-sheet__header-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

/* --- Two Column Layout --- */
.cs-sheet__columns {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: var(--space-lg);
    align-items: start;
}

@media (max-width: 860px) {
    .cs-sheet__columns {
        grid-template-columns: 1fr;
    }
}

/* --- Panel --- */
.cs-panel {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.cs-panel__title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-gold);
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-body);
    font-weight: 600;
}

.cs-panel__note {
    font-size: 0.75rem;
    color: var(--accent-blue-bright);
    margin-top: var(--space-xs);
    font-style: italic;
}

/* --- Ability Scores --- */
.cs-ability-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

@media (max-width: 400px) {
    .cs-ability-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.cs-ability-box {
    background: var(--surface-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
    padding: var(--space-sm) var(--space-xs);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    position: relative;
    overflow: hidden;
}

.cs-ability-box::after {
    content: 'd20';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s;
    font-family: var(--font-mono);
}

.cs-ability-box:hover {
    border-color: var(--accent-gold);
    background: var(--surface-input);
    transform: translateY(-1px);
}

.cs-ability-box:hover::after {
    opacity: 1;
}

.cs-ability-box:active {
    transform: translateY(0);
}

.cs-ability__name {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}

.cs-ability__score {
    font-size: 1.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.cs-ability__mod {
    font-size: 0.875rem;
    color: var(--accent-gold);
    font-weight: 600;
}

/* --- Save List --- */
.cs-save-list,
.cs-skill-list {
    list-style: none;
}

.cs-save-item,
.cs-skill-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 3px var(--space-xs);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s;
    font-size: 0.875rem;
}

.cs-save-item:hover,
.cs-skill-item:hover {
    background: var(--surface-overlay);
}

.cs-proficiency-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    flex-shrink: 0;
    background: transparent;
}

.cs-proficiency-dot--proficient {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
}

.cs-proficiency-dot--expertise {
    background: var(--accent-blue-bright);
    border-color: var(--accent-blue-bright);
    box-shadow: 0 0 4px var(--accent-blue-bright);
}

.cs-save-item__mod,
.cs-skill-item__mod {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-gold);
    font-weight: 600;
    min-width: 32px;
    text-align: right;
}

.cs-save-item__name,
.cs-skill-item__name {
    flex: 1;
    color: var(--text-secondary);
}

.cs-skill-item__ability {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    width: 28px;
    text-align: right;
}

/* --- Senses --- */
.cs-senses-list {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs) var(--space-md);
}

.cs-senses-item {
    display: flex;
    flex-direction: column;
}

.cs-senses-item__value {
    font-size: 1.1rem;
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 600;
}

.cs-senses-item__label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* --- Combat --- */
.cs-panel--combat {
    border-color: var(--accent-gold-dim);
}

.cs-combat-row {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    flex-wrap: wrap;
}

/* AC Shield */
.cs-stat-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    width: 60px;
}

.cs-stat-bubble svg {
    color: var(--accent-gold-dim);
    width: 52px;
    height: 60px;
}

.cs-stat-bubble__value {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cs-stat-bubble__label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-top: 2px;
}

/* HP Block */
.cs-hp-block {
    flex: 1;
    min-width: 140px;
}

.cs-hp-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
    font-weight: 600;
}

.cs-hp-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.cs-hp-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-overlay);
    color: var(--text-primary);
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s;
}

.cs-hp-btn--minus:hover {
    background: var(--accent-red);
    border-color: var(--accent-red-light);
}

.cs-hp-btn--plus:hover {
    background: var(--accent-green);
    border-color: var(--accent-green-bright);
}

.cs-hp-display {
    flex: 1;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
}

.cs-hp-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    width: 3.5em;
    text-align: center;
    padding: 2px 4px;
    -moz-appearance: textfield;
}
.cs-hp-input::-webkit-inner-spin-button,
.cs-hp-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cs-hp-input:focus {
    border-color: var(--accent-gold);
    outline: none;
    background: var(--surface-input);
}
.cs-hp-input--max {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
    width: 3em;
}

.cs-hp-sep {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0 2px;
}

.cs-hp-bar-wrap {
    margin-top: var(--space-xs);
    height: 6px;
    background: var(--surface-input);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.cs-hp-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease, background-color 0.3s ease;
    background: var(--accent-green-bright);
}

.cs-hp-temp-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}

.cs-hp-temp-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.cs-hp-temp-input {
    width: 56px;
    background: var(--surface-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent-blue-bright);
    font-size: 0.875rem;
    padding: 2px var(--space-xs);
    text-align: center;
}

.cs-hp-temp-input:focus {
    outline: none;
    border-color: var(--accent-blue-bright);
}

/* Stat Group */
.cs-stat-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs) var(--space-md);
    flex-shrink: 0;
}

.cs-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cs-stat-item__value {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.cs-stat-item__label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    text-align: center;
}

/* Death Saves */
.cs-death-saves {
    margin-top: var(--space-md);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm) var(--space-lg);
}

.cs-death-saves__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    width: 100%;
}

.cs-death-saves__row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cs-death-saves__type {
    font-size: 0.75rem;
    min-width: 60px;
}

.cs-death-saves__type--success { color: var(--accent-green-bright); }
.cs-death-saves__type--fail { color: var(--accent-red-light); }

.cs-death-saves__circles {
    display: flex;
    gap: var(--space-xs);
}

.cs-ds-circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--accent-green);
    background: transparent;
    transition: background 0.15s, border-color 0.15s;
}

.cs-ds-circle:hover {
    border-color: var(--accent-green-bright);
}

.cs-ds-circle[aria-pressed="true"] {
    background: var(--accent-green-bright);
    border-color: var(--accent-green-bright);
}

.cs-ds-circle--fail {
    border-color: var(--accent-red);
}

.cs-ds-circle--fail:hover {
    border-color: var(--accent-red-light);
}

.cs-ds-circle--fail[aria-pressed="true"] {
    background: var(--accent-red-light);
    border-color: var(--accent-red-light);
}

/* --- Spellcasting --- */
.cs-spell-stats {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.cs-spell-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cs-spell-stat__value {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-blue-bright);
}

.cs-spell-stat__label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* --- Spell Slots --- */
.cs-spell-slots {
    width: 100%;
    margin-top: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.cs-spell-slot-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cs-spell-slot-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    min-width: 70px;
    flex-shrink: 0;
}

.cs-spell-slot-circles {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.cs-spell-slot-count {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
}

.cs-slot-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.cs-slot-circle:hover {
    border-color: var(--accent-blue-bright);
    box-shadow: 0 0 6px rgba(106, 163, 204, 0.4);
}

.cs-slot-circle--used {
    background: var(--accent-blue-bright);
    border-color: var(--accent-blue-bright);
}

.cs-slot-circle--used:hover {
    background: var(--accent-blue);
    box-shadow: 0 0 6px rgba(106, 163, 204, 0.4);
}

/* Resource color variants */
.cs-slot-circle--gold { border-color: var(--accent-gold-dim); }
.cs-slot-circle--gold:hover { border-color: var(--accent-gold); box-shadow: 0 0 6px rgba(200,168,78,0.4); }
.cs-slot-circle--gold.cs-slot-circle--used { background: var(--accent-gold); border-color: var(--accent-gold); }
.cs-slot-circle--gold.cs-slot-circle--used:hover { background: var(--accent-gold-dim); }

.cs-slot-circle--green { border-color: var(--accent-green); }
.cs-slot-circle--green:hover { border-color: var(--accent-green-bright); box-shadow: 0 0 6px rgba(122,170,103,0.4); }
.cs-slot-circle--green.cs-slot-circle--used { background: var(--accent-green-bright); border-color: var(--accent-green-bright); }
.cs-slot-circle--green.cs-slot-circle--used:hover { background: var(--accent-green); }

.cs-slot-circle--red { border-color: var(--accent-red); }
.cs-slot-circle--red:hover { border-color: var(--accent-red-light); box-shadow: 0 0 6px rgba(194,58,26,0.4); }
.cs-slot-circle--red.cs-slot-circle--used { background: var(--accent-red-light); border-color: var(--accent-red-light); }
.cs-slot-circle--red.cs-slot-circle--used:hover { background: var(--accent-red); }

.cs-slot-circle--purple { border-color: var(--accent-purple); }
.cs-slot-circle--purple:hover { border-color: #a07acc; box-shadow: 0 0 6px rgba(122,90,155,0.4); }
.cs-slot-circle--purple.cs-slot-circle--used { background: #a07acc; border-color: #a07acc; }
.cs-slot-circle--purple.cs-slot-circle--used:hover { background: var(--accent-purple); }

/* --- Attacks Table --- */
.cs-attacks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.cs-attacks-table th {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    font-family: var(--font-body);
    padding: 0 var(--space-sm) var(--space-xs);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.cs-attacks-table td {
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.cs-attacks-table tr:last-child td {
    border-bottom: none;
}

.cs-attack-hit,
.cs-attack-dmg {
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 2px var(--space-xs);
    transition: background 0.12s, color 0.12s;
    display: inline-block;
    font-family: var(--font-mono);
}

.cs-attack-hit {
    color: var(--accent-green-bright);
}

.cs-attack-dmg {
    color: var(--accent-red-light);
}

.cs-attack-hit:hover {
    background: var(--accent-green);
    color: var(--text-primary);
}

.cs-attack-dmg:hover {
    background: var(--accent-red);
    color: var(--text-primary);
}

.cs-attack-notes {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* --- Features --- */
.cs-features-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cs-feature-item {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid transparent;
    transition: border-color 0.12s;
}

.cs-feature-item:hover {
    border-color: var(--border);
}

.cs-feature-summary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: background 0.12s, color 0.12s;
}

.cs-feature-summary:hover {
    background: var(--surface-overlay);
    color: var(--text-primary);
}

.cs-feature-summary::-webkit-details-marker { display: none; }

.cs-feature-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.15s;
    font-size: 0.65rem;
}

details[open] .cs-feature-chevron {
    transform: rotate(90deg);
}

.cs-feature-name {
    flex: 1;
    font-weight: 500;
}

.cs-feature-body {
    padding: var(--space-xs) var(--space-sm) var(--space-sm) calc(var(--space-sm) + 16px);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.5;
}

/* --- Proficiencies --- */
.cs-profs-block {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.cs-prof-row {
    display: flex;
    gap: var(--space-sm);
    font-size: 0.8rem;
    align-items: baseline;
}

.cs-prof-row__label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-gold);
    font-weight: 600;
    min-width: 64px;
    flex-shrink: 0;
}

.cs-prof-row__value {
    color: var(--text-secondary);
    line-height: 1.4;
}

/* --- Equipment --- */
.cs-equip-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cs-equip-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 3px var(--space-xs);
    border-radius: var(--radius-sm);
    transition: background 0.12s;
}

.cs-equip-item:hover {
    background: var(--surface-overlay);
}

.cs-equip-qty {
    background: var(--surface-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent-gold);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    width: 40px;
    text-align: center;
    padding: 1px 4px;
    transition: border-color 0.12s;
}

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

.cs-equip-name {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.cs-equip-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
}

.cs-equip-item:hover .cs-equip-remove {
    opacity: 1;
}

.cs-equip-remove:hover {
    color: var(--accent-red-light);
}

/* Add item row */
.cs-equip-item--add {
    margin-top: var(--space-xs);
    border-top: 1px solid var(--border);
    padding-top: var(--space-xs);
}

.cs-equip-add-input {
    flex: 1;
    background: var(--surface-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    padding: 3px var(--space-sm);
    transition: border-color 0.12s;
}

.cs-equip-add-input::placeholder {
    color: var(--text-muted);
}

.cs-equip-add-input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.cs-equip-add-btn {
    background: none;
    border: 1px solid var(--accent-green);
    color: var(--accent-green-bright);
    font-size: 1rem;
    font-weight: 700;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    padding: 0;
    line-height: 1;
}

.cs-equip-add-btn:hover {
    background: var(--accent-green);
    color: var(--surface-base);
}

/* --- Buttons --- */
.cs-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
}

.cs-btn--primary {
    background: var(--accent-gold);
    color: var(--surface-base);
    border-color: var(--accent-gold);
}

.cs-btn--primary:hover {
    background: #e2c070;
    border-color: #e2c070;
}

.cs-btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.cs-btn--ghost:hover {
    color: var(--accent-gold);
    border-color: var(--accent-gold-dim);
    background: var(--surface-overlay);
}

.cs-btn--danger {
    background: transparent;
    color: var(--accent-red-light);
    border-color: var(--accent-red);
}

.cs-btn--danger:hover {
    background: var(--accent-red);
    color: var(--text-primary);
}

/* --- Modal --- */
.cs-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.cs-modal {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.cs-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.cs-modal__title {
    font-size: 1.1rem;
    color: var(--accent-gold);
}

.cs-modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    z-index: 10;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.cs-modal__close:hover {
    color: var(--text-primary);
    background: var(--surface-overlay);
}

.cs-modal__body {
    padding: var(--space-lg);
}

/* --- Form --- */
.cs-form-section {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-gold);
    font-family: var(--font-body);
    font-weight: 600;
    margin: var(--space-md) 0 var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border);
}

.cs-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.cs-form-ability-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.cs-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cs-form-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cs-form-group input {
    background: var(--surface-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.cs-form-group input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.cs-required {
    color: var(--accent-red-light);
}

.cs-form-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    margin-top: var(--space-lg);
}

/* --- Feature View Button --- */
.cs-feature-view {
    background: none;
    border: none;
    color: var(--accent-gold-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
    margin-left: auto;
    opacity: 0.5;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.cs-feature-view:hover {
    opacity: 1;
    color: var(--accent-gold);
}
.cs-feature-summary {
    display: flex;
    align-items: center;
}

/* --- Print Styles --- */
@media print {
    .cs-top-bar, .cs-tab-bar, .cs-sheet__header-actions,
    .cs-toast-container, .cs-detail-backdrop, .cs-modal-backdrop,
    .cs-feature-view { display: none !important; }
    body { background: white; color: #1a1a1e; }
    .cs-main { padding: 0; }
    .cs-sheet { padding: 1rem; }
    .cs-columns { gap: 1.5rem; }
    .cs-section { background: white; border: 1px solid #ccc; }
    .cs-section__title { color: #333; }
    .cs-ability-box { border-color: #999; }
    .cs-ability-box__score { color: #1a1a1e; }
    .cs-ability-box__mod { color: #333; }
    .cs-hp-bar { background: #eee; }
    .cs-hp-bar__fill { background: #5a7247; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* --- Detail Panel (5etools reference popover) --- */
.cs-detail-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 600;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}
.cs-detail-panel {
    width: 420px;
    max-width: 90vw;
    height: 100vh;
    background: var(--surface-raised);
    border-left: 2px solid var(--accent-gold-dim);
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.cs-detail-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.cs-detail-panel__title {
    font-family: var(--font-heading);
    font-variant: small-caps;
    font-size: 1.2rem;
    color: var(--accent-gold);
    margin: 0;
}
.cs-detail-panel__close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.cs-detail-panel__close:hover {
    color: var(--text-primary);
    background: var(--surface-overlay);
}
.cs-detail-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
}
.cs-detail-panel__body h2,
.cs-detail-panel__body h3 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-variant: small-caps;
}
.cs-detail-panel__body p {
    margin: 0 0 var(--space-sm);
}
.cs-detail-panel__body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}
.cs-detail-panel__body .fluff-image,
.cs-detail-panel__body figure {
    max-width: 100%;
    margin: 0 0 var(--space-md) 0;
}
.cs-detail-panel__body .spell-card,
.cs-detail-panel__body .monster-card,
.cs-detail-panel__body .condition-card,
.cs-detail-panel__body .rule-card,
.cs-detail-panel__body .item-card {
    border: none;
    background: none;
    padding: 0;
}
.cs-detail-panel__body a {
    color: var(--accent-gold);
    text-decoration: dotted underline;
    text-underline-offset: 2px;
}
.cs-detail-panel__body a:hover {
    color: var(--text-primary);
}
.cs-detail-panel__not-found {
    color: var(--text-muted);
    font-style: italic;
    padding: var(--space-lg);
}

/* --- Toast --- */
.cs-toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.cs-toast {
    background: var(--surface-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 240px;
    max-width: 360px;
    animation: cs-toast-in 0.2s ease;
    pointer-events: auto;
}

.cs-toast--out {
    animation: cs-toast-out 0.3s ease forwards;
}

.cs-toast__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.cs-toast__result {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-primary);
}

.cs-toast__nat20 {
    color: var(--accent-gold) !important;
    text-shadow: 0 0 8px rgba(200, 168, 78, 0.6);
}

.cs-toast__nat1 {
    color: var(--accent-red-light) !important;
}

.cs-toast__d20 {
    font-weight: 700;
    font-size: 1.2rem;
}

@keyframes cs-toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes cs-toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(20px); }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* --- Scrollbar styling --- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
