:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f1f6fa;
    --surface-strong: #e2e8f0;
    --button-surface: #f8fafc;
    --button-surface-hover: #eef4f8;
    --button-border: #cfd9e5;
    --text: #142033;
    --muted: #627086;
    --faint: #8a96a8;
    --line: #d9e2ec;
    --primary: #126d78;
    --primary-strong: #0d5661;
    --primary-soft: #e1f4f6;
    --choice-catalog-bg: #f0f7ff;
    --choice-catalog-border: #c7ddf5;
    --choice-random-bg: #f2fbf5;
    --choice-random-border: #c8ead5;
    --choice-upload-bg: #fff8ed;
    --choice-upload-border: #f2d5a6;
    --picker-section-bg: #f7fbfd;
    --picker-section-border: #d6e5ee;
    --on-primary: #ffffff;
    --tour: #f59e0b;
    --tour-soft: #fff3cf;
    --danger: #c24141;
    --shadow: 0 18px 46px rgba(30, 41, 59, 0.09);
    --shadow-subtle: 0 1px 0 rgba(20, 32, 51, 0.04);
    --shadow-overlay: 0 8px 22px rgba(15, 23, 42, 0.12);
    --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --page-bg: var(--bg);
    --page-ambient-bg: linear-gradient(180deg, rgba(18, 109, 120, 0.08), rgba(245, 247, 251, 0) 260px), var(--bg);
    --panel-bg: var(--surface);
    --panel-soft-bg: var(--surface-soft);
    --panel-strong-bg: var(--surface-strong);
    --panel-translucent-bg: rgba(255, 255, 255, 0.70);
    --panel-border: var(--line);
    --panel-shadow: var(--shadow);
    --topbar-bg: rgba(255, 255, 255, 0.90);
    --overlay-bg: rgba(15, 23, 42, 0.34);
    --drawer-overlay-bg: rgba(15, 23, 42, 0.28);
    --control-bg: var(--surface);
    --control-muted-bg: var(--button-surface);
    --control-muted-bg-hover: var(--button-surface-hover);
    --control-border: var(--button-border);
    --control-border-hover: #bdcad8;
    --control-disabled-bg: #f8fafc;
    --control-disabled-text: var(--faint);
    --control-disabled-border: var(--line);
    --control-disabled-accent: #94a3b8;
    --focus-ring: rgba(18, 109, 120, 0.20);
    --input-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
    --action-shadow: 0 8px 18px rgba(18, 109, 120, 0.20);
    --active-action-shadow: 0 5px 14px rgba(18, 109, 120, 0.18);
    --tooltip-bg: var(--surface);
    --tooltip-text: var(--text);
    --tooltip-border: var(--line);
    --info-border: rgba(18, 109, 120, 0.20);
    --info-border-strong: rgba(18, 109, 120, 0.35);
    --info-text: var(--primary-strong);
    --info-surface-bg: rgba(255, 255, 255, 0.96);
    --attention-bg: #fff7df;
    --attention-bg-soft: #fffdf5;
    --attention-border: rgba(217, 119, 6, 0.28);
    --attention-border-strong: rgba(217, 119, 6, 0.42);
    --attention-text: #7a4b00;
    --warning-text: #7a4b00;
    --warning-strong: #5f3700;
    --warning-pill-text: #92400e;
    --warning-bg: #fff7df;
    --warning-bg-soft: #fffaf0;
    --warning-pill-bg: #fef3c7;
    --warning-border: rgba(245, 158, 11, 0.26);
    --warning-border-strong: rgba(245, 158, 11, 0.34);
    --danger-text: var(--danger);
    --danger-emphasis: #8a2f2f;
    --danger-bg: #fff5f5;
    --danger-bg-soft: #fffafa;
    --danger-pill-bg: #fee2e2;
    --danger-prompt-bg: #fff7ed;
    --danger-border: rgba(194, 65, 65, 0.22);
    --danger-border-strong: rgba(194, 65, 65, 0.45);
    --danger-border-prominent: rgba(194, 65, 65, 0.72);
    --danger-shadow: 0 8px 24px rgba(194, 65, 65, 0.08);
    --success-text: #166534;
    --success-bg: #dcfce7;
    --success-bg-soft: #ecfdf3;
    --success-border: rgba(22, 101, 52, 0.24);
    --neutral-pill-text: #475569;
    --neutral-pill-bg: #e2e8f0;
    --canvas-grid-bg: #f8fafc;
    --canvas-grid-line: var(--surface-soft);
    --canvas-dark-bg: radial-gradient(circle at 50% 48%, rgba(38, 48, 64, 0.78), rgba(17, 20, 26, 0.96) 58%, #11141a 78%), linear-gradient(180deg, #171d27 0%, #0f1218 100%);
    --sequence-text: #243244;
    --sequence-focus-ring: rgba(37, 99, 235, 0.18);
    --sequence-focus-border: rgba(37, 99, 235, 0.45);
    --code-bg: #f8fafc;
    --code-text: #102a43;
    --code-dark-bg: #0f172a;
    --code-dark-border: #1e293b;
    --code-dark-text: #dbeafe;
    --code-dark-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --syntax-key: #7dd3fc;
    --syntax-string: #bbf7d0;
    --syntax-number: #fdba74;
    --syntax-literal: #c4b5fd;
    --math-text: #5f3700;
    --radius-control: 8px;
    --radius-panel: 8px;
    --radius-pill: 999px;
    --space-2xs: 2px;
    --space-xs: 4px;
    --space-sm: 6px;
    --space-md: 8px;
    --space-lg: 10px;
    --space-xl: 12px;
    --space-2xl: 14px;
    --space-3xl: 16px;
    --space-4xl: 18px;
    --control-height: 40px;
    --control-height-compact: 32px;
    --control-height-mobile: 38px;
    --icon-button-size: 28px;
    --space-control-x: 14px;
    --space-control-compact-x: 10px;
    --font-size-label: 0.72rem;
    --font-size-caption: 0.78rem;
    --font-size-small: 0.84rem;
    --font-size-body: 0.9rem;
    --font-size-subtitle: 0.9rem;
    --font-size-control: 0.92rem;
    --font-size-control-small: 0.82rem;
    --font-size-input: 0.94rem;
    --font-size-overlay-metric: 0.88rem;
    --font-weight-label: 760;
    --font-weight-control: 720;
    --font-weight-copy-strong: 650;
    --font-weight-emphasis: 680;
    --font-size-heading-lg: 1.28rem;
    --font-size-heading-md: 1.05rem;
    --font-size-heading-sm: 1rem;
    --font-size-heading-mobile: 1.05rem;
    --font-size-subtitle-mobile: 0.82rem;
    --font-size-stat: 1.18rem;
    --line-height-tight: 1.1;
    --line-height-heading: 1.2;
    --line-height-heading-mobile: 1.16;
    --line-height-control: 1.15;
    --line-height-label: 1.35;
    --line-height-label-mobile: 1.32;
    --line-height-copy: 1.45;
    --line-height-longform: 1.55;
    --letter-spacing-label: 0.02em;
    --shell-padding: var(--space-4xl);
    --shell-gap: var(--space-2xl);
    --panel-padding: var(--space-3xl);
    --section-padding: var(--space-2xl);
    --control-gap: var(--space-md);
    --cluster-gap: var(--space-xl);
    --tooltip-padding: var(--space-md) var(--space-lg);
    --tooltip-line-height: var(--line-height-label);
    --tooltip-transition: opacity 140ms ease, transform 140ms ease;
    --metric-card-min-height: 74px;
    --canvas-grid-size: 26px;
    --overlay-pill-bg: rgba(255, 255, 255, 0.82);
    --overlay-pill-border: rgba(217, 226, 236, 0.72);
    font-family: var(--font-ui);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    width: 100%;
}

body {
    overflow-x: hidden;
    background: var(--page-bg);
    color: var(--text);
    font-family: var(--font-ui);
}

button,
select,
input {
    font: inherit;
}

button,
a,
select,
input[type="checkbox"] {
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

button:hover,
a:hover {
    transform: translateY(-1px);
}

button:disabled,
.disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

button:disabled,
.switch.disabled {
    color: var(--control-disabled-text);
    background: var(--control-disabled-bg);
    border-color: var(--control-disabled-border);
    box-shadow: none;
}

.switch.disabled input {
    accent-color: var(--control-disabled-accent);
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
    padding: var(--shell-padding);
    gap: var(--shell-gap);
}

.zkp-shell {
    background: var(--page-ambient-bg);
}

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4xl);
    padding: var(--space-2xl) var(--space-3xl);
    background: var(--topbar-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.brand-block,
.toolbar,
.panel-heading.split,
.canvas-pills,
.tour-controls,
.download-row,
.panel-actions {
    display: flex;
    align-items: center;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: var(--cluster-gap);
    min-width: 250px;
}

.menu-button {
    width: var(--control-height);
    height: var(--control-height);
    flex: 0 0 auto;
    display: inline-grid;
    place-content: center;
    gap: var(--space-xs);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-control);
    background: var(--control-bg);
}

.menu-button span {
    width: 18px;
    height: 2px;
    display: block;
    border-radius: var(--radius-pill);
    background: var(--text);
}

.side-nav {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--drawer-overlay-bg);
}

.side-nav[hidden] {
    display: none;
}

.side-nav-panel {
    width: min(260px, 84vw);
    min-height: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--panel-padding);
    border-right: 1px solid var(--panel-border);
    background: var(--panel-bg);
    box-shadow: var(--panel-shadow);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: var(--font-size-label);
    font-weight: var(--font-weight-label);
    letter-spacing: var(--letter-spacing-label);
    text-transform: uppercase;
}

h1,
h2,
p {
    letter-spacing: 0;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: var(--font-size-heading-lg);
    line-height: var(--line-height-tight);
    font-weight: 760;
}

.topbar-subtitle {
    max-width: 780px;
    margin: var(--space-sm) 0 0;
    color: var(--muted);
    font-size: var(--font-size-subtitle);
    font-weight: var(--font-weight-copy-strong);
    line-height: var(--line-height-label);
}

.topbar-subtitle a {
    color: inherit;
    text-decoration-color: currentColor;
    text-underline-offset: 0.18em;
}

.topbar-guide-link {
    width: 1.25em;
    height: 1.25em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 0.82em;
    font-weight: 780;
    font-style: italic;
    line-height: 1;
    text-decoration: none;
    vertical-align: text-bottom;
}

h2 {
    font-size: var(--font-size-heading-sm);
    line-height: var(--line-height-heading);
    font-weight: 720;
}

h3 {
    margin: 0;
    font-size: var(--font-size-heading-sm);
    line-height: var(--line-height-heading);
    font-weight: 760;
}

code,
pre {
    font-family: var(--font-mono);
}

.section-subtitle {
    margin: var(--space-xs) 0 0;
    color: var(--attention-text);
    font-size: var(--font-size-control-small);
    font-weight: var(--font-weight-emphasis);
    line-height: var(--line-height-label);
}

.toolbar {
    justify-content: flex-end;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.page-nav {
    align-items: center;
    min-width: 0;
}

.page-nav .secondary-action.active {
    color: var(--primary-strong);
    background: var(--panel-soft-bg);
    border-color: var(--info-border-strong);
    box-shadow: none;
}

.field {
    display: grid;
    gap: var(--space-sm);
    color: var(--muted);
    font-size: var(--font-size-label);
    font-weight: var(--font-weight-control);
    letter-spacing: var(--letter-spacing-label);
    text-transform: uppercase;
}

.field input,
.field select {
    width: min(34vw, 320px);
    min-width: 220px;
    height: var(--control-height);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-control);
    padding: 0 36px 0 12px;
    color: var(--text);
    background: var(--control-bg);
    font-size: var(--font-size-input);
    box-shadow: var(--input-shadow);
}

.primary-action,
.secondary-action,
.tool-button,
.mode-button,
.file-action,
.download-link {
    min-width: 0;
    max-width: 100%;
    height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-control);
    border: 1px solid transparent;
    padding: 0 var(--space-control-x);
    font-size: var(--font-size-control);
    font-weight: var(--font-weight-control);
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.primary-action {
    color: var(--on-primary);
    background: var(--primary);
    box-shadow: var(--action-shadow);
}

.primary-action:hover {
    background: var(--primary-strong);
}

.secondary-action,
.tool-button,
.mode-button,
.file-action,
.download-link {
    color: var(--text);
    background: var(--control-muted-bg);
    border-color: var(--control-border);
}

.secondary-action:hover,
.tool-button:hover,
.mode-button:hover,
.file-action:hover,
.download-link:hover {
    background: var(--control-muted-bg-hover);
    border-color: var(--control-border-hover);
}

.upload-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.app-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: var(--space-4xl);
    background: var(--overlay-bg);
}

.app-dialog-backdrop[hidden] {
    display: none;
}

.app-dialog {
    position: relative;
    width: min(440px, 100%);
    display: grid;
    gap: var(--space-2xl);
    padding: var(--space-4xl);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-panel);
    color: var(--text);
    background: var(--panel-bg);
    box-shadow: var(--panel-shadow);
}

.popup-close-button {
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--control-border);
    border-radius: var(--radius-control);
    padding: 0;
    color: var(--muted);
    background: var(--control-muted-bg);
    font-size: 1.15rem;
    font-weight: var(--font-weight-label);
    line-height: 1;
    cursor: pointer;
}

.popup-close-button:hover {
    color: var(--text);
    background: var(--control-muted-bg-hover);
    border-color: var(--control-border-hover);
}

.dialog-close-button {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
}

.app-dialog-heading {
    display: grid;
    gap: var(--space-2xs);
    padding-right: calc(var(--icon-button-size) + var(--space-md));
}

.app-dialog-heading h2 {
    margin: 0;
    font-size: var(--font-size-heading-md);
    line-height: var(--line-height-heading);
}

.app-dialog-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-lg);
}

.app-dialog-wide {
    grid-column: 1 / -1;
}

.app-dialog input {
    width: 100%;
    height: var(--control-height);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-control);
    padding: 0 var(--space-control-compact-x);
    color: var(--text);
    background: var(--control-bg);
}

.app-dialog-help {
    margin: 0;
    color: var(--muted);
    font-size: var(--font-size-control-small);
    line-height: var(--line-height-copy);
}

.app-dialog-help.error {
    color: var(--danger-text);
}

.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--control-gap);
    flex-wrap: wrap;
}

.info-button {
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    flex: 0 0 auto;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-pill);
    color: var(--muted);
    background: var(--control-muted-bg);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-label);
    line-height: 1;
}

.info-button:hover,
.info-button:focus-visible {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: var(--info-border-strong);
}

.upload-help-text {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 20;
    width: min(280px, 78vw);
    padding: var(--tooltip-padding);
    border: 1px solid var(--tooltip-border);
    border-radius: var(--radius-panel);
    color: var(--tooltip-text);
    background: var(--tooltip-bg);
    box-shadow: var(--panel-shadow);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-copy-strong);
    line-height: var(--tooltip-line-height);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: var(--tooltip-transition);
}

.upload-help-text.viewport-tooltip,
.animation-help-text.viewport-tooltip {
    position: fixed;
    left: 0;
    right: auto;
    top: 0;
    bottom: auto;
    z-index: 120;
    width: min(360px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
}

.upload-help-text.tooltip-open,
.animation-help-text.tooltip-open {
    opacity: 1;
    transform: translateY(0);
}

#upload-help:hover + .upload-help-text,
.info-button:focus-visible + .upload-help-text {
    opacity: 1;
    transform: translateY(0);
}

.switch {
    min-width: 0;
    max-width: 100%;
    height: var(--control-height);
    display: inline-flex;
    align-items: center;
    gap: var(--control-gap);
    padding: 0 var(--space-control-compact-x);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-control);
    color: var(--text);
    background: var(--control-bg);
    font-size: var(--font-size-body);
    font-weight: 680;
}

.switch input {
    width: 34px;
    height: 20px;
    margin: 0;
    accent-color: var(--primary);
}
