/* ── Reset & Base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         #0e0e10;
    --bg-card:    #18181b;
    --bg-hover:   #1f1f23;
    --bg-input:   #121214;
    --border:     #2a2a2e;
    --border-focus:#5c5cf0;
    --text:       #e4e4e7;
    --text-dim:   #8b8b94;
    --accent:     #6d5dfc;
    --accent-glow: rgba(109, 93, 252, .25);
    --green:      #34d399;
    --red:        #f87171;
    --orange:     #fbbf24;
    --radius:     10px;
    --radius-sm:  6px;
    --transition: 150ms ease;
    --font:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Header ───────────────────────────────────────── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 22px;
    color: var(--accent);
    line-height: 1;
}

header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Badges ───────────────────────────────────────── */
.badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 3px 10px;
    border-radius: 20px;
}

.badge-ok {
    background: rgba(52, 211, 153, .12);
    color: var(--green);
}

.badge-err {
    background: rgba(248, 113, 113, .12);
    color: var(--red);
}

.meta-text {
    font-size: 12px;
    color: var(--text-dim);
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 16px;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 0 16px var(--accent-glow);
}

.btn-small {
    font-size: 12px;
    padding: 5px 12px;
}

.btn-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, .25);
    font-size: 11px;
    padding: 3px 8px;
}

.btn-danger:hover {
    background: rgba(248, 113, 113, .1);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
    border-radius: 4px;
    transition: color var(--transition), background var(--transition);
}

.btn-icon:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* ── Modal ────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 380px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal h2 {
    font-size: 17px;
    font-weight: 600;
}

.modal input, .modal select {
    font-family: var(--font);
    font-size: 14px;
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition);
}

.modal input:focus, .modal select:focus {
    border-color: var(--border-focus);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

.error-text {
    font-size: 12px;
    color: var(--red);
}

/* ── Info bar ─────────────────────────────────────── */
.info-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 28px;
    font-size: 13px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.info-bar strong {
    color: var(--text);
    font-weight: 500;
}

/* ── Main & Category ──────────────────────────────── */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 0 60px;
}

.category {
    padding: 24px 28px 8px;
}

.category h2 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cat-icon {
    font-size: 16px;
    color: var(--accent);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

/* ── Cards ────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: #3a3a3e;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.card-key {
    font-size: 14px;
    font-weight: 500;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-value {
    font-size: 12px;
    color: var(--text-dim);
}

.card-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Toggle Switch ────────────────────────────────── */
.toggle-switch {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: #333;
    border-radius: 12px;
    transition: background var(--transition);
    cursor: pointer;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
}

.toggle-switch input:checked + .toggle-track {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(18px);
}

.toggle-switch.readonly .toggle-track {
    cursor: default;
    opacity: .6;
}

/* ── Number input ─────────────────────────────────── */
.num-input {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.num-input button {
    font-family: var(--font);
    font-size: 15px;
    width: 30px;
    height: 30px;
    background: var(--bg-hover);
    color: var(--text);
    border: none;
    cursor: pointer;
    transition: background var(--transition);
}

.num-input button:hover {
    background: var(--accent);
    color: #fff;
}

.num-input input {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    width: 64px;
    text-align: center;
    background: var(--bg-input);
    color: var(--text);
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    outline: none;
    padding: 4px 0;
    height: 30px;
}

/* ── String edit ──────────────────────────────────── */
.str-input {
    font-family: var(--font);
    font-size: 13px;
    padding: 6px 10px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    width: 180px;
    max-width: 100%;
    transition: border-color var(--transition);
}

.str-input:focus {
    border-color: var(--border-focus);
}

.str-input:read-only {
    cursor: default;
    border-color: transparent;
    background: transparent;
    color: var(--text-dim);
}

/* ── Value badges (read-only) ─────────────────────── */
.val-badge {
    font-size: 13px;
    font-weight: 500;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    color: var(--text);
    white-space: nowrap;
}

.val-true { color: var(--green); }
.val-false { color: var(--red); }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 640px) {
    header { padding: 12px 16px; flex-wrap: wrap; }
    .category { padding: 18px 16px 8px; }
    .info-bar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
    .grid { grid-template-columns: 1fr; }
    .str-input { width: 120px; }
    .world-selector { width: 100%; }
    .world-selector select { width: 100%; }
}

/* ── World selector ───────────────────────────────── */
.world-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.world-selector select {
    font-family: var(--font);
    font-size: 13px;
    padding: 5px 10px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    max-width: 240px;
    transition: border-color var(--transition);
}

.world-selector select:focus {
    border-color: var(--border-focus);
}

.world-selector select:disabled {
    opacity: .5;
    cursor: default;
}

/* ── No worlds message ────────────────────────────── */
.no-worlds {
    text-align: center;
    padding: 60px 28px;
    color: var(--text-dim);
}

.no-worlds p:first-child {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

/* ── Player Lists (GMMenu) ────────────────────────── */
.lists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 4px;
}

.list-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.list-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 3px 10px;
    border-radius: 20px;
}

.list-gm          { background: rgba(109, 93, 252, .18); color: #a08eff; }
.list-facilitator { background: rgba(251, 191, 36, .15);  color: var(--orange); }
.list-deactivated { background: rgba(248, 113, 113, .12); color: var(--red); }

.list-url {
    font-size: 11px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--text-dim);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 7px;
    white-space: nowrap;
}

.list-textarea {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    width: 100%;
    min-height: 120px;
    resize: vertical;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    outline: none;
    transition: border-color var(--transition);
}

.list-textarea:focus {
    border-color: var(--border-focus);
}

.list-textarea:read-only {
    cursor: default;
    color: var(--text-dim);
}

.list-actions {
    display: flex;
    justify-content: flex-end;
}
