/* The isolated editor (editor/index.html), drawn inside the frame of the outer page. */
/* Colours as tokens: light by default, dark when the outer page says so (theme.js posts "light"
   or "dark", shared.js sets data-theme) or, until then, when the system prefers dark. The same
   tokens as ../site.css; keep the two in step. */
:root {
    --ink: #15171C;
    --ink-2: #2A2F36;
    --ink-3: #3A3F47;
    --muted: #4F555E;
    --ground: #F3F4F1;
    --surface: #FFFFFF;
    --line: #D9DBD5;
    --line-soft: #E6E8E3;
    --line-strong: #B9BDB5;
    --head: #FAFAF8;
    --accent: #1F3FC4;
    --accent-hover: #18329E;
    --link: #1F3FC4;
    --on-ink: #FFFFFF;
    --chip: #E3E5E8;
    --dashed: #8C929B;
    --warn-bg: #FDF3D6;
    --warn-ink: #5C3B00;
    --danger-line: #E2B4A4;
    --danger-ink: #7F240A;
    --danger-bg: #FFF1EC;
    --text-font: 15px;
    --text-line: 1.75;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --ink: #ECEDE9;
    --ink-2: #D4D6D1;
    --ink-3: #BFC2BC;
    --muted: #9CA1A9;
    --ground: #111316;
    --surface: #1A1D21;
    --line: #30353C;
    --line-soft: #262A30;
    --line-strong: #474D55;
    --head: #202328;
    --accent: #3F5BE0;
    --accent-hover: #3651D6;
    --link: #9DB1FF;
    --on-ink: #111316;
    --chip: #343A43;
    --dashed: #7A8089;
    --warn-bg: #3A2E10;
    --warn-ink: #F6DFA2;
    --danger-line: #7A3A28;
    --danger-ink: #FFB9A3;
    --danger-bg: #2C1A14;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --ink: #ECEDE9;
        --ink-2: #D4D6D1;
        --ink-3: #BFC2BC;
        --muted: #9CA1A9;
        --ground: #111316;
        --surface: #1A1D21;
        --line: #30353C;
        --line-soft: #262A30;
        --line-strong: #474D55;
        --head: #202328;
        --accent: #3F5BE0;
        --accent-hover: #3651D6;
        --link: #9DB1FF;
        --on-ink: #111316;
        --chip: #343A43;
        --dashed: #7A8089;
        --warn-bg: #3A2E10;
        --warn-ink: #F6DFA2;
        --danger-line: #7A3A28;
        --danger-ink: #FFB9A3;
        --danger-bg: #2C1A14;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--surface); }

body {
    color: var(--ink);
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

button { font: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

/* the frame's 1px of slack, so the body never scrolls inside the iframe */
.editor { display: flex; flex-direction: column; gap: 20px; padding-bottom: 1px; }

.controls { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

select, input[type=text] {
    font: inherit;
    font-size: 15px;
    font-weight: 400;
    min-height: 44px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
}
select { padding: 0 12px; }
input[type=text] { padding: 0 12px; flex: 1; min-width: 0; }

.modes { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--ground); border: 1px solid var(--line); border-radius: 10px; }
.mode { font-size: 14px; font-weight: 500; border: 0; border-radius: 6px; padding: 0 14px; min-height: 40px; background: transparent; color: var(--ink-2); }
.mode:hover { background: var(--line-soft); }
.mode[aria-pressed="true"], .mode[aria-pressed="true"]:hover { background: var(--ink); color: var(--on-ink); }

.panels { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }

.panel {
    flex: 1 1 360px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}
.panel.review { flex: 1 1 300px; background: var(--head); }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 57px;
    padding: 10px 12px 10px 16px;
    border-bottom: 1px solid var(--line-soft);
    background: var(--head);
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-head .count { font-size: 13px; color: var(--muted); }

.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel-head .panel-actions { gap: 4px; }

.panel-foot { padding: 10px 16px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
.output-foot, .review-foot { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; }
.output-foot p { margin: 0; }
.review-foot { margin-top: auto; }

.small { font-size: 14px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.small.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.small:hover { background: var(--line-soft); }

.primary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    min-height: 46px;
    padding: 0 20px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #FFFFFF;
}
.primary:hover { background: var(--accent-hover); }
.primary:disabled, .secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary { font-size: 15px; font-weight: 500; min-height: 46px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); }
.secondary:hover { background: var(--ground); }
.secondary[hidden] { display: none; }

.outline { font-size: 14px; font-weight: 600; min-height: 44px; padding: 0 14px; border: 1px solid var(--ink); border-radius: 8px; background: var(--surface); color: var(--ink); }
.outline:hover { background: var(--ground); }

/* Input: a transparent textarea over a backdrop that draws the same text with the highlights.
   Both must keep exactly the same font, padding and wrapping, or the highlights drift. */
.input-wrap { position: relative; flex: 1; min-height: 340px; }
.backdrop, textarea {
    margin: 0;
    padding: 16px;
    border: 0;
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: var(--text-font);
    line-height: var(--text-line);
    letter-spacing: normal;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    tab-size: 4;
}
.backdrop { position: absolute; inset: 0; color: transparent; overflow: hidden; pointer-events: none; }
textarea {
    position: relative;
    display: block;
    width: 100%;
    min-height: 340px;
    resize: none;
    overflow: hidden;
    background: transparent;
    color: var(--ink);
    caret-color: var(--ink);
}
textarea:focus-visible { outline-offset: -2px; }
textarea::placeholder { color: var(--muted); }

.text-view {
    flex: 1;
    min-height: 340px;
    padding: 16px;
    font-size: var(--text-font);
    line-height: var(--text-line);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.empty { color: var(--muted); }

/* finding colours: mk = highlight in the input, rp = replacement in the result, tag = review label */
.mk { border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.mk-person, .rp-person, .tag-person { background: #FCE3A7; color: #5C3B00; }
.mk-email, .rp-email, .tag-email { background: #D6E2FF; color: #1C3578; }
.mk-phone, .rp-phone, .tag-phone { background: #E6DAFA; color: #43207F; }
.mk-iban, .rp-iban, .tag-iban { background: #C9EDE1; color: #0C4A33; }
.mk-card, .rp-card, .tag-card { background: #DDEFC4; color: #2F4A0C; }
.mk-nationalid, .rp-nationalid, .tag-nationalid { background: #F6DDEA; color: #6E1F47; }
.mk-ip, .rp-ip, .tag-ip { background: #D3ECF2; color: #0D4552; }
.mk-secret, .rp-secret, .tag-secret { background: #FFD5C7; color: #7F240A; }
.mk-term, .rp-term, .tag-term { background: #E3E5E8; color: #2A2F36; }
.mk-address, .rp-address, .tag-address { background: #F3E3CF; color: #5A3410; }
.mk-dob, .rp-dob, .tag-dob { background: #EFD9F1; color: #5B1E63; }
.mk-bic, .rp-bic, .tag-bic { background: #D5EFE8; color: #0E4A3C; }
.mk-mac, .rp-mac, .tag-mac { background: #D9E8F6; color: #173E66; }
.mk-url, .rp-url, .tag-url { background: #E2E6FA; color: #27317A; }
.mk-cell, .rp-cell, .tag-cell { background: #E8E4D6; color: #3F3820; }
/* dark: each pair swapped, the light text colour as the background */
:root[data-theme="dark"] .mk-person, :root[data-theme="dark"] .rp-person, :root[data-theme="dark"] .tag-person { background: #5C3B00; color: #FCE3A7; }
:root[data-theme="dark"] .mk-email, :root[data-theme="dark"] .rp-email, :root[data-theme="dark"] .tag-email { background: #1C3578; color: #D6E2FF; }
:root[data-theme="dark"] .mk-phone, :root[data-theme="dark"] .rp-phone, :root[data-theme="dark"] .tag-phone { background: #43207F; color: #E6DAFA; }
:root[data-theme="dark"] .mk-iban, :root[data-theme="dark"] .rp-iban, :root[data-theme="dark"] .tag-iban { background: #0C4A33; color: #C9EDE1; }
:root[data-theme="dark"] .mk-card, :root[data-theme="dark"] .rp-card, :root[data-theme="dark"] .tag-card { background: #2F4A0C; color: #DDEFC4; }
:root[data-theme="dark"] .mk-nationalid, :root[data-theme="dark"] .rp-nationalid, :root[data-theme="dark"] .tag-nationalid { background: #6E1F47; color: #F6DDEA; }
:root[data-theme="dark"] .mk-ip, :root[data-theme="dark"] .rp-ip, :root[data-theme="dark"] .tag-ip { background: #0D4552; color: #D3ECF2; }
:root[data-theme="dark"] .mk-secret, :root[data-theme="dark"] .rp-secret, :root[data-theme="dark"] .tag-secret { background: #7F240A; color: #FFD5C7; }
:root[data-theme="dark"] .mk-term, :root[data-theme="dark"] .rp-term, :root[data-theme="dark"] .tag-term { background: #343A43; color: #E3E5E8; }
:root[data-theme="dark"] .mk-address, :root[data-theme="dark"] .rp-address, :root[data-theme="dark"] .tag-address { background: #5A3410; color: #F3E3CF; }
:root[data-theme="dark"] .mk-dob, :root[data-theme="dark"] .rp-dob, :root[data-theme="dark"] .tag-dob { background: #5B1E63; color: #EFD9F1; }
:root[data-theme="dark"] .mk-bic, :root[data-theme="dark"] .rp-bic, :root[data-theme="dark"] .tag-bic { background: #0E4A3C; color: #D5EFE8; }
:root[data-theme="dark"] .mk-mac, :root[data-theme="dark"] .rp-mac, :root[data-theme="dark"] .tag-mac { background: #173E66; color: #D9E8F6; }
:root[data-theme="dark"] .mk-url, :root[data-theme="dark"] .rp-url, :root[data-theme="dark"] .tag-url { background: #27317A; color: #E2E6FA; }
:root[data-theme="dark"] .mk-cell, :root[data-theme="dark"] .rp-cell, :root[data-theme="dark"] .tag-cell { background: #3F3820; color: #E8E4D6; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .mk-person, :root:not([data-theme]) .rp-person, :root:not([data-theme]) .tag-person { background: #5C3B00; color: #FCE3A7; }
    :root:not([data-theme]) .mk-email, :root:not([data-theme]) .rp-email, :root:not([data-theme]) .tag-email { background: #1C3578; color: #D6E2FF; }
    :root:not([data-theme]) .mk-phone, :root:not([data-theme]) .rp-phone, :root:not([data-theme]) .tag-phone { background: #43207F; color: #E6DAFA; }
    :root:not([data-theme]) .mk-iban, :root:not([data-theme]) .rp-iban, :root:not([data-theme]) .tag-iban { background: #0C4A33; color: #C9EDE1; }
    :root:not([data-theme]) .mk-card, :root:not([data-theme]) .rp-card, :root:not([data-theme]) .tag-card { background: #2F4A0C; color: #DDEFC4; }
    :root:not([data-theme]) .mk-nationalid, :root:not([data-theme]) .rp-nationalid, :root:not([data-theme]) .tag-nationalid { background: #6E1F47; color: #F6DDEA; }
    :root:not([data-theme]) .mk-ip, :root:not([data-theme]) .rp-ip, :root:not([data-theme]) .tag-ip { background: #0D4552; color: #D3ECF2; }
    :root:not([data-theme]) .mk-secret, :root:not([data-theme]) .rp-secret, :root:not([data-theme]) .tag-secret { background: #7F240A; color: #FFD5C7; }
    :root:not([data-theme]) .mk-term, :root:not([data-theme]) .rp-term, :root:not([data-theme]) .tag-term { background: #343A43; color: #E3E5E8; }
    :root:not([data-theme]) .mk-address, :root:not([data-theme]) .rp-address, :root:not([data-theme]) .tag-address { background: #5A3410; color: #F3E3CF; }
    :root:not([data-theme]) .mk-dob, :root:not([data-theme]) .rp-dob, :root:not([data-theme]) .tag-dob { background: #5B1E63; color: #EFD9F1; }
    :root:not([data-theme]) .mk-bic, :root:not([data-theme]) .rp-bic, :root:not([data-theme]) .tag-bic { background: #0E4A3C; color: #D5EFE8; }
    :root:not([data-theme]) .mk-mac, :root:not([data-theme]) .rp-mac, :root:not([data-theme]) .tag-mac { background: #173E66; color: #D9E8F6; }
    :root:not([data-theme]) .mk-url, :root:not([data-theme]) .rp-url, :root:not([data-theme]) .tag-url { background: #27317A; color: #E2E6FA; }
    :root:not([data-theme]) .mk-cell, :root:not([data-theme]) .rp-cell, :root:not([data-theme]) .tag-cell { background: #3F3820; color: #E8E4D6; }
}
/* the input's text is drawn by the textarea, so the backdrop only paints the background */
.backdrop .mk { color: transparent; }
.text-view .mk { padding: 1px 3px; }
.mk-off { background: transparent; outline: 1px dashed var(--dashed); outline-offset: -1px; }
.rp { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 0.9em; border-radius: 4px; padding: 1px 4px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.tag { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }

.findings { display: flex; flex-direction: column; padding: 6px; }
.findings .empty { padding: 10px; font-size: 14px; }
.finding { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 8px; cursor: pointer; }
.finding:hover { background: var(--line-soft); }
.finding.off { opacity: 0.62; }
.finding input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--ink); }
.finding-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.finding-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.finding-repl { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.finding-value { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.finding-why { font-size: 12px; color: var(--muted); }

.term-row { display: flex; gap: 6px; }
.terms { display: flex; flex-wrap: wrap; gap: 6px; }
.terms:empty { display: none; }
.term-chip { display: flex; align-items: center; gap: 2px; padding-left: 10px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-size: 13px; font-weight: 500; }
.term-chip button { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); }
.term-chip button:hover { background: var(--line-strong); }

/* views: Anonymize and Restore (shared.js switches them) */
.view { display: flex; flex-direction: column; gap: 20px; }
.view[hidden] { display: none; }

.panel.wide { flex: 1 1 420px; }

/* link-style buttons: as the outer page's links, ink with a faint accent underline */
.link { align-self: flex-start; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent); text-underline-offset: 0.22em; }
.link:hover { color: var(--link); text-decoration-color: currentColor; }
.link[hidden] { display: none; }

.secondary.danger { border-color: var(--danger-line); color: var(--danger-ink); }
.secondary.danger:hover { background: var(--danger-bg); }

/* a placeholder that isn't in the mapping: left as it is */
.rp-unknown { background: transparent; color: var(--muted); outline: 1px dashed var(--dashed); outline-offset: -1px; }

.mapping { display: flex; flex-direction: column; gap: 12px; }
.mapping-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.mapping-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.mapping-head p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.mapping-status { margin: 0; font-size: 14px; color: var(--ink-2); }
.mapping-status:empty { display: none; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--head); }
td.value { overflow-wrap: anywhere; }
td.used { color: var(--ink-3); }
.mapping-empty { margin: 0; padding: 16px; border: 1px dashed var(--line-strong); border-radius: 10px; font-size: 14px; color: var(--muted); }
.mapping-empty[hidden], .table-wrap[hidden] { display: none; }

.warning { margin: 0; display: flex; gap: 8px; font-size: 13px; color: var(--warn-ink); background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; }
.warning svg { flex: none; margin-top: 2px; stroke: currentColor; }

/* presets, categories and files (anonymize.js) */
.controls-main { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.cats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cats-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-right: 4px; }
.cat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 10px 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
}
/* off: white and grey; on: the category's colours (.tag-<cat>, set by anonymize.js) */
.cat[aria-pressed="false"] { background: var(--surface); color: var(--muted); }
.cat::before { content: ''; width: 10px; height: 10px; border-radius: 999px; border: 1.5px solid currentColor; box-sizing: border-box; }
.cat[aria-pressed="false"]:hover { background: var(--ground); }
.cat[aria-pressed="true"]:hover { filter: brightness(0.96); }
.cat[aria-pressed="true"] { border-color: transparent; }
.cat[aria-pressed="true"]::before { border: 0; background: currentColor; }
.cats .link { min-height: 32px; font-size: 13px; }

.file-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file-name { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.file-note[hidden] { display: none; }

.columns { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.columns[hidden] { display: none; }
.columns p { margin: 0; font-size: 13px; color: var(--muted); }
.column-list { display: flex; flex-wrap: wrap; gap: 6px; }
.column-list label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 13px; cursor: pointer; }
.column-list input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }

.terms-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.terms-actions .link { min-height: 32px; font-size: 13px; }
.findings .more { padding: 10px; font-size: 13px; color: var(--muted); }
