/* ───────────────────────── Tokens ───────────────────────── */
:root {
    --bg: #f3f2ec;
    --surface: #ffffff;
    --surface-2: #f8f7f2;
    --surface-3: #efeee7;
    --border: #e2e0d6;
    --border-strong: #cfccbf;
    --text: #1c1e1a;
    --text-2: #4a4e46;
    --muted: #7a7e74;
    --accent: #23794a;
    --accent-hover: #1b653c;
    --accent-soft: #e2f0e7;
    --accent-text: #ffffff;
    --danger: #c23a2c;
    --danger-soft: #fbe7e4;
    --warning: #a86a12;
    --warning-soft: #fbf0dc;
    --info: #2c63c9;
    --info-soft: #e5edfb;
    --chat-bg: #1d201d;
    --chat-surface: #262a26;
    --chat-text: #e6e8e2;
    --chat-muted: #8d948a;
    --shadow-sm: 0 1px 2px rgba(28, 30, 26, .06);
    --shadow: 0 1px 2px rgba(28, 30, 26, .05), 0 8px 24px -8px rgba(28, 30, 26, .12);
    --shadow-lg: 0 24px 64px -16px rgba(28, 30, 26, .28);
    --radius: 10px;
    --radius-sm: 7px;
    --radius-lg: 14px;
    --sidebar: 248px;
    --panel: clamp(420px, 34vw, 680px);
    --font: "Manrope", ui-sans-serif, system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111311;
        --surface: #191c19;
        --surface-2: #1e221e;
        --surface-3: #252a25;
        --border: #2b302b;
        --border-strong: #3a413a;
        --text: #e8eae4;
        --text-2: #c0c5bc;
        --muted: #8e958b;
        --accent: #4fbf80;
        --accent-hover: #63cf92;
        --accent-soft: #1d3326;
        --accent-text: #0d1a12;
        --danger: #ef6b5c;
        --danger-soft: #3a1d19;
        --warning: #e3a447;
        --warning-soft: #362a16;
        --info: #77a3f2;
        --info-soft: #1b2741;
        --chat-bg: #141614;
        --chat-surface: #1d211d;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -8px rgba(0, 0, 0, .5);
        --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .7);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #111311;
    --surface: #191c19;
    --surface-2: #1e221e;
    --surface-3: #252a25;
    --border: #2b302b;
    --border-strong: #3a413a;
    --text: #e8eae4;
    --text-2: #c0c5bc;
    --muted: #8e958b;
    --accent: #4fbf80;
    --accent-hover: #63cf92;
    --accent-soft: #1d3326;
    --accent-text: #0d1a12;
    --danger: #ef6b5c;
    --danger-soft: #3a1d19;
    --warning: #e3a447;
    --warning-soft: #362a16;
    --info: #77a3f2;
    --info-soft: #1b2741;
    --chat-bg: #141614;
    --chat-surface: #1d211d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -8px rgba(0, 0, 0, .5);
    --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

/* ───────────────────────── Base ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; letter-spacing: -0.02em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────────────────────── Shell ───────────────────────── */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
}

body.has-panel .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr) auto; }

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    min-height: 0;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 16px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-text);
    display: grid;
    place-items: center;
    font-size: 18px;
    flex-shrink: 0;
    object-fit: cover;
}

.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.nav-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 14px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    border: 0;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.nav-room { font-weight: 500; font-size: 13px; padding: 5px 10px 5px 14px; }
.nav-room .code { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: auto; }
.nav-empty { font-size: 12.5px; color: var(--muted); padding: 4px 14px; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conn {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    padding: 6px 10px;
}

.main {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.page {
    padding: 24px 28px 40px;
    max-width: 1480px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page.full { max-width: none; height: 100%; padding-bottom: 20px; min-height: 0; }

.page-head {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.page-head .titles { flex: 1; min-width: 220px; }
.page-head .eyebrow { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }

.mobile-bar, .nav-backdrop { display: none; }

/* ───────────────────────── Surfaces ───────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.card-head h2 { font-size: 14.5px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-dash { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

/* ───────────────────────── Stats ───────────────────────── */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat-label svg { width: 14px; height: 14px; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.stat-foot { font-size: 12px; color: var(--muted); }

.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s; }

/* ───────────────────────── Buttons & inputs ───────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-weight: 650;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s, color .12s;
    text-decoration: none !important;
}

.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.hint { font-size: 12px; color: var(--muted); }

.input, .select, .textarea {
    width: 100%;
    height: 36px;
    padding: 0 11px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .12s, box-shadow .12s;
    min-width: 0;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.input.sm, .select.sm { height: 30px; font-size: 13px; padding: 0 9px; }
.input.mono { font-family: var(--mono); letter-spacing: 0.06em; }
.textarea { height: auto; min-height: 80px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7e74' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }

.search {
    position: relative;
    display: flex;
    align-items: center;
}
.search svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 32px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13px; user-select: none; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; font-size: 13px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 32px; height: 18px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented {
    display: inline-flex;
    background: var(--surface-3);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
}

.segmented button {
    border: 0;
    background: transparent;
    padding: 4px 11px;
    border-radius: 5px;
    font-weight: 650;
    font-size: 12.5px;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
}

.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs button {
    border: 0;
    background: none;
    padding: 11px 10px;
    font-weight: 650;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs button .count { font-size: 11px; color: var(--muted); margin-left: 4px; }

/* ───────────────────────── Badges ───────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 21px;
    padding: 0 8px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--surface-3);
    color: var(--text-2);
    white-space: nowrap;
}

.badge.green { background: var(--accent-soft); color: var(--accent); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); }
.badge.mono { font-family: var(--mono); letter-spacing: .04em; }
.badge svg { width: 12px; height: 12px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.online { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.dot.connecting, .dot.reconnecting { background: var(--warning); animation: pulse 1.2s infinite; }
.dot.closed, .dot.offline { background: var(--danger); }

@keyframes pulse { 50% { opacity: .35; } }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: 5px;
    font-size: 11.5px;
    font-weight: 650;
    background: var(--surface-3);
    color: var(--text-2);
}

/* ───────────────────────── Tables ───────────────────────── */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th {
    text-align: left;
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .arrow { font-size: 10px; margin-left: 3px; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table tbody tr.selected td { background: var(--accent-soft); }
.table td.num, .table th.num { text-align: right; }
.table .cell-clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table.dense td { padding: 6px 12px; }
.table .null { color: var(--muted); font-style: italic; }

.empty {
    padding: 36px 16px;
    text-align: center;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.empty svg { width: 28px; height: 28px; opacity: .6; }

.pager {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--muted);
}

/* ───────────────────────── Rooms (dashboard) ───────────────────────── */
.room-list { display: flex; flex-direction: column; }

.room-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.room-row:last-child { border-bottom: 0; }
.room-row:hover { background: var(--surface-2); }
.room-row .name { font-weight: 700; }
.room-row .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.room-row .players { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 64px; }
.room-row .players small { display: block; font-weight: 600; color: var(--muted); font-size: 11.5px; }
.room-row .actions { display: flex; gap: 4px; }

/* ───────────────────────── Room page ───────────────────────── */
/* Children of a full-height page never shrink, only the chat grows/shrinks (and the page scrolls when too short) */
.page.full > * { flex-shrink: 0; }
.page.full > .room-chat { flex: 1 0 0; }
.room-tabs { padding: 0; margin-top: -4px; overflow: visible; }
.room-tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; }

.room-chat {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
    flex: 1;
    min-height: 520px;
}

.room-chat > .card { display: flex; flex-direction: column; min-height: 0; }

.room-game {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

.panel-scroll { overflow-y: auto; min-height: 0; flex: 1; }

.chatter {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.chatter:hover { background: var(--surface-2); }
.chatter:last-child { border-bottom: 0; }
.chatter .nick { font-weight: 700; font-size: 13px; }
.chatter .sub { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.chatter .more { opacity: 0; transition: opacity .1s; }
.chatter:hover .more, .chatter .more[aria-expanded="true"] { opacity: 1; }

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-3);
    flex-shrink: 0;
}
.avatar.sm { width: 26px; height: 26px; }

.chat-card { background: var(--chat-bg) !important; border-color: var(--chat-bg) !important; color: var(--chat-text); overflow: hidden; }
.chat-card .card-head { border-color: rgba(255, 255, 255, .07); }
.chat-card .card-head h2 { color: var(--chat-text); }
.chat-card .card-head .sub { color: var(--chat-muted); }

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 10px 6px 10px 12px;
    min-height: 0;
    scrollbar-color: #3a3f3a transparent;
}

.msg {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 9px;
    padding: 4px 8px;
    border-radius: 7px;
}
.msg:hover { background: rgba(255, 255, 255, .03); }
.msg.cont { padding-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg-head { display: flex; align-items: baseline; gap: 7px; font-size: 12.5px; }
.msg-head .author { font-weight: 700; color: #f2f3ef; cursor: pointer; }
.msg-head .author:hover { text-decoration: underline; }
.msg-head .time { color: var(--chat-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.msg-head .tag { font-size: 10px; font-weight: 800; padding: 0 5px; border-radius: 4px; background: rgba(255, 255, 255, .1); color: #cfd3cc; text-transform: uppercase; letter-spacing: .04em; }
.msg-head .tag.bot { background: #23794a; color: #fff; }
.msg-head .tag.mod { background: #2c63c9; color: #fff; }
.msg-text { font-size: 13.5px; word-break: break-word; white-space: pre-wrap; padding: 1px 0; color: var(--chat-text); }
.msg-text.styled { padding: 1px 4px; border-radius: 3px; display: inline; }
.msg.self .msg-head .author { color: #7fd8a4; }

.console-block {
    margin: 6px 8px;
    border: 1px solid rgba(255, 255, 255, .09);
    background: rgba(255, 255, 255, .03);
    border-radius: 8px;
    font-size: 12.5px;
    overflow: hidden;
}
.console-block .cmd {
    font-family: var(--mono);
    color: #9fe3bb;
    padding: 6px 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(255, 255, 255, .03);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.console-block .cmd .as { color: var(--chat-muted); font-family: var(--font); font-size: 11.5px; margin-left: auto; }
.console-block .out { padding: 6px 10px; white-space: pre-wrap; word-break: break-word; color: var(--chat-text); }
.console-block .out + .out { border-top: 1px dashed rgba(255, 255, 255, .06); }
.console-block .state { padding: 5px 10px; color: var(--chat-muted); font-size: 11.5px; }
.console-block.error .state { color: #ff8c7e; }

.composer {
    border-top: 1px solid rgba(255, 255, 255, .07);
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    background: var(--chat-surface);
}

.composer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.composer .segmented { background: rgba(255, 255, 255, .06); }
.composer .segmented button { color: var(--chat-muted); }
.composer .segmented button.active { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: none; }

.composer-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: rgba(0, 0, 0, .25);
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 9px;
    padding: 6px 6px 6px 10px;
}
.composer-input:focus-within { border-color: #4fbf80; }
.composer-input .prefix { font-family: var(--mono); color: #9fe3bb; padding-bottom: 6px; font-weight: 700; }
.composer-input textarea {
    flex: 1;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--chat-text);
    resize: none;
    min-height: 22px;
    max-height: 140px;
    line-height: 1.45;
    padding: 4px 0;
}
.composer-input.command textarea { font-family: var(--mono); font-size: 13px; }
.composer .chars { font-size: 11px; color: var(--chat-muted); font-variant-numeric: tabular-nums; }
.composer .select.sm {
    background-color: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .1);
    color: var(--chat-text);
    width: auto;
    max-width: 200px;
}
.composer .select.sm option { color: initial; background: initial; }
.composer .btn.ghost { color: var(--chat-muted); }
.composer .btn.ghost:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.composer .label-inline { font-size: 11.5px; color: var(--chat-muted); font-weight: 600; }

.suggestions {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% - 4px);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
    z-index: 20;
}
.suggestion {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 10px;
    padding: 6px 9px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
}
.suggestion.active, .suggestion:hover { background: var(--accent-soft); }
.suggestion .name { font-family: var(--mono); font-weight: 700; }
.suggestion .desc { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.style-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 9px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .05);
    color: var(--chat-text);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 650;
}
.style-chip:hover { background: rgba(255, 255, 255, .1); }
.style-chip .swatch { font-weight: 700; padding: 0 4px; border-radius: 3px; }

/* Game state */
.lives { color: var(--danger); letter-spacing: 1px; font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.game-meta { gap: 6px; }
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.pcard {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    min-width: 0;
}
.pcard.current { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.pcard.dead { opacity: .5; }
.pcard-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pcard-head .nick { font-weight: 750; font-size: 13.5px; }
.pcard.dead .nick { text-decoration: line-through; }

.live-word {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    overflow: hidden;
}
.live-word .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.live-word mark { background: var(--warning-soft); color: var(--warning); border-radius: 3px; padding: 0 1px; }
.live-word.typing { border-color: var(--accent); }
.live-word.typing .text::after { content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--accent); animation: pulse 1s infinite; }
.live-word.idle { color: var(--text-2); }
.live-word.valid { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.live-word.invalid { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.live-word.invalid .text { text-decoration: line-through; }
.live-word .reason { font-family: var(--font); font-size: 11.5px; font-weight: 650; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.live-word svg { flex-shrink: 0; }

.pstats { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 4px 12px; font-size: 12px; }
.pstat { display: flex; justify-content: space-between; gap: 6px; min-width: 0; }
.pstat span { color: var(--muted); font-weight: 600; white-space: nowrap; }
.pstat b { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcats { display: flex; flex-wrap: wrap; gap: 4px; }
.pcard-foot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pcard-foot .recent { display: flex; gap: 4px; overflow: hidden; min-width: 0; mask-image: linear-gradient(to right, #000 85%, transparent); }
.pcard-foot .recent .chip { flex-shrink: 0; text-transform: lowercase; }

.words-list { max-height: 55vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.word-row { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.word-row:last-child { border-bottom: 0; }
.word-row .time { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ───────────────────────── Menus, popovers, modals ───────────────────────── */
.menu {
    position: fixed;
    min-width: 190px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    z-index: 100;
    animation: pop .12s ease-out;
}
.menu button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    border: 0;
    background: none;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    color: var(--text);
}
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); }
.menu button svg { width: 15px; height: 15px; color: var(--muted); }
.menu button.danger svg { color: inherit; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.menu .menu-title { font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 10px 4px; text-transform: uppercase; letter-spacing: .06em; }

@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 19, 17, .45);
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 16px;
    animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: min(440px, 100%);
    /* dvh: on mobile, 100vh is taller than the visible area and would hide the head and the foot */
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pop .15s ease-out;
}
.modal.wide { width: min(720px, 100%); }
/* Only the body scrolls, the title, close button and actions stay visible */
.modal-head { padding: 18px 20px 6px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.modal-body { padding: 8px 20px 16px; color: var(--text-2); overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal-foot { padding: 12px 20px 18px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* Side panel: docked on the right of any view, stacked panels get a back button */
.side-panel {
    width: var(--panel);
    min-width: 0;
    min-height: 0;
    background: var(--bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    animation: slide .2s ease-out;
}
.side-panel[hidden], .panel-back[hidden] { display: none; }
.side-panel { position: relative; }
.panel-resize {
    position: absolute;
    inset: 0 auto 0 -4px;
    width: 8px;
    cursor: col-resize;
    z-index: 3;
    touch-action: none;
}
.panel-resize:hover, .panel-resize.active { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px 5px, transparent 5px); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.side-panel-head {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.panel-title { min-width: 0; }
.panel-title h2 { min-width: 0; }
.panel-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    max-width: 100%;
    border: 0;
    background: none;
    padding: 2px 6px 2px 2px;
    margin-left: -4px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.panel-back:hover { background: var(--surface-3); color: var(--text); }
.side-panel-body { flex: 1; overflow-y: auto; padding: 18px 20px 32px; display: flex; flex-direction: column; gap: 16px; }

/* Toasts */
.toasts {
    position: fixed;
    bottom: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 300;
    max-width: min(380px, calc(100vw - 36px));
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--text);
    color: var(--bg);
    padding: 10px 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 600;
    animation: pop .15s ease-out;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast.success svg { color: #6fdc9c; }
.toast.error svg { color: #ff8c7e; }
.toast.warning svg { color: #f2bd62; }
.toast.info svg { color: #8fb4f5; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .2s; }

/* Style editor */
.style-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.style-preview {
    background: var(--chat-bg);
    border-radius: var(--radius);
    padding: 14px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.style-preview .msg { padding: 0; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type="color"] { width: 36px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; flex-shrink: 0; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset {
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    padding: 5px 9px;
    background: var(--chat-bg);
    cursor: pointer;
    font-size: 12.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--chat-text);
}
.preset.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.preset .x { color: var(--chat-muted); margin-left: 2px; font-size: 14px; line-height: 1; }
.preset .x:hover { color: #ff8c7e; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-row output { font-family: var(--mono); font-size: 12px; min-width: 44px; text-align: right; color: var(--muted); }

/* Dictionary */
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.word-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    cursor: pointer;
    min-width: 0;
}
.word-cell:hover { background: var(--surface-2); }
.word-cell.selected { background: var(--accent-soft); }
.word-cell .w { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-cell .cats { display: flex; gap: 3px; margin-left: auto; }
.cat-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.syll-list { display: flex; flex-wrap: wrap; gap: 6px; }
.syll {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    font-family: var(--mono);
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--surface-3);
    text-transform: uppercase;
    font-size: 12.5px;
}
.syll small { font-weight: 600; color: var(--muted); font-size: 11px; }
.syll.sub8 { background: var(--danger-soft); color: var(--danger); }
.syll.sub50 { background: var(--warning-soft); color: var(--warning); }
.syll.sub500 { background: var(--info-soft); color: var(--info); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 60px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .track { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-row .track span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .field { flex: 0 1 auto; }

/* Chatbot conversations */
.page.full > .convo-layout { flex: 1 0 0; }
.convo-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
    flex: 1;
    min-height: 520px;
}
.convo-layout > .card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.convo-list { padding: 6px; }
.convo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
}
.convo-item:hover { background: var(--surface-2); text-decoration: none; }
.convo-item.active { background: var(--accent-soft); }
.convo-item .time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.convo-item .preview { font-size: 12.5px; color: var(--muted); }

.avatar.initial {
    display: inline-grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    background: var(--muted);
    text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

.convo-placeholder { flex: 1; display: grid; place-items: center; }
.convo-back { display: none; }

.convo-scroll { flex: 1; overflow-y: auto; min-height: 0; background: var(--surface-2); }
.convo-thread { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; max-width: 900px; margin: 0 auto; }
.convo-more { display: flex; justify-content: center; padding-bottom: 8px; }

.convo-day { display: flex; justify-content: center; margin: 10px 0 4px; }
.convo-day span {
    font-size: 11.5px;
    font-weight: 650;
    color: var(--muted);
    background: var(--surface-3);
    padding: 3px 10px;
    border-radius: 999px;
}

.bubble-row { display: flex; }
.bubble-row.bot { justify-content: flex-end; margin-bottom: 8px; }
.bubble {
    max-width: min(75%, 620px);
    padding: 8px 12px 6px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.bubble-row.player .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.bubble-row.bot .bubble { background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 5px; }
.bubble-time { display: block; text-align: right; font-size: 10.5px; opacity: .65; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Database browser */
.db-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.table-list { max-height: calc(100vh - 220px); overflow-y: auto; padding: 6px; }
.table-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 9px;
    border: 0;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
    font-family: var(--mono);
    text-align: left;
    color: var(--text-2);
}
.table-item:hover { background: var(--surface-3); }
.table-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.table-item .n { margin-left: auto; color: var(--muted); font-size: 11px; font-family: var(--font); font-weight: 600; }
.table-item.empty-table { opacity: .55; }
.db-viewer .table-wrap { max-height: calc(100vh - 290px); overflow: auto; }

.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.export-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface-2);
}
.export-card h3 { display: flex; align-items: center; gap: 8px; }
.export-card h3 svg { width: 16px; height: 16px; color: var(--accent); }
.export-card p { color: var(--muted); font-size: 12.5px; flex: 1; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 30px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--warning-soft);
    color: var(--warning);
    font-weight: 650;
    font-size: 13px;
}
.banner svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ───────────────────────── Anticheat ───────────────────────── */
/*
 * Chart colors: validated categorical slots (all-pairs, light and dark), and an ordinal one-hue ramp for the
 * levels (Info → Certain), the most severe level being the most contrasted against the surface in both themes
 */
:root {
    --viz-1: #2a78d6;
    --viz-2: #eb6834;
    --viz-3: #1baf7a;
    --viz-muted: #b9b7ad;
    --viz-ref: #52514e;
    --lvl-0: #b9b7ad;
    --lvl-1: #f9875e;
    --lvl-2: #d6673f;
    --lvl-3: #b4481e;
    --lvl-4: #922800;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --viz-1: #3987e5;
        --viz-2: #d95926;
        --viz-3: #199e70;
        --viz-muted: #55554f;
        --viz-ref: #c3c2b7;
        --lvl-0: #55554f;
        --lvl-1: #a94620;
        --lvl-2: #cd6642;
        --lvl-3: #f28862;
        --lvl-4: #ffaa83;
    }
}
:root[data-theme="dark"] {
    --viz-1: #3987e5;
    --viz-2: #d95926;
    --viz-3: #199e70;
    --viz-muted: #55554f;
    --viz-ref: #c3c2b7;
    --lvl-0: #55554f;
    --lvl-1: #a94620;
    --lvl-2: #cd6642;
    --lvl-3: #f28862;
    --lvl-4: #ffaa83;
}

.notice { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); background: var(--info-soft); color: var(--text-2); font-size: 13px; }
.notice svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--info); }
.notice.warning { background: var(--warning-soft); }
.notice.warning svg { color: var(--warning); }

/* The level is carried by the dot, the text stays in the text color */
.lvl-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lvl-0); flex-shrink: 0; }
.lvl-0 > .lvl-dot, .lvl-dot.lvl-0 { background: var(--lvl-0); }
.lvl-1 > .lvl-dot, .lvl-dot.lvl-1 { background: var(--lvl-1); }
.lvl-2 > .lvl-dot, .lvl-dot.lvl-2 { background: var(--lvl-2); }
.lvl-3 > .lvl-dot, .lvl-dot.lvl-3 { background: var(--lvl-3); }
.lvl-4 > .lvl-dot, .lvl-dot.lvl-4 { background: var(--lvl-4); }
.badge.lvl { background: var(--surface-3); color: var(--text); }
.badge.lvl-4 { background: var(--danger-soft); }
.chip.lvl-chip { gap: 5px; }
.chip.lvl-0 { opacity: .7; }

.refreshing { opacity: .55; transition: opacity .15s; }

.ac-top { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.ac-review .segmented { display: flex; flex-wrap: wrap; }
.ac-review .segmented button { flex: 1 0 auto; }
.ac-overview { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.ac-flags { display: flex; flex-direction: column; }
.ac-flag { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.ac-flag:last-child { border-bottom: 0; }
.ac-flag summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.ac-flag summary::-webkit-details-marker { display: none; }
.ac-flag[open] > summary { margin-bottom: 4px; }
.ac-flag > :not(summary) { margin-left: 2px; }
.ac-kv { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr) minmax(50px, auto)); }

.ac-suspects { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; }
.ac-suspect { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); color: inherit; }
.ac-suspect:hover { background: var(--surface-2); text-decoration: none; }
.ac-suspect:last-child { border-bottom: 0; }

.ac-turns td { vertical-align: middle; }
.ac-word mark, .replay-log mark { background: var(--warning-soft); color: var(--warning); border-radius: 3px; padding: 0 1px; }
.ac-word .chip { margin-left: 6px; }

.ac-threshold { gap: 12px; align-items: center; }
.ac-slider { flex: 1; min-width: 200px; accent-color: var(--accent); }

/* Charts */
.viz-figure { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.viz-box { width: 100%; min-width: 0; }
.viz { display: block; overflow: visible; font-family: var(--font); }
.viz-grid { stroke: var(--border); stroke-width: 1; }
.viz-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-ref { stroke: var(--viz-ref); stroke-width: 1; opacity: .7; }
.viz-ref-label { fill: var(--text-2); font-size: 11px; font-weight: 650; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.viz-band { fill: var(--surface-3); }
.viz-dot { stroke: var(--surface); stroke-width: 2; transition: r .1s; }
.viz-point:hover .viz-dot { r: 6; }
.viz-hit { fill: transparent; }
.viz-hit:hover { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.viz-point.clickable, .viz-hit.clickable { cursor: pointer; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); }
.viz-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; flex-shrink: 0; }
.viz-swatch.dot { border-radius: 50%; }
.viz-swatch.rect { border-radius: 2px; }
.viz-tip {
    position: fixed;
    z-index: 300;
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 8px 10px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 320px;
}
.viz-tip-title { font-weight: 700; color: var(--text); margin-bottom: 2px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.viz-tip-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.viz-key { width: 12px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.viz-bars { display: flex; flex-direction: column; gap: 4px; }
.viz-bar-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 56px; align-items: center; gap: 10px; font-size: 12px; padding: 2px 0; border-radius: 4px; }
.viz-bar-row:hover, .viz-bar-row:focus-visible { background: var(--surface-2); outline: none; }
.viz-bar-label { text-align: right; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.viz-bar-track { position: relative; height: 14px; }
.viz-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 2px; }
.viz-bar-ref { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--viz-ref); border-radius: 1px; }
.viz-bar-value { color: var(--text-2); font-variant-numeric: tabular-nums; text-align: right; }

/* Replay */
.replay { display: flex; flex-direction: column; gap: 12px; outline: none; }
.replay:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); border-radius: var(--radius); }
.replay-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 24px; }
.replay-stage { display: flex; flex-direction: column; gap: 6px; }
.replay-word { min-height: 60px; font-size: 28px; padding: 10px 16px; }
.replay-status { min-height: 18px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.replay-status .long { color: var(--warning); }
.replay-track-wrap { display: flex; flex-direction: column; gap: 6px; }
.replay-track { position: relative; height: 34px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; overflow: hidden; }
.replay-mark { position: absolute; top: 6px; bottom: 6px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--viz-1); }
.replay-mark.delete, .replay-mark.replace { background: var(--viz-2); }
.replay-mark.attempt { background: var(--lvl-4); top: 2px; bottom: 2px; width: 4px; margin-left: -2px; }
.replay-mark.valid { background: var(--accent); top: 2px; bottom: 2px; width: 4px; margin-left: -2px; }
.replay-pattern { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, var(--surface-3) 0 6px, transparent 6px 12px); }
.replay-start { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--viz-ref); }
.replay-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }
.replay-track-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); }
.replay-track-legend span { display: inline-flex; align-items: center; gap: 5px; }
.replay-track-legend .k { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--viz-1); }
.replay-track-legend .k.delete { background: var(--viz-2); }
.replay-track-legend .k.attempt { background: var(--lvl-4); }
.replay-track-legend .k.valid { background: var(--accent); }
.replay-track-legend .k.pattern { background: repeating-linear-gradient(45deg, var(--border-strong) 0 3px, transparent 3px 6px); border: 1px solid var(--border); }
.replay-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.replay-clock { font-size: 12.5px; color: var(--text-2); min-width: 130px; }
.replay-log { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); display: flex; flex-direction: column; }
.replay-log-row {
    display: grid;
    grid-template-columns: 70px 70px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 4px 10px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    text-align: left;
    font-size: 12.5px;
    cursor: pointer;
}
.replay-log-row:last-child { border-bottom: 0; }
.replay-log-row:hover { background: var(--surface-2); }
.replay-log-row.current { background: var(--accent-soft); }
.replay-log-row .t { color: var(--text-2); }
.replay-log-row .gap { color: var(--muted); }
.replay-log-row .gap.long { color: var(--warning); font-weight: 700; }
.replay-log-row .text { text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replay-log-row .detail { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.replay-log-row.attempt .detail { color: var(--danger); font-weight: 650; }
.replay-log-row.valid .detail { color: var(--accent); font-weight: 650; }
.replay-log-row.delete .detail, .replay-log-row.replace .detail { color: var(--warning); }

@media (max-width: 1100px) {
    .ac-top, .ac-overview { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
    .replay-word { font-size: 20px; }
    .replay-log-row { grid-template-columns: 60px 60px minmax(0, 1fr); }
    .replay-log-row .detail { display: none; }
    .ac-kv { grid-template-columns: auto 1fr; }
}

/* ───────────────────────── Responsive ───────────────────────── */
@media (max-width: 1280px) {
    .room-chat { grid-template-columns: 250px minmax(0, 1fr); }
}

/* Not enough room to dock the side panel next to the view: it floats over it */
@media (max-width: 1279px) {
    body.has-panel .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
    .side-panel {
        position: fixed;
        inset: 0 0 0 auto;
        width: min(var(--panel), 100vw);
        z-index: 120;
        box-shadow: var(--shadow-lg);
    }
}

@media (max-width: 1100px) {
    .grid-dash { grid-template-columns: minmax(0, 1fr); }
    .db-layout { grid-template-columns: minmax(0, 1fr); }
    .table-list { max-height: 240px; }
}

@media (max-width: 860px) {
    .shell, body.has-panel .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(280px, 85vw);
        z-index: 150;
        transform: translateX(-100%);
        transition: transform .2s;
        box-shadow: var(--shadow-lg);
    }
    .shell.nav-open .sidebar { transform: none; }
    .shell.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 140; animation: fade .15s ease-out; }
    .mobile-bar {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 16px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }
    .page { padding: 16px 16px 32px; }
    .room-chat { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; min-height: 0; }
    .page.full > .room-chat { flex: none; }
    .room-chat .chat-card { height: 78vh; order: -1; }
    .room-chat .panel-scroll { flex: none; max-height: 50vh; }
    .room-game { grid-template-columns: minmax(0, 1fr); }
    .convo-layout { grid-template-columns: minmax(0, 1fr); height: 78vh; min-height: 0; }
    .page.full > .convo-layout { flex: none; }
    .convo-layout.has-selection .convo-players, .convo-layout:not(.has-selection) .convo-chat { display: none; }
    .convo-back { display: inline-flex; }
    .bubble { max-width: 88%; }
    .page.full { height: auto; }
    .grid-2, .grid-3, .style-editor { grid-template-columns: minmax(0, 1fr); }
    .room-row { grid-template-columns: auto minmax(0, 1fr) auto; }
    .room-row .actions { display: none; }
    .stat-value { font-size: 20px; }
    .suggestion { grid-template-columns: minmax(0, 1fr); }
    .suggestion .desc { display: none; }

    /* Card toolbars (rooms, database table…) wrap, their search takes a whole line */
    .card-head { flex-wrap: wrap; row-gap: 8px; }
    .card-head h2 { min-width: 0; overflow-wrap: anywhere; }
    .card-head > .search { flex: 1 1 100%; }
    .card-head > .search .input { width: 100% !important; }
    .card-head > .segmented { display: flex; flex-wrap: wrap; flex: 1 1 auto; }
    .card-head > .segmented button { flex: 1 0 auto; }

    /* Filters never get wider than the screen: segmented controls wrap their options */
    .filters .field { max-width: 100%; }
    .filters .segmented { display: flex; flex-wrap: wrap; }
    .filters .segmented button { flex: 1 0 auto; }

    /* Sticky table headers float over the side panel without a frame around them */
    .side-panel .table th { position: static; }
}
