@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
    color-scheme: dark;
    --bg: #0d1117;
    --bg-strong: #161b22;
    --bg-muted: rgba(22, 27, 34, 0.85);
    --surface: #1c2128;
    --surface-strong: #21262d;
    --border: rgba(48, 54, 61, 0.7);
    --border-strong: rgba(57, 255, 20, 0.25);
    --text: #e6edf3;
    --text-soft: #8b949e;
    --accent: #39ff14;
    --accent-strong: #2bda0e;
    --accent-soft: rgba(57, 255, 20, 0.1);
    --secondary: #00d4ff;
    --warn: #d29922;
    --error: #f85149;
    --success: #39ff14;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --glow: 0 0 20px rgba(57, 255, 20, 0.08);
    --radius: 6px;
    --radius-small: 4px;
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    background: var(--bg);
}

html::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ── Top Navigation Bar ── */
.top-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-strong);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.brand-mark {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.12em;
    /* text-transform: uppercase; */
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-mark::before {
    content: ">";
    color: var(--secondary);
    animation: blink-cursor 1.2s step-end infinite;
}

@keyframes blink-cursor {
    50% { opacity: 0; }
}

.top-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.top-nav a {
    padding: 6px 14px;
    border-radius: var(--radius);
    color: var(--text-soft);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 120ms, color 120ms;
    border: 1px solid transparent;
}

.top-nav a:hover {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}

.top-nav a.active {
    background: rgba(57, 255, 20, 0.12);
    color: var(--accent);
    border-color: var(--border-strong);
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.3);
}

.session-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem;
    color: var(--text-soft);
}

.session-chip strong {
    color: var(--text);
}

.signout-link {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem;
    color: var(--error);
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid rgba(248, 81, 73, 0.25);
    border-radius: var(--radius);
}

.signout-link:hover {
    background: rgba(248, 81, 73, 0.1);
    text-decoration: none;
}

/* ── Main Layout ── */
.page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-stage {
    padding: 24px;
    display: grid;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ── Cards & Panels ── */
.hero-card,
.content-panel,
.login-panel,
.card,
.list-panel,
.detail-panel,
.result-panel,
.snippet-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 20px;
}

.hero-card {
    border-left: 3px solid var(--accent);
    position: relative;
    overflow: hidden;
}

.hero-card::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 200px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(57, 255, 20, 0.02));
    pointer-events: none;
}

/* ── Typography ── */
.eyebrow {
    margin: 0;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--secondary);
}

h1, h2, h3, p { margin: 0; }

h1 {
    font-family: "IBM Plex Mono", monospace;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
}

h2 {
    font-family: "IBM Plex Mono", monospace;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.2;
}

h3 {
    font-family: "IBM Plex Mono", monospace;
    font-size: 1rem;
    font-weight: 600;
}

.lede, .panel-copy, .muted {
    color: var(--text-soft);
}

/* ── Grids ── */
.hero-grid { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); }
.overview-grid, .api-grid, .playground-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr); }
.content-grid { display: grid; gap: 20px; grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr); }
.queries-grid { display: grid; gap: 20px; grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1.28fr); }
.filter-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }

/* ── Metric Cards ── */
.metric-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-strong);
    padding: 16px;
    display: grid;
    gap: 6px;
}

.metric-value {
    font-family: "IBM Plex Mono", monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 16px rgba(57, 255, 20, 0.25);
}

.metric-value-error {
    color: var(--error);
    text-shadow: 0 0 16px rgba(248, 81, 73, 0.22);
}

.metric-label, .inline-label {
    color: var(--text-soft);
    font-size: 0.85rem;
    font-family: "IBM Plex Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Panels & Sections ── */
.panel-header, .section-header, .list-item-header, .message-row-header, .result-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.section-stack, .form-stack, .list-stack, .detail-stack, .snippet-stack, .result-stack, .message-stack {
    display: grid;
    gap: 16px;
    align-content: start;
}

.compact-stack { gap: 8px; }

.list-stack {
    max-height: 720px;
    overflow: auto;
}

/* ── List Items ── */
.list-item {
    display: grid;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-strong);
    padding: 14px;
    cursor: pointer;
    transition: border-color 120ms, background 120ms;
    text-align: left;
    width: 100%;
    color: inherit;
    appearance: none;
    font: inherit;
}

.list-item:hover {
    border-color: rgba(0, 212, 255, 0.3);
    background: rgba(0, 212, 255, 0.04);
}

.list-item.active {
    border-color: var(--border-strong);
    background: rgba(57, 255, 20, 0.05);
    box-shadow: var(--glow);
}

.pill-error {
    border-color: rgba(248, 81, 73, 0.3);
    color: var(--error);
}

/* ── Buttons ── */
.button-row, .inline-actions, .hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button, .secondary-button, .danger-button, .text-button {
    appearance: none;
    border-radius: var(--radius);
    padding: 8px 16px;
    border: 1px solid transparent;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 120ms, border-color 120ms, box-shadow 120ms;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.button {
    background: var(--accent);
    color: #0d1117;
    border-color: var(--accent);
    font-weight: 600;
}

.button:hover {
    box-shadow: 0 0 16px rgba(57, 255, 20, 0.3);
    text-decoration: none;
}

.secondary-button {
    background: transparent;
    color: var(--secondary);
    border-color: rgba(0, 212, 255, 0.3);
}

.secondary-button:hover {
    background: rgba(0, 212, 255, 0.08);
    text-decoration: none;
}

.danger-button {
    background: transparent;
    color: var(--error);
    border-color: rgba(248, 81, 73, 0.3);
}

.danger-button:hover {
    background: rgba(248, 81, 73, 0.08);
}

.text-button {
    background: transparent;
    color: var(--text-soft);
    border-color: var(--border);
}

.text-button:hover {
    background: var(--bg-strong);
}

.button:disabled, .secondary-button:disabled, .danger-button:disabled, .text-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Forms ── */
.form-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, 1fr);
}

.field, .field-span-2 { display: grid; gap: 6px; }
.field-span-2 { grid-column: span 2; }
.compact-field span { font-size: 0.72rem; }
.checkbox-field { align-content: end; }

.field span, .field-span-2 span {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.input, .textarea, .select, .inline-code {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
    transition: border-color 120ms;
}

.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.15);
}

.textarea { min-height: 120px; resize: vertical; }

.textarea.code-area, .code-block, .inline-code {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.82rem;
}

.inline-code {
    display: inline;
    width: auto;
    padding: 2px 6px;
    background: rgba(57, 255, 20, 0.08);
    border-color: var(--border-strong);
    color: var(--accent);
}

.code-block {
    margin: 0;
    padding: 14px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #0a0e14;
    color: var(--accent);
    white-space: pre-wrap;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.82rem;
}

.limit-stack {
    display: grid;
    gap: 10px;
}

.limit-row {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 0.9fr 0.8fr 1.15fr 1.25fr 0.8fr auto;
    align-items: end;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-strong);
    padding: 12px;
}

.usage-scope-controls {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) auto;
    align-items: end;
}

.usage-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, 1fr);
}

.usage-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-strong);
    padding: 14px;
}

.sticky-detail-panel {
    position: sticky;
    top: 84px;
    align-self: start;
}

.detail-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.detail-kv-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, 1fr);
}

.detail-kv-grid strong {
    display: block;
    font-family: "IBM Plex Mono", monospace;
    margin-top: 6px;
}

.wrap-block {
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Status Messages ── */
.status {
    display: none;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
}

.status.visible { display: block; }

.status.success {
    border-color: rgba(57, 255, 20, 0.3);
    color: var(--success);
    background: rgba(57, 255, 20, 0.06);
}

.status.error {
    border-color: rgba(248, 81, 73, 0.3);
    color: var(--error);
    background: rgba(248, 81, 73, 0.06);
}

.status.info {
    border-color: rgba(0, 212, 255, 0.2);
    color: var(--secondary);
    background: rgba(0, 212, 255, 0.05);
}

/* ── Pills & Meta ── */
.pill-row, .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill, .meta-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-family: "IBM Plex Mono", monospace;
    color: var(--text-soft);
    background: var(--bg);
    border: 1px solid var(--border);
}

.empty-state {
    padding: 20px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-soft);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
    text-align: center;
}

/* ── Login Layout ── */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top, rgba(0, 212, 255, 0.08), transparent 32%),
        radial-gradient(circle at bottom, rgba(57, 255, 20, 0.08), transparent 36%),
        var(--bg);
}

.login-card-shell {
    width: 100%;
    max-width: 420px;
    padding: 28px;
    gap: 20px;
    position: relative;
    overflow: hidden;
    border-color: rgba(0, 212, 255, 0.16);
    background: linear-gradient(180deg, rgba(28, 33, 40, 0.98), rgba(13, 17, 23, 0.96));
}

.login-card-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.08), transparent 40%, rgba(57, 255, 20, 0.06));
}

.login-brand-lockup,
.login-card-shell > * {
    position: relative;
    z-index: 1;
}

.login-brand {
    width: fit-content;
}

.login-card-shell h1 {
    font-size: 1.9rem;
}

.login-provider-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid rgba(0, 212, 255, 0.28);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(0, 212, 255, 0.12), rgba(0, 212, 255, 0.06));
    color: var(--text);
    font-family: "IBM Plex Mono", monospace;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 120ms, background 120ms, box-shadow 120ms, transform 120ms;
}

.login-provider-button:hover {
    text-decoration: none;
    border-color: rgba(0, 212, 255, 0.48);
    background: linear-gradient(180deg, rgba(0, 212, 255, 0.18), rgba(0, 212, 255, 0.08));
    box-shadow: 0 0 24px rgba(0, 212, 255, 0.16);
}

.login-provider-button:active {
    transform: translateY(1px);
}

.login-provider-button svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.login-footnote {
    text-align: center;
    font-size: 0.82rem;
}

.login-dev-button {
    width: 100%;
}

/* ── Messages ── */
.message-row {
    display: grid;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-strong);
    padding: 14px;
}

.message-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: 150px minmax(0, 1fr);
}

/* ── Response Metrics ── */
.response-metrics {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, 1fr);
}

.response-metric {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-strong);
    padding: 12px;
}

/* ── Generated Key Panel ── */
.card {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-strong);
    padding: 18px;
    box-shadow: var(--glow);
}

/* ── Image Gallery ── */
.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.image-thumb {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    width: 180px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-strong);
    color: var(--text-soft);
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.image-thumb:hover {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.2);
    text-decoration: none;
}

.image-thumb img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius-small);
    background: var(--bg);
}

.image-thumb-meta {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    color: var(--text-soft);
}

.image-thumb-source {
    display: block;
    font-size: 0.68rem;
    word-break: break-all;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.hidden { display: none !important; }

/* ── Select styling ── */
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    .overview-grid, .api-grid, .playground-grid, .content-grid, .queries-grid,
    .hero-grid, .stat-grid, .filter-grid, .usage-grid {
        grid-template-columns: 1fr;
    }

    .limit-row {
        grid-template-columns: 1fr;
    }

    .usage-scope-controls {
        grid-template-columns: 1fr;
    }

    .sticky-detail-panel {
        position: static;
    }
}

@media (max-width: 700px) {
    .main-stage { padding: 16px; }
    .top-bar { flex-wrap: wrap; padding: 12px 16px; }
    .top-nav { order: 3; width: 100%; }
    .form-grid, .message-grid, .response-metrics, .callout-grid { grid-template-columns: 1fr; }
    .field-span-2 { grid-column: span 1; }
    .login-shell { padding: 16px; }
    .login-card-shell { padding: 22px; }
}
