/* rustplusplus web interface */

:root {
    --bg: #0d0f12;
    --bg-elevated: #14171c;
    --surface: #191d23;
    --surface-2: #20252d;
    --surface-3: #2a3039;
    --border: #2a3039;
    --border-strong: #3a414c;
    --text: #e7e9ec;
    --text-muted: #9aa3af;
    --text-faint: #6b7280;
    --accent: #e8622c;
    --accent-strong: #ff7a3d;
    --accent-soft: rgba(232, 98, 44, 0.14);
    --green: #3ecf8e;
    --green-soft: rgba(62, 207, 142, 0.14);
    --red: #f2555a;
    --red-soft: rgba(242, 85, 90, 0.14);
    --yellow: #f5c04e;
    --yellow-soft: rgba(245, 192, 78, 0.14);
    --blue: #5b9cff;
    --blue-soft: rgba(91, 156, 255, 0.14);
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --sidebar: 248px;
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; }

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

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
code, pre { font-family: var(--mono); font-size: 0.86em; }
pre { white-space: pre-wrap; word-break: break-word; }
::selection { background: var(--accent-soft); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }

/* ---------- Layout ---------- */

.app {
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 14px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 14px;
    font-weight: 700;
    font-size: 1.05rem;
}
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand small { display: block; font-weight: 500; color: var(--text-faint); font-size: 0.75rem; }

.guild-select {
    width: 100%;
    margin-bottom: 10px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
    margin: 14px 10px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 550;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav a .icon { width: 19px; height: 19px; flex: none; }

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 8px 2px;
    border-top: 1px solid var(--border);
}
.sidebar-footer .avatar { width: 34px; height: 34px; }
.sidebar-footer .who { flex: 1; min-width: 0; }
.sidebar-footer .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .who span { font-size: 0.78rem; color: var(--text-faint); }

.main {
    min-width: 0;
    padding: 26px 32px 60px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-header p { margin: 4px 0 0; color: var(--text-muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.topbar-mobile { display: none; }

/* ---------- Generic UI ---------- */

.icon { width: 18px; height: 18px; flex: none; }
.card-title .icon { width: 18px; height: 18px; color: var(--accent-strong); }
.stat .value .icon { width: 22px; height: 22px; color: var(--yellow); }
.sidebar-status { display: flex; align-items: center; gap: 8px; padding: 0 10px 6px; font-size: 0.85rem; min-width: 0; }
.sidebar-status .ellipsis { min-width: 0; }
.messages.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.messages.settings-grid .embed { max-width: none; }
@media (max-width: 560px) { .messages.settings-grid { grid-template-columns: 1fr; } }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.card-title h3 { display: flex; align-items: center; gap: 8px; }
.card.flush { padding: 0; overflow: hidden; }

.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-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat .label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .sub { font-size: 0.85rem; color: var(--text-faint); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-success { background: rgba(62, 207, 142, 0.16); border-color: rgba(62, 207, 142, 0.45); color: var(--green); }
.btn-success:hover { background: rgba(62, 207, 142, 0.26); }
.btn-danger { background: var(--red-soft); border-color: rgba(242, 85, 90, 0.45); color: var(--red); }
.btn-danger:hover { background: rgba(242, 85, 90, 0.26); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 0.82rem; }
.btn-icon { padding: 6px; min-width: 36px; }
.btn .icon { width: 17px; height: 17px; }

input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 90px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; font-weight: 600; color: var(--text-muted); }
label.field .hint { font-weight: 400; color: var(--text-faint); font-size: 0.8rem; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.checkbox input { width: auto; }

.search {
    position: relative;
}
.search input { padding-left: 36px; }
.search .icon { position: absolute; left: 11px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--text-faint); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 650;
    background: var(--surface-3);
    color: var(--text-muted);
    white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex: none; }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-soft); }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

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

.tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}
.tabs button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 6px 13px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--surface-3); color: var(--text); }
.tabs .count { font-size: 0.72rem; padding: 0 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-faint); }

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.empty .icon { width: 36px; height: 36px; color: var(--text-faint); }

.spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid var(--surface-3);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 15px; height: 15px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px 0; color: var(--text-muted); }

.banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 18px;
}
.banner.warn { border-color: rgba(245, 192, 78, 0.35); background: var(--yellow-soft); color: var(--yellow); }
.banner.error { border-color: rgba(242, 85, 90, 0.35); background: var(--red-soft); color: var(--red); }

/* Toggle switch */
.toggle {
    position: relative;
    width: 50px;
    height: 28px;
    flex: none;
    border-radius: 999px;
    border: 0;
    background: var(--surface-3);
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}
.toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s;
}
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(22px); }
.toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.toggle.busy::after { animation: pulse 0.8s infinite; }

/* ---------- Toasts & dialogs ---------- */

.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 40px));
}
.toast {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    animation: toast-in 0.2s ease-out;
}
.toast.error { border-color: rgba(242, 85, 90, 0.5); }
.toast.success { border-color: rgba(62, 207, 142, 0.5); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(5, 6, 8, 0.7);
    backdrop-filter: blur(4px);
    animation: fade-in 0.15s;
}
@keyframes fade-in { from { opacity: 0; } }
.dialog {
    width: min(620px, 100%);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.dialog.wide { width: min(900px, 100%); }
.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.dialog-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}

/* ---------- Discord message rendering ---------- */

.messages { display: flex; flex-direction: column; gap: 12px; }
.message { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.message-meta { font-size: 0.75rem; color: var(--text-faint); }
.message-content { white-space: pre-wrap; word-break: break-word; }
.message-files { display: flex; flex-wrap: wrap; gap: 8px; }
.message-files img { max-height: 420px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elevated); }

.embed {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 14px;
    padding: 14px 16px 14px 18px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    overflow: hidden;
    max-width: 760px;
}
.embed::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--embed-color, var(--border-strong));
}
.embed-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.embed-author { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; font-weight: 600; }
.embed-author img { width: 22px; height: 22px; border-radius: 50%; }
.embed-title { font-weight: 700; font-size: 0.98rem; }
.embed-description { font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; color: #d7dbe0; }
.embed-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin-top: 4px; }
.embed-field { min-width: 0; grid-column: 1 / -1; }
.embed-field.inline { grid-column: auto; }
.embed-field-name { font-size: 0.8rem; font-weight: 700; margin-bottom: 2px; color: var(--text); }
.embed-field-value { font-size: 0.86rem; white-space: pre-wrap; word-break: break-word; color: #c9ced5; }
.embed-thumbnail img { width: 60px; height: 60px; object-fit: contain; border-radius: 8px; }
.embed-image { grid-column: 1 / -1; }
.embed-image img { max-height: 420px; border-radius: 10px; }
.embed-footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--text-faint); }
.embed-footer img { width: 18px; height: 18px; border-radius: 50%; }

.md-code { white-space: nowrap; padding: 1px 6px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); }
.md-block { margin: 4px 0; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); overflow-x: auto; }
.md-mention { padding: 0 4px; border-radius: 4px; background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.md-time { padding: 0 4px; border-radius: 4px; background: var(--surface-3); }
.md-quote { border-left: 3px solid var(--border-strong); padding-left: 10px; color: var(--text-muted); }

.components { display: flex; flex-direction: column; gap: 8px; }
.components .action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.components select { max-width: 420px; }
.btn-discord-1 { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn-discord-1:hover { background: #6d78f5; }
.btn-discord-2 { }
.btn-discord-3 { background: #248046; border-color: #248046; color: #fff; }
.btn-discord-3:hover { background: #2a9152; }
.btn-discord-4 { background: #da373c; border-color: #da373c; color: #fff; }
.btn-discord-4:hover { background: #e2484d; }

.mirror-message {
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}

/* ---------- Dashboard ---------- */

.hero {
    position: relative;
    overflow: hidden;
    padding: 22px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background:
        radial-gradient(1200px 300px at 0% 0%, rgba(232, 98, 44, 0.18), transparent 60%),
        linear-gradient(135deg, var(--surface) 0%, var(--bg-elevated) 100%);
}
.hero-top { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.hero-img { width: 96px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface-3); }
.hero h1 { font-size: 1.45rem; }
.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.hero-stats .stat { padding: 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--border); }

.event-list { display: flex; flex-direction: column; gap: 2px; }
.event-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.event-item:last-child { border-bottom: 0; }
.event-item img { width: 28px; height: 28px; object-fit: contain; }
.event-item .name { font-weight: 600; min-width: 110px; }
.event-item .value { color: var(--text-muted); font-size: 0.9rem; flex: 1; min-width: 0; }

.team-list { display: flex; flex-direction: column; }
.team-member { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.team-member:last-child { border-bottom: 0; }
.team-member .name { font-weight: 600; flex: 1; min-width: 0; }
.team-member .meta { font-size: 0.82rem; color: var(--text-faint); }

/* ---------- Devices ---------- */

.device {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.device.on { border-color: rgba(62, 207, 142, 0.4); box-shadow: inset 0 0 0 1px rgba(62, 207, 142, 0.08); }
.device.alert { border-color: rgba(242, 85, 90, 0.5); }
.device.unreachable { opacity: 0.75; }
.device-head { display: flex; align-items: center; gap: 12px; }
.device-head img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: var(--bg-elevated); padding: 4px; }
.device-head .title { flex: 1; min-width: 0; }
.device-head .title b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.device-head .title span { font-size: 0.8rem; color: var(--text-faint); }
.device-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.device-actions select { font-size: 0.82rem; padding: 6px 10px; }

.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.item-slot {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}
.item-slot img { width: 76%; height: 76%; object-fit: contain; }
.item-slot .qty { position: absolute; right: 4px; bottom: 1px; font-size: 0.7rem; font-weight: 700; text-shadow: 0 1px 2px #000; }
.item-slot .bp { position: absolute; left: 3px; top: 1px; font-size: 0.6rem; color: var(--blue); font-weight: 800; }

.progress { height: 7px; border-radius: 99px; background: var(--bg-elevated); overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; background: var(--green); transition: width 0.4s; }
.progress.warn > div { background: var(--yellow); }
.progress.danger > div { background: var(--red); }

/* ---------- Map ---------- */

.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.map-viewport {
    position: relative;
    height: calc(100vh - 170px);
    min-height: 420px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #0b2533;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
    user-select: none;
}
.map-viewport.dragging { cursor: grabbing; }
.map-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.map-canvas img { display: block; max-width: none; pointer-events: none; }
.map-canvas svg { position: absolute; left: 0; top: 0; overflow: visible; }
.map-controls { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.map-controls .btn { background: rgba(20, 23, 28, 0.85); backdrop-filter: blur(4px); }
.map-legend {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: calc(100% - 24px);
}
.map-legend label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 99px;
    background: rgba(20, 23, 28, 0.85);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.map-legend input { width: auto; }
.map-tooltip {
    position: absolute;
    z-index: 10;
    min-width: 220px;
    max-width: 320px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(20, 23, 28, 0.96);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    font-size: 0.85rem;
    pointer-events: auto;
}
.map-side { display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 170px); overflow-y: auto; }
.marker-label { font: 700 11px var(--font); fill: #fff; paint-order: stroke; stroke: rgba(0, 0, 0, 0.75); stroke-width: 3px; pointer-events: none; }
.monument-label { font: 700 10px var(--font); fill: rgba(255, 255, 255, 0.85); paint-order: stroke; stroke: rgba(0, 0, 0, 0.7); stroke-width: 3px; letter-spacing: 0.04em; pointer-events: none; }
.grid-label { font: 600 9px var(--font); fill: rgba(255, 255, 255, 0.55); pointer-events: none; }
.map-marker { cursor: pointer; }

/* ---------- Chat ---------- */

.chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 150px);
    min-height: 420px;
    padding: 0;
    overflow: hidden;
}
.chat-log { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.chat-line { display: flex; gap: 10px; padding: 5px 8px; border-radius: 8px; }
.chat-line:hover { background: var(--surface-2); }
.chat-line time { flex: none; color: var(--text-faint); font-size: 0.78rem; padding-top: 2px; font-variant-numeric: tabular-nums; }
.chat-line .author { font-weight: 700; margin-right: 6px; }
.chat-line .text { word-break: break-word; }
.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); background: var(--bg-elevated); }

/* ---------- Commands ---------- */

.command-list { display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 230px); overflow-y: auto; }
.command-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: left;
    background: transparent;
    color: inherit;
    font: inherit;
}
.command-item:hover { background: var(--surface-2); }
.command-item.active { background: var(--accent-soft); border-color: rgba(232, 98, 44, 0.35); }
.command-item b { font-family: var(--mono); font-size: 0.9rem; }
.command-item span { font-size: 0.8rem; color: var(--text-muted); }
.commands-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Market ---------- */

.market-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.market-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.market-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.market-table tr:hover td { background: var(--surface-2); }
.item-cell { display: flex; align-items: center; gap: 10px; }
.item-cell img { width: 30px; height: 30px; object-fit: contain; }
.table-wrap { overflow-x: auto; max-height: calc(100vh - 250px); overflow-y: auto; }

.market-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

/* ---------- Login ---------- */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(900px 500px at 15% 10%, rgba(232, 98, 44, 0.2), transparent 60%),
        radial-gradient(700px 500px at 90% 90%, rgba(91, 156, 255, 0.12), transparent 60%),
        var(--bg);
}
.login-card, .error-page main {
    width: min(420px, 100%);
    padding: 34px 30px;
    border-radius: 22px;
    background: rgba(25, 29, 35, 0.88);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card img.logo { width: 76px; height: 76px; border-radius: 20px; }
.login-card p { margin: 0; color: var(--text-muted); }
.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; min-height: 46px; padding: 10px 22px; font-size: 1rem; width: 100%; }
.btn-discord:hover { background: #6d78f5; }

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .map-layout { grid-template-columns: 1fr; }
    .market-layout { grid-template-columns: 1fr; }
    .map-side { max-height: none; }
}

@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        z-index: 800;
        left: 0;
        width: min(300px, 86vw);
        transform: translateX(-100%);
        transition: transform 0.2s;
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: none; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 799; background: rgba(0, 0, 0, 0.5); }
    .topbar-mobile {
        display: flex;
        align-items: center;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 700;
        padding: 10px 14px;
        background: rgba(13, 15, 18, 0.92);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--border);
    }
    .main { padding: 18px 16px 50px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .commands-layout { grid-template-columns: 1fr; }
    .command-list { max-height: 260px; }
    .form-grid { grid-template-columns: 1fr; }
    .embed-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .map-viewport { height: 70vh; }
    .chat { height: calc(100vh - 190px); }
}

@media (max-width: 560px) {
    .grid-4, .hero-stats { grid-template-columns: 1fr 1fr; }
    .embed-fields { grid-template-columns: 1fr; }
    .embed { grid-template-columns: 1fr; }
    .embed-thumbnail { display: none; }
    h1 { font-size: 1.35rem; }
}
