:root {
    --bg: #ffffff;
    --fg: #111111;
    --muted: rgba(0,0,0,0.45);
    --faint: rgba(0,0,0,0.08);
    --border: rgba(0,0,0,0.1);
    --card-bg: #ffffff;
    --input-bg: rgba(0,0,0,0.03);
    --code-bg: rgba(0,0,0,0.04);
    --emerald: #059669;
    --emerald-bg: rgba(5,150,105,0.06);
    --emerald-border: rgba(5,150,105,0.2);
    --blue: #2563eb;
    --blue-bg: rgba(37,99,235,0.06);
    --red: #dc2626;
    --red-bg: rgba(220,38,38,0.06);
    --amber: #d97706;
    --amber-bg: rgba(217,119,6,0.06);
    --purple: #9333ea;
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a0a;
        --fg: #f0f0f0;
        --muted: rgba(255,255,255,0.45);
        --faint: rgba(255,255,255,0.06);
        --border: rgba(255,255,255,0.1);
        --card-bg: #141414;
        --input-bg: rgba(255,255,255,0.05);
        --code-bg: rgba(255,255,255,0.05);
        --emerald-bg: rgba(5,150,105,0.1);
        --emerald-border: rgba(5,150,105,0.25);
        --blue-bg: rgba(37,99,235,0.12);
        --red-bg: rgba(220,38,38,0.1);
        --amber-bg: rgba(217,119,6,0.1);
    }
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    min-height: 100vh;
}
code, pre, .mono { font-family: var(--mono); }

/* ── Layout ─────────────────────────────────── */
.app-header {
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 56px;
}
.app-header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    color: var(--fg);
}
.app-header .logo svg { width: 24px; height: 24px; }
.app-header .sep { width: 1px; height: 24px; background: var(--border); }

.main-content { max-width: 960px; margin: 0 auto; padding: 24px; }
.hidden { display: none; }

/* ── Connection screen ──────────────────────── */
.connect-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 57px);
    padding: 24px;
}
.connect-card {
    width: 100%;
    max-width: 560px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}
.connect-card h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}
.connect-card .subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 24px;
}
.connect-section {
    border: 1px solid var(--faint);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}
.connect-section legend {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    padding: 0 6px;
}
.connect-card label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
}
.connect-card label .optional {
    font-weight: 400;
    color: var(--muted);
    font-size: 11px;
}
.connect-card input {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    font-family: var(--mono);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--fg);
    outline: none;
    margin-bottom: 12px;
}
.connect-card input:focus { border-color: var(--blue); }
.connect-card .or-separator {
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    margin: -4px 0 12px;
    position: relative;
}
.connect-card .or-separator::before,
.connect-card .or-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 20px);
    height: 1px;
    background: var(--border);
}
.connect-card .or-separator::before { left: 0; }
.connect-card .or-separator::after { right: 0; }
.connect-card .connect-btn {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--fg);
    color: var(--bg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.connect-card .connect-btn:hover { opacity: 0.85; }
.connect-card .example {
    margin-top: 16px;
    font-size: 11px;
    color: var(--muted);
}
.connect-card .example code {
    display: block;
    margin-top: 4px;
    padding: 6px 10px;
    background: var(--code-bg);
    border-radius: 6px;
    font-size: 11px;
    word-break: break-all;
}
.field-hint {
    font-size: 11px;
    color: var(--muted);
    margin-top: -8px;
    margin-bottom: 12px;
}
.header-connected { display: none; }
body.connected .header-connected { display: inline-flex; }
body.connected .connect-screen { display: none; }
body.connected #connected-view { display: block; }

/* ── Tabs ───────────────────────────────────── */
.tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.tab-btn {
    padding: 12px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active {
    color: var(--fg);
    border-bottom-color: var(--fg);
}

/* ── Cards ──────────────────────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}
.card-emerald {
    border-color: var(--emerald-border);
    background: var(--emerald-bg);
}
.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--faint);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 {
    font-size: 13px;
    font-weight: 600;
}
.card-body { padding: 16px; }
.card-body p { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

/* ── Fields ─────────────────────────────────── */
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field-label {
    font-size: 11px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.field-value {
    margin-top: 4px;
    font-size: 12px;
    font-family: var(--mono);
    background: var(--code-bg);
    padding: 6px 10px;
    border-radius: 6px;
    word-break: break-all;
    line-height: 1.6;
}
.field-desc { font-size: 11px; color: var(--muted); opacity: 0.7; margin-top: 2px; }

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: var(--muted);
    opacity: 0.5;
    transition: opacity 0.15s;
}
.copy-btn:hover { opacity: 1; }

/* ── Extension items ────────────────────────── */
.ext-item {
    border-bottom: 1px solid var(--faint);
    padding-bottom: 12px;
    margin-bottom: 12px;
}
.ext-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.ext-label { font-size: 12px; font-weight: 500; }
.ext-oid { font-size: 10px; font-family: var(--mono); color: var(--muted); margin-top: 2px; }

/* ── Badges ─────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
}
.badge-ok { background: var(--emerald-bg); color: var(--emerald); }
.badge-err { background: var(--red-bg); color: var(--red); }
.badge-warn { background: var(--amber-bg); color: var(--amber); }
.badge-info { background: var(--blue-bg); color: var(--blue); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--emerald); }
.dot-err { background: var(--red); }

/* ── API Testing ────────────────────────────── */
.rpc-bar {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
}
.rpc-method {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--emerald-bg);
    border-right: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    color: var(--emerald);
    letter-spacing: 0.5px;
}
.rpc-select {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    font-size: 13px;
    font-family: var(--mono);
    color: var(--fg);
    cursor: pointer;
    outline: none;
}
.rpc-send {
    padding: 10px 24px;
    background: var(--blue);
    color: white;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.rpc-send:hover { opacity: 0.9; }
.rpc-send:disabled { opacity: 0.4; cursor: not-allowed; }

.sig-bar {
    padding: 8px 16px;
    background: var(--faint);
    border-bottom: 1px solid var(--faint);
    font-size: 12px;
    font-family: var(--mono);
}
.sig-kw { color: var(--blue); }
.sig-fn { font-weight: 600; color: var(--fg); }
.sig-pname { color: var(--muted); }
.sig-type { color: var(--purple); }
.sig-ret { color: var(--emerald); }
.sig-sep { color: var(--muted); opacity: 0.5; }

.params-section { padding: 16px; }
.params-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 12px;
}
.param-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}
.param-info {
    min-width: 120px;
    flex-shrink: 0;
    padding-top: 8px;
}
.param-name { font-size: 12px; font-family: var(--mono); font-weight: 500; }
.param-type { font-size: 10px; font-family: var(--mono); color: var(--muted); }
.param-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--mono);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--fg);
    outline: none;
    transition: border-color 0.15s;
}
.param-input:focus { border-color: var(--blue); }
select.param-input { cursor: pointer; }
textarea.param-input { resize: vertical; min-height: 60px; }

.toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 6px;
}
.toggle-track.off { background: var(--border); }
.toggle-track.on { background: var(--blue); }
.toggle-thumb {
    position: absolute;
    top: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: left 0.15s;
}
.toggle-track.off .toggle-thumb { left: 2px; }
.toggle-track.on .toggle-thumb { left: 18px; }

.shortcut-hint {
    padding: 8px 16px;
    border-top: 1px solid var(--faint);
    font-size: 10px;
    color: var(--muted);
    opacity: 0.5;
}
.shortcut-hint kbd {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--code-bg);
    font-family: var(--mono);
    font-size: 10px;
}

/* ── Response ───────────────────────────────── */
.response-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.response-header .label { font-size: 13px; font-weight: 600; }
.response-header .meta { font-size: 11px; color: var(--muted); }
.response-body {
    padding: 16px;
    font-size: 12px;
    font-family: var(--mono);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.7;
    background: var(--faint);
}
.response-error {
    padding: 16px;
    font-size: 13px;
    color: var(--red);
    background: var(--red-bg);
}

/* ── History ────────────────────────────────── */
.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--faint);
    cursor: pointer;
    transition: background 0.1s;
    width: 100%;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    color: var(--fg);
    text-align: left;
    font-family: var(--font);
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--faint); }
.history-fn { flex: 1; font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-ms { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.history-time { font-size: 10px; color: var(--muted); opacity: 0.6; flex-shrink: 0; }

/* ── Attestation specifics ──────────────────── */
.challenge-input-group { max-width: 600px; margin: 0 auto 20px; }
.challenge-input-group label { font-size: 12px; font-weight: 500; display: block; margin-bottom: 6px; }
.challenge-input-group .row { display: flex; gap: 8px; }
.challenge-input-group input {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
    font-family: var(--mono);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--fg);
    outline: none;
}
.challenge-input-group input:focus { border-color: var(--blue); }
.challenge-input-group .hint { font-size: 11px; color: var(--muted); margin-top: 6px; }

.btn {
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--fg);
    color: var(--bg);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-outline {
    background: transparent;
    color: var(--fg);
}
.btn-sm { padding: 5px 14px; font-size: 12px; }

.actions-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-xs { font-size: 12px; }
.text-xxs { font-size: 11px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }

/* ── Loading/Empty states ───────────────────── */
.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--fg);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}
.empty-state .icon { font-size: 32px; margin-bottom: 12px; opacity: 0.3; }
.empty-state h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--fg); opacity: 0.6; }
.empty-state p { font-size: 13px; }

/* ── PEM block ──────────────────────────────── */
.pem-block {
    font-size: 11px;
    font-family: var(--mono);
    background: var(--code-bg);
    padding: 12px;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}

/* ── Quote verification detail ──────────────── */
.quote-verify-card {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
}
.quote-verify-ok {
    background: var(--emerald-bg);
    border: 1px solid var(--emerald-border);
}
.quote-verify-err {
    background: var(--red-bg);
    border: 1px solid rgba(220,38,38,0.2);
}
.quote-verify-detail { margin-top: 6px; }
.quote-verify-detail dt { color: var(--muted); font-size: 10px; }
.quote-verify-detail dd { font-family: var(--mono); font-size: 11px; margin-bottom: 4px; }
