/* PII Pseudonymizer by Kwizmo.
   Brand colours: Kwizmo purple (Pantone 267, #61398B) carries the interface;
   Kwizmo red (Pantone 193, #BF0D3E) is used sparingly, like the dot in the
   logo: for the main action and for errors. Replaced values are marked with a
   purple tint. System fonts only: no requests to third parties. */

:root {
    --kwizmo-purple: #61398B;
    --kwizmo-red: #BF0D3E;

    --ink: #241B30;
    --ink-soft: #5B5168;
    --desk: #F3F0F7;
    --paper: #FFFFFF;
    --rule: #DCD5E6;
    --field: #FCFBFE;

    --pen: var(--kwizmo-purple);          /* links, secondary buttons, focus */
    --pen-hover: #4A2B6B;
    --pen-soft: #EFE9F6;

    --action: var(--kwizmo-red);          /* main button */
    --action-hover: #9A0A32;
    --on-action: #FFFFFF;

    --marker: #E9E0F4;                    /* replaced values */
    --marker-edge: var(--kwizmo-purple);

    --alert: var(--kwizmo-red);
    --alert-soft: #FBEBEF;

    --code-bg: #241B30;
    --code-ink: #F1ECF7;

    --font-text: Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;

    --step--1: 0.875rem;
    --step-0: 1rem;
    --step-1: 1.25rem;
    --step-2: 1.625rem;
    --step-3: 2.25rem;

    --space: 1.5rem;
    --radius-sheet: 6px;
    --radius-control: 4px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #EEE9F4;
        --ink-soft: #B5ABC2;
        --desk: #15101C;
        --paper: #201A2A;
        --rule: #3B3149;
        --field: #1A1523;

        --pen: #C3A8E6;
        --pen-hover: #DCCBF2;
        --pen-soft: #33284A;

        --action: var(--kwizmo-red);
        --action-hover: #D8174E;
        --on-action: #FFFFFF;

        --marker: #3F2D59;
        --marker-edge: #A98BD6;

        --alert: #FF8FA8;
        --alert-soft: #3A1622;

        --code-bg: #0F0B15;
        --code-ink: #EEE9F4;
        color-scheme: dark;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--desk);
    color: var(--ink);
    font-family: var(--font-text);
    font-size: var(--step-0);
    line-height: 1.5;
}

a { color: var(--pen); text-underline-offset: 0.15em; }
a:hover { color: var(--pen-hover); }

:focus-visible {
    outline: 3px solid var(--pen);
    outline-offset: 2px;
}

[hidden] { display: none !important; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip {
    position: absolute;
    left: 1rem; top: -3rem;
    background: var(--paper);
    padding: 0.5rem 1rem;
    z-index: 10;
}
.skip:focus { top: 1rem; }

.wrap {
    width: min(100% - 2rem, 76rem);
    margin-inline: auto;
}

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

.masthead {
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    box-shadow: inset 0 3px 0 var(--kwizmo-purple);
}
.masthead-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--ink);
    text-decoration: none;
    padding: 0.35rem 0;
}
.brand:hover { color: var(--ink); }
.brand picture { display: block; line-height: 0; }
.brand-logo { display: block; width: 120px; height: auto; }
.brand-name {
    font-weight: 600;
    font-size: var(--step-0);
    color: var(--ink-soft);
    padding-left: 0.8rem;
    border-left: 1px solid var(--rule);
    line-height: 1.6;
}
.masthead nav a { font-weight: 600; text-decoration: none; }
.masthead nav a:hover { text-decoration: underline; }
.masthead nav a[aria-current="page"] {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--kwizmo-red);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.35em;
}

/* Intro -------------------------------------------------------------- */

.intro { padding: 2.5rem 0 1.5rem; }
.intro h1 {
    font-size: clamp(var(--step-2), 4vw, var(--step-3));
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 0.75rem;
    max-width: 22ch;
}
.intro p { max-width: 68ch; margin: 0 0 0.5rem; color: var(--ink-soft); }
.intro .privacy-line { color: var(--ink); font-weight: 600; }
.intro .privacy-line::before {
    content: "";
    display: inline-block;
    width: 0.6em;
    height: 0.6em;
    margin-right: 0.5em;
    border-radius: 50%;
    background: var(--kwizmo-red);
    vertical-align: 0.05em;
}

/* Workbench ---------------------------------------------------------- */

.workbench {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space);
    align-items: start;
}

.sheet {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sheet);
    padding: var(--space);
}

h2 { font-size: var(--step-1); margin: 0 0 1rem; line-height: 1.25; }

.field { margin-bottom: 1.25rem; }
.field > label,
.label-row label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}
.counter { font-size: var(--step--1); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--alert); font-weight: 700; }

textarea,
input[type="password"],
input[type="text"],
select {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--field);
    border: 1px solid var(--rule);
    border-radius: var(--radius-control);
    padding: 0.6rem 0.7rem;
}
textarea {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.55;
    resize: vertical;
    min-height: 6rem;
}
textarea[readonly] { background: var(--paper); }
select { max-width: 22rem; }

/* Options ------------------------------------------------------------ */

.option {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: 0;
    padding: 1rem 0 1.1rem;
    min-width: 0;
}
.option legend {
    font-weight: 700;
    padding: 0;
    float: left;
    width: 100%;
    margin-bottom: 0.5rem;
}
.option legend + * { clear: left; }
.optional { font-weight: 400; color: var(--ink-soft); font-size: var(--step--1); margin-left: 0.35rem; }

.hint {
    font-size: var(--step--1);
    color: var(--ink-soft);
    margin: 0.4rem 0 0;
    max-width: 70ch;
}

.checks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.35rem 1.25rem;
}
.checks li,
.check-line {
    display: grid;
    grid-template-columns: 1.25rem 1fr;
    gap: 0.5rem;
    align-items: start;
}
.checks label { cursor: pointer; }
.checks .hint { display: block; margin-top: 0.05rem; }
input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0.2rem 0 0;
    accent-color: var(--pen);
}

.bulk { display: flex; gap: 1rem; margin-bottom: 0.5rem; }

.key-row { display: flex; gap: 0.5rem; }
.key-row input { flex: 1; font-family: var(--font-mono); }

.submit-area {
    border-top: 1px solid var(--rule);
    padding-top: 1.1rem;
}
.terms-line { margin-bottom: 1rem; }

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

button { font: inherit; cursor: pointer; }

.primary,
.secondary {
    border-radius: var(--radius-control);
    padding: 0.6rem 1.1rem;
    font-weight: 700;
    border: 2px solid var(--pen);
}
.primary { background: var(--action); border-color: var(--action); color: var(--on-action); }
.primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.primary:disabled { opacity: 0.7; cursor: progress; }
.secondary { background: transparent; color: var(--pen); }
.secondary:hover { background: var(--pen-soft); }

.link-button {
    background: none;
    border: 0;
    padding: 0;
    color: var(--pen);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    font-size: var(--step--1);
}

.actions,
.restore-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.9rem;
}
.status { font-size: var(--step--1); color: var(--ink-soft); }

/* Result ------------------------------------------------------------- */

.summary { margin: 0 0 0.9rem; color: var(--ink-soft); font-size: var(--step--1); }

.empty {
    color: var(--ink-soft);
    border: 1px dashed var(--rule);
    border-radius: var(--radius-control);
    padding: 2.5rem 1.5rem;
    margin: 0;
    text-align: center;
}

.view-switch { display: inline-flex; margin-bottom: 0.6rem; border: 1px solid var(--rule); border-radius: var(--radius-control); }
.tab {
    background: transparent;
    border: 0;
    padding: 0.35rem 0.9rem;
    color: var(--ink-soft);
    font-size: var(--step--1);
}
.tab[aria-pressed="true"] { background: var(--pen-soft); color: var(--ink); font-weight: 700; }

.marked-view {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.75;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    border: 1px solid var(--rule);
    border-radius: var(--radius-control);
    padding: 0.8rem 0.9rem;
    max-height: 32rem;
    overflow: auto;
    background: var(--paper);
}

/* the marker stroke */
mark {
    color: inherit;
    background: var(--marker);
    box-shadow: inset 0 -0.14em 0 var(--marker-edge);
    padding: 0.05em 0.25em;
    margin: 0 -0.05em;
    border-radius: 0.2em;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.mapping { margin-top: 1.25rem; border-top: 1px solid var(--rule); padding-top: 0.9rem; }
.mapping summary { cursor: pointer; font-weight: 700; }
.table-scroll { overflow-x: auto; margin-top: 0.75rem; max-height: 24rem; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { position: sticky; top: 0; background: var(--paper); }
.mapping td:nth-child(2), .mapping td:nth-child(3) { font-family: var(--font-mono); overflow-wrap: anywhere; }
.mapping td:first-child { white-space: nowrap; color: var(--ink-soft); }

/* Notices ------------------------------------------------------------ */

.notice {
    border-left: 4px solid var(--alert);
    background: var(--alert-soft);
    padding: 0.7rem 1rem;
    margin: 0 0 1rem;
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
}
.notice p { margin: 0; }
.notice p + p { margin-top: 0.35rem; }

/* Restore ------------------------------------------------------------ */

.restore-sheet { margin-top: var(--space); }
.restore-sheet > p { max-width: 70ch; color: var(--ink-soft); margin-top: 0; }
.restore-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space);
}
.restore-controls { margin-top: 0; align-items: end; }
.file-field { margin-bottom: 0; margin-right: auto; }
.file-field label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
input[type="file"] { font: inherit; font-size: var(--step--1); max-width: 100%; }

/* Terms -------------------------------------------------------------- */

.terms {
    margin: 2rem auto;
    max-width: 48rem;
    line-height: 1.6;
}
.terms h1 { font-size: var(--step-3); line-height: 1.15; margin: 0 0 0.25rem; }
.terms h2 { margin-top: 2rem; margin-bottom: 0.5rem; }
.terms p, .terms li { max-width: 70ch; }
.terms ul { padding-left: 1.25rem; }
.terms li + li { margin-top: 0.3rem; }

/* API documentation -------------------------------------------------- */

.masthead nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }

.docs {
    margin: 2rem auto;
    max-width: 60rem;
    line-height: 1.6;
}
.docs h1 { font-size: var(--step-3); line-height: 1.15; margin: 0 0 1rem; }
.docs h2 { margin-top: 2.5rem; margin-bottom: 0.6rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.docs h3 { font-size: var(--step-0); margin: 1.5rem 0 0.4rem; }
.docs > p, .docs section > p, .docs li { max-width: 72ch; }
.docs section { scroll-margin-top: 1rem; }
.docs .table-scroll { max-height: none; overflow-y: visible; }
.docs table { margin: 0.25rem 0 0.75rem; min-width: 34rem; }
.docs td:first-child, .docs td:nth-child(2) { white-space: nowrap; }
.docs td:last-child { min-width: 14rem; }
.docs th[scope="row"] { white-space: nowrap; font-weight: 600; }
.docs td code, .docs p code, .docs li code, .terms code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--desk);
    padding: 0.08em 0.3em;
    border-radius: 2px;
    overflow-wrap: anywhere;
}

.toc {
    border: 1px solid var(--rule);
    border-radius: var(--radius-control);
    padding: 0.8rem 1.1rem;
    margin: 1.5rem 0;
    background: var(--field);
}
.toc p { margin: 0 0 0.35rem; font-weight: 700; }
.toc ul { margin: 0; padding: 0; list-style: none; columns: 2 16rem; column-gap: 2rem; }
.toc li { margin: 0.15rem 0; }

.steps { padding-left: 1.5rem; }
.steps li + li { margin-top: 0.4rem; }

.code { margin: 1rem 0 1.25rem; }
.code figcaption {
    font-size: var(--step--1);
    color: var(--ink-soft);
    margin-bottom: 0.3rem;
}
.code pre {
    margin: 0;
    padding: 0.9rem 1rem;
    background: var(--code-bg);
    color: var(--code-ink);
    border-radius: var(--radius-control);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.55;
    tab-size: 4;
}
@media (prefers-color-scheme: dark) {
    .code pre { border: 1px solid var(--rule); }
}

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

.footer {
    padding: 2rem 0 3rem;
    font-size: var(--step--1);
    color: var(--ink-soft);
}
.footer p { margin: 0 0 0.35rem; max-width: 80ch; }

/* Small screens ------------------------------------------------------ */

@media (max-width: 56rem) {
    .workbench,
    .restore-grid { grid-template-columns: 1fr; }
    .intro { padding-top: 1.75rem; }
}

@media (max-width: 30rem) {
    :root { --space: 1rem; }
    .brand-name { display: none; }
    .key-row { flex-wrap: wrap; }
    .key-row input { flex-basis: 100%; }
    .primary, .secondary { width: 100%; }
    .actions .primary, .actions .secondary { width: auto; flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
    body { background: #fff; }
    .masthead nav, form, .restore-sheet, .actions, .view-switch { display: none !important; }
    .workbench { grid-template-columns: 1fr; }
    .sheet { border: 0; }
}
