:root {
    color-scheme: light dark;
    --bg: #f7f7f8;
    --card: #ffffff;
    --text: #1b1c1f;
    --muted: #5c606b;
    --border: #d9dbe0;
    --accent: #2457c5;
    --code-bg: #f0f1f4;
    --critical: #b00020;
    --high: #c2410c;
    --medium: #a16207;
    --low: #2f7d4f;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121317;
        --card: #1c1e24;
        --text: #e8e9ec;
        --muted: #a0a4ae;
        --border: #343741;
        --accent: #7aa2ff;
        --code-bg: #24262d;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

header, main, footer {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px;
}

header { padding-top: 20px; }
h1 { font-size: 1.5rem; margin: 0 0 6px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; display: flex; align-items: center; gap: 10px; }
.tagline { margin: 0 0 6px; }
.privacy { margin: 0 0 16px; color: var(--low); font-weight: 600; }
.muted { color: var(--muted); }

section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

select, button, .file-btn {
    font: inherit;
    min-height: 44px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    padding: 0 12px;
}

select { max-width: 100%; min-width: 0; }
/* WebKit sizes a select's scrollable overflow by the selected option's text, so
   a long example title widens the page unless the row clips it. */
label.grow { flex: 1 1 100%; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
label.grow select { flex: 1 1 auto; width: 100%; }
label.grow select:focus-visible { outline-offset: -2px; }

.file-btn { cursor: pointer; display: inline-flex; align-items: center; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 2px solid var(--accent); }

textarea {
    width: 100%;
    min-height: 240px;
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--code-bg);
    color: var(--text);
    resize: vertical;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}

#analyze {
    width: 100%;
    margin-top: 10px;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

#analyze:disabled { opacity: 0.6; }
button.small { min-height: 32px; font-size: 0.9rem; }

.summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.risk {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.risk-critical { background: var(--critical); }
.risk-high { background: var(--high); }
.risk-medium { background: var(--medium); }
.risk-low { background: var(--low); }

.warning {
    border-left: 4px solid var(--high);
    background: var(--code-bg);
    padding: 8px 10px;
    border-radius: 6px;
}

#signals { padding-left: 0; list-style: none; margin: 0; }

#signals li {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
    cursor: pointer;
}

#signals li:focus { outline: 2px solid var(--accent); }
.signal-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.signal-line { color: var(--muted); font-size: 0.9rem; }

code, pre, .snippet {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.snippet {
    display: block;
    margin-top: 4px;
    background: var(--code-bg);
    padding: 4px 6px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
}

dl { margin: 0; }
dt { font-weight: 600; margin-top: 8px; }
dd { margin: 2px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    word-break: break-all;
}

pre#ir {
    margin: 0;
    background: var(--code-bg);
    padding: 10px;
    border-radius: 8px;
    overflow: auto;
    max-height: 420px;
    white-space: pre-wrap;
    word-break: break-word;
}

footer { padding-bottom: 32px; font-size: 0.9rem; }
footer a { color: var(--accent); }
