/* ==========================================================================
   Host An App — documents.css
   --------------------------------------------------------------------------
   Deployed documents served on visitor origins: Markdown, Mermaid, JSON/CSV
   viewers, deploy-meta share bar. Requires core.css.
   See AGENTS.md (CSS: modular stylesheets).
   ========================================================================== */
/* ==========================================================================
   Deployed document styles (Markdown & Mermaid)
   ========================================================================== */

/* Markdown + Mermaid content structure. Token-driven: under body.paper the
   flipped tokens render it in the light paper theme automatically. */

/* Document sizing */
.md-content { max-width: 720px; margin: 0 auto; padding: 3rem 1.5rem 4rem; width: 100%; }
@media (max-width: 768px) { .md-content { padding: 2rem 1rem 3rem; max-width: 100%; } }
.md-content h1, .md-content h2, .md-content h3, .md-content h4,
.md-content h5, .md-content h6 { font-weight: 600; line-height: 1.25; color: var(--text-bright); }
.md-content h1 { font-size: 1.6rem; margin-top: 0.5rem; margin-bottom: 1.5rem; }
@media (max-width: 768px) { .md-content h1 { font-size: 1.35rem; } }
.md-content h2 { font-size: 1.25rem; margin-top: 2.5rem; margin-bottom: 0.75rem; }
@media (max-width: 768px) { .md-content h2 { font-size: 1.1rem; } }
.md-content h3 { font-size: 1.05rem; margin-top: 2rem; margin-bottom: 0.5rem; }
.md-content h4 { font-size: 1rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }
.md-content h5 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted-2); }
.md-content h6 { font-size: 0.75rem; color: var(--text-muted-2); }
.md-content p { margin-bottom: 1rem; color: var(--text); line-height: 1.7; }
.md-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.md-content a:hover { color: var(--accent-hover); }
.md-content strong { font-weight: 600; color: var(--text-bright); }
.md-content em { font-style: italic; color: var(--text); }
.md-content del { text-decoration: line-through; color: var(--text-muted); }
.md-content code {
    font-family: var(--font-mono); font-size: 0.875em; background: var(--bg-surface);
    border: 1px solid var(--border); padding: 0.15em 0.4em; border-radius: 4px; color: var(--text-bright);
}
.md-content pre {
    position: relative;
    background: var(--bg-deep); border: 1px solid var(--border); border-radius: 6px;
    padding: 1rem 1.25rem; overflow-x: auto; margin-bottom: 1.25rem;
    font-size: 0.85rem; line-height: 1.6; -webkit-overflow-scrolling: touch;
}
@media (max-width: 768px) { .md-content pre { padding: 0.75rem 0.85rem; font-size: 0.78rem; } }
.md-content pre code { background: none; padding: 0; border: none; border-radius: 0; font-size: inherit; color: inherit; line-height: inherit; }
.md-content blockquote {
    margin: 1.5rem 0; padding: 0.75rem 1rem; border-left: 2px solid var(--border-active);
    color: var(--text-muted); background: rgba(255,255,255,0.015); border-radius: 0 4px 4px 0;
}
.md-content blockquote p { margin-bottom: 0.25rem; }
.md-content blockquote p:last-child { margin-bottom: 0; }
.md-content ul, .md-content ol { margin: 0.5rem 0 1rem 1.5rem; color: var(--text); }
.md-content li { margin-bottom: 0.3rem; }
.md-content li p { margin-bottom: 0.25rem; }
.md-content hr { border: none; height: 1px; background: var(--border); margin: 2.5rem 0; }
.md-content img { max-width: 100%; height: auto; border-radius: 4px; margin: 1rem 0; }
.md-content .table-wrapper {
    overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0 1.5rem;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg-surface);
}
@media (max-width: 768px) { .md-content .table-wrapper { border-radius: 4px; } }
.md-content table { width: 100%; border-collapse: collapse; font-size: 0.875rem; min-width: 400px; }
.md-content th, .md-content td { text-align: left; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.md-content thead tr:last-child th { border-bottom: 1px solid var(--line-strong); }
.md-content th { font-weight: 600; color: var(--text-bright); background: var(--bg-deep); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.md-content tbody tr:last-child td { border-bottom: none; }
.md-content td { color: var(--text); }
.doc-header { margin-bottom: 1.5rem; }
.doc-header h1 { margin-top: 0; color: var(--text-bright); font-size: 1.8rem; }

/* Mermaid diagram tabs (shared by Markdown inline and standalone Mermaid pages) */
.md-content .mermaid-block, .mermaid-content .mermaid-block { border: 1px solid var(--border); border-radius: 6px; margin: 1.5rem 0; }
.mermaid-content .mermaid-block { margin: 0 0 1.5rem; }
.md-content .mermaid-tabs, .mermaid-content .mermaid-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg-deep); }
.md-content .mermaid-tab, .mermaid-content .mermaid-tab {
    padding: 0.5rem 1rem; font-size: 0.6875rem; font-weight: 500; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted-2); background: none; border: none;
    border-bottom: 2px solid transparent; cursor: pointer; font-family: var(--font-mono);
    transition: color 0.15s; outline: none;
}
.md-content .mermaid-tab:hover, .mermaid-content .mermaid-tab:hover { color: var(--text-bright); }
.md-content .mermaid-tab.active, .mermaid-content .mermaid-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.md-content .mermaid-panel, .mermaid-content .mermaid-panel { background: var(--bg-surface); padding: 1.5rem; display: flex; justify-content: center; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md-content .mermaid-panel[data-panel="visual"], .mermaid-content .mermaid-panel[data-panel="visual"] {
    position: relative; overflow: hidden; display: block; padding: 0;
    background: #FFFFFF; height: 60vh; min-height: 280px;
    touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
    transition: position 0s, inset 0s;
}
.md-content .mermaid-panel[data-panel="visual"].panning, .mermaid-content .mermaid-panel[data-panel="visual"].panning { cursor: grabbing; }
.md-content .mermaid-panel[data-panel="visual"] pre.mermaid, .mermaid-content .mermaid-panel[data-panel="visual"] pre.mermaid { margin: 0; padding: 0; background: none; border: none; display: block; }
.md-content .mermaid-panel[data-panel="visual"] svg, .mermaid-content .mermaid-panel[data-panel="visual"] svg { display: block; position: absolute; top: 0; left: 0; max-width: none !important; transform-origin: 0 0; }
.md-content .mermaid-panel pre.mermaid, .mermaid-content .mermaid-panel pre.mermaid { margin: 0; background: none; border: none; padding: 0; font-family: inherit; color: inherit; border-radius: 0; }
.md-content .mermaid-panel pre.mermaid svg, .mermaid-content .mermaid-panel pre.mermaid svg { max-width: 100%; height: auto; }
.md-content .mermaid-raw, .mermaid-content .mermaid-raw {
    position: relative;
    margin: 0; background: var(--bg-deep); border: 1px solid var(--border); border-radius: 4px;
    padding: 1rem 1.25rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
    font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.6; color: var(--text); white-space: pre; width: 100%;
}
.md-content .mermaid-raw code, .mermaid-content .mermaid-raw code { background: none; border: none; padding: 0; font-size: inherit; color: inherit; }
@media (max-width: 768px) {

    .md-content .mermaid-block, .mermaid-content .mermaid-block { border-radius: 4px; }
    .md-content .mermaid-panel, .mermaid-content .mermaid-panel { padding: 1rem 0.5rem; }
    .md-content .mermaid-raw, .mermaid-content .mermaid-raw { padding: 0.75rem 0.85rem; font-size: 0.78rem; }
    .md-content .mermaid-tab, .mermaid-content .mermaid-tab { padding: 0.4rem 0.75rem; font-size: 0.625rem; }
}

/* --- Mermaid standalone page (container only — block rules shared above) --- */
.mermaid-content { max-width: 100%; margin: 0 auto; padding: 2rem 1rem 3rem; width: 100%; }
@media (min-width: 768px) { .mermaid-content { max-width: 960px; padding: 3rem 1.5rem 4rem; } }
.mermaid-content h1 { font-weight: 600; font-size: 1.6rem; line-height: 1.3; margin-bottom: 1.25rem; color: var(--text-bright); }
@media (max-width: 768px) { .mermaid-content h1 { font-size: 1.3rem; } }

/* Diagram panel styles (pan / zoom / fullscreen — shared by Markdown inline
   tabs and standalone Mermaid pages) */
.diagram-container {
    position: relative; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1.25rem;
    overflow: hidden; display: block; height: 65vh; min-height: 300px; background: #FFFFFF;
    touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.diagram-container.panning { cursor: grabbing; }
.diagram-container pre.mermaid { margin: 0; padding: 0; background: none; border: none; display: block; }
.diagram-container svg { display: block; position: absolute; top: 0; left: 0; max-width: none !important; transform-origin: 0 0; }
.diagram-zoom {
    position: absolute; top: 0.6rem; right: 0.6rem; z-index: 5;
    display: flex; flex-direction: column; gap: 0.3rem;
    opacity: 0.85; transition: opacity 0.15s;
}
.diagram-container:hover .diagram-zoom { opacity: 1; }
.diagram-zoom button {
    width: 34px; height: 34px; padding: 0; border: 1px solid #D1D5DB;
    background: #FFFFFF; color: #1F2937; border-radius: 6px; cursor: pointer;
    font-size: 1.15rem; line-height: 1; font-weight: 500;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.diagram-zoom button:hover { background: #F3F4F6; }
.diagram-zoom button:active { background: #E5E7EB; }
.diagram-hint {
    position: absolute; left: 0.6rem; bottom: 0.5rem; z-index: 5;
    font-size: 0.7rem; color: #6B7280; pointer-events: none;
    font-family: var(--font-mono);
}

/* Fullscreen diagram panel */
.mermaid-panel[data-panel="visual"].is-fullscreen,
.diagram-container.is-fullscreen {
    position: fixed !important; inset: 0 !important; z-index: 9999;
    width: 100vw !important; height: 100dvh !important;
    border-radius: 0; margin: 0;
    background: #FFFFFF;
}
/* Let the mermaid block container overflow so the fixed panel breaks out */
.mermaid-block:has(.is-fullscreen) { overflow: visible; }
.source-label {
    font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted-2);
    margin-bottom: 0.5rem; font-weight: 500; font-family: var(--font-mono);
}
.source-block {
    background: var(--bg-deep); border: 1px solid var(--border); border-radius: 6px;
    padding: 1rem 1.25rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
    font-size: 0.85rem; line-height: 1.6; font-family: var(--font-mono);
    color: var(--text); white-space: pre;
}
@media (max-width: 768px) { .source-block { padding: 0.75rem 0.85rem; font-size: 0.78rem; } }

/* =========================================================
   DEPLOYED DOCUMENTS ON PAPER (Markdown + Mermaid)
   Server-rendered deployments share the paper theme. Code
   panels stay dark (like the docs-page code blocks), tables
   and quotes go light, headings pick up paper typography.
   ========================================================= */

/* dark panels keep their own dark tokens regardless of theme */
body.paper .md-content pre,
body.paper .md-content .mermaid-tabs,
body.paper .mermaid-content .mermaid-tabs,
body.paper .mermaid-panel[data-panel="raw"],
body.paper .mermaid-raw,
body.paper .source-block {
    color: #deddd8;
    --text: #deddd8;
    --text-muted: #9b9890;
    --text-muted-2: #8f8f8f;
    --border: #30302e;
    --border-active: #41413f;
    --bg-surface: #232321;
    --bg-deep: #181817;
}

/* headings — paper typography (Inter, tight tracking) */
body.paper .doc-header h1 {
    font-size: clamp(2.125rem, 5vw, 2.875rem);
    letter-spacing: -.055em;
}

body.paper .md-content h1 { font-size: clamp(1.9rem, 4.5vw, 2.5rem); letter-spacing: -.045em; }
body.paper .md-content h2 { font-size: 1.45rem; letter-spacing: -.035em; }
body.paper .md-content h3 { letter-spacing: -.025em; }
body.paper .mermaid-content h1 { font-size: clamp(1.9rem, 4.5vw, 2.5rem); letter-spacing: -.045em; }

/* quotes — orange rule on translucent paper */
body.paper .md-content blockquote {
    background: var(--bg-surface);
    border-left-color: var(--orange);
}

/* code blocks — dark panels with paper-card radius */
body.paper .md-content pre { border-radius: 12px; }

/* anchor targets clear the sticky header */
body.paper .md-content :is(h1, h2, h3, h4, h5, h6) { scroll-margin-top: 96px; }

/* tables — light cards like the docs param tables */
body.paper .md-content .table-wrapper {
    background: var(--bg-surface);
    border-radius: 12px;
}

body.paper .md-content th { background: var(--bg-surface); }

/* mermaid blocks — paper cards around the white canvas */
body.paper .md-content .mermaid-block,
body.paper .mermaid-content .mermaid-block { border-radius: 14px; }

/* =========================================================
   DEPLOYED PAGE — share bar + expiry (paper)
   Shown on every deployment via layout.html (.deploy-meta)
   or injected into raw HTML. Uses paper tokens, no dark
   override needed.
   ========================================================= */

.deploy-meta {
    width: min(720px, calc(100% - 32px));
    margin: 18px auto 0;
    padding: 14px 0 18px;
    border-top: 1px solid var(--line);
}

.deploy-meta__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;

    padding: 10px 12px;

    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md); /* ramp (was one-off 13px) */

    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

.deploy-meta__expiry {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.deploy-meta__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(32, 165, 107, .45);
    animation: statusPulse 2.5s infinite;
}

.deploy-meta__countdown {
    color: var(--ink);
    font-weight: 600;
}

.deploy-meta__share {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.deploy-meta__url {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}

@media (max-width: 600px) { .deploy-meta__url { max-width: 160px; } }

.deploy-meta__copy {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;

    padding: 7px 10px;
    border-radius: 9px;

    border: 1px solid var(--line);
    background: var(--paper-bright);
    color: var(--ink);

    font-family: var(--sans);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .02em;

    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.deploy-meta__copy:hover {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
    transform: translateY(-1px);
}

.deploy-meta__copy:active { transform: scale(.97); }

.deploy-meta__copy.is-copied {
    background: var(--success-fill);
    border-color: var(--success-fill);
    color: var(--on-success);
}

/* Share button + popover (next to Copy link) */
.deploy-share-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.deploy-share__popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;

    min-width: 210px;
    padding: 8px;

    background: var(--paper-bright);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(20, 24, 32, .16);

    font-family: var(--sans);
    font-size: 13px;
    color: var(--ink);
}

.deploy-share__label {
    display: block;
    padding: 4px 10px 8px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.deploy-share__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 550;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background .16s ease;
}

.deploy-share__item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: currentColor;
}

.deploy-share__item:hover {
    background: var(--paper);
}

.deploy-share__item:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

/* playground copy button next to URL */

.deploy-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.deploy-url-row .deploy-url {
    margin-top: 0;
    flex: 1;
    min-width: 0;
}

.deploy-url-copy {
    flex-shrink: 0;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #3a3a38;
    background: #1e1e1c;
    color: #deddd8;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .15s;
}

.deploy-url-copy:hover { background: #2a2a28; }
.deploy-url-copy:active { transform: scale(.97); }
.deploy-url-copy.is-copied { background: var(--green); border-color: var(--green); color: white; }

.deploy-expiry {
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 10px;
    color: #9a9893;
    display: none;
}

.deploy-card.live .deploy-expiry { display: block; }

/* ==========================================================================
   DATA VIEWERS (JSON + CSV deployments)
   Server-rendered interactive explorers on the paper theme. Tree/table go
   on light paper cards; raw JSON stays on a dark code panel like Markdown
   code blocks. All classes are BEM under .jsonv-* / .csvv-*.
   ========================================================================== */

/* ----- shared viewer primitives ----- */

.jsonv-title, .csvv-title {
    font-size: clamp(1.9rem, 4.5vw, 2.5rem);
    letter-spacing: -.045em;
    margin: 0 0 1.25rem;
}

.jsonv {
    width: min(880px, 100%);
    margin-inline: auto;
}

/* CSV tables benefit from extra horizontal room for more columns/data. */
.csvv {
    width: min(1400px, calc(100% - 2rem));
    margin-inline: auto;
}

.jsonv-toolbar, .csvv-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.jsonv-search, .csvv-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 260px;
    min-width: 0;
}

.jsonv-search input[type="search"], .csvv-search input[type="search"],
.csvv-filter-input, .csvv-range-input {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--ink);
    background: var(--paper-bright);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 7px 10px;
    outline: none;
    transition: border-color .15s ease;
    min-width: 0;
}

.jsonv-search input[type="search"] { flex: 1 1 160px; }
.csvv-filter-input { width: 100%; }

.jsonv-search input:focus-visible, .csvv-search input:focus-visible,
.csvv-filter-input:focus-visible, .csvv-range-input:focus-visible {
    border-color: var(--orange);
}

.jsonv-search-count, .csvv-count {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.jsonv-actions, .csvv-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.jsonv-btn, .csvv-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--paper-bright);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .02em;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.jsonv-btn:hover:not(:disabled), .csvv-btn:hover:not(:disabled) {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
    transform: translateY(-1px);
}

.jsonv-btn:active:not(:disabled), .csvv-btn:active:not(:disabled) { transform: scale(.97); }
.jsonv-btn:disabled, .csvv-btn:disabled { opacity: .45; cursor: not-allowed; }

.jsonv-btn--primary, .csvv-btn--primary {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.jsonv-btn--primary:hover, .csvv-btn--primary:hover {
    background: var(--orange);
    border-color: var(--orange);
    color: var(--on-accent);
}

.jsonv-btn.active, .csvv-btn.active {
    background: var(--orange-soft);
    border-color: var(--orange);
    color: var(--orange);
}

.jsonv-depth, .csvv-perpage {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

.jsonv-depth select, .csvv-perpage select {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink);
    background: var(--paper-bright);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 6px 8px;
    cursor: pointer;
}

/* ----- JSON viewer: tree ----- */

.jsonv-panels { position: relative; }

.jsonv-tree {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink);
    overflow-x: auto;
}

.jsonv-node { position: relative; }

.jsonv-children {
    margin-left: 14px;
    padding-left: 14px;
    border-left: 1px solid var(--line);
}

.jsonv-line {
    display: flex;
    align-items: baseline;
    gap: 2px;
    white-space: nowrap;
}

.jsonv-toggle {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    padding: 0;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    transition: color .15s ease, background .15s ease;
}

.jsonv-toggle:hover { color: var(--ink); background: var(--orange-soft); }
.jsonv-toggle--leaf { cursor: default; }
.jsonv-toggle--leaf:hover { color: var(--muted); background: none; }

.jsonv-key {
    color: var(--ink);
    font-weight: 500;
    cursor: copy;
    border-radius: 4px;
    transition: background .15s ease;
}

.jsonv-key:hover { background: var(--orange-soft); }

.jsonv-colon { color: var(--muted); }

.jsonv-value { cursor: copy; border-radius: 4px; transition: background .15s ease; }
.jsonv-value:hover { background: var(--orange-soft); }

.jsonv-value--string { color: #187a4f; }
.jsonv-value--number { color: var(--blue); }
.jsonv-value--boolean { color: #8250df; }
.jsonv-value--null { color: var(--muted); font-style: italic; }

.jsonv-bracket { color: var(--muted); }

.jsonv-preview {
    color: var(--muted);
    font-size: 11px;
    margin: 0 4px;
}

.jsonv-badge {
    margin-left: 8px;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    background: rgba(23, 23, 21, .06);
    border-radius: 99px;
    padding: 1px 7px;
}

.jsonv-row--match {
    outline: 2px solid var(--orange);
    outline-offset: 2px;
    border-radius: 6px;
    background: var(--orange-soft);
}

/* ----- JSON viewer: raw tab ----- */

.jsonv-rawwrap { display: flex; flex-direction: column; gap: 0.75rem; }

.jsonv-rawbar { display: flex; gap: 8px; }

.jsonv-raw {
    margin: 0;
    background: #181817;
    border: 1px solid #30302e;
    border-radius: 14px;
    padding: 1.125rem 1.375rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.7;
    color: #deddd8;
}

.jsonv-stats {
    margin-top: 0.75rem;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

.jsonv-tabs {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 9px;
    overflow: hidden;
}

.jsonv-tab {
    padding: 7px 12px;
    border: none;
    background: var(--paper-bright);
    color: var(--muted);
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 650;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.jsonv-tab + .jsonv-tab { border-left: 1px solid var(--line); }
.jsonv-tab.active { background: var(--ink); color: var(--paper); }

/* ----- CSV viewer: table ----- */

.csvv-tablewrap {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: auto;
    max-height: 70vh;
}

.csvv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.csvv-table th, .csvv-table td {
    padding: 8px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csvv-headrow th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--paper);
    backdrop-filter: blur(4px);
    border-bottom: 1px solid var(--border-active, rgba(23, 23, 21, .38));
}

.csvv-sortbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: none;
    padding: 0;
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .01em;
    color: var(--ink);
    cursor: pointer;
}

.csvv-sortarrow { color: var(--orange); min-width: 12px; }

.csvv-type {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 500;
    color: var(--muted);
    background: rgba(23, 23, 21, .06);
    border-radius: 99px;
    padding: 1px 6px;
}

.csvv-type--badge { margin-left: 4px; text-transform: uppercase; letter-spacing: .05em; }

th.csvv-th--number .csvv-sortbtn, td.csvv-cell--number { text-align: right; }
td.csvv-cell--number { font-family: var(--mono); font-size: 12px; }

.csvv-filterrow td {
    position: sticky;
    top: 41px;
    z-index: 1;
    background: rgba(251, 250, 247, .95);
    padding: 6px 8px;
}

.csvv-range {
    display: inline-flex;
    gap: 4px;
}

.csvv-range-input { width: 72px; }

.csvv-row:nth-child(even) { background: var(--bg-surface-hover); }
.csvv-row:hover { background: var(--orange-soft); }

.csvv-empty { color: var(--muted); font-style: italic; text-align: center; }

.csvv-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 0.75rem;
}

.csvv-pager-label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

/* ----- CSV viewer: summary + charts ----- */

.csvv-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 1rem;
}

.csvv-statcard {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 14px;
}

.csvv-statcard-name {
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 650;
    color: var(--ink);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.csvv-statline {
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.7;
}

.csvv-statkey { color: var(--muted); }
.csvv-statval { color: var(--ink); }

.csvv-chart {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 1rem;
}

.csvv-chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

.csvv-chart-controls select {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink);
    background: var(--paper-bright);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 6px 8px;
    cursor: pointer;
}

.csvv-chart-stage { overflow-x: auto; }

.csvv-svg { width: 100%; height: auto; min-width: 480px; }

.csvv-grid { stroke: var(--line); stroke-width: 1; }
.csvv-axis { stroke: rgba(23, 23, 21, .38); stroke-width: 1; }
.csvv-tick { fill: var(--muted); font-family: var(--mono); font-size: 10px; }
.csvv-line { fill: none; stroke: var(--orange); stroke-width: 2; stroke-linejoin: round; }
.csvv-point { fill: var(--orange); stroke: #fff; stroke-width: 1.5; transition: r .15s ease; }
.csvv-point:hover { fill: var(--ink); }
.csvv-bar { fill: var(--orange); opacity: .85; transition: opacity .15s ease; }
.csvv-bar:hover { opacity: 1; }

.csvv-chart-empty {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 24px 0;
}

/* ----- shared toast ----- */

.jsonv-toast, .csvv-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(12px);
    background: var(--ink);
    color: var(--paper);
    font-family: var(--mono);
    font-size: 11px;
    padding: 8px 14px;
    border-radius: 99px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 1200;
}

.jsonv-toast.is-visible, .csvv-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ----- responsive ----- */

@media (max-width: 640px) {

    .jsonv, .csvv { width: 100%; }
    .jsonv-tree { padding: 0.75rem 0.85rem; font-size: 12px; }
    .jsonv-children { margin-left: 8px; padding-left: 8px; }
    .csvv-table th, .csvv-table td { padding: 6px 10px; }
    .csvv-filterrow td { top: 37px; }
}

