html, body {
    height: 100%;
}

/* The whole app is drawn a fifth larger than a browser's default, the same scale as
   TextFlex, CronFlex and SetFlex - the *Flex apps are drawn at one size.

   Every size in this app is in `rem`, so this one number is the app's scale and nothing
   else has to know about it - change it and the type, the panes and the tables all move
   together. A percentage rather than a pixel count so that a reader who has already set
   a larger default font in their browser keeps the increase.

   The media queries are the exception and cannot use it: `rem` inside a media query is
   always the browser's initial 16px, whatever this says. So every breakpoint in this app
   is written at 1.2x the width it would otherwise be - the content is 1.2x, so it runs
   out of room 1.2x sooner. */
:root {
    font-size: 120%;
}

/* JwtFlex theme.
   Dark is the default (this is a developer tool, and it is what most users of it
   want); light applies when the user picks it, or when the system asks for it and
   the user has not overridden that. Every token is defined here on bare `:root`
   so no colour exists only inside a media query. */
:root {
    color-scheme: dark;
    --jf-bg: #0d1015;
    --jf-pane: #15191f;
    --jf-pane-alt: #11151a;
    --jf-chrome: #0a0d11;
    --jf-chrome-2: #12161c;
    --jf-chrome-hover: #1e242d;
    --jf-border: #262f3a;
    --jf-border-soft: #1a212a;
    --jf-text: #dde5ee;
    --jf-muted: #8391a2;
    --jf-faint: #56626f;
    --jf-accent: #8b7cf6;
    --jf-accent-bright: #a396ff;
    --jf-accent-ink: #120a2e;
    --jf-accent-dim: rgba(139, 124, 246, 0.45);
    --jf-accent-wash: rgba(139, 124, 246, 0.14);

    /* The three verdict colours, used for findings, the signature badge and the
       segment hues alike - so that green always means the same thing on this page
       whichever pane it turns up in. */
    --jf-good: #3ecf8e;
    --jf-good-wash: rgba(62, 207, 142, 0.13);
    --jf-warn: #e8a33c;
    --jf-warn-wash: rgba(232, 163, 60, 0.13);
    --jf-danger: #f2777a;
    --jf-danger-wash: rgba(242, 119, 122, 0.13);

    /* One hue per part of the token. These are the whole idea of the input pane:
       the colours in the pasted token are the colours of the panes that decode it. */
    --jf-seg-header: #4cb7ec;
    --jf-seg-claims: #8b7cf6;
    --jf-seg-signature: #3ecf8e;

    --jf-json-key: #7fc8f0;
    --jf-json-string: #86dbaf;
    --jf-json-number: #e8b76c;
    --jf-json-keyword: #a396ff;

    --jf-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* The FlexTools menu, Feedback and the privacy sheet (css/tools-menu.css, css/feedback.css and
   css/privacy-sheet.css, the same files in every tool) in this tool's colours. Only references, so
   the light theme below carries straight through. */
:root {
    --fxm-pane: var(--jf-pane);
    --fxm-pane-alt: var(--jf-pane-alt);
    --fxm-field: var(--jf-chrome-2);
    --fxm-hover: var(--jf-chrome-hover);
    --fxm-border: var(--jf-border);
    --fxm-border-soft: var(--jf-border-soft);
    --fxm-text: var(--jf-text);
    --fxm-muted: var(--jf-muted);
    --fxm-faint: var(--jf-faint);
    --fxm-danger: var(--jf-danger);
    --fxm-accent: var(--jf-accent);
    --fxm-accent-dim: var(--jf-accent-dim);
    --fxm-accent-wash: var(--jf-accent-wash);
    --fxm-statusbar-h: var(--jf-statusbar-h);
}

:root[data-theme="light"] {
    color-scheme: light;
    --jf-bg: #e7ebf0;
    --jf-pane: #ffffff;
    --jf-pane-alt: #f7f9fb;
    --jf-chrome: #f9fbfc;
    --jf-chrome-2: #f1f4f7;
    --jf-chrome-hover: #e4e9ef;
    --jf-border: #ccd5df;
    --jf-border-soft: #dde4eb;
    --jf-text: #18202a;
    --jf-muted: #5a6673;
    --jf-faint: #98a3af;
    --jf-accent: #5b48d8;
    --jf-accent-bright: #6d5ae6;
    --jf-accent-ink: #ffffff;
    --jf-accent-dim: rgba(91, 72, 216, 0.45);
    --jf-accent-wash: rgba(91, 72, 216, 0.10);

    --jf-good: #0f7a52;
    --jf-good-wash: rgba(15, 122, 82, 0.10);
    --jf-warn: #9a5c00;
    --jf-warn-wash: rgba(154, 92, 0, 0.10);
    --jf-danger: #c02f33;
    --jf-danger-wash: rgba(192, 47, 51, 0.09);

    --jf-seg-header: #1a86c4;
    --jf-seg-claims: #5b48d8;
    --jf-seg-signature: #0f7a52;

    --jf-json-key: #1a6fa8;
    --jf-json-string: #0f7a52;
    --jf-json-number: #9a5c00;
    --jf-json-keyword: #5b48d8;

    --jf-shadow: 0 1px 2px rgba(24, 32, 42, 0.06);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        --jf-bg: #e7ebf0;
        --jf-pane: #ffffff;
        --jf-pane-alt: #f7f9fb;
        --jf-chrome: #f9fbfc;
        --jf-chrome-2: #f1f4f7;
        --jf-chrome-hover: #e4e9ef;
        --jf-border: #ccd5df;
        --jf-border-soft: #dde4eb;
        --jf-text: #18202a;
        --jf-muted: #5a6673;
        --jf-faint: #98a3af;
        --jf-accent: #5b48d8;
        --jf-accent-bright: #6d5ae6;
        --jf-accent-ink: #ffffff;
        --jf-accent-dim: rgba(91, 72, 216, 0.45);
        --jf-accent-wash: rgba(91, 72, 216, 0.10);

        --jf-good: #0f7a52;
        --jf-good-wash: rgba(15, 122, 82, 0.10);
        --jf-warn: #9a5c00;
        --jf-warn-wash: rgba(154, 92, 0, 0.10);
        --jf-danger: #c02f33;
        --jf-danger-wash: rgba(192, 47, 51, 0.09);

        --jf-seg-header: #1a86c4;
        --jf-seg-claims: #5b48d8;
        --jf-seg-signature: #0f7a52;

        --jf-json-key: #1a6fa8;
        --jf-json-string: #0f7a52;
        --jf-json-number: #9a5c00;
        --jf-json-keyword: #5b48d8;

        --jf-shadow: 0 1px 2px rgba(24, 32, 42, 0.06);
    }
}

body {
    margin: 0;
    background: var(--jf-bg);
}

/* A standing document scrolls, so the page background has to be the theme's rather than the
   browser's white - otherwise overscroll, and any gap under a short document, flashes white
   behind a dark page. Set on body rather than on .doc itself, because it is body's background
   that propagates to the canvas the overscroll paints. Redundant with the bare `body` rule
   above today - JwtFlex has no undecorated template page left to be selective about - but kept
   explicit so it says why, the way TextFlex's does. */
body:has(.doc) {
    margin: 0;
    background: var(--jf-bg);
}

/* Whatever the script hides stays hidden, whatever display a component rule gives it. */
[hidden] {
    display: none !important;
}

/* ── Shared controls ──────────────────────────────────────────────────────────
   Used across the token pane, the claims pane and both folding sections, so they
   are defined once here rather than with any one of them. */

/* Small ghost button: the pane and section header bars are full of these. */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.1875rem 0.4375rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--jf-muted);
    font: inherit;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
}

.btn:hover:not(:disabled) {
    background: var(--jf-chrome-hover);
    border-color: var(--jf-border);
    color: var(--jf-text);
}

.btn:disabled {
    cursor: default;
    opacity: 0.5;
}

/* The one button on screen that does something outward-facing - fetching an
   issuer's keys - so it is the one that looks like a button rather than a hint. */
.btn-strong {
    border-color: var(--jf-border);
    background: var(--jf-pane);
    color: var(--jf-text);
}

.btn-strong:hover:not(:disabled) {
    border-color: var(--jf-accent-dim);
    background: var(--jf-accent-wash);
    color: var(--jf-text);
}

/* A two- or three-way switch drawn as one joined strip: Table/JSON, and the time
   format. Pressed rather than one-shot - the state is what the pane is showing. */
.seg {
    display: inline-flex;
    flex: none;
    overflow: hidden;
    border: 1px solid var(--jf-border);
    border-radius: 5px;
}

.seg > button {
    padding: 0.125rem 0.4375rem;
    border: 0;
    background: transparent;
    color: var(--jf-muted);
    font: inherit;
    font-size: 0.6875rem;
    white-space: nowrap;
    cursor: pointer;
}

.seg > button + button {
    border-left: 1px solid var(--jf-border);
}

.seg > button:hover:not(.is-on) {
    background: var(--jf-chrome-hover);
    color: var(--jf-text);
}

.seg > button.is-on {
    background: var(--jf-accent-wash);
    color: var(--jf-accent);
    font-weight: 600;
}

/* A verdict, wherever one is stated: the token's status, a signature result, the
   severity of a finding. The hue comes from a --tone the caller sets, so one rule
   covers good, warning and bad. */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    flex: none;
    padding: 0.0625rem 0.4375rem 0.0625rem 0.375rem;
    border: 1px solid color-mix(in srgb, var(--tone, var(--jf-muted)) 40%, transparent);
    border-radius: 999px;
    background: var(--tone-wash, transparent);
    color: var(--tone, var(--jf-muted));
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-good {
    --tone: var(--jf-good);
    --tone-wash: var(--jf-good-wash);
}

.badge-warn {
    --tone: var(--jf-warn);
    --tone-wash: var(--jf-warn-wash);
}

.badge-bad {
    --tone: var(--jf-danger);
    --tone-wash: var(--jf-danger-wash);
}

.badge-mark {
    font-size: 0.8125rem;
    line-height: 1;
}

/* A checkbox with its label, as used for the base64 secret switch. */
.opt {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex: none;
    color: var(--jf-muted);
    font-size: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.opt input {
    width: 0.875rem;
    height: 0.875rem;
    margin: 0;
    accent-color: var(--jf-accent);
}

/* ── Panes ───────────────────────────────────────────────────────────────────
   The two panes that are always open - the token and the claims - share their
   chrome with each other and with the collapsible sections' bars, and they are
   laid out from three different components, so the chrome is global. */
.pane {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--jf-pane);
}

/* The pane's hue, used for the hairline under its header and for the focus rule -
   enough to tie a pane to the part of the token it belongs to without colouring
   the text the user is actually reading. */
.pane-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: none;
    min-height: 1.875rem;
    padding: 0.1875rem 0.5rem 0.1875rem 0.625rem;
    background: var(--jf-pane-alt);
    border-bottom: 1px solid var(--jf-border-soft);
    box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--pane-hue, var(--jf-accent)) 35%, transparent);
}

.pane-title {
    margin: 0;
    flex: none;
    color: var(--jf-text);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.pane-meta {
    min-width: 0;
    overflow: hidden;
    color: var(--jf-muted);
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pane-spacer {
    flex: 1;
    min-width: 0.25rem;
}

.pane-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: none;
}

/* The strip under the token editor, where the verdict and the findings go. */
.pane-foot {
    flex: none;
    max-height: 45%;
    overflow-y: auto;
    padding: 0.4375rem 0.625rem 0.5rem;
    background: var(--jf-pane-alt);
    border-top: 1px solid var(--jf-border-soft);
    font-size: 0.75rem;
}

/* Stacked and scrolling with the page: nothing clips its own content, and each
   pane's header follows it down the screen so Copy and Clear stay to hand. */
@media (max-width: 57.59rem) {
    .pane {
        overflow: visible;
    }

    .pane-head {
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .pane-foot {
        max-height: none;
        overflow-y: visible;
    }
}

/* Monospace, for everything that is a token, a claim name or a key. Claim names
   and their values are exact strings, and a proportional font makes an l and a 1
   the same character - which on this page is the difference between two tenants. */
.mono {
    font-family: 'JetBrains Mono', 'Cascadia Mono', 'Consolas', ui-monospace, monospace;
    font-size: 0.8125rem;
}

