/* ================================================================
   VEILBORN — SHARED COMPONENT LIBRARY
   Reusable patterns across multiple views.
   All values reference tokens.css custom properties.
   ================================================================ */


/* ================================================================
   0. KEYFRAMES
   ================================================================ */

@keyframes comp-spin {
    to { transform: rotate(360deg); }
}

@keyframes comp-toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes comp-toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

@keyframes comp-modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes comp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}


/* ================================================================
   1. BUTTONS
   ================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-4);
    font-family: var(--f-display);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid var(--c-gold-lo);
    border-radius: var(--r-sm);
    background: var(--c-shadow);
    color: var(--c-gold);
    transition: transform 0.15s var(--ease-out),
                box-shadow 0.15s var(--ease-out),
                opacity 0.15s var(--ease-out);
}

.btn i {
    font-size: 1em;
    line-height: 1;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .btn:hover:not(:disabled) {
        transform: scale(1.02);
        box-shadow: var(--sh-glow-gold);
    }
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

/* --- Primary: gold gradient, dark text --- */
.btn-primary {
    background: linear-gradient(180deg, rgba(212,160,48,.22) 0%, rgba(138,100,32,.18) 100%);
    border: 1px solid rgba(212,160,48,.45);
    color: var(--c-gold-hi);
}

@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover:not(:disabled) {
        background: linear-gradient(180deg, rgba(212,160,48,.32) 0%, rgba(138,100,32,.26) 100%);
        border-color: var(--c-gold);
        color: #fff;
    }
}

.btn-primary:active:not(:disabled) {
    background: linear-gradient(180deg, rgba(138,100,32,.15) 0%, rgba(212,160,48,.12) 100%);
}

/* --- Ghost: transparent with subtle border --- */
.btn-ghost {
    background: rgba(200,162,200,.04);
    border: 1px solid rgba(200,162,200,.18);
    color: var(--c-text-sub);
}

@media (hover: hover) and (pointer: fine) {
    .btn-ghost:hover:not(:disabled) {
        background: rgba(200,162,200,.10);
        border-color: rgba(200,162,200,.35);
        color: var(--c-gold);
    }
}

.btn-ghost:active:not(:disabled) {
    background: rgba(200,162,200,.06);
}

/* --- Danger: red/error colored --- */
.btn-danger {
    background: linear-gradient(180deg, rgba(224,64,64,.16) 0%, rgba(128,32,32,.12) 100%);
    border: 1px solid rgba(224,64,64,.35);
    color: var(--c-error);
}

@media (hover: hover) and (pointer: fine) {
    .btn-danger:hover:not(:disabled) {
        background: linear-gradient(180deg, rgba(224,64,64,.24) 0%, rgba(128,32,32,.20) 100%);
        border-color: rgba(224,64,64,.60);
        color: #ff9090;
    }
}

.btn-danger:active:not(:disabled) {
    background: linear-gradient(180deg, rgba(128,32,32,.10) 0%, rgba(224,64,64,.08) 100%);
}

/* --- Size: small --- */
.btn-sm {
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-xs);
    gap: var(--sp-1);
}


/* ================================================================
   1A. SECTION CARDS
   ================================================================ */

.char-section {
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--r-lg);
    position: relative;
    box-shadow: var(--sh-md);
    transition:
        border-color .2s var(--ease-out),
        box-shadow .2s var(--ease-out);
}

.char-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    font-family: var(--f-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-text-sub);
    border-bottom: var(--b-subtle);
}

.char-section-heading {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
}

.char-section-header::after {
    content: '';
    flex: 1 1 auto;
    min-width: var(--sp-4);
    height: 1px;
    background: linear-gradient(90deg, rgba(212, 160, 48, .22), rgba(200, 162, 200, 0));
}

.char-section-header i {
    color: var(--c-gold);
    font-size: var(--fs-xl);
}

.char-section-body {
    padding: var(--sp-4) var(--sp-5);
}


/* ================================================================
   2. FORM CONTROLS
   ================================================================ */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.form-group label {
    font-family: var(--f-display);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-text-sub);
}

.form-group input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    background: var(--c-shadow);
    border: var(--b-default);
    border-radius: var(--r-md);
    color: var(--c-text);
    font-family: var(--f-body);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    outline: none;
    transition: border-color 0.15s var(--ease-out),
                box-shadow 0.15s var(--ease-out);
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus {
    border-color: rgba(212,160,48,.50);
    box-shadow: 0 0 0 1px rgba(212,160,48,.18), inset 0 0 8px rgba(0,0,0,.35);
}

.form-group input:not([type="checkbox"]):not([type="radio"])::placeholder {
    color: var(--c-text-dim);
    opacity: 0.8;
}

.form-group small {
    font-size: var(--fs-2xs);
    color: var(--c-text-muted);
    line-height: var(--lh-base);
}

/* Direct input class (used in system.js and admin UI) */
.form-control {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    background: var(--c-shadow);
    border: var(--b-default);
    border-radius: var(--r-md);
    color: var(--c-text);
    font-family: var(--f-body);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    outline: none;
    transition: border-color 0.15s var(--ease-out),
                box-shadow 0.15s var(--ease-out);
}

.form-control:focus {
    border-color: rgba(212,160,48,.50);
    box-shadow: 0 0 0 1px rgba(212,160,48,.18), inset 0 0 8px rgba(0,0,0,.35);
}

.form-control::placeholder {
    color: var(--c-text-dim);
    opacity: 0.8;
}

textarea.form-control {
    resize: vertical;
    min-height: 72px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23c8a2c8' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-3) center;
    padding-right: var(--sp-6);
}

select.form-control option {
    background: var(--c-abyss);
    color: var(--c-text);
}

input[type="checkbox"]:not(.admin-checkbox-input):not(.admin-chip-option-input) {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    display: inline-block;
    vertical-align: middle;
    flex: 0 0 18px;
    border-radius: 6px;
    border: 1px solid rgba(200,162,200,.24);
    background: linear-gradient(180deg, rgba(8,8,14,.92), rgba(20,14,28,.96));
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px 10px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.04),
        inset 0 0 0 1px rgba(0,0,0,.18);
    cursor: pointer;
    transition:
        border-color .16s var(--ease-out),
        background-color .16s var(--ease-out),
        box-shadow .16s var(--ease-out),
        transform .1s var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    input[type="checkbox"]:not(.admin-checkbox-input):not(.admin-chip-option-input):hover:not(:disabled) {
        border-color: rgba(212,160,48,.34);
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.05),
            0 0 0 1px rgba(212,160,48,.08),
            0 0 10px rgba(212,160,48,.10);
    }
}

input[type="checkbox"]:not(.admin-checkbox-input):not(.admin-chip-option-input):checked {
    border-color: rgba(212,160,48,.58);
    background-color: rgba(212,160,48,.18);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.2 4.7 9 10 3.5' fill='none' stroke='%23f0d060' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.06),
        0 0 0 1px rgba(212,160,48,.10),
        0 0 12px rgba(212,160,48,.12);
}

input[type="checkbox"]:not(.admin-checkbox-input):not(.admin-chip-option-input):focus-visible {
    outline: none;
    box-shadow:
        0 0 0 1px rgba(212,160,48,.24),
        0 0 0 3px rgba(212,160,48,.12),
        inset 0 1px 0 rgba(255,255,255,.06);
}

input[type="checkbox"]:not(.admin-checkbox-input):not(.admin-chip-option-input):active:not(:disabled) {
    transform: scale(.96);
}

input[type="checkbox"]:not(.admin-checkbox-input):not(.admin-chip-option-input):disabled {
    opacity: .45;
    cursor: not-allowed;
}


/* ================================================================
   3. GLASS CARDS
   ================================================================ */

.panel-card {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
    padding: var(--sp-4);
    color: var(--c-text);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.panel-head h3 {
    font-family: var(--f-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    color: var(--c-gold);
    margin: 0;
}


/* ================================================================
   4. RESOURCE BARS
   ================================================================ */

/* Generic bar track + fill (combat UI) */
.bar-track {
    flex: 1;
    height: 18px;
    background: rgba(0,0,0,.50);
    border-radius: var(--r-pill);
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.40);
    box-shadow: inset 0 2px 4px rgba(0,0,0,.40);
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: var(--r-pill);
    transition: width 0.45s var(--ease-out);
    position: relative;
}

.bar-fill.hp {
    background: linear-gradient(90deg, #7a0e0e, var(--c-hp));
    box-shadow: 0 0 8px rgba(224,64,64,.20);
}

.bar-fill.mp {
    background: linear-gradient(90deg, #0e2070, var(--c-mp));
    box-shadow: 0 0 8px rgba(48,128,224,.20);
}

.bar-fill.sp {
    background: linear-gradient(90deg, #185018, var(--c-sp));
    box-shadow: 0 0 8px rgba(64,184,64,.20);
}

.bar-fill.xp {
    background: linear-gradient(90deg, #8a6420, var(--c-xp));
    box-shadow: 0 0 8px rgba(232,200,64,.15);
}

/* HUD resource bars (main.php bottom bar) */
.hud-resource-bar {
    height: 6px;
    background: rgba(0,0,0,.50);
    border-radius: var(--r-pill);
    overflow: hidden;
}

.hud-resource-fill {
    height: 100%;
    border-radius: var(--r-pill);
    transition: width 0.4s var(--ease-out);
}

.hp-fill {
    background: linear-gradient(90deg, var(--c-hp-dark), var(--c-hp));
}

.mp-fill {
    background: linear-gradient(90deg, var(--c-mp-dark), var(--c-mp));
}


/* ================================================================
   5. BADGES & PILLS
   ================================================================ */

/* --- Quest type badges (quest.js) --- */
.quest-type-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px 8px;
    border-radius: var(--r-sm);
    font-family: var(--f-display);
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.4;
}

.quest-type-main {
    background: rgba(212,160,48,.14);
    color: var(--c-gold);
    border: 1px solid rgba(212,160,48,.28);
}

.quest-type-side {
    background: rgba(200,162,200,.10);
    color: var(--c-veil);
    border: 1px solid rgba(200,162,200,.25);
}

.quest-type-daily {
    background: rgba(64,184,64,.10);
    color: var(--c-success);
    border: 1px solid rgba(64,184,64,.22);
}

.quest-type-exploration {
    background: rgba(48,128,224,.10);
    color: var(--c-info);
    border: 1px solid rgba(48,128,224,.22);
}

.quest-type-lore {
    background: rgba(176,64,232,.10);
    color: var(--c-epic);
    border: 1px solid rgba(176,64,232,.22);
}

/* --- Status badges (combat.js) --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px 8px;
    border-radius: var(--r-sm);
    font-size: var(--fs-2xs);
    white-space: nowrap;
    border: 1px solid rgba(200,162,200,.18);
    color: var(--c-text-sub);
}

.status-badge strong {
    font-weight: 700;
}

.status-badge em {
    color: var(--c-text-muted);
    font-style: normal;
    font-size: var(--fs-2xs);
}

.status-badge.buff {
    border-color: rgba(64,184,64,.35);
    color: var(--c-success);
}

.status-badge.debuff {
    border-color: rgba(224,64,64,.35);
    color: var(--c-hp);
}

.status-badge.neutral {
    border-color: rgba(48,128,224,.30);
    color: var(--c-info);
}

/* --- System badges (system.js) --- */
.system-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px 8px;
    border-radius: var(--r-sm);
    font-family: var(--f-display);
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.4;
    background: rgba(200,162,200,.06);
    border: 1px solid rgba(200,162,200,.18);
    color: var(--c-text-sub);
}

.system-badge-new {
    background: rgba(212,160,48,.14);
    border-color: rgba(212,160,48,.30);
    color: var(--c-gold);
}

.system-badge-active {
    background: rgba(64,184,64,.10);
    border-color: rgba(64,184,64,.22);
    color: var(--c-success);
}

/* --- Bestiary pills (bestiary.js) --- */
.bestiary-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-family: var(--f-display);
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.4;
    background: rgba(200,162,200,.06);
    border: 1px solid rgba(200,162,200,.18);
    color: var(--c-text-sub);
}

.bestiary-pill.is-unlocked {
    background: rgba(64,184,64,.10);
    border-color: rgba(64,184,64,.22);
    color: var(--c-success);
}

.bestiary-pill.is-locked {
    background: rgba(224,64,64,.10);
    border-color: rgba(224,64,64,.22);
    color: var(--c-error);
}


/* ================================================================
   6. RARITY COLORS
   ================================================================ */

.rarity-common    { color: var(--c-common); }
.rarity-rare      { color: var(--c-rare); }
.rarity-epic      { color: var(--c-epic); }
.rarity-legendary { color: var(--c-legendary); }
.rarity-ancient   { color: var(--c-ancient); }


/* ================================================================
   7. LOADING STATES
   ================================================================ */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--c-dusk);
    border-top-color: var(--c-gold);
    border-radius: 50%;
    margin: var(--sp-7) auto;
    animation: comp-spin 0.7s linear infinite;
}


/* ================================================================
   8. TOAST NOTIFICATIONS
   ================================================================ */

#toast-container {
    position: fixed;
    bottom: var(--sp-4);
    right: var(--sp-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    width: 340px;
    max-width: calc(100vw - var(--sp-6));
    pointer-events: none;
}

.toast {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(212,160,48,.30);
    border-left: 3px solid var(--c-gold);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
    color: var(--c-text);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    animation: comp-toast-in 0.25s var(--ease-out);
    pointer-events: auto;
}

.toast.is-leaving {
    animation: comp-toast-out 0.2s var(--ease-out) forwards;
}

.toast-main {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    min-width: 0;
    flex: 1;
}

.toast-icon {
    width: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-base);
    color: var(--c-gold-hi);
    margin-top: 1px;
    flex-shrink: 0;
}

.toast-text {
    flex: 1;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-close {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    border: 1px solid rgba(200,162,200,.18);
    background: transparent;
    color: var(--c-text-sub);
    cursor: pointer;
    transition: color 0.15s var(--ease-out),
                border-color 0.15s var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .toast-close:hover {
        border-color: rgba(212,160,48,.50);
        color: var(--c-gold);
    }
}

.toast-close i {
    font-size: var(--fs-sm);
    line-height: 1;
}

/* Toast variants */
.toast-success {
    border-color: rgba(64,184,64,.30);
    border-left-color: var(--c-success);
    color: #70e070;
}

.toast-success .toast-icon { color: #89e69f; }

.toast-error {
    border-color: rgba(224,64,64,.35);
    border-left-color: var(--c-error);
    color: #e07070;
}

.toast-error .toast-icon { color: #ef8a8a; }

.toast-warning {
    border-color: rgba(232,160,48,.35);
    border-left-color: var(--c-warning);
    color: #f0ca7d;
}

.toast-warning .toast-icon { color: #f0d89a; }

.toast-info {
    border-color: rgba(48,128,224,.30);
    border-left-color: var(--c-info);
    color: #80b0e8;
}

.toast-info .toast-icon { color: #80b0e8; }


/* ================================================================
   9. MODAL BASE
   ================================================================ */

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    z-index: var(--z-modal);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8,8,14,.88);
    z-index: var(--z-modal);
    animation: comp-fade-in 0.2s var(--ease-out);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - var(--sp-7));
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--b-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xl), var(--sh-glow-veil);
    z-index: calc(var(--z-modal) + 1);
    overflow: hidden;
    animation: comp-modal-in 0.25s var(--ease-spring);
}

.modal-header {
    padding: var(--sp-4);
    border-bottom: var(--b-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.modal-header h2,
.modal-header h3,
.modal-title {
    font-family: var(--f-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    color: var(--c-gold-hi);
    margin: 0;
}

.modal-body {
    padding: var(--sp-4);
    overflow-y: auto;
    flex: 1;
    color: var(--c-text);
    line-height: var(--lh-relaxed);
    scrollbar-width: thin;
    scrollbar-color: var(--c-fog) var(--c-void);
}

.modal-body::-webkit-scrollbar       { width: 5px; }
.modal-body::-webkit-scrollbar-track  { background: var(--c-void); }
.modal-body::-webkit-scrollbar-thumb  { background: var(--c-fog); border-radius: var(--r-xs); }

.modal-footer {
    padding: var(--sp-3) var(--sp-4);
    border-top: var(--b-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(200,162,200,.15);
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--c-text-sub);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s var(--ease-out),
                border-color 0.15s var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .modal-close:hover {
        color: var(--c-gold);
        border-color: rgba(212,160,48,.40);
    }
}

.modal-close i {
    font-size: var(--fs-base);
    line-height: 1;
}

/* System modal overlay (app.js level-up / combat resume) */
.system-modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    background: rgba(8,8,14,.88);
    z-index: var(--z-modal);
}

#global-level-up-modal {
    z-index: 11000;
}

.system-modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--b-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xl), var(--sh-glow-veil);
    overflow: hidden;
    animation: comp-modal-in 0.25s var(--ease-spring);
}

.system-modal-title {
    font-family: var(--f-display);
    color: var(--c-gold-hi);
}

.system-modal-text {
    color: var(--c-text-sub);
    line-height: var(--lh-base);
}


/* ================================================================
   10. ITEM ICONS
   ================================================================ */

/* Primary wrapper — renderItemIcon() output */
.item-icon-wrap,
.vb-item-icon,
.item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

/* Image inside the icon wrapper */
.item-icon-img,
.vb-item-icon-image,
.item-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
}

/* Fallback: Phosphor icon when no image */
.vb-item-icon--fallback {
    color: var(--c-gold);
}

.vb-item-icon--fallback i {
    font-size: inherit;
    line-height: 1;
}

/* Rarity border colors on item icons */
.item-icon.rarity-common,
.vb-item-icon.rarity-common  { border-color: var(--c-common); }
.item-icon.rarity-rare,
.vb-item-icon.rarity-rare    { border-color: var(--c-rare); }
.item-icon.rarity-epic,
.vb-item-icon.rarity-epic    { border-color: var(--c-epic); }
.item-icon.rarity-legendary,
.vb-item-icon.rarity-legendary { border-color: var(--c-legendary); }
.item-icon.rarity-ancient,
.vb-item-icon.rarity-ancient { border-color: var(--c-ancient); }


/* ================================================================
   11. BACKWARD-COMPAT PATTERNS
   Selectors used across admin and game views that must remain
   defined until migrated to view-specific CSS.
   ================================================================ */

/* --- Cards & panels (admin views, character, map) --- */
.card {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--b-default);
    border-radius: var(--r-md);
    box-shadow: var(--sh-md);
    color: var(--c-text);
    overflow: hidden;
}

.card-header {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: var(--b-subtle);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--f-display);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-gold);
}

.card-header i { font-size: var(--fs-base); color: var(--c-gold); }
.card-body { padding: var(--sp-4); }

.card-footer {
    padding: var(--sp-3) var(--sp-4);
    border-top: var(--b-subtle);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.panel,
.ui-card {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--b-default);
    border-radius: var(--r-md);
    box-shadow: var(--sh-md);
    color: var(--c-text);
    overflow: hidden;
}

.panel-header,
.ui-card-header {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: var(--b-subtle);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.panel-body,
.ui-card-body { padding: var(--sp-4); }

.panel-title,
.ui-card-title {
    font-family: var(--f-display);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-gold);
}

/* --- Badge base (admin, character, quests) --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px 8px;
    border-radius: var(--r-sm);
    font-family: var(--f-display);
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.4;
    vertical-align: middle;
}

.badge-primary {
    background: rgba(212,160,48,.14);
    color: var(--c-gold);
    border: 1px solid rgba(212,160,48,.28);
}

.badge-success {
    background: rgba(64,184,64,.10);
    color: var(--c-success);
    border: 1px solid rgba(64,184,64,.22);
}

.badge-warning {
    background: rgba(232,160,48,.10);
    color: var(--c-warning);
    border: 1px solid rgba(232,160,48,.22);
}

.badge-danger {
    background: rgba(224,64,64,.10);
    color: var(--c-error);
    border: 1px solid rgba(224,64,64,.22);
}

.badge-info {
    background: rgba(48,128,224,.10);
    color: var(--c-info);
    border: 1px solid rgba(48,128,224,.22);
}

.badge-gold {
    background: rgba(212,160,48,.14);
    color: var(--c-gold);
    border: 1px solid rgba(212,160,48,.30);
}

.badge-veil,
.badge-purple {
    background: rgba(200,162,200,.10);
    color: var(--c-veil);
    border: 1px solid rgba(200,162,200,.25);
}

.badge-red {
    background: rgba(224,64,64,.10);
    color: #e07070;
    border: 1px solid rgba(224,64,64,.25);
}

.badge-green {
    background: rgba(64,184,64,.10);
    color: #70c870;
    border: 1px solid rgba(64,184,64,.22);
}

.badge-blue {
    background: rgba(48,128,224,.10);
    color: #6090e0;
    border: 1px solid rgba(48,128,224,.25);
}

.badge-gray {
    background: rgba(120,112,106,.12);
    color: var(--c-text-muted);
    border: 1px solid rgba(120,112,106,.25);
}

/* --- Tabs (character, map, admin) --- */
.tab-bar {
    display: flex;
    align-items: stretch;
    gap: 0;
    border-bottom: 1px solid rgba(200,162,200,.10);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    padding: var(--sp-3) var(--sp-4);
    font-family: var(--f-display);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s var(--ease-out),
                border-color 0.15s var(--ease-out);
}

.tab-item i { font-size: var(--fs-sm); }

@media (hover: hover) and (pointer: fine) {
    .tab-item:hover {
        color: var(--c-text-sub);
        border-bottom-color: rgba(200,162,200,.20);
    }
}

.tab-item.active {
    color: var(--c-gold);
    border-bottom-color: var(--c-gold);
}

/* --- Tables (character stats, admin) --- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

.table th {
    font-family: var(--f-display);
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-text-muted);
    padding: var(--sp-2) var(--sp-3);
    text-align: left;
    border-bottom: 1px solid rgba(212,160,48,.18);
    white-space: nowrap;
}

.table td {
    padding: var(--sp-2) var(--sp-3);
    color: var(--c-text-sub);
    border-bottom: 1px solid rgba(0,0,0,.30);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

/* --- Alerts (auth, map, combat) --- */
.alert {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    line-height: var(--lh-base);
}

.alert i:first-child {
    font-size: var(--fs-base);
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-error {
    background: rgba(224,64,64,.08);
    border: 1px solid rgba(224,64,64,.22);
    color: #e07070;
}

.alert-success {
    background: rgba(64,184,64,.07);
    border: 1px solid rgba(64,184,64,.20);
    color: #70c870;
}

.alert-warning {
    background: rgba(232,160,48,.08);
    border: 1px solid rgba(232,160,48,.20);
    color: var(--c-gold);
}

.alert-info {
    background: rgba(48,128,224,.08);
    border: 1px solid rgba(48,128,224,.20);
    color: #6090e0;
}

/* --- Dividers (decorative separators) --- */
.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(212,160,48,.20), transparent);
    margin: var(--sp-3) 0;
    border: none;
}

.section-title,
.loc-section-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
    font-family: var(--f-display);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-gold);
}

.section-title::after,
.loc-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(212,160,48,.22), transparent);
}

/* --- Empty states (quest, map, bestiary) --- */
.empty-state {
    padding: var(--sp-7) var(--sp-4);
    text-align: center;
    font-style: italic;
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    display: block;
    margin: 0 auto var(--sp-3);
    opacity: 0.3;
    color: var(--c-text-muted);
}

.empty-state-text {
    color: var(--c-text-muted);
    line-height: var(--lh-relaxed);
    max-width: 320px;
    margin: 0 auto;
}

.quest-empty,
.loc-loading {
    padding: var(--sp-7) var(--sp-4);
    text-align: center;
    font-style: italic;
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
}

.quest-empty .ph,
.loc-loading i {
    font-size: 2rem;
    display: block;
    margin-bottom: var(--sp-2);
    opacity: 0.35;
}

.view-error {
    padding: var(--sp-7) var(--sp-4);
    text-align: center;
    color: var(--c-error);
    font-size: var(--fs-sm);
}

.view-error i {
    font-size: 2rem;
    display: block;
    margin-bottom: var(--sp-2);
    opacity: 0.55;
}

/* --- Form extras (admin, forge) --- */
.form-label {
    font-family: var(--f-display);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--c-text-muted);
}

.form-label.required::after {
    content: ' *';
    color: var(--c-error);
}

.form-hint {
    font-size: var(--fs-xs);
    color: var(--c-text-muted);
    font-style: italic;
    line-height: var(--lh-base);
}

.form-error-text,
.form-error-msg {
    font-size: var(--fs-xs);
    color: var(--c-error);
    line-height: var(--lh-base);
}

.form-control.is-error {
    border-color: rgba(224,64,64,.55) !important;
    box-shadow: 0 0 0 1px rgba(224,64,64,.12);
}

/* --- Thin scroll utility --- */
.thin-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--c-fog) var(--c-void);
}

.thin-scroll::-webkit-scrollbar       { width: 5px; }
.thin-scroll::-webkit-scrollbar-track  { background: var(--c-void); }
.thin-scroll::-webkit-scrollbar-thumb  { background: var(--c-fog); border-radius: var(--r-xs); }


/* ================================================================
   12. ACCESSIBILITY & MOTION
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .loading-spinner {
        animation-duration: 1.2s !important;
        animation-iteration-count: infinite !important;
    }
}

/* Focus-visible ring for keyboard navigation */
.btn:focus-visible,
.tab-item:focus-visible,
.form-control:focus-visible,
.modal-close:focus-visible,
.toast-close:focus-visible {
    outline: 2px solid rgba(212,160,48,.60);
    outline-offset: 2px;
}
