@layer reset, base, components, layout, utilities;

/* ------------------------------------------------------------------ */
/* Reset                                                               */
/* ------------------------------------------------------------------ */

@layer reset {
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    html {
        scroll-behavior: smooth;
        scroll-padding-top: 5.5rem;
    }

    body,
    h1,
    h2,
    h3,
    h4,
    h5,
    p,
    ul,
    ol,
    fieldset,
    figure,
    pre {
        margin: 0;
    }

    ul,
    ol {
        padding: 0;
    }

    fieldset {
        border: 0;
        padding: 0;
        min-width: 0;
    }

    button,
    input,
    textarea {
        color: inherit;
        font: inherit;
    }

    button,
    summary,
    input[type="file"] {
        cursor: pointer;
    }

    button:disabled,
    input:disabled {
        cursor: not-allowed;
    }

    img,
    svg {
        display: block;
        max-width: 100%;
    }

    [hidden] {
        display: none !important;
    }
}

/* ------------------------------------------------------------------ */
/* Design tokens & base elements                                       */
/* ------------------------------------------------------------------ */

@layer base {
    :root {
        color-scheme: light;

        /* warm neutrals */
        --paper: #ffffff;
        --canvas: #f7f6f2;
        --canvas-deep: #f0eee7;
        --ink-900: #23221c;
        --ink-800: #33322a;
        --ink-700: #47453b;
        --ink-600: #5c5a4e;
        --ink-500: #737163;
        --ink-400: #8e8b7c;
        --ink-300: #b3b0a1;
        --ink-200: #d8d5c9;
        --border: #e6e3d8;
        --border-strong: #d2cfc1;

        /* single accent: pine green */
        --pine-800: #17492f;
        --pine-700: #1d5a3e;
        --pine-600: #256b4b;
        --pine-500: #2f7d59;
        --pine-100: #e2eee6;
        --pine-50: #f1f6f2;
        --pine-border: #bcd4c4;

        /* semantic states, used sparingly */
        --warn-700: #8a5d15;
        --warn-100: #f7efda;
        --warn-border: #e2d0a2;
        --error-700: #a63d33;
        --error-100: #f8ebe8;
        --error-border: #e5c4bc;

        --shadow-sm: 0 1px 2px rgba(35, 34, 28, .05), 0 3px 10px rgba(35, 34, 28, .04);
        --shadow-md: 0 14px 40px rgba(35, 34, 28, .08), 0 2px 8px rgba(35, 34, 28, .04);

        --radius-sm: .5rem;
        --radius-md: .75rem;
        --radius-lg: 1.1rem;
        --radius-xl: 1.4rem;

        --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
        --font-mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, Menlo, monospace;

        --shell: 1200px;
    }

    body {
        min-width: 320px;
        min-height: 100vh;
        background: var(--canvas);
        color: var(--ink-900);
        font-family: var(--font-sans);
        line-height: 1.6;
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
    }

    ::selection {
        background: #d5e6da;
        color: var(--ink-900);
    }

    a {
        color: inherit;
        text-decoration: none;
    }

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

    code {
        border-radius: .3rem;
        background: var(--canvas-deep);
        color: var(--ink-800);
        font-size: .9em;
        padding: .1em .35em;
    }

    :focus-visible {
        outline: 3px solid rgba(37, 107, 75, .4);
        outline-offset: 2px;
    }

    @media (prefers-reduced-motion: reduce) {
        html {
            scroll-behavior: auto;
        }

        *,
        *::before,
        *::after {
            animation-duration: .01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: .01ms !important;
        }
    }
}

/* ------------------------------------------------------------------ */
/* Shared components                                                   */
/* ------------------------------------------------------------------ */

@layer components {
    .protocol-warning {
        border-bottom: 1px solid var(--error-border);
        background: var(--error-100);
        color: var(--error-700);
        font-size: .88rem;
        line-height: 1.7;
        padding: .8rem 1.5rem;
        text-align: center;
    }

    .protocol-warning strong {
        display: block;
    }

    .protocol-warning code {
        background: rgba(166, 61, 51, .1);
        color: inherit;
    }

    .protocol-warning a {
        color: inherit;
        font-weight: 700;
        text-decoration: underline;
        text-underline-offset: .2em;
    }

    .skip-link {
        position: fixed;
        z-index: 1000;
        left: 1rem;
        top: 1rem;
        transform: translateY(-180%);
        border-radius: var(--radius-sm);
        background: var(--paper);
        box-shadow: var(--shadow-md);
        color: var(--pine-700);
        font-weight: 700;
        padding: .7rem 1rem;
        transition: transform .18s ease;
    }

    .skip-link:focus {
        transform: translateY(0);
    }

    /* Buttons ------------------------------------------------------- */

    .button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .5rem;
        min-height: 2.7rem;
        border: 1px solid transparent;
        border-radius: var(--radius-sm);
        font-size: .9rem;
        font-weight: 600;
        line-height: 1;
        padding: .7rem 1.05rem;
        -webkit-tap-highlight-color: transparent;
        transition: border-color .16s ease, background-color .16s ease, color .16s ease, box-shadow .16s ease;
    }

    .button i {
        font-size: .85em;
    }

    .button-primary {
        background: var(--pine-700);
        color: #fdfdfb;
    }

    .button-primary:hover:not(:disabled) {
        background: var(--pine-800);
    }

    .button-primary:disabled {
        background: var(--ink-300);
        color: var(--paper);
    }

    .button-secondary {
        background: var(--paper);
        border-color: var(--border-strong);
        color: var(--ink-800);
    }

    .button-secondary:hover:not(:disabled) {
        border-color: var(--pine-600);
        color: var(--pine-700);
    }

    .button-secondary:disabled {
        color: var(--ink-300);
        border-color: var(--border);
    }

    .button-quiet {
        background: transparent;
        border-color: transparent;
        color: var(--ink-700);
    }

    .button-quiet:hover {
        color: var(--pine-700);
        background: var(--pine-50);
    }

    .button-danger {
        background: var(--paper);
        border-color: var(--error-border);
        color: var(--error-700);
    }

    .button-danger:hover:not(:disabled) {
        background: var(--error-100);
    }

    .button-danger:disabled {
        color: var(--ink-300);
        border-color: var(--border);
    }

    .button-large {
        min-height: 3rem;
        font-size: .95rem;
        padding: .8rem 1.4rem;
    }

    .button-small {
        min-height: 2.15rem;
        font-size: .8rem;
        padding: .45rem .75rem;
    }

    .text-button {
        border: 0;
        background: none;
        color: var(--pine-700);
        font-size: .82rem;
        font-weight: 600;
        padding: .25rem .35rem;
        border-radius: .35rem;
        -webkit-tap-highlight-color: transparent;
    }

    .text-button:hover:not(:disabled) {
        background: var(--pine-50);
    }

    .text-button:disabled {
        color: var(--ink-300);
    }

    /* Kickers, eyebrows, badges ------------------------------------- */

    .eyebrow {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
        color: var(--pine-700);
        font-size: .78rem;
        font-weight: 700;
        letter-spacing: .12em;
        text-transform: uppercase;
    }

    .eyebrow span {
        width: 1.4rem;
        height: 2px;
        border-radius: 1px;
        background: var(--pine-600);
    }

    .graph-kicker {
        display: block;
        color: var(--ink-400);
        font-size: .68rem;
        font-weight: 700;
        letter-spacing: .14em;
        text-transform: uppercase;
    }

    .state-badge {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
        border: 1px solid var(--border);
        border-radius: 999px;
        background: var(--paper);
        color: var(--ink-600);
        font-size: .82rem;
        font-weight: 600;
        padding: .45rem .9rem;
        white-space: nowrap;
    }

    .state-badge i {
        width: .55rem;
        height: .55rem;
        border-radius: 50%;
        background: var(--ink-300);
    }

    .state-badge[data-state="ready"] {
        border-color: var(--pine-border);
        color: var(--pine-700);
    }

    .state-badge[data-state="ready"] i {
        background: var(--pine-500);
    }

    .state-badge[data-state="working"] {
        border-color: var(--warn-border);
        color: var(--warn-700);
    }

    .state-badge[data-state="working"] i {
        background: var(--warn-700);
        animation: pulse 1.4s ease-in-out infinite;
    }

    .state-badge[data-state="error"] {
        border-color: var(--error-border);
        color: var(--error-700);
    }

    .state-badge[data-state="error"] i {
        background: var(--error-700);
    }

    @keyframes pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: .35; }
    }

    .mini-status {
        border: 1px solid var(--border);
        border-radius: 999px;
        background: var(--canvas);
        color: var(--ink-500);
        font-size: .78rem;
        font-weight: 600;
        padding: .35rem .8rem;
        white-space: nowrap;
    }

    .mini-status[data-state="working"] {
        border-color: var(--warn-border);
        background: var(--warn-100);
        color: var(--warn-700);
    }

    .mini-status[data-state="ready"] {
        border-color: var(--pine-border);
        background: var(--pine-50);
        color: var(--pine-700);
    }

    .mini-status[data-state="error"] {
        border-color: var(--error-border);
        background: var(--error-100);
        color: var(--error-700);
    }

    /* Inline status lines ------------------------------------------- */

    .inline-status {
        display: inline-flex;
        align-items: center;
        gap: .55rem;
        color: var(--ink-500);
        font-size: .85rem;
    }

    .inline-status > span:first-child {
        flex: none;
        width: .55rem;
        height: .55rem;
        border-radius: 50%;
        background: var(--ink-300);
    }

    .inline-status[data-state="valid"],
    .inline-status[data-state="success"] {
        color: var(--pine-700);
    }

    .inline-status[data-state="valid"] > span:first-child,
    .inline-status[data-state="success"] > span:first-child {
        background: var(--pine-500);
    }

    .inline-status[data-state="warning"] {
        color: var(--warn-700);
    }

    .inline-status[data-state="warning"] > span:first-child {
        background: var(--warn-700);
    }

    .inline-status[data-state="error"] {
        color: var(--error-700);
    }

    .inline-status[data-state="error"] > span:first-child {
        background: var(--error-700);
    }

    .field-help {
        color: var(--ink-500);
        font-size: .82rem;
    }
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */

@layer layout {
    .shell {
        width: min(var(--shell), 100% - 2.5rem);
        margin-inline: auto;
    }

    /* Header --------------------------------------------------------- */

    .site-header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: rgba(247, 246, 242, .92);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--border);
    }

    .header-inner {
        width: min(var(--shell), 100% - 2.5rem);
        margin-inline: auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding-block: .7rem;
    }

    .brand {
        display: inline-flex;
        align-items: center;
        gap: .7rem;
    }

    .brand-mark {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.4rem;
        height: 2.4rem;
        border-radius: .7rem;
        background: var(--pine-700);
        color: #fdfdfb;
        font-size: 1rem;
    }

    .brand-mark.small {
        width: 2rem;
        height: 2rem;
        font-size: .85rem;
    }

    .brand-text {
        display: flex;
        flex-direction: column;
        line-height: 1.25;
    }

    .brand-text strong {
        font-size: .98rem;
        letter-spacing: .01em;
    }

    .brand-text small {
        color: var(--ink-500);
        font-size: .74rem;
    }

    .header-nav {
        display: flex;
        align-items: center;
        gap: .35rem;
    }

    .header-nav a {
        border-radius: var(--radius-sm);
        color: var(--ink-600);
        font-size: .88rem;
        font-weight: 600;
        padding: .5rem .8rem;
        transition: color .16s ease, background-color .16s ease;
    }

    .header-nav a:hover {
        color: var(--pine-700);
        background: var(--pine-50);
    }

    .header-nav .github-link {
        display: inline-flex;
        align-items: center;
        gap: .45rem;
        border: 1px solid var(--border-strong);
        background: var(--paper);
    }

    /* Hero ------------------------------------------------------------ */

    .hero {
        border-bottom: 1px solid var(--border);
        background:
            linear-gradient(180deg, rgba(37, 107, 75, .045), transparent 55%),
            var(--canvas);
    }

    .hero-inner {
        width: min(var(--shell), 100% - 2.5rem);
        margin-inline: auto;
        display: grid;
        grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
        align-items: center;
        gap: clamp(2rem, 5vw, 4rem);
        padding-block: clamp(3rem, 7vw, 5.5rem);
    }

    .hero-copy {
        display: grid;
        gap: 1.15rem;
        justify-items: start;
    }

    .hero h1 {
        font-size: clamp(1.9rem, 4vw, 2.7rem);
        font-weight: 800;
        line-height: 1.22;
        letter-spacing: -.01em;
        max-width: 22ch;
    }

    .hero h1 span {
        color: var(--pine-700);
    }

    .hero-lead {
        color: var(--ink-600);
        font-size: 1.02rem;
        max-width: 34rem;
    }

    .hero-actions {
        display: flex;
        flex-wrap: wrap;
        gap: .7rem;
        margin-top: .3rem;
    }

    .hero-points {
        display: flex;
        flex-wrap: wrap;
        gap: .5rem 1.4rem;
        list-style: none;
        margin-top: .4rem;
    }

    .hero-points li {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
        color: var(--ink-600);
        font-size: .88rem;
        font-weight: 600;
    }

    .hero-points i {
        color: var(--pine-600);
        font-size: .8rem;
    }

    /* Hero illustration */

    .hero-visual {
        border: 1px solid var(--border);
        border-radius: var(--radius-xl);
        background: var(--paper);
        box-shadow: var(--shadow-md);
        overflow: hidden;
    }

    .visual-toolbar {
        display: flex;
        align-items: center;
        gap: .45rem;
        border-bottom: 1px solid var(--border);
        background: var(--canvas);
        padding: .65rem .95rem;
    }

    .visual-toolbar span {
        width: .62rem;
        height: .62rem;
        border-radius: 50%;
        background: var(--ink-200);
    }

    .visual-toolbar small {
        margin-left: .5rem;
        color: var(--ink-500);
        font-family: var(--font-mono);
        font-size: .74rem;
    }

    .hero-graph {
        width: 100%;
        height: auto;
        padding: .8rem;
    }

    .hero-graph .closure-boundary {
        fill: var(--pine-50);
        stroke: var(--pine-500);
        stroke-width: 2;
        stroke-dasharray: 8 7;
    }

    .hero-graph .closure-label {
        fill: var(--pine-700);
        font-size: 14px;
        font-weight: 700;
        letter-spacing: .12em;
    }

    .hero-graph .graph-edge path {
        fill: none;
        stroke: var(--ink-400);
        stroke-width: 2.4;
        marker-end: url(#hero-arrow);
    }

    .hero-graph marker path {
        fill: var(--ink-400);
    }

    .hero-graph .graph-node circle {
        fill: var(--paper);
        stroke: var(--pine-600);
        stroke-width: 2.4;
    }

    .hero-graph .graph-node text {
        fill: var(--ink-800);
        font-size: 16px;
        font-weight: 700;
        text-anchor: middle;
    }

    .hero-graph .graph-node-muted circle {
        fill: var(--canvas);
        stroke: var(--ink-300);
        stroke-dasharray: 4 4;
    }

    .hero-graph .graph-node-muted text {
        fill: var(--ink-500);
    }

    .hero-graph .visual-badge rect {
        fill: var(--pine-700);
    }

    .hero-graph .visual-badge text {
        fill: #fdfdfb;
        font-size: 13px;
        font-weight: 700;
        text-anchor: middle;
    }

    /* Steps strip ------------------------------------------------------ */

    .steps-strip {
        border-bottom: 1px solid var(--border);
        background: var(--paper);
    }

    .steps-strip-inner {
        width: min(var(--shell), 100% - 2.5rem);
        margin-inline: auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding-block: 1.15rem;
        overflow-x: auto;
    }

    .steps-strip-inner > div {
        display: flex;
        align-items: center;
        gap: .7rem;
        flex: none;
    }

    .steps-strip-inner > div > span {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        border-radius: 50%;
        border: 1px solid var(--pine-border);
        background: var(--pine-50);
        color: var(--pine-700);
        font-size: .74rem;
        font-weight: 700;
    }

    .steps-strip-inner p {
        display: flex;
        flex-direction: column;
        line-height: 1.35;
    }

    .steps-strip-inner strong {
        font-size: .9rem;
    }

    .steps-strip-inner small {
        color: var(--ink-500);
        font-size: .76rem;
    }

    .steps-strip-inner > i {
        flex: none;
        color: var(--ink-300);
        font-size: .85rem;
    }

    /* Section headings ------------------------------------------------- */

    .section-heading {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        gap: 1.5rem;
        margin-bottom: 1.6rem;
    }

    .section-heading h2 {
        font-size: clamp(1.5rem, 3vw, 1.9rem);
        font-weight: 800;
        letter-spacing: -.01em;
        margin-block: .35rem .3rem;
    }

    .section-heading > div > p:last-child {
        color: var(--ink-500);
        font-size: .92rem;
    }

    /* Workspace panels -------------------------------------------------- */

    .workspace {
        display: grid;
        gap: 1.4rem;
        padding-block: clamp(2.5rem, 5vw, 4rem) 1.5rem;
    }

    .panel {
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        background: var(--paper);
        box-shadow: var(--shadow-sm);
        padding: clamp(1.2rem, 3vw, 1.8rem);
        display: grid;
        gap: 1.3rem;
    }

    .panel-heading {
        display: flex;
        align-items: flex-start;
        gap: .95rem;
    }

    .panel-heading h3 {
        font-size: 1.12rem;
        font-weight: 750;
    }

    .panel-heading p {
        color: var(--ink-500);
        font-size: .88rem;
        margin-top: .15rem;
        max-width: 46rem;
    }

    .panel-heading-split {
        justify-content: space-between;
        flex-wrap: wrap;
        gap: .9rem;
    }

    .heading-group {
        display: flex;
        align-items: flex-start;
        gap: .95rem;
    }

    .step-index {
        flex: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.1rem;
        height: 2.1rem;
        border-radius: .65rem;
        background: var(--pine-700);
        color: #fdfdfb;
        font-size: .92rem;
        font-weight: 700;
    }

    /* Panel 1: source ---------------------------------------------------- */

    .source-layout {
        display: grid;
        grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
        gap: 1.2rem;
    }

    .file-source {
        display: grid;
        gap: .8rem;
        align-content: start;
    }

    .drop-zone {
        display: grid;
        justify-items: center;
        gap: .35rem;
        border: 1.5px dashed var(--border-strong);
        border-radius: var(--radius-md);
        background: var(--canvas);
        padding: 1.6rem 1.2rem 1.2rem;
        text-align: center;
        transition: border-color .16s ease, background-color .16s ease;
    }

    .drop-zone:hover {
        border-color: var(--pine-500);
    }

    .drop-zone[data-state="dragover"] {
        border-color: var(--pine-600);
        background: var(--pine-50);
    }

    .drop-zone[data-state="loaded"] {
        border-color: var(--pine-border);
        background: var(--pine-50);
    }

    .drop-zone[data-state="error"] {
        border-color: var(--error-border);
        background: var(--error-100);
    }

    .drop-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.9rem;
        height: 2.9rem;
        border-radius: 50%;
        background: var(--pine-100);
        color: var(--pine-700);
        font-size: 1.1rem;
        margin-bottom: .3rem;
    }

    .drop-zone strong {
        font-size: .95rem;
    }

    .drop-zone p {
        color: var(--ink-500);
        font-size: .82rem;
    }

    .file-readout {
        display: grid;
        gap: .1rem;
        margin-top: .55rem;
        padding-top: .65rem;
        border-top: 1px solid var(--border);
        width: 100%;
    }

    .file-readout span {
        font-size: .84rem;
        font-weight: 600;
        color: var(--ink-700);
        overflow-wrap: anywhere;
    }

    .file-readout small {
        color: var(--ink-400);
        font-size: .74rem;
        font-family: var(--font-mono);
    }

    .example-button {
        display: flex;
        align-items: center;
        gap: .8rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--paper);
        padding: .85rem 1rem;
        text-align: left;
        transition: border-color .16s ease, background-color .16s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .example-button:hover {
        border-color: var(--pine-border);
        background: var(--pine-50);
    }

    .example-button > i {
        flex: none;
        color: var(--pine-600);
        font-size: 1rem;
    }

    .example-button strong {
        display: block;
        font-size: .88rem;
    }

    .example-button small {
        color: var(--ink-500);
        font-size: .76rem;
    }

    .editor-source {
        display: grid;
        gap: .55rem;
        align-content: start;
    }

    .editor-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .8rem;
    }

    .editor-toolbar > div {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
    }

    .editor-toolbar label {
        font-size: .85rem;
        font-weight: 650;
        color: var(--ink-700);
    }

    .language-dot {
        width: .55rem;
        height: .55rem;
        border-radius: 50%;
        background: var(--pine-500);
    }

    .editor-wrap {
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-md);
        background: var(--paper);
        overflow: hidden;
        transition: border-color .16s ease, box-shadow .16s ease;
    }

    .editor-wrap:focus-within {
        border-color: var(--pine-600);
        box-shadow: 0 0 0 3px rgba(37, 107, 75, .14);
    }

    .editor-wrap textarea {
        display: block;
        width: 100%;
        min-height: 19rem;
        border: 0;
        background: transparent;
        color: var(--ink-800);
        font-family: var(--font-mono);
        font-size: .84rem;
        line-height: 1.6;
        padding: .9rem 1rem;
        resize: vertical;
        outline: none;
        tab-size: 4;
    }

    .editor-wrap textarea::placeholder {
        color: var(--ink-300);
    }

    .panel-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: .9rem;
        border-top: 1px solid var(--border);
        padding-top: 1.1rem;
    }

    /* Panel 2: analysis --------------------------------------------------- */

    .stat-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: .8rem;
    }

    .stat-card {
        display: flex;
        align-items: center;
        gap: .8rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--canvas);
        padding: .85rem 1rem;
    }

    .stat-icon {
        flex: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        border-radius: .7rem;
        background: var(--pine-100);
        color: var(--pine-700);
        font-size: .95rem;
    }

    .stat-card p {
        display: flex;
        flex-direction: column;
        line-height: 1.3;
    }

    .stat-card strong {
        font-size: 1.25rem;
        font-weight: 750;
        font-variant-numeric: tabular-nums;
    }

    .stat-card span:last-child {
        color: var(--ink-500);
        font-size: .78rem;
    }

    .graph-card {
        display: grid;
        gap: .9rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--paper);
        padding: 1rem 1.1rem 1.1rem;
    }

    .graph-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: .8rem;
    }

    .graph-toolbar h4 {
        font-size: 1rem;
        font-weight: 700;
        margin-top: .1rem;
    }

    .graph-stage {
        position: relative;
        display: grid;
        place-items: center;
        min-height: 17rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background:
            radial-gradient(circle, var(--border) 1px, transparent 1px) 0 0 / 22px 22px,
            var(--canvas);
        padding: 1rem;
        overflow: auto;
    }

    .graph-stage[data-state="error"] {
        border-color: var(--error-border);
    }

    .graph-empty {
        display: grid;
        justify-items: center;
        gap: .4rem;
        max-width: 26rem;
        color: var(--ink-500);
        font-size: .88rem;
        text-align: center;
    }

    .graph-empty::before {
        content: "\f542"; /* diagram-project */
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        font-size: 1.3rem;
        color: var(--ink-300);
    }

    .graph-empty.compact {
        font-size: .82rem;
    }

    .graph-empty.compact::before {
        font-size: 1.05rem;
    }

    .graph-stage[data-state="error"] .graph-empty {
        color: var(--error-700);
    }

    .graph-stage[data-state="error"] .graph-empty::before {
        content: "\f071"; /* triangle-exclamation */
        color: var(--error-700);
    }

    .mermaid-render {
        width: 100%;
    }

    .mermaid-render svg {
        margin-inline: auto;
        max-width: 100%;
        height: auto;
    }

    .source-disclosure {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--canvas);
        overflow: hidden;
    }

    .source-disclosure summary {
        list-style: none;
        display: flex;
        align-items: center;
        gap: .5rem;
        color: var(--ink-600);
        font-size: .82rem;
        font-weight: 600;
        padding: .65rem .95rem;
        user-select: none;
    }

    .source-disclosure summary::-webkit-details-marker {
        display: none;
    }

    .source-disclosure summary::before {
        content: "\f054"; /* chevron-right */
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        font-size: .62rem;
        color: var(--ink-400);
        transition: transform .16s ease;
    }

    .source-disclosure[open] summary::before {
        transform: rotate(90deg);
    }

    .source-disclosure pre {
        border-top: 1px solid var(--border);
        background: var(--canvas-deep);
        color: var(--ink-700);
        font-size: .78rem;
        line-height: 1.6;
        padding: .9rem 1rem;
        margin: 0;
        overflow: auto;
        max-height: 16rem;
    }

    /* Panel 3: configuration ----------------------------------------------- */

    #extraction-form {
        display: grid;
        gap: 1.2rem;
    }

    .config-grid {
        display: grid;
        grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
        gap: 1.2rem;
    }

    .config-block {
        display: grid;
        gap: .7rem;
        align-content: start;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--canvas);
        padding: 1.05rem 1.15rem 1.2rem;
    }

    .config-block legend {
        float: left;
        width: 100%;
        font-size: .95rem;
        font-weight: 700;
        margin-bottom: .35rem;
    }

    .bound-inputs {
        display: flex;
        align-items: flex-end;
        gap: .9rem;
    }

    .bound-inputs label {
        display: grid;
        gap: .35rem;
        font-size: .8rem;
        font-weight: 600;
        color: var(--ink-600);
    }

    .number-input {
        display: inline-flex;
        align-items: center;
        gap: .4rem;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-sm);
        background: var(--paper);
        padding: .35rem .6rem .35rem .2rem;
        transition: border-color .16s ease, box-shadow .16s ease;
    }

    .number-input:focus-within {
        border-color: var(--pine-600);
        box-shadow: 0 0 0 3px rgba(37, 107, 75, .14);
    }

    .number-input input {
        width: 5rem;
        border: 0;
        background: transparent;
        color: var(--ink-900);
        font-size: .95rem;
        font-weight: 650;
        font-variant-numeric: tabular-nums;
        text-align: right;
        padding: .3rem .2rem;
        outline: none;
    }

    .number-input small {
        color: var(--ink-400);
        font-size: .78rem;
    }

    .range-divider {
        flex: none;
        width: 1.1rem;
        height: 2px;
        border-radius: 1px;
        background: var(--border-strong);
        margin-bottom: 1.15rem;
    }

    .property-entry {
        display: flex;
        gap: .6rem;
    }

    .property-entry input {
        flex: 1;
        min-width: 0;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-sm);
        background: var(--paper);
        font-size: .88rem;
        padding: .55rem .8rem;
        outline: none;
        transition: border-color .16s ease, box-shadow .16s ease;
    }

    .property-entry input:focus {
        border-color: var(--pine-600);
        box-shadow: 0 0 0 3px rgba(37, 107, 75, .14);
    }

    .chip-list {
        display: flex;
        flex-wrap: wrap;
        gap: .45rem;
        min-height: 2.2rem;
        align-items: center;
    }

    .chip-empty {
        color: var(--ink-500);
        font-size: .8rem;
    }

    .filter-chip {
        display: inline-flex;
        align-items: center;
        gap: .45rem;
        border: 1px solid var(--pine-border);
        border-radius: 999px;
        background: var(--pine-50);
        color: var(--pine-700);
        padding: .3rem .45rem .3rem .75rem;
    }

    .filter-chip code {
        background: none;
        color: inherit;
        font-size: .8rem;
        font-weight: 600;
        padding: 0;
    }

    .filter-chip button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.35rem;
        height: 1.35rem;
        border: 0;
        border-radius: 50%;
        background: transparent;
        color: var(--pine-600);
        font-size: .7rem;
        transition: background-color .16s ease, color .16s ease;
    }

    .filter-chip button:hover {
        background: var(--pine-100);
        color: var(--pine-800);
    }

    /* complexity / scale card */

    .complexity-card {
        display: flex;
        align-items: center;
        gap: 1rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--canvas);
        padding: 1rem 1.15rem;
    }

    .complexity-icon {
        flex: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.7rem;
        height: 2.7rem;
        border-radius: .75rem;
        background: var(--paper);
        border: 1px solid var(--border);
        color: var(--ink-500);
        font-size: 1rem;
    }

    .complexity-copy {
        display: grid;
        gap: .1rem;
        flex: 1;
        min-width: 0;
    }

    .complexity-copy > span {
        color: var(--ink-500);
        font-size: .76rem;
        font-weight: 700;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

    .complexity-copy strong {
        font-size: 1.15rem;
        font-weight: 750;
        font-variant-numeric: tabular-nums;
    }

    .complexity-copy strong small {
        color: var(--ink-500);
        font-size: .78rem;
        font-weight: 600;
    }

    .complexity-copy p {
        color: var(--ink-600);
        font-size: .84rem;
    }

    .risk-scale {
        flex: none;
        display: grid;
        gap: .3rem;
    }

    .risk-scale span {
        width: 2.4rem;
        height: .35rem;
        border-radius: 2px;
        background: var(--border);
    }

    .complexity-card[data-level="low"] {
        border-color: var(--pine-border);
        background: var(--pine-50);
    }

    .complexity-card[data-level="low"] .complexity-icon {
        color: var(--pine-700);
        border-color: var(--pine-border);
    }

    .complexity-card[data-level="low"] .risk-scale span:nth-child(-n+1) {
        background: var(--pine-500);
    }

    .complexity-card[data-level="medium"] {
        border-color: var(--warn-border);
        background: var(--warn-100);
    }

    .complexity-card[data-level="medium"] .complexity-icon {
        color: var(--warn-700);
        border-color: var(--warn-border);
    }

    .complexity-card[data-level="medium"] .risk-scale span:nth-child(-n+2) {
        background: var(--warn-700);
    }

    .complexity-card[data-level="high"] {
        border-color: var(--error-border);
        background: var(--error-100);
    }

    .complexity-card[data-level="high"] .complexity-icon {
        color: var(--error-700);
        border-color: var(--error-border);
    }

    .complexity-card[data-level="high"] .risk-scale span:nth-child(-n+3) {
        background: var(--error-700);
    }

    .complexity-card[data-level="critical"] {
        border-color: var(--error-border);
        background: var(--error-100);
    }

    .complexity-card[data-level="critical"] .complexity-icon {
        color: var(--error-700);
        border-color: var(--error-border);
    }

    .complexity-card[data-level="critical"] .risk-scale span {
        background: var(--error-700);
    }

    .semantics-note {
        display: flex;
        align-items: flex-start;
        gap: .75rem;
        border: 1px solid var(--pine-border);
        border-radius: var(--radius-md);
        background: var(--pine-50);
        padding: .95rem 1.1rem;
    }

    .semantics-note > i {
        flex: none;
        color: var(--pine-600);
        font-size: .95rem;
        margin-top: .15rem;
    }

    .semantics-note strong {
        display: block;
        font-size: .88rem;
        color: var(--pine-800);
        margin-bottom: .15rem;
    }

    .semantics-note p {
        color: var(--ink-700);
        font-size: .84rem;
    }

    .enumeration-controls {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 1.2rem;
        border-top: 1px solid var(--border);
        padding-top: 1.2rem;
    }

    .progress-group {
        display: grid;
        gap: .4rem;
    }

    .progress-copy {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: .8rem;
    }

    .progress-copy span {
        color: var(--ink-600);
        font-size: .85rem;
        font-weight: 600;
    }

    .progress-copy strong {
        font-size: .9rem;
        font-weight: 750;
        font-variant-numeric: tabular-nums;
    }

    .progress-track {
        height: .5rem;
        border-radius: 999px;
        background: var(--canvas-deep);
        overflow: hidden;
    }

    .progress-track span {
        display: block;
        width: 0;
        height: 100%;
        border-radius: inherit;
        background: var(--pine-600);
        transition: width .25s ease;
    }

    .progress-group[data-state="error"] .progress-track span {
        background: var(--error-700);
    }

    .progress-group[data-state="cancelled"] .progress-track span {
        background: var(--warn-700);
    }

    #progress-detail {
        color: var(--ink-500);
        font-size: .8rem;
        font-variant-numeric: tabular-nums;
    }

    .progress-group[data-state="error"] #enumeration-status {
        color: var(--error-700);
    }

    .enumeration-buttons {
        display: flex;
        gap: .7rem;
    }

    /* Panel 4: results -------------------------------------------------------- */

    .result-summary {
        display: flex;
        align-items: center;
        gap: 1.3rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--canvas);
        padding: .85rem 1.15rem;
        flex-wrap: wrap;
    }

    .result-summary p {
        display: flex;
        align-items: baseline;
        gap: .55rem;
    }

    .result-summary p span {
        color: var(--ink-500);
        font-size: .8rem;
    }

    .result-summary strong {
        font-size: 1.1rem;
        font-weight: 750;
        font-variant-numeric: tabular-nums;
    }

    .summary-separator {
        width: 1px;
        height: 1.4rem;
        background: var(--border-strong);
    }

    .results-layout {
        display: grid;
        grid-template-columns: minmax(0, .95fr) minmax(0, 1.55fr);
        gap: 1.2rem;
        align-items: start;
    }

    .result-browser {
        display: grid;
        gap: .8rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--canvas);
        padding: 1rem;
        min-width: 0;
    }

    .result-browser-heading {
        display: grid;
        gap: .7rem;
    }

    .result-browser-heading h4 {
        font-size: .98rem;
        font-weight: 700;
        margin-top: .1rem;
    }

    .result-search {
        display: flex;
        align-items: center;
        gap: .55rem;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-sm);
        background: var(--paper);
        padding: .45rem .75rem;
        transition: border-color .16s ease, box-shadow .16s ease;
    }

    .result-search:focus-within {
        border-color: var(--pine-600);
        box-shadow: 0 0 0 3px rgba(37, 107, 75, .14);
    }

    .result-search i {
        color: var(--ink-400);
        font-size: .8rem;
    }

    .result-search input {
        flex: 1;
        min-width: 0;
        border: 0;
        background: transparent;
        font-size: .85rem;
        outline: none;
    }

    .result-list-wrap {
        position: relative;
        min-height: 14rem;
        max-height: 34rem;
        overflow-y: auto;
        border-radius: var(--radius-sm);
    }

    .result-empty {
        display: grid;
        justify-items: center;
        align-content: center;
        gap: .4rem;
        min-height: 14rem;
        color: var(--ink-500);
        text-align: center;
        padding: 1rem;
    }

    .result-empty > span {
        font-family: var(--font-mono);
        font-size: 1.35rem;
        font-weight: 700;
        color: var(--ink-300);
    }

    .result-empty strong {
        font-size: .92rem;
        color: var(--ink-700);
    }

    .result-empty p {
        font-size: .82rem;
        max-width: 20rem;
    }

    .result-list {
        display: grid;
        gap: .45rem;
        list-style: none;
    }

    .result-item {
        min-width: 0;
    }

    .result-button {
        display: flex;
        align-items: center;
        gap: .7rem;
        width: 100%;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--paper);
        padding: .65rem .8rem;
        text-align: left;
        transition: border-color .16s ease, background-color .16s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .result-button:hover {
        border-color: var(--pine-border);
    }

    .result-button[aria-current="true"] {
        border-color: var(--pine-600);
        background: var(--pine-50);
    }

    .result-rank {
        flex: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 1.9rem;
        height: 1.9rem;
        border-radius: .55rem;
        background: var(--canvas-deep);
        color: var(--ink-600);
        font-size: .78rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        padding-inline: .3rem;
    }

    .result-button[aria-current="true"] .result-rank {
        background: var(--pine-700);
        color: #fdfdfb;
    }

    .result-copy {
        flex: 1;
        min-width: 0;
        display: grid;
        gap: .1rem;
    }

    .result-copy strong {
        font-size: .8rem;
        font-weight: 650;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-family: var(--font-mono);
    }

    .result-copy small {
        color: var(--ink-500);
        font-size: .74rem;
    }

    .result-id-preview {
        color: var(--ink-400);
        font-size: .72rem;
        font-family: var(--font-mono);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .result-button > i {
        flex: none;
        color: var(--ink-300);
        font-size: .72rem;
    }

    .result-button[aria-current="true"] > i {
        color: var(--pine-600);
    }

    .result-item-load-more {
        display: grid;
    }

    .load-more-button {
        border: 1px dashed var(--border-strong);
        border-radius: var(--radius-sm);
        background: transparent;
        color: var(--ink-600);
        font-size: .82rem;
        font-weight: 600;
        padding: .6rem;
        transition: border-color .16s ease, color .16s ease;
    }

    .load-more-button:hover {
        border-color: var(--pine-600);
        color: var(--pine-700);
    }

    /* module preview */

    .module-preview {
        min-width: 0;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--paper);
    }

    .module-preview-empty {
        display: grid;
        justify-items: center;
        align-content: center;
        gap: .45rem;
        min-height: 20rem;
        color: var(--ink-500);
        text-align: center;
        padding: 1.5rem;
    }

    .module-preview-empty > span {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 3rem;
        height: 3rem;
        border-radius: 50%;
        background: var(--canvas);
        color: var(--ink-400);
        font-size: 1.15rem;
        margin-bottom: .2rem;
    }

    .module-preview-empty strong {
        color: var(--ink-700);
        font-size: .95rem;
    }

    .module-preview-empty p {
        font-size: .84rem;
        max-width: 22rem;
    }

    .module-preview-content {
        display: grid;
        gap: 1.15rem;
        padding: 1.2rem;
    }

    .module-heading {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: .9rem;
    }

    .module-heading h4 {
        font-size: 1rem;
        font-weight: 700;
        font-family: var(--font-mono);
        overflow-wrap: anywhere;
        margin-block: .25rem .1rem;
    }

    .module-heading p {
        color: var(--ink-500);
        font-size: .82rem;
    }

    .preview-section {
        display: grid;
        gap: .7rem;
    }

    .preview-section-heading {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .8rem;
        flex-wrap: wrap;
    }

    .preview-section-heading h5 {
        font-size: .92rem;
        font-weight: 700;
    }

    .preview-section-heading > div > span {
        color: var(--ink-400);
        font-size: .78rem;
        margin-left: .6rem;
    }

    .module-graph-stage {
        min-height: 13rem;
    }

    .json-preview {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--canvas-deep);
        color: var(--ink-800);
        font-size: .8rem;
        line-height: 1.6;
        padding: 1rem 1.1rem;
        overflow: auto;
        max-height: 24rem;
    }

    /* Rules section ------------------------------------------------------------ */

    .rules-section {
        display: grid;
        gap: 1.4rem;
        padding-block: clamp(2.5rem, 5vw, 4rem);
    }

    .compact-heading {
        margin-bottom: 0;
    }

    .rules-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: .9rem;
    }

    .rules-grid article {
        display: grid;
        gap: .5rem;
        align-content: start;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--paper);
        padding: 1.2rem 1.25rem 1.35rem;
    }

    .rules-grid article > span {
        color: var(--pine-600);
        font-family: var(--font-mono);
        font-size: .8rem;
        font-weight: 700;
    }

    .rules-grid h3 {
        font-size: 1rem;
        font-weight: 750;
    }

    .rules-grid p {
        color: var(--ink-600);
        font-size: .86rem;
    }

    .formula-card {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 1rem;
        border: 1px solid var(--pine-border);
        border-radius: var(--radius-md);
        background: var(--pine-50);
        padding: 1.15rem 1.4rem;
    }

    .formula-card > div > span {
        display: block;
        color: var(--pine-600);
        font-size: .68rem;
        font-weight: 700;
        letter-spacing: .14em;
        margin-bottom: .3rem;
    }

    .formula-card code {
        background: none;
        color: var(--pine-800);
        font-size: 1.15rem;
        font-weight: 650;
        padding: 0;
    }

    .formula-card p {
        color: var(--ink-700);
        font-size: .86rem;
        max-width: 30rem;
    }

    .cli-note {
        display: flex;
        align-items: center;
        gap: .6rem;
        color: var(--ink-600);
        font-size: .88rem;
    }

    .cli-note i {
        color: var(--ink-400);
        font-size: .8rem;
    }

    .cli-note a {
        color: var(--pine-700);
        font-weight: 650;
        text-decoration: underline;
        text-underline-offset: .2em;
    }

    /* Footer -------------------------------------------------------------------- */

    .site-footer {
        border-top: 1px solid var(--border);
        background: var(--paper);
        margin-top: 1rem;
    }

    .footer-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 1.2rem;
        padding-block: 1.8rem;
    }

    .footer-brand {
        display: flex;
        align-items: center;
        gap: .7rem;
    }

    .footer-brand strong {
        font-size: .92rem;
    }

    .footer-brand p {
        color: var(--ink-500);
        font-size: .8rem;
    }

    .footer-links {
        display: flex;
        flex-wrap: wrap;
        gap: .3rem 1.2rem;
    }

    .footer-links a {
        color: var(--ink-600);
        font-size: .85rem;
        font-weight: 600;
    }

    .footer-links a:hover {
        color: var(--pine-700);
    }

    .copyright {
        color: var(--ink-400);
        font-size: .8rem;
    }

    /* Responsive ------------------------------------------------------------------ */

    @media (max-width: 1080px) {
        .hero-inner {
            grid-template-columns: 1fr;
        }

        .hero-visual {
            max-width: 34rem;
        }

        .results-layout {
            grid-template-columns: 1fr;
        }

        .result-list-wrap {
            max-height: 22rem;
        }
    }

    @media (max-width: 900px) {
        .source-layout,
        .config-grid {
            grid-template-columns: 1fr;
        }

        .stat-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }

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

        .enumeration-buttons {
            justify-content: flex-end;
        }
    }

    @media (max-width: 640px) {
        .brand-text small {
            display: none;
        }

        .header-nav a:not(.github-link) {
            padding-inline: .5rem;
        }

        .section-heading {
            flex-direction: column;
            align-items: flex-start;
            gap: .8rem;
        }

        .steps-strip-inner {
            justify-content: flex-start;
        }

        .complexity-card {
            flex-wrap: wrap;
        }

        .risk-scale {
            grid-auto-flow: column;
            width: 100%;
        }

        .risk-scale span {
            width: 100%;
        }

        .panel-footer {
            flex-direction: column;
            align-items: stretch;
        }

        .panel-footer .button {
            width: 100%;
        }

        .footer-inner {
            flex-direction: column;
            align-items: flex-start;
        }
    }
}

/* ------------------------------------------------------------------ */
/* Utilities                                                           */
/* ------------------------------------------------------------------ */

@layer utilities {
    .visually-hidden {
        position: absolute !important;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        border: 0;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        overflow: hidden;
        white-space: nowrap;
    }
}
