/* The isolated editor (editor/index.html), drawn inside the frame of the outer page. */
:root {
    --ink: #15171C;
    --ink-2: #2A2F36;
    --ink-3: #3A3F47;
    --muted: #4F555E;
    --ground: #F3F4F1;
    --line: #D9DBD5;
    --line-soft: #E6E8E3;
    --line-strong: #B9BDB5;
    --head: #FAFAF8;
    --accent: #1F3FC4;
    --text-font: 15px;
    --text-line: 1.75;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: #FFFFFF; }

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(--accent);
    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: #FFFFFF;
    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: #FFFFFF; }

.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: #FFFFFF;
}
.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: #FFFFFF; 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: #18329E; }
.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: #FFFFFF; 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: #FFFFFF; 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; }
/* 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 #8C929B; 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: #E3E5E8; 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 { align-self: flex-start; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }
.link[hidden] { display: none; }

.secondary.danger { border-color: #E2B4A4; color: #7F240A; }
.secondary.danger:hover { background: #FFF1EC; }

/* a placeholder that isn't in the mapping: left as it is */
.rp-unknown { background: transparent; color: var(--muted); outline: 1px dashed #8C929B; 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: #5C3B00; background: #FDF3D6; border-radius: 8px; padding: 10px 12px; }
.warning svg { flex: none; margin-top: 2px; }
