@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Space+Grotesk:wght@400;600;700&display=swap');

/* Hide all sections until JS init completes and shows the correct one */
.db-content > section { display: none; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0e1a;
    color: #ddd;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: rgba(15, 20, 35, 0.95);
    border-bottom: 1px solid rgba(114, 137, 218, 0.2);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    background: linear-gradient(90deg, #7289DA, #99AAF0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.9rem;
    color: #888;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.user-name {
    font-size: 0.9rem;
    color: #aaa;
}

.login-hint {
    font-size: 0.85rem;
    color: #666;
}

.wiki-header-link {
    font-size: 0.82rem;
    color: #b8952a;
    text-decoration: none;
    border: 1px solid rgba(184,149,42,0.3);
    border-radius: 3px;
    padding: 4px 10px;
    transition: border-color 0.15s, color 0.15s;
}
.wiki-header-link:hover {
    color: #e8c870;
    border-color: rgba(232,200,112,0.5);
}

.login-hint a {
    color: #7289DA;
    text-decoration: none;
}

.login-hint a:hover {
    text-decoration: underline;
}

.edit-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: rgba(68, 204, 68, 0.15);
    color: #44cc44;
    border: 1px solid rgba(68, 204, 68, 0.3);
    border-radius: 10px;
}

/* Edit mode toggle */
.edit-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    user-select: none;
}

.edit-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 32px;
    height: 18px;
    background: rgba(136, 136, 136, 0.3);
    border-radius: 9px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.edit-toggle input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #888;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.edit-toggle input[type="checkbox"]:checked {
    background: rgba(68, 204, 68, 0.3);
}

.edit-toggle input[type="checkbox"]:checked::after {
    transform: translateX(14px);
    background: #44cc44;
}

.edit-toggle-label {
    color: #888;
    transition: color 0.2s;
}

.edit-toggle input[type="checkbox"]:checked ~ .edit-toggle-label {
    color: #44cc44;
}

/* Admin badge on player cards */
.player-admin-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    background: rgba(114, 137, 218, 0.2);
    color: #7289DA;
    border: 1px solid rgba(114, 137, 218, 0.4);
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.btn-grant-admin {
    background: rgba(114, 137, 218, 0.15) !important;
    border-color: rgba(114, 137, 218, 0.3) !important;
    color: #7289DA !important;
}

.btn-revoke-admin {
    background: rgba(200, 50, 50, 0.15) !important;
    border-color: rgba(200, 50, 50, 0.3) !important;
    color: #cc4444 !important;
}

/* Nav */
/* ── Sidebar layout ─────────────────────────────────────── */
.db-layout {
    display: flex;
    min-height: calc(100vh - 57px);
}

.db-content {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.section-nav {
    width: 172px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 8px 0 24px;
    background: rgba(15, 20, 35, 0.7);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 57px;
    height: calc(100vh - 57px);
    overflow-y: auto;
}

.section-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #999;
    text-decoration: none;
    font-size: 0.88rem;
    white-space: nowrap;
    border-left: 2px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.section-nav a:hover {
    background: rgba(114, 137, 218, 0.12);
    color: #ddd;
    border-left-color: rgba(114, 137, 218, 0.35);
}

.section-nav a.active {
    background: rgba(114, 137, 218, 0.2);
    color: #7289DA;
    font-weight: 600;
    border-left-color: #7289DA;
}

.nav-section-label {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 16px 16px 5px;
    user-select: none;
    pointer-events: none;
    white-space: nowrap;
}

.nav-section-label--admin {
    color: rgba(80, 200, 120, 0.4);
}

.nav-divider { display: none; }

/* Main */
main {
    max-width: none;
    margin: 0 auto;
}

section {
    padding: 24px 32px;
}

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

section h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #ccc;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    /* max-height + overflow-y set in keyboard nav block below for sticky header support */
}

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

thead th {
    text-align: left;
    padding: 10px 12px;
    background: rgba(114, 137, 218, 0.1);
    color: #99AAF0;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(114, 137, 218, 0.2);
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: top;
}

tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

tbody tr:hover {
    background: rgba(114, 137, 218, 0.06);
}

/* Type badges */
.type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.type-weapon     { background: rgba(204, 68, 68, 0.2); color: #cc4444; border: 1px solid rgba(204, 68, 68, 0.3); }
.type-npc        { background: rgba(114, 137, 218, 0.2); color: #7289da; border: 1px solid rgba(114, 137, 218, 0.3); }
.type-armor      { background: rgba(68, 136, 204, 0.2); color: #4488cc; border: 1px solid rgba(68, 136, 204, 0.3); }
.type-consumable { background: rgba(68, 204, 68, 0.2); color: #44cc44; border: 1px solid rgba(68, 204, 68, 0.3); }
.type-material   { background: rgba(204, 136, 68, 0.2); color: #cc8844; border: 1px solid rgba(204, 136, 68, 0.3); }
.type-quest      { background: rgba(136, 68, 204, 0.2); color: #8844cc; border: 1px solid rgba(136, 68, 204, 0.3); }
.type-utility    { background: rgba(180, 180, 68, 0.2); color: #bbbb44; border: 1px solid rgba(180, 180, 68, 0.3); }
.type-relic      { background: rgba(204, 170, 34, 0.2); color: #ccaa22; border: 1px solid rgba(204, 170, 34, 0.3); }
.type-slime      { background: rgba(68, 204, 68, 0.2); color: #44cc44; border: 1px solid rgba(68, 204, 68, 0.3); }
.type-wolf       { background: rgba(136, 136, 136, 0.2); color: #aaa; border: 1px solid rgba(136, 136, 136, 0.3); }
.type-circle     { background: rgba(255, 68, 136, 0.2); color: #ff4488; border: 1px solid rgba(255, 68, 136, 0.3); }
.type-donut      { background: rgba(68, 170, 255, 0.2); color: #44aaff; border: 1px solid rgba(68, 170, 255, 0.3); }
.type-square     { background: rgba(255, 170, 34, 0.2); color: #ffaa22; border: 1px solid rgba(255, 170, 34, 0.3); }
.type-rectangle  { background: rgba(170, 102, 255, 0.2); color: #aa66ff; border: 1px solid rgba(170, 102, 255, 0.3); }
.type-kill       { background: rgba(204, 68, 68, 0.2); color: #cc4444; border: 1px solid rgba(204, 68, 68, 0.3); }
.type-collect    { background: rgba(204, 136, 68, 0.2); color: #cc8844; border: 1px solid rgba(204, 136, 68, 0.3); }
.type-talk_to    { background: rgba(68, 136, 204, 0.2); color: #4488cc; border: 1px solid rgba(68, 136, 204, 0.3); }
.type-explore    { background: rgba(68, 204, 136, 0.2); color: #44cc88; border: 1px solid rgba(68, 204, 136, 0.3); }
.type-gift       { background: rgba(255, 215, 0, 0.2); color: #ffd700; border: 1px solid rgba(255, 215, 0, 0.3); }

/* Class tag badges */
.class-warrior   { background: rgba(204, 68, 68, 0.15); color: #e06040; border: 1px solid rgba(204, 68, 68, 0.25); }
.class-ranger    { background: rgba(68, 170, 68, 0.15); color: #55bb55; border: 1px solid rgba(68, 170, 68, 0.25); }
.class-mage      { background: rgba(100, 68, 204, 0.15); color: #8866dd; border: 1px solid rgba(100, 68, 204, 0.25); }

/* Realm-bound badge */
.realm-bound     { background: rgba(200, 170, 50, 0.15); color: #c8aa44; border: 1px solid rgba(200, 170, 50, 0.25); }

/* Properties display */
.props {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    color: #aab;
}

.prop-key {
    color: #99AAF0;
}

.prop-val {
    color: #44cc44;
}

/* Editable cells */
td.editable {
    cursor: pointer;
    position: relative;
}

select.inline-select {
    background: #1e1e2e;
    color: #c8ccd4;
    border: 1px solid #3a3a5a;
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 0.82rem;
    width: 100%;
    cursor: pointer;
}
select.inline-select:focus {
    outline: none;
    border-color: #7289DA;
}

td.editable:hover {
    background: rgba(114, 137, 218, 0.1);
}

td.editable::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

td.editing {
    padding: 4px;
}

td.editing input,
td.editing textarea {
    width: 100%;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(114, 137, 218, 0.5);
    border-radius: 4px;
    color: #eee;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

td.editing textarea {
    min-height: 60px;
    resize: vertical;
}

td.editing input:focus,
td.editing textarea:focus {
    border-color: #7289DA;
}

/* Save feedback */
@keyframes flash-green {
    0% { background: rgba(68, 204, 68, 0.3); }
    100% { background: transparent; }
}

@keyframes flash-red {
    0% { background: rgba(204, 68, 68, 0.3); }
    100% { background: transparent; }
}

td.save-success {
    animation: flash-green 0.8s ease-out;
}

td.save-error {
    animation: flash-red 0.8s ease-out;
}

/* ID column */
td:first-child {
    color: #666;
    font-size: 0.8rem;
}

/* Add button */
.btn-add {
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: rgba(68, 204, 68, 0.2);
    border: 1px solid rgba(68, 204, 68, 0.4);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add:hover {
    background: rgba(68, 204, 68, 0.35);
}

/* Delete button */
.col-actions {
    width: 40px;
    text-align: center;
}

.btn-delete {
    padding: 4px 8px;
    font-size: 0.8rem;
    color: rgba(204, 68, 68, 0.6);
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-delete:hover {
    color: #cc4444;
    background: rgba(204, 68, 68, 0.1);
    border-color: rgba(204, 68, 68, 0.3);
}

/* Row visibility toggle button */
.btn-row-vis {
    padding: 4px 6px;
    font-size: 0.8rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s, border-color 0.15s;
    margin-right: 2px;
}
.btn-row-vis:hover { opacity: 1; border-color: rgba(255,255,255,0.2); }
.btn-row-vis-off { opacity: 0.35; }
.btn-row-vis-off:hover { opacity: 0.7; }

/* Hidden rows shown in edit mode — dimmed */
tr.row-hidden { opacity: 0.4; }
.player-card.row-hidden { opacity: 0.4; }

/* Per-player visibility toggle button */
.player-card-vis {
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

/* New row highlight */
@keyframes flash-new {
    0% { background: rgba(68, 204, 68, 0.25); }
    100% { background: transparent; }
}

tr.row-new {
    animation: flash-new 1.5s ease-out;
}

/* Player cards */
/* Players layout — list + sidebar */
.players-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
#players-list {
    flex: 1;
    min-width: 0;
}
.players-vis-panel {
    flex: 0 0 180px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 12px;
    position: sticky;
    top: 16px;
}
.pvis-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
    margin-bottom: 10px;
}
.pvis-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    cursor: pointer;
    gap: 8px;
}
.pvis-label {
    font-size: 0.82rem;
    color: #ccc;
}
.pvis-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.4;
    transition: opacity 0.15s;
}
.pvis-on  { opacity: 1; }
.pvis-off { opacity: 0.4; }
/* Hidden player card fields — only shown in edit mode, very faded */
.pvis-hidden-field { opacity: 0.7; pointer-events: none; }

.player-card {
    display: flex;
    gap: 16px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.player-card:hover {
    background: rgba(114, 137, 218, 0.06);
}

.player-card-left {
    flex-shrink: 0;
}

.player-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(114, 137, 218, 0.3);
}

.player-avatar-none {
    background: rgba(255, 255, 255, 0.08);
}

.player-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.player-name {
    font-weight: 600;
    font-size: 1rem;
    color: #eee;
}

.player-char-name {
    font-size: 0.85rem;
    color: #888;
}

.player-char-name::before {
    content: '—';
    margin-right: 6px;
    color: #444;
}

.player-level {
    font-size: 0.75rem;
    padding: 1px 8px;
    background: rgba(114, 137, 218, 0.15);
    color: #99AAF0;
    border: 1px solid rgba(114, 137, 218, 0.3);
    border-radius: 10px;
    font-weight: 600;
}

.player-zone {
    font-size: 0.75rem;
}

.player-login {
    font-size: 0.75rem;
    color: #555;
    margin-left: auto;
}

/* Health bar */
.player-health {
    position: relative;
    height: 16px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
    max-width: 240px;
}

.player-health-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.player-health-text {
    position: absolute;
    top: 0;
    left: 8px;
    line-height: 16px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Inventory mini-grid */
.player-inv {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.inv-slot {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inv-slot-empty {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
}

.player-admin-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-player-action {
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-player-action:hover:not(:disabled) { opacity: 0.8; }
.btn-player-action:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-kill {
    background: rgba(180, 40, 40, 0.25);
    border-color: rgba(180, 40, 40, 0.5);
    color: #ff8888;
}
.btn-clear-inv {
    background: rgba(180, 120, 40, 0.25);
    border-color: rgba(180, 120, 40, 0.5);
    color: #ffcc88;
}
.btn-grant-level {
    background: rgba(60, 160, 60, 0.25);
    border-color: rgba(60, 160, 60, 0.5);
    color: #88ee88;
}
.btn-reset-quests {
    background: rgba(136, 68, 204, 0.25);
    border-color: rgba(136, 68, 204, 0.5);
    color: #bb88ee;
}
.btn-reset-tier {
    background: rgba(204, 120, 30, 0.25);
    border-color: rgba(204, 120, 30, 0.5);
    color: #ffaa55;
}
.player-tier-badge {
    font-size: 0.75rem;
    padding: 1px 8px;
    background: rgba(180, 100, 255, 0.15);
    color: #cc88ff;
    border: 1px solid rgba(180, 100, 255, 0.35);
    border-radius: 10px;
    font-weight: 600;
}

/* Player professions (edit mode) */
.player-professions {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.prof-label {
    font-size: 0.72rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: block;
}
.prof-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.prof-row {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.78rem;
}
.prof-row-empty {
    opacity: 0.5;
}
.prof-name {
    color: #aaa;
    min-width: 90px;
    font-size: 0.72rem;
}
.prof-input {
    width: 42px;
    padding: 1px 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    color: #ddd;
    font-size: 0.75rem;
    text-align: center;
}
.prof-input-xp {
    width: 56px;
}
.prof-del {
    padding: 0 4px;
    font-size: 0.65rem;
    line-height: 1;
    min-width: unset;
}
.prof-add {
    padding: 1px 8px;
    font-size: 0.7rem;
    line-height: 1;
    min-width: unset;
}

/* Recipe profession row */
.recipe-prof-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: #aaa;
    flex-wrap: wrap;
}

.inv-slot-icon {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
}

.inv-slot-qty {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 0 3px;
    border-radius: 3px;
    line-height: 1.2;
}

/* Zone type badges for player cards */
.type-spawn { background: rgba(68, 204, 68, 0.2); color: #44cc44; border: 1px solid rgba(68, 204, 68, 0.3); }
.type-mine  { background: rgba(136, 102, 68, 0.2); color: #cc8844; border: 1px solid rgba(136, 102, 68, 0.3); }
.type-none  { background: rgba(100, 100, 100, 0.2); color: #888; border: 1px solid rgba(100, 100, 100, 0.3); }

/* Tool Sub-Tabs */
.tool-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0;
}

.tool-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #888;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 18px 10px;
    margin-bottom: -1px;
    border-radius: 6px 6px 0 0;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tool-tab:hover {
    color: #ccc;
    background: rgba(255, 255, 255, 0.04);
}

.tool-tab.active {
    color: #7289da;
    border-bottom-color: #7289da;
    background: rgba(114, 137, 218, 0.07);
}

.tool-panel {
    display: none;
}

.tool-panel.active {
    display: block;
}

/* ── Models Sub-Tabs ── */
.models-sub-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0;
}

.models-sub-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #888;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 18px 10px;
    margin-bottom: -1px;
    border-radius: 6px 6px 0 0;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.models-sub-tab:hover {
    color: #ccc;
    background: rgba(255, 255, 255, 0.04);
}

.models-sub-tab.active {
    color: #7289da;
    border-bottom-color: #7289da;
    background: rgba(114, 137, 218, 0.07);
}

/* Camera Lock Form */
.camera-lock-form {
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 12px;
}

.cl-row {
    background: rgba(15, 20, 35, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cl-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #ddd;
    user-select: none;
}

.cl-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #7289da;
    cursor: pointer;
}

.cl-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.15s;
}

.cl-input-group.enabled {
    opacity: 1;
    pointer-events: auto;
}

.cl-input-group input[type="range"] {
    flex: 1;
    accent-color: #7289da;
}

.cl-input-group input[type="number"] {
    width: 72px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: #ddd;
    font-size: 0.9rem;
    padding: 4px 8px;
    text-align: right;
}

.cl-unit {
    color: #888;
    font-size: 0.85rem;
    min-width: 30px;
}

.cl-minmax {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cl-minmax-label {
    font-size: 0.75rem;
    color: #777;
    min-width: 28px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cl-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.cl-actions .btn-save {
    background: #7289da;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 18px;
    transition: background 0.15s;
}

.cl-actions .btn-save:hover { background: #5b73c7; }

.cl-actions .btn-reset {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #bbb;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 16px;
    transition: background 0.15s;
}

.cl-actions .btn-reset:hover { background: rgba(255, 255, 255, 0.12); }

.cl-status {
    color: #5cb85c;
    font-size: 0.85rem;
    flex: 1;
}

.cl-status.error { color: #e74c3c; }

/* Tools Section */
.tools-section {
    background: rgba(15, 20, 35, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.tools-section h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tools-desc {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.tools-divider {
    border: none;
    border-top: 1px solid rgba(180,140,60,0.15);
    margin: 18px 0;
}

.wip-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: rgba(204, 136, 68, 0.2);
    color: #cc8844;
    border: 1px solid rgba(204, 136, 68, 0.3);
    border-radius: 10px;
    font-weight: 600;
}

.wip-placeholder {
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 32px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* ── Model Explorer ─────────────────────────────────── */
.me-category {
    margin-bottom: 20px;
}

.me-category-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
    margin-bottom: 12px;
}

.me-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.me-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    padding: 8px;
    transition: border-color 0.15s;
}

.me-card:hover {
    border-color: rgba(114, 137, 218, 0.4);
}

.me-canvas {
    width: 140px;
    height: 160px;
    border-radius: 4px;
    display: block;
}

.me-canvas-tall {
    height: 200px;
}

.me-label {
    font-size: 0.75rem;
    color: #999;
    font-weight: 500;
}

.me-card-wrapper {
    display: flex;
    flex-direction: column;
}

.me-btn-row {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.me-btn-row button {
    flex: 1;
    padding: 3px 6px;
    font-size: 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-edit-in-editor {
    background: rgba(114, 137, 218, 0.12);
    border: 1px solid rgba(114, 137, 218, 0.3);
    color: #9aabdf;
}

.btn-edit-in-editor:hover {
    background: rgba(114, 137, 218, 0.25);
    color: #c5cfef;
}

.btn-duplicate-model {
    background: rgba(100, 200, 100, 0.1);
    border: 1px solid rgba(100, 200, 100, 0.3);
    color: #8fc88f;
}

.btn-duplicate-model:hover {
    background: rgba(100, 200, 100, 0.22);
    color: #b8e8b8;
}

.me-no-db-badge {
    font-size: 0.65rem;
    font-weight: normal;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(180, 140, 60, 0.18);
    border: 1px solid rgba(180, 140, 60, 0.35);
    color: #c8a84a;
    vertical-align: middle;
    margin-left: 6px;
}

/* Toast notification */
#db-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 35, 45, 0.95);
    border: 1px solid rgba(114, 137, 218, 0.4);
    color: #c5cfef;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 9999;
}

#db-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.editor-save-status {
    font-size: 0.75rem;
    min-height: 1.2em;
}

.editor-save-status.ok  { color: #6ddb6d; }
.editor-save-status.err { color: #e06060; }

.me-card.mappable {
    cursor: pointer;
}

.me-card.mappable:hover {
    border-color: rgba(114, 137, 218, 0.5);
    box-shadow: 0 0 8px rgba(114, 137, 218, 0.15);
}

.me-card.expanded {
    border-color: #7289DA;
    box-shadow: 0 0 12px rgba(114, 137, 218, 0.25);
}

.me-mapped-panel {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(114, 137, 218, 0.2);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ── Zones ──────────────────────────────────────────── */
.zone-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding-bottom: 0;
}

.zone-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #888;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 18px 10px;
    transition: color 0.15s, border-color 0.15s;
}

.zone-tab:hover { color: #ccc; }
.zone-tab.active { color: #7289DA; border-bottom-color: #7289DA; }

.zone-panel { display: none; }
.zone-panel.active { display: block; }

/* ── Zone type tabs (Static / Procgen top-level) ──── */
.zone-type-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.zone-type-tab {
    padding: 8px 22px;
    background: rgba(114, 137, 218, 0.08);
    border: 1px solid rgba(114, 137, 218, 0.2);
    border-radius: 6px;
    color: #99aacc;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.15s;
}

.zone-type-tab:hover  { background: rgba(114,137,218,0.18); color: #ccd; }
.zone-type-tab.active { background: rgba(114,137,218,0.22); border-color: #7289DA; color: #fff; font-weight: 600; }

/* ── Procgen sub-tabs (Realm / Dungeon / Haven) ───── */
.procgen-type-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0;
}

.procgen-type-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #888;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    padding: 8px 18px;
    transition: color 0.15s, border-color 0.15s;
}

.procgen-type-tab:hover  { color: #ccc; }
.procgen-type-tab.active { color: #7289DA; border-bottom-color: #7289DA; }

/* ── Procgen UI components ──────────────────────────── */
.pg-base-hint {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 14px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    border-left: 3px solid rgba(114,137,218,0.35);
}

.pg-instances-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    flex-wrap: wrap;
}

.pg-instances-list {
    margin-bottom: 18px;
}
.pg-instances-list .db-table { margin-bottom: 0; }

/* ── Procgen loot table groups ───────────────────────── */
.pg-loot-group { margin-bottom: 6px; }

.pg-loot-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: rgba(114,137,218,0.1);
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    user-select: none;
}

.pg-loot-group-header:hover { background: rgba(114,137,218,0.16); }

.pg-loot-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #c8c8ff;
}

.pg-loot-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pg-loot-count { font-size: 0.78rem; color: #888; }

.pg-loot-group-body {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-top: none;
    border-radius: 0 0 4px 4px;
    padding: 0;
    overflow: hidden;
}

.btn-add-sm {
    padding: 2px 8px !important;
    font-size: 0.75rem !important;
    margin-left: 8px;
}

/* ── Haven list ─────────────────────────────────────── */
.pg-haven-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.pg-haven-loading {
    color: #888;
    font-size: 0.85rem;
    padding: 12px 0;
}

.pg-haven-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
}

.pg-haven-avatar { font-size: 1.5rem; line-height: 1; }

.pg-haven-info { flex: 1; }

.pg-haven-player { font-weight: 600; color: #c8c8ff; margin-bottom: 2px; }

.pg-haven-objects { font-size: 0.8rem; color: #888; }

.pg-haven-detail {
    padding: 8px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-top: none;
    border-radius: 0 0 6px 6px;
    margin-top: -8px;
    margin-bottom: 8px;
}

.zone-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.zone-map-panel {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.zone-map-canvas {
    display: block;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.10);
    cursor: crosshair;
}

.zone-map-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-map-tool {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    color: #ccc;
    border-radius: 5px;
    padding: 3px 9px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-map-tool:hover { background: rgba(255,255,255,0.14); }
.btn-map-tool.active { background: rgba(80,180,255,0.22); border-color: #50b4ff88; color: #80ccff; }

.zone-zoom-label {
    font-size: 0.75rem;
    color: #666;
    min-width: 32px;
}

.zone-paint-opts {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.btn-terrain {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.12s, transform 0.1s;
}
.btn-terrain:hover { transform: scale(1.2); }
.btn-terrain.active { border-color: #fff; transform: scale(1.15); }

.zone-brush-size {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    color: #ccc;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 0.75rem;
    cursor: pointer;
    width: 44px;
}

.zone-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #999;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.zone-entity-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.zone-subsection h3 {
    font-size: 1rem;
    font-weight: 600;
}

.zone-add-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.border-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    align-items: center;
    font-size: 0.82rem;
    margin-top: 8px;
    margin-bottom: 6px;
}
.border-settings-grid input[type="number"],
.border-settings-grid input[type="color"] {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    color: #ccc;
    font-size: 0.82rem;
    padding: 3px 6px;
    width: 100%;
    box-sizing: border-box;
}
.border-settings-grid input[type="color"] {
    padding: 2px;
    height: 28px;
    cursor: pointer;
}
.border-hint {
    font-size: 0.72rem;
    color: #777;
    font-style: italic;
}

.zone-type-select {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    color: #ccc;
    font-size: 0.82rem;
    padding: 4px 8px;
}

.zone-enemy-table,
.zone-npc-table,
.zone-collider-table {
    width: 100%;
}

.zone-enemy-table tr.map-highlight td,
.zone-npc-table tr.map-highlight td,
.zone-collider-table tr.map-highlight td {
    background: rgba(114, 137, 218, 0.15);
}

/* Collider shape badges in legend */
.badge-circle    { border-radius: 50%; }
.badge-donut     { border-radius: 50%; border: 2px solid currentColor; }
.badge-square    { border-radius: 0; }
.badge-rectangle { border-radius: 0; width: 14px !important; height: 8px !important; }

/* Inline editable spans (inside multi-field table cells) */
.inline-editable {
    cursor: pointer;
    border-bottom: 1px dashed rgba(255,255,255,0.2);
    padding: 0 2px;
}
.inline-editable:hover {
    border-bottom-color: #7289DA;
    color: #fff;
}

/* Dimmed cells for irrelevant collider fields */
.zone-collider-table td.dim {
    color: #444;
    text-align: center;
}

/* Expand/collapse button */
.btn-expand {
    background: none;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
    transition: color 0.15s, border-color 0.15s;
}
.btn-expand:hover { color: #ccc; border-color: rgba(255,255,255,0.3); }
.btn-expand.expanded { color: #7289DA; border-color: #7289DA; }

/* Detail row */
.detail-row { background: rgba(0,0,0,0.2); }
.detail-td  { padding: 10px 12px !important; }

.detail-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 80px;
}

.detail-label {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-value {
    font-size: 0.85rem;
    color: #ccc;
}

.detail-value.editable {
    cursor: pointer;
    border-bottom: 1px dashed rgba(255,255,255,0.15);
    padding-bottom: 1px;
}
.detail-value.editable:hover { border-bottom-color: #7289DA; color: #fff; }

/* Model Mapping */
.model-categories {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.model-category h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: #aaa;
}

.model-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.model-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.model-preview-canvas {
    width: 110px;
    height: 150px;
    flex-shrink: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: block;
}

.model-item-info {
    flex: 1;
    min-width: 0;
}

.model-name {
    font-weight: 600;
    color: #7289DA;
    margin-bottom: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.model-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mapped-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 6px 10px;
}

.item-badge {
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.item-type {
    font-size: 0.75rem;
    color: #666;
}

.item-model {
    font-size: 0.75rem;
    color: #888;
    font-family: 'Consolas', 'Monaco', monospace;
}

.model-select {
    font-size: 0.75rem;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #aaa;
    font-family: 'Consolas', 'Monaco', monospace;
}

.empty-model {
    color: #555;
    font-style: italic;
    font-size: 0.85rem;
}

/* Page Visibility Controls */
.page-visibility-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.page-visibility-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 12px 16px;
    transition: background 0.2s;
}

.page-visibility-item:hover {
    background: rgba(0, 0, 0, 0.4);
}

.page-visibility-item label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex: 1;
}

.page-visibility-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.page-visibility-item span {
    font-size: 0.95rem;
}

.visibility-status {
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 500;
    background: rgba(68, 204, 68, 0.2);
    color: #44cc44;
    border: 1px solid rgba(68, 204, 68, 0.3);
}

.page-visibility-item input[type="checkbox"]:not(:checked) ~ .visibility-status,
.page-visibility-item:has(input[type="checkbox"]:not(:checked)) .visibility-status {
    background: rgba(204, 136, 68, 0.2);
    color: #cc8844;
    border: 1px solid rgba(204, 136, 68, 0.3);
}

/* Column Visibility Toggles */
.visibility-toggle {
    margin-left: 6px;
    font-size: 0.85rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    user-select: none;
}

.visibility-toggle:hover {
    opacity: 1;
}

th {
    position: relative;
}

/* ── Shop NPC Cards ────────────────────────────────── */
.shop-npc-card {
    background: rgba(15, 20, 35, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 16px 20px;
}

.shop-npc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.shop-npc-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ccc;
}

.shop-npc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.shop-npc-table thead th {
    text-align: left;
    padding: 8px 10px;
    background: rgba(114, 137, 218, 0.08);
    color: #99AAF0;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(114, 137, 218, 0.15);
}

.shop-npc-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.shop-npc-table tbody tr:hover {
    background: rgba(114, 137, 218, 0.06);
}

.shop-select,
.shop-num-input {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: #ccc;
    font-size: 0.85rem;
    font-family: inherit;
    padding: 5px 8px;
    outline: none;
    transition: border-color 0.2s, background 0.2s, outline 0.3s;
}

.shop-select:hover,
.shop-num-input:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.2);
}

.shop-select:focus,
.shop-num-input:focus {
    border-color: #7289DA;
    background: rgba(114, 137, 218, 0.08);
}

.shop-select {
    min-width: 160px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

.shop-select option {
    background: #151a2e;
    color: #ccc;
    padding: 4px 8px;
}

.shop-num-input {
    width: 72px;
    text-align: right;
}

.shop-empty {
    color: #555;
    font-style: italic;
    font-size: 0.9rem;
    padding: 8px 0;
}

/* ── Model Editor ──────────────────────────────────────── */

.editor-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.editor-viewport-wrap {
    flex-shrink: 0;
    position: relative;
}

.editor-canvas {
    width: 560px;
    height: 420px;
    display: block;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #1a1e2e;
    cursor: grab;
}

.editor-canvas:active {
    cursor: grabbing;
}

.editor-viewport-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}

.btn-editor-action {
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #aaa;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.btn-editor-action:hover {
    background: rgba(114, 137, 218, 0.3);
    color: #fff;
}

.editor-controls {
    flex: 1;
    min-width: 280px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 420px;
    overflow-y: auto;
}

.editor-section {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    padding: 12px;
}

.editor-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.editor-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: #ccc;
    font-size: 0.85rem;
    padding: 6px 8px;
    cursor: pointer;
}

.editor-parts-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 180px;
    overflow-y: auto;
}

.editor-part-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.82rem;
}

.editor-part-row:hover {
    background: rgba(114, 137, 218, 0.1);
}

.editor-part-row.selected {
    background: rgba(114, 137, 218, 0.2);
    border-left-color: #7289DA;
}

.editor-part-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.editor-part-name {
    flex: 1;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-part-type {
    font-size: 0.72rem;
    color: #666;
    font-family: 'Consolas', 'Monaco', monospace;
}

.editor-part-delete {
    font-size: 0.7rem;
    padding: 1px 5px;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #888;
    border-radius: 3px;
    cursor: pointer;
}

.editor-part-delete:hover {
    background: rgba(220, 53, 69, 0.3);
    border-color: rgba(220, 53, 69, 0.5);
    color: #ff6b6b;
}

.editor-empty {
    color: #555;
    font-style: italic;
    font-size: 0.85rem;
    padding: 8px;
}

.editor-props {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.editor-prop-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-prop-row label {
    min-width: 85px;
    font-size: 0.78rem;
    color: #888;
    text-align: right;
}

.editor-prop-row input[type="number"],
.editor-prop-row input[type="text"] {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    color: #ddd;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    padding: 3px 6px;
    outline: none;
    min-width: 0;
}

.editor-prop-row input[type="number"]:focus,
.editor-prop-row input[type="text"]:focus {
    border-color: #7289DA;
}

.editor-prop-row input[type="color"] {
    width: 28px;
    height: 22px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    background: none;
    cursor: pointer;
}

.editor-prop-row select {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    color: #ddd;
    font-size: 0.8rem;
    padding: 3px 6px;
}

.editor-prop-group-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #666;
    margin-top: 8px;
    margin-bottom: 2px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.editor-json-preview {
    margin-top: 8px;
    max-height: 120px;
    overflow: auto;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.72rem;
    color: #aab;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Context / Glossary Tool ── */
.context-section {
    margin-bottom: 24px;
}

.context-heading {
    font-size: 1rem;
    font-weight: 600;
    color: #c8b4ff;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(110, 80, 220, 0.2);
}

.context-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-bottom: 8px;
}

.context-table th {
    text-align: left;
    padding: 8px 10px;
    background: rgba(88, 101, 242, 0.15);
    color: #a8b8ff;
    font-weight: 600;
    border-bottom: 1px solid rgba(114, 137, 218, 0.2);
}

.context-table td {
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: #bbb;
}

.context-table td strong {
    color: #fff;
}

.context-table code {
    background: rgba(88, 101, 242, 0.15);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.78rem;
    color: #a8b8ff;
}

.context-map {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(114, 137, 218, 0.2);
    border-radius: 6px;
    padding: 16px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.72rem;
    color: #8899bb;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

/* ── Procgen Editor ──────────────────────────────────── */
.pg-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.pg-label {
    font-size: 0.85rem;
    color: #999;
    font-weight: 600;
}

.pg-seed-input {
    width: 100px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: #ddd;
    font-size: 0.9rem;
    padding: 6px 10px;
    text-align: right;
}

.pg-seed-input:focus {
    border-color: #7289DA;
    outline: none;
}

.pg-status {
    color: #5cb85c;
    font-size: 0.85rem;
    margin-left: 4px;
}

.pg-status.error {
    color: #e74c3c;
}

.pg-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.pg-map-panel {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pg-map-canvas {
    display: block;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    cursor: crosshair;
    background: #111;
}

.pg-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.pg-info-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 540px;
    overflow-y: auto;
}

.pg-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.pg-stat-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 10px 12px;
}

.pg-stat-label {
    font-size: 0.72rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.pg-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ccc;
}

.pg-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #999;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pg-poi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.pg-poi-table th {
    text-align: left;
    padding: 6px 8px;
    background: rgba(114, 137, 218, 0.08);
    color: #99AAF0;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(114, 137, 218, 0.15);
}

.pg-poi-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: #bbb;
}

.pg-poi-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pg-poi-town     { background: rgba(255, 215, 0, 0.2); color: #ffd700; border: 1px solid rgba(255, 215, 0, 0.3); }
.pg-poi-dungeon  { background: rgba(136, 68, 204, 0.2); color: #aa66ff; border: 1px solid rgba(136, 68, 204, 0.3); }
.pg-poi-boss     { background: rgba(204, 68, 68, 0.2); color: #cc4444; border: 1px solid rgba(204, 68, 68, 0.3); }

.pg-biome-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pg-biome-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 8px 12px;
}

.pg-biome-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.pg-biome-info {
    flex: 1;
    min-width: 0;
}

.pg-biome-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #ddd;
    text-transform: capitalize;
}

.pg-biome-detail {
    font-size: 0.75rem;
    color: #777;
}

/* ── OriginStory Theme Overrides ─────────────────────────────────────────── */
:root {
    --bg:       #08041a;
    --panel:    #0c0520;
    --border:   #c87e12;
    --border2:  #ffc832;
    --gold:     #ffc832;
    --gold-lt:  #ffeb82;
    --purple:   #501c8c;
    --cyan:     #50dcff;
    --discord:  #5865f2;
    --disc-h:   #7289ff;
    --db:       #1e96c8;
    --db-h:     #50c8f0;
    --text:     #e0d4f0;
    --muted:    #6e5f87;
}

body.db-theme {
    background:
        radial-gradient(1200px 800px at 70% -10%, rgba(80, 28, 140, 0.28), transparent 60%),
        radial-gradient(900px 600px at 10% 20%, rgba(30, 150, 200, 0.18), transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    position: relative;
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */
#db-loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #0b0b12;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}
#db-loading.db-loading-done {
    opacity: 0;
    pointer-events: none;
}
.db-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}
.db-loading-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.85rem;
    color: var(--gold, #c9a84c);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}
.db-loading-dots {
    display: flex;
    gap: 10px;
}
.db-loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold, #c9a84c);
    animation: db-dot-bounce 1.2s ease-in-out infinite;
}
.db-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.db-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes db-dot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
    40%            { transform: translateY(-10px); opacity: 1; }
}

.db-theme #stars {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.7;
}

.db-theme .scanlines {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.03),
        rgba(255, 255, 255, 0.03) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0.12;
    mix-blend-mode: screen;
}

.db-theme .rune {
    position: fixed;
    font-size: 12px;
    color: var(--purple);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    animation: floatRune 9s ease-in-out infinite;
}

@keyframes floatRune {
    0%   { opacity: 0; transform: translateY(0) rotate(0deg); }
    20%  { opacity: 0.35; }
    80%  { opacity: 0.2; }
    100% { opacity: 0; transform: translateY(-120px) rotate(360deg); }
}

.db-theme header,
.db-theme main {
    position: relative;
    z-index: 2;
}

.db-theme header {
    background: rgba(12, 5, 32, 0.92);
    border-bottom: 1px solid rgba(200, 126, 18, 0.45);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
}

.db-theme .logo {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.9rem;
    letter-spacing: 1px;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 200, 50, 0.5);
    background: none;
    -webkit-text-fill-color: unset;
}

.db-theme .subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: var(--cyan);
    text-shadow: 0 0 6px rgba(80, 220, 255, 0.6);
}

.db-theme .section-nav {
    background: rgba(8, 4, 20, 0.85);
    border-right: 1px solid rgba(200, 126, 18, 0.2);
    border-bottom: none;
}

.db-theme .nav-section-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.48rem;
    color: rgba(200, 126, 18, 0.45);
    letter-spacing: 0.08em;
}

.db-theme .nav-section-label--admin {
    color: rgba(80, 200, 120, 0.45);
}

.db-theme .section-nav a {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.58rem;
    letter-spacing: 0.3px;
    color: var(--muted);
    border-left: 2px solid transparent;
    border-top: none;
    border-right: none;
    border-bottom: none;
}

.db-theme .section-nav a:hover {
    background: rgba(80, 28, 140, 0.25);
    color: var(--gold-lt);
    border-left-color: rgba(255, 200, 50, 0.4);
}

.db-theme .section-nav a.active {
    background: rgba(80, 28, 140, 0.45);
    color: var(--gold);
    border-left-color: var(--gold);
    box-shadow: inset 0 0 12px rgba(255, 200, 50, 0.06);
}

.db-theme .section-header {
    border-bottom: 1px solid rgba(255, 200, 50, 0.25);
}

.db-theme section h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.9rem;
    color: var(--gold);
    text-shadow: 0 0 8px rgba(255, 200, 50, 0.3);
}

.db-theme .table-wrap {
    background: rgba(12, 5, 32, 0.65);
    border: 1px solid rgba(200, 126, 18, 0.35);
    border-radius: 10px;
    box-shadow: inset 0 0 20px rgba(80, 28, 140, 0.2);
}

.db-theme table {
    color: var(--text);
}

.db-theme thead th {
    background: rgba(80, 28, 140, 0.35);
    color: var(--gold-lt);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    border-bottom: 1px solid rgba(255, 200, 50, 0.25);
}

.db-theme tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.db-theme tbody tr:hover {
    background: rgba(80, 28, 140, 0.25);
}

.db-theme td.editing input,
.db-theme td.editing textarea,
.db-theme input,
.db-theme textarea,
.db-theme select {
    background: rgba(6, 3, 18, 0.7);
    border: 1px solid rgba(255, 200, 50, 0.35);
    color: var(--text);
    font-family: 'Space Grotesk', sans-serif;
}

.db-theme td.editing input:focus,
.db-theme td.editing textarea:focus,
.db-theme input:focus,
.db-theme textarea:focus,
.db-theme select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 8px rgba(255, 200, 50, 0.35);
}

.db-theme .btn-add {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.5px;
    padding: 8px 14px;
    background: rgba(30, 150, 200, 0.2);
    border: 1px solid rgba(80, 200, 240, 0.5);
    color: var(--gold-lt);
    box-shadow: 0 0 10px rgba(80, 200, 240, 0.2);
}

.db-theme .btn-add:hover {
    background: rgba(30, 150, 200, 0.35);
    box-shadow: 0 0 16px rgba(80, 200, 240, 0.35);
}

.db-theme .btn-delete:hover {
    background: rgba(204, 68, 68, 0.2);
    border-color: rgba(204, 68, 68, 0.5);
}

.db-theme .player-card,
.db-theme .tool-panel,
.db-theme .zone-panel,
.db-theme .pg-map-panel,
.db-theme .pg-info-panel {
    background: rgba(12, 5, 32, 0.7);
    border: 1px solid rgba(200, 126, 18, 0.25);
    box-shadow: inset 0 0 18px rgba(80, 28, 140, 0.18);
}

.db-theme .tools-desc,
.db-theme .subtitle,
.db-theme .login-hint,
.db-theme .user-name {
    color: var(--muted);
}

.db-theme .type-badge {
    border-radius: 12px;
    font-weight: 700;
}

.db-theme .edit-badge {
    background: rgba(255, 200, 50, 0.12);
    color: var(--gold-lt);
    border-color: rgba(255, 200, 50, 0.35);
}

/* ── Remaining Discord-blue purge ──────────────────────────────────────────── */

/* Tool tabs, models sub-tabs & zone tabs */
.db-theme .tool-tab.active,
.db-theme .models-sub-tab.active,
.db-theme .zone-tab.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
    background: rgba(200, 126, 18, 0.1);
}
.db-theme .tool-tab:hover,
.db-theme .models-sub-tab:hover,
.db-theme .zone-tab:hover {
    background: rgba(200, 126, 18, 0.08);
    color: var(--gold-lt);
}
/* Zone-type tabs (Static / Procgen) */
.db-theme .zone-type-tab.active {
    color: var(--gold);
    border-color: var(--gold);
    background: rgba(200, 126, 18, 0.15);
}
.db-theme .zone-type-tab:hover {
    background: rgba(200, 126, 18, 0.1);
    color: var(--gold-lt);
}
/* Procgen sub-tabs (Realm / Dungeon / Haven) */
.db-theme .procgen-type-tab.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
    background: rgba(200, 126, 18, 0.1);
}
.db-theme .procgen-type-tab:hover {
    background: rgba(200, 126, 18, 0.08);
    color: var(--gold-lt);
}
/* Procgen loot group header */
.db-theme .pg-loot-group-header { background: rgba(200, 126, 18, 0.08); }
.db-theme .pg-loot-group-header:hover { background: rgba(200, 126, 18, 0.14); }
.db-theme .pg-loot-group-title { color: var(--gold-lt); }
/* Haven card */
.db-theme .pg-haven-player { color: var(--gold-lt); }

/* Save / action buttons */
.db-theme .cl-actions .btn-save,
.db-theme .btn-save {
    background: linear-gradient(135deg, rgba(80, 28, 140, 0.8), rgba(200, 126, 18, 0.6));
    border: 1px solid rgba(200, 126, 18, 0.5);
    color: var(--gold-lt);
    box-shadow: 0 0 10px rgba(200, 126, 18, 0.2);
}
.db-theme .cl-actions .btn-save:hover,
.db-theme .btn-save:hover {
    background: linear-gradient(135deg, rgba(80, 28, 140, 1), rgba(200, 126, 18, 0.8));
    box-shadow: 0 0 16px rgba(200, 126, 18, 0.4);
}

/* Checkbox & range accent colour */
.db-theme .cl-toggle input[type="checkbox"],
.db-theme input[type="checkbox"] {
    accent-color: var(--gold);
}
.db-theme .cl-input-group input[type="range"],
.db-theme input[type="range"] {
    accent-color: var(--gold);
}

/* Model explorer cards */
.db-theme .me-card.mappable:hover {
    border-color: rgba(200, 126, 18, 0.5);
    box-shadow: 0 0 8px rgba(200, 126, 18, 0.2);
}
.db-theme .me-card.expanded {
    border-color: var(--gold);
    box-shadow: 0 0 14px rgba(200, 126, 18, 0.35);
}
.db-theme .me-mapped-panel {
    border-color: rgba(200, 126, 18, 0.2);
}
.db-theme .btn-edit-in-editor {
    background: rgba(200, 126, 18, 0.1);
    border-color: rgba(200, 126, 18, 0.3);
    color: var(--gold-lt);
}
.db-theme .btn-edit-in-editor:hover {
    background: rgba(200, 126, 18, 0.22);
    color: #fff;
}

/* Inline editable hover underlines */
.db-theme .inline-editable:hover,
.db-theme .detail-value.editable:hover {
    border-bottom-color: var(--gold);
    color: #fff;
}

/* Expand button active state */
.db-theme .btn-expand.expanded {
    color: var(--gold);
    border-color: var(--gold);
}

/* Editable table cells */
.db-theme td.editable:hover {
    background: rgba(200, 126, 18, 0.08);
}
.db-theme td.editing input,
.db-theme td.editing textarea {
    border-color: rgba(200, 126, 18, 0.5);
}
.db-theme td.editing input:focus,
.db-theme td.editing textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 6px rgba(200, 126, 18, 0.3);
}

/* Editor part list */
.db-theme .editor-part-row:hover {
    background: rgba(200, 126, 18, 0.08);
}
.db-theme .editor-part-row.selected {
    background: rgba(200, 126, 18, 0.15);
    border-left-color: var(--gold);
}
.db-theme .editor-prop-row input[type="number"]:focus,
.db-theme .editor-prop-row input[type="text"]:focus,
.db-theme .editor-prop-row select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 6px rgba(200, 126, 18, 0.25);
}

/* Model name label */
.db-theme .model-name {
    color: var(--gold);
}

/* Procgen / seed inputs */
.db-theme .pg-seed-input:focus {
    border-color: var(--gold);
}

/* Shop inputs */
.db-theme .shop-select:focus,
.db-theme .shop-num-input:focus {
    border-color: var(--gold);
    background: rgba(200, 126, 18, 0.06);
}

/* Shop / zone / procgen table headers using Discord blue */
.db-theme .shop-npc-table thead th,
.db-theme .pg-poi-table th {
    background: rgba(80, 28, 140, 0.25);
    color: var(--gold-lt);
    border-bottom-color: rgba(200, 126, 18, 0.2);
}
.db-theme .shop-npc-table tbody tr:hover {
    background: rgba(200, 126, 18, 0.05);
}

/* Context table */
.db-theme .context-table th {
    background: rgba(80, 28, 140, 0.25);
    color: var(--gold-lt);
    border-bottom-color: rgba(200, 126, 18, 0.2);
}
.db-theme .context-map {
    border-color: rgba(200, 126, 18, 0.2);
}

/* Zone map highlights */
.db-theme .zone-enemy-table tr.map-highlight td,
.db-theme .zone-npc-table tr.map-highlight td,
.db-theme .zone-collider-table tr.map-highlight td {
    background: rgba(200, 126, 18, 0.12);
}

/* Player card hover & avatar border */
.db-theme .player-card:hover {
    background: rgba(80, 28, 140, 0.12);
    border-color: rgba(200, 126, 18, 0.35);
}
.db-theme .player-avatar {
    border-color: rgba(200, 126, 18, 0.4);
}

/* Player level badge */
.db-theme .player-level {
    background: rgba(80, 28, 140, 0.3);
    color: var(--gold-lt);
    border-color: rgba(200, 126, 18, 0.35);
}

/* Admin badge & grant-admin button */
.db-theme .player-admin-badge {
    background: rgba(80, 28, 140, 0.35);
    color: var(--gold);
    border-color: rgba(200, 126, 18, 0.45);
}
.db-theme .btn-grant-admin {
    background: rgba(80, 28, 140, 0.2) !important;
    border-color: rgba(200, 126, 18, 0.35) !important;
    color: var(--gold-lt) !important;
}

/* Login hint link */
.db-theme .login-hint a {
    color: var(--gold);
}
.db-theme .login-hint a:hover {
    color: var(--gold-lt);
}

/* btn-editor-action hover */
.db-theme .btn-editor-action:hover {
    background: rgba(80, 28, 140, 0.4);
    color: var(--gold-lt);
}

/* NPC type badge (was discord blue) */
.db-theme .type-npc {
    background: rgba(80, 28, 140, 0.3);
    color: var(--gold-lt);
    border-color: rgba(200, 126, 18, 0.3);
}

/* Scrollbars */
.db-theme ::-webkit-scrollbar { width: 8px; height: 8px; }
.db-theme ::-webkit-scrollbar-track { background: rgba(8, 4, 26, 0.8); }
.db-theme ::-webkit-scrollbar-thumb {
    background: rgba(80, 28, 140, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(200, 126, 18, 0.2);
}
.db-theme ::-webkit-scrollbar-thumb:hover {
    background: rgba(80, 28, 140, 0.9);
}

/* ── Item Card View ────────────────────────────────────────────────────── */
.btn-view-toggle {
    padding: 4px 10px;
    font-size: 0.75rem;
    background: rgba(114, 137, 218, 0.1);
    border: 1px solid rgba(114, 137, 218, 0.3);
    border-radius: 4px;
    color: #9aabdf;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-view-toggle:hover {
    background: rgba(114, 137, 218, 0.22);
}
.btn-view-toggle.active {
    background: rgba(114, 137, 218, 0.25);
    border-color: rgba(114, 137, 218, 0.6);
    color: #c5cfef;
}

.items-card-view {
    padding: 4px 0 8px;
}

.item-type-group {
    margin-bottom: 24px;
}

.item-type-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 6px;
}

.item-type-group-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666;
    font-weight: 600;
}

.item-type-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.item-public-card {
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    overflow: hidden;
    width: 154px;
    transition: border-color 0.15s;
}

.item-public-card:hover {
    border-color: rgba(114, 137, 218, 0.35);
}

.item-public-card.row-hidden {
    opacity: 0.35;
}

.item-card-icon-wrap {
    width: 154px;
    height: 100px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.item-card-icon {
    width: 80px;
    height: 80px;
    image-rendering: pixelated;
    display: block;
}

.item-card-no-icon {
    font-size: 2rem;
    line-height: 1;
    user-select: none;
}

.item-card-vis-btn {
    position: absolute;
    top: 4px;
    right: 4px;
}

.item-card-vis-btn .btn-row-vis {
    padding: 1px 4px;
    font-size: 0.7rem;
}

.item-card-body {
    padding: 10px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.item-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #ddd;
    line-height: 1.2;
}

.item-card-desc {
    font-size: 0.72rem;
    color: #777;
    line-height: 1.3;
}

.item-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.item-card-stat {
    font-size: 0.68rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    padding: 2px 5px;
    color: #aaa;
    white-space: nowrap;
}

.item-card-sell {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
    font-size: 0.72rem;
    color: #c89a3e;
    cursor: help;
}

/* Asset model category type-badges */
.type-enemy  { background: rgba(204, 68, 68, 0.2); color: #cc4444; border: 1px solid rgba(204, 68, 68, 0.3); }
.type-item   { background: rgba(204, 136, 68, 0.2); color: #cc8844; border: 1px solid rgba(204, 136, 68, 0.3); }
.type-world  { background: rgba(68, 170, 102, 0.2); color: #44aa66; border: 1px solid rgba(68, 170, 102, 0.3); }
.type-vfx    { background: rgba(68, 170, 255, 0.2); color: #44aaff; border: 1px solid rgba(68, 170, 255, 0.3); }

/* Asset model file status badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.status-official { background: rgba(68, 204, 68, 0.15); color: #44cc44; border: 1px solid rgba(68, 204, 68, 0.3); }
.status-temp     { background: rgba(255, 170, 34, 0.15); color: #ffaa22; border: 1px solid rgba(255, 170, 34, 0.3); }
.status-missing  { background: rgba(204, 68, 68, 0.15); color: #cc4444; border: 1px solid rgba(204, 68, 68, 0.3); }

/* ─── Keyboard Navigation & Accessibility (Issue #266) ─────────────────────── */

/* Visible focus ring for all interactive elements */
:focus-visible {
    outline: 2px solid #7289DA;
    outline-offset: 2px;
    border-radius: 3px;
}

/* Editable cells get a distinct focus ring and are tabbable */
td.editable:focus-visible {
    outline: 2px solid #7289DA;
    outline-offset: -2px;
    background: rgba(114, 137, 218, 0.12);
}

/* Row highlight when any cell inside is focused or editing */
tbody tr:focus-within {
    background: rgba(114, 137, 218, 0.07);
}

/* Sticky table headers so column labels stay visible while scrolling */
.table-wrap {
    max-height: 68vh;
    overflow-y: auto;
    overflow-x: auto;
}
.table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    /* keep background opaque so content doesn't show through */
    background: rgba(114, 137, 218, 0.15);
    backdrop-filter: blur(4px);
}
/* db-theme override for sticky headers */
.db-theme .table-wrap thead th {
    background: rgba(60, 20, 110, 0.9);
    backdrop-filter: blur(6px);
}

/* Filter / search box above tables */
.table-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.table-filter-input {
    flex: 1;
    max-width: 300px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(114, 137, 218, 0.3);
    border-radius: 6px;
    color: #ddd;
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.15s;
}
.table-filter-input::placeholder { color: rgba(255,255,255,0.28); }
.table-filter-input:focus { border-color: #7289DA; outline: none; box-shadow: 0 0 0 2px rgba(114,137,218,0.2); }
.db-theme .table-filter-input {
    background: rgba(6, 3, 18, 0.7);
    border-color: rgba(255, 200, 50, 0.3);
    color: var(--text);
}
.db-theme .table-filter-input:focus { border-color: var(--gold); box-shadow: 0 0 8px rgba(255,200,50,0.25); }
.table-filter-count { font-size: 0.78rem; color: rgba(255,255,255,0.35); white-space: nowrap; }

/* "Saved ✓" success flash now shows brief border highlight (existing .save-success handles bg) */
td.save-success { transition: background 0.15s; }

/* ── Hex Library ─────────────────────────────────────────── */
.hex-lib-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(114, 137, 218, 0.2);
    padding-bottom: 0;
}
.hex-lib-tab {
    background: transparent;
    border: none;
    color: #888;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.hex-lib-tab:hover { color: #bbb; }
.hex-lib-tab.active {
    color: #ddd;
    border-bottom-color: #7289DA;
}
/* ── Enemy Type Detail Panel ── */
#enemy-type-detail-panel {
    background: rgba(15, 20, 35, 0.6);
    border: 1px solid rgba(114, 137, 218, 0.2);
    border-radius: 8px;
    padding: 8px 16px 16px;
    margin-top: 12px;
}
.et-detail-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 4px 0 8px;
}
.et-detail-grid .detail-field {
    min-width: 120px;
}
.et-badge-counts {
    font-size: 10px;
    color: #7289DA;
    opacity: 0.7;
    margin-left: 4px;
    vertical-align: middle;
}
.et-props-wrap .detail-field {
    width: 100%;
}
.et-props-wrap .detail-value,
.et-props-wrap .editable {
    font-family: monospace;
    font-size: 12px;
    white-space: pre-wrap;
    max-width: 100%;
    word-break: break-all;
}

.hex-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0 8px;
    border-top: 1px solid rgba(114, 137, 218, 0.15);
    margin-top: 16px;
}
.hex-detail-header h3 { font-size: 1rem; }

/* Hex grid canvas */
.hex-canvas-toolbar {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(15, 20, 35, 0.5);
    border: 1px solid rgba(114, 137, 218, 0.15);
    border-radius: 8px;
}
.hex-canvas-toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.hex-canvas-toolbar-group label {
    font-size: 0.78rem;
    color: #888;
    text-transform: uppercase;
}
.hex-canvas-stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.hex-canvas-stat {
    font-size: 0.78rem;
    color: #aaa;
    padding: 3px 8px;
    background: rgba(15, 20, 35, 0.6);
    border: 1px solid rgba(114, 137, 218, 0.1);
    border-radius: 4px;
}
.hex-canvas-stat strong { color: #ccc; }
.hex-canvas-layout {
    display: flex;
    gap: 16px;
}
.hex-grid-canvas {
    background: #0a0e1a;
    border: 1px solid rgba(114, 137, 218, 0.2);
    border-radius: 8px;
    cursor: crosshair;
    flex-shrink: 0;
}
.hex-canvas-sidebar {
    flex: 1;
    min-width: 200px;
    max-width: 280px;
}
.hex-sidebar-card {
    background: rgba(15, 20, 35, 0.6);
    border: 1px solid rgba(114, 137, 218, 0.15);
    border-radius: 8px;
    padding: 12px;
}
.hex-sidebar-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 8px;
}
.hex-sidebar-field {
    font-size: 0.82rem;
    margin: 4px 0;
    color: #aaa;
}
.hex-sidebar-field .detail-label {
    display: inline-block;
    width: 60px;
    color: #888;
    font-size: 0.78rem;
    text-transform: uppercase;
}

/* Hex type badge colors */
.type-badge.type-normal  { background: rgba(68,170,68,0.2); color: #44aa44; border: 1px solid rgba(68,170,68,0.3); }
.type-badge.type-dungeon { background: rgba(204,68,68,0.2); color: #cc4444; border: 1px solid rgba(204,68,68,0.3); }
.type-badge.type-boss    { background: rgba(170,68,255,0.2); color: #aa44ff; border: 1px solid rgba(170,68,255,0.3); }
.type-badge.type-town    { background: rgba(221,187,34,0.2); color: #ddbb22; border: 1px solid rgba(221,187,34,0.3); }
.type-badge.type-spawn   { background: rgba(68,136,255,0.2); color: #4488ff; border: 1px solid rgba(68,136,255,0.3); }

/* ── Items Editor Panel ────────────────────────────────────────────────────── */
#items-editor-panel {
    background: rgba(15, 20, 35, 0.6);
    border: 1px solid rgba(114, 137, 218, 0.2);
    border-radius: 8px;
    margin-top: 12px;
    overflow: hidden;
}
.ie-layout {
    display: flex;
    min-height: 500px;
    max-height: calc(100vh - 180px);
}
/* Left sidebar — item list */
.ie-sidebar {
    flex: 0 0 260px;
    border-right: 1px solid rgba(114, 137, 218, 0.15);
    display: flex;
    flex-direction: column;
    background: rgba(10, 14, 26, 0.5);
}
.ie-sidebar-header {
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(114, 137, 218, 0.1);
}
.ie-search {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 6px 10px;
    color: #ddd;
    font-size: 0.85rem;
    outline: none;
}
.ie-search:focus {
    border-color: rgba(114, 137, 218, 0.5);
}
.ie-type-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px 12px 4px;
    border-bottom: 1px solid rgba(114, 137, 218, 0.1);
}
.ie-type-tab {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 7px;
    color: #999;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.ie-type-tab:hover { color: #ccc; background: rgba(255,255,255,0.04); }
.ie-type-tab.active {
    color: #7289DA;
    border-color: rgba(114, 137, 218, 0.3);
    background: rgba(114, 137, 218, 0.1);
}
.ie-item-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}
.ie-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.1s;
    border-left: 3px solid transparent;
}
.ie-item-row:hover { background: rgba(255,255,255,0.04); }
.ie-item-row.active {
    background: rgba(114, 137, 218, 0.12);
    border-left-color: #7289DA;
}
.ie-item-row .ie-item-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.ie-item-row .ie-item-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}
.ie-item-row .ie-item-name {
    flex: 1;
    font-size: 0.82rem;
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ie-item-row .ie-item-type-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.06);
    color: #999;
    flex-shrink: 0;
}
.ie-item-row .ie-item-id {
    font-size: 0.7rem;
    color: #666;
    flex-shrink: 0;
}

/* Right detail panel */
.ie-detail {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    min-width: 0;
}
.ie-detail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
}
.ie-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(114, 137, 218, 0.15);
}
.ie-detail-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #eee;
}
.ie-detail-actions {
    display: flex;
    gap: 6px;
}
.ie-btn {
    background: rgba(114, 137, 218, 0.15);
    border: 1px solid rgba(114, 137, 218, 0.25);
    border-radius: 5px;
    padding: 4px 10px;
    color: #99AAF0;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}
.ie-btn:hover {
    background: rgba(114, 137, 218, 0.25);
    border-color: rgba(114, 137, 218, 0.4);
}
.ie-btn-danger {
    color: #ff6b6b;
    border-color: rgba(255,107,107,0.25);
    background: rgba(255,107,107,0.08);
}
.ie-btn-danger:hover {
    background: rgba(255,107,107,0.18);
    border-color: rgba(255,107,107,0.4);
}
.ie-section {
    margin-bottom: 18px;
}
.ie-model-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.ie-model-preview {
    width: 160px;
    height: 160px;
    min-width: 160px;
    border-radius: 8px;
    background: #1a1a2e;
    border: 1px solid rgba(114, 137, 218, 0.2);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ie-model-preview canvas {
    border-radius: 8px;
}
.ie-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #7289DA;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(114, 137, 218, 0.1);
}
.ie-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px 14px;
}
.ie-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.ie-field.full-width {
    grid-column: 1 / -1;
}
.ie-field label {
    font-size: 0.72rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ie-field input,
.ie-field select,
.ie-field textarea {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 5px;
    padding: 5px 8px;
    color: #ddd;
    font-size: 0.82rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}
.ie-field input:focus,
.ie-field select:focus,
.ie-field textarea:focus {
    border-color: rgba(114, 137, 218, 0.5);
}
.ie-field textarea {
    resize: vertical;
    min-height: 48px;
}
.ie-field select {
    cursor: pointer;
}
.ie-field .ie-save-ok {
    border-color: rgba(68,170,68,0.5);
    animation: ie-flash-ok 0.6s ease-out;
}
@keyframes ie-flash-ok {
    0% { background: rgba(68,170,68,0.15); }
    100% { background: rgba(255,255,255,0.06); }
}
.ie-field .ie-save-err {
    border-color: rgba(255,80,80,0.5);
    animation: ie-flash-err 0.6s ease-out;
}
@keyframes ie-flash-err {
    0% { background: rgba(255,80,80,0.15); }
    100% { background: rgba(255,255,255,0.06); }
}
/* Computed stats */
.ie-computed {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}
.ie-stat {
    background: rgba(114, 137, 218, 0.08);
    border: 1px solid rgba(114, 137, 218, 0.15);
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 0.8rem;
    color: #bbb;
}
.ie-stat-label {
    font-size: 0.7rem;
    color: #888;
    display: block;
    margin-bottom: 2px;
}
.ie-stat-value {
    font-weight: 600;
    color: #ddd;
}
/* Reverse lookup lists */
.ie-lookup-list {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
}
.ie-lookup-list li {
    font-size: 0.8rem;
    color: #bbb;
    padding: 3px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ie-lookup-list li .ie-lookup-badge {
    font-size: 0.68rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.06);
    color: #999;
}
.ie-close-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: #888;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}
.ie-close-btn:hover { color: #ddd; }

@media (max-width: 768px) {
    .ie-layout {
        flex-direction: column;
        max-height: none;
    }
    .ie-sidebar {
        flex: none;
        max-height: 280px;
        border-right: none;
        border-bottom: 1px solid rgba(114, 137, 218, 0.15);
    }
}
