
:root {
    --bg: #0a0a0a;
    --surface: #121212;
    --surface2: #161616;
    --border: #232323;
    --border-light: #2e2e2e;
    --text: #f2f2f2;
    --text-dim: #8a8a8a;
    --accent: #00d97a;
    --accent-mid: #00b35f;
    --accent-dim: rgba(0, 217, 122, 0.08);
    --danger: #f87171;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Poppins', system-ui, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Shared site background: animated connected dots (shared.js) + grid + blurred orbs. */
#bg-canvas { position: fixed; inset: 0; z-index: -3; pointer-events: none; }
.grid-overlay {
    position: fixed; inset: 0; z-index: -2; pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
    background-size: 54px 54px;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 60%, transparent 100%);
            mask-image: linear-gradient(180deg, #000 0%, #000 60%, transparent 100%);
}
.orb { position: fixed; border-radius: 50%; pointer-events: none; z-index: -3; filter: blur(90px); opacity: .05; }
.orb-1 { width: 480px; height: 480px; background: radial-gradient(circle, #00d97a, transparent 70%); top: -120px; left: -120px; }
.orb-2 { width: 380px; height: 380px; background: radial-gradient(circle, #00d9ad, transparent 70%); bottom: -100px; right: -100px; }
.orb-3 { width: 300px; height: 300px; background: radial-gradient(circle, #00d97a, transparent 70%); top: 45%; left: 55%; opacity: .04; }

.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-light); object-fit: cover; }
.brand span { font-size: .9rem; font-weight: 600; letter-spacing: .03em; }

.wrap { max-width: 880px; margin: 0 auto; padding: 36px 20px 80px; }
.loading { text-align: center; color: var(--text-dim); font-size: .9rem; padding: 120px 20px; }

.btn {
    font-family: inherit; font-size: .85rem; font-weight: 600;
    padding: 10px 18px; border-radius: 8px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap; text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-light); background: var(--surface2); }
.btn-accent { background: var(--accent); color: #04130b; border: 1px solid var(--accent); }
.btn-accent:hover:not(:disabled) { background: var(--accent-mid); border-color: var(--accent-mid); }

.btn-soft-indigo { background: rgba(79,70,229,.09);  color: #8b93e0; border: 1px solid rgba(79,70,229,.30); }
.btn-soft-cyan   { background: rgba(8,145,178,.09);   color: #58b6c9; border: 1px solid rgba(8,145,178,.30); }
.btn-soft-purple { background: rgba(124,58,237,.09);  color: #a994e8; border: 1px solid rgba(124,58,237,.30); }
.btn-soft-green  { background: rgba(5,150,105,.09);   color: #54c596; border: 1px solid rgba(5,150,105,.30); }
.btn-soft-amber  { background: rgba(217,119,6,.09);   color: #d39a3a; border: 1px solid rgba(217,119,6,.30); }
.btn-soft-indigo:hover:not(:disabled) { background: rgba(79,70,229,.17); }
.btn-soft-cyan:hover:not(:disabled)   { background: rgba(8,145,178,.17); }
.btn-soft-purple:hover:not(:disabled) { background: rgba(124,58,237,.17); }
.btn-soft-green:hover:not(:disabled)  { background: rgba(5,150,105,.17); }
.btn-soft-amber:hover:not(:disabled)  { background: rgba(217,119,6,.17); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }

.profile { display: flex; align-items: center; gap: 16px; padding: 22px 24px; margin-bottom: 28px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border-light); object-fit: cover; flex-shrink: 0; background: var(--surface2); }
.profile-meta { flex: 1; min-width: 0; }
.profile-name { font-size: 1.05rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-id { font-size: .76rem; color: var(--text-dim); margin-top: 2px; font-family: 'Cascadia Code', 'Consolas', monospace; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 26px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.tab {
    font-family: inherit; font-size: .84rem; font-weight: 500;
    color: var(--text-dim); background: transparent; border: none;
    padding: 8px 18px; border-radius: 7px; cursor: pointer;
    transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface2); color: var(--text); border: 1px solid var(--border-light); padding: 7px 17px; }

.server-group { margin-bottom: 34px; }
.group-title { font-size: .8rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.server-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
@media (max-width: 600px) { .server-card { flex-basis: calc(50% - 6px); } }

.server-card {
    flex: 0 0 calc(25% - 9px);
    display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 16px;
    transition: border-color .15s, background .15s;
}
.server-card:hover { border-color: var(--border-light); background: var(--surface2); }
.server-icon, .server-icon-fallback {
    width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; object-fit: cover;
    background: var(--surface2); border: 1px solid var(--border);
}
.server-icon-fallback {
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 600; color: var(--text-dim);
}
.server-name { text-align: center; font-size: .92rem; font-weight: 500; word-break: break-word; line-height: 1.3; }
.server-card .btn { width: 100%; justify-content: center; }
.server-empty { flex-basis: 100%; width: 100%; color: var(--text-dim); font-size: .85rem; padding: 18px; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }

.notice {
    background: rgba(248, 113, 113, 0.06); border: 1px solid rgba(248, 113, 113, 0.25);
    color: var(--danger); font-size: .84rem; border-radius: 8px;
    padding: 11px 14px; margin-bottom: 20px;
}

.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal {
    position: relative;
    background: var(--surface); border: 1px solid var(--border-light); border-radius: 14px;
    width: 100%; max-width: 860px; max-height: 90vh; overflow-y: auto;
    padding: 30px 28px;
}
.api-layout { display: flex; gap: 26px; align-items: flex-start; }
.api-charts { flex: 0 0 360px; display: flex; gap: 16px; }
.api-main { flex: 1; min-width: 0; }

.donut-block {
    flex: 1; min-width: 0; text-align: center;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 16px 12px;
}
.donut-block h3 {
    font-size: .74rem; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px;
}
.donut svg { width: 100%; height: auto; display: block; overflow: visible; }
.donut-slice { transition: filter .12s ease; cursor: pointer; }
.donut-total { fill: var(--text); font-size: 13px; font-weight: 600; }
.donut-cap { fill: var(--text-dim); font-size: 6px; font-weight: 500; }
.donut-legend { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.donut-leg { display: flex; align-items: center; gap: 7px; font-size: .78rem; color: var(--text-dim); }
.leg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.leg-val { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-tip {
    position: fixed; z-index: 1100; pointer-events: none;
    background: var(--bg); border: 1px solid var(--border-light); border-radius: 7px;
    padding: 5px 9px; font-size: .76rem; color: var(--text); white-space: nowrap;
}
.modal-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; color: var(--text-dim);
    font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 4px;
    transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-title { font-size: 1.1rem; font-weight: 600; text-align: center; margin-bottom: 22px; }
.modal-generate { display: flex; margin: 0 auto 24px; }

.key-row {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
    padding: 11px 14px; margin-bottom: 24px;
}
.key-value {
    flex: 1; min-width: 0;
    font-family: 'Cascadia Code', 'Consolas', monospace; font-size: .82rem;
    color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    letter-spacing: .04em;
}
.icon-btn {
    background: none; border: 1px solid var(--border); border-radius: 7px;
    color: var(--text-dim); cursor: pointer; padding: 6px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    transition: color .15s, border-color .15s, background .15s;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--text); border-color: var(--border-light); background: var(--surface2); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.06); }
.icon-btn.copied { color: var(--accent); border-color: var(--accent-mid); }

.api-section { border-top: 1px solid var(--border); padding-top: 18px; margin-bottom: 22px; }
.api-section h3 { font-size: .78rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.usage-row { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; margin-bottom: 8px; gap: 10px; flex-wrap: wrap; }
.usage-reset { color: var(--text-dim); font-size: .74rem; }
.usage-bar { height: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.usage-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }

.meta-row {
    display: flex; justify-content: space-between; gap: 12px;
    font-size: .85rem; padding: 7px 0;
}
.meta-row span:first-child { color: var(--text-dim); }
.api-empty { color: var(--text-dim); font-size: .85rem; text-align: center; line-height: 1.6; }
.api-docs-link { text-align: center; margin-top: 18px; font-size: .85rem; }
.api-docs-link a { color: var(--accent); text-decoration: none; font-weight: 600; }
.api-docs-link a:hover { color: var(--accent-mid); text-decoration: underline; }

[hidden] { display: none !important; }

@media (max-width: 560px) {
    .profile { flex-wrap: wrap; }
    .profile .btn { width: 100%; justify-content: center; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .tabs { justify-content: center; }
    .toolbar .btn { justify-content: center; }
    .api-layout { flex-direction: column; }
    .api-charts { flex-basis: auto; width: 100%; }
}
