/* Signatur-Generator – Oberfläche
   Systemschriften, keine externen Ressourcen (datenschutzfreundlich). */

:root {
    --bg: #e9edf1;
    --surface: #ffffff;
    --surface-2: #f5f7f9;
    --ink: #18222e;
    --muted: #5b6878;
    --line: #d5dce3;
    --accent: #2b50c8;
    --accent-ink: #ffffff;
    --accent-soft: #e4eafb;
    --ok: #1d7347;
    --ok-soft: #e3f3ea;
    --warn: #8a5a00;
    --warn-soft: #fbf0d9;
    --danger: #b3261e;
    --danger-soft: #fbe7e5;
    --focus: 0 0 0 3px rgba(43, 80, 200, .35);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12161c;
        --surface: #1a2029;
        --surface-2: #222a35;
        --ink: #e6ebf1;
        --muted: #98a4b3;
        --line: #2e3845;
        --accent: #8ea6ff;
        --accent-ink: #0d1530;
        --accent-soft: #1f2a4a;
        --ok: #6fd39d;
        --ok-soft: #173326;
        --warn: #f0c46a;
        --warn-soft: #362b14;
        --danger: #ff8a80;
        --danger-soft: #3a1b19;
        --focus: 0 0 0 3px rgba(142, 166, 255, .4);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 16px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Kopfzeile ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topnav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.topnav a { color: var(--ink); text-decoration: none; }
.topnav a:hover { color: var(--accent); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 50% 50% 50% 4px;
    background: var(--accent); color: var(--accent-ink);
    display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.tag {
    display: inline-block; font-size: 12px; font-weight: 600; line-height: 1;
    padding: 5px 9px; border-radius: 99px;
    background: var(--accent-soft); color: var(--accent);
}
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Layout ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
.grid {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 28px;
    align-items: start;
}
.area-admin .grid { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
@media (max-width: 920px) {
    .grid, .area-admin .grid { grid-template-columns: 1fr; }
    .area-admin .panel-preview { order: -1; }
}
.stack-lg { display: grid; gap: 28px; }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 26px;
}
.panel-preview { background: transparent; border: 0; padding: 0; }
.sticky { position: sticky; top: 20px; }
@media (max-width: 920px) { .sticky { position: static; } }

/* ---------- Formulare ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-weight: 650; font-size: 15px; padding: 0; margin-bottom: 12px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field.is-dimmed { opacity: .45; }
label { font-size: 13px; font-weight: 600; }

input[type=text], input[type=email], input[type=tel], input[type=url],
input[type=password], input[type=number], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: 15px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible, a:focus-visible {
    outline: none; box-shadow: var(--focus); border-color: var(--accent);
}
input[aria-invalid=true] { border-color: var(--danger); background: var(--danger-soft); }
input[type=file] { font: inherit; font-size: 14px; max-width: 100%; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .row, .row-3 { grid-template-columns: 1fr; } }

.hint { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.color-field { display: flex; align-items: center; gap: 8px; }
input[type=color] {
    width: 42px; height: 36px; padding: 2px; border: 1px solid var(--line);
    border-radius: 6px; background: var(--surface-2); cursor: pointer; flex: none;
}
.color-field output { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.form-errors {
    margin: 0 0 14px; padding: 10px 14px 10px 30px;
    background: var(--danger-soft); color: var(--danger);
    border-radius: 6px; font-size: 14px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--line); border-radius: 6px;
    background: var(--surface); color: var(--ink);
    font: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); color: var(--accent-ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); padding-inline: 8px; }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 18px 0 8px; }

/* ---------- Meldungen ---------- */
.alert { padding: 11px 15px; border-radius: 6px; margin-bottom: 18px; font-size: 14px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert a { color: inherit; font-weight: 600; }

.status { min-height: 1.5em; font-size: 14px; margin: 0 0 12px; }
.status-ok { color: var(--ok); }
.status-error { color: var(--danger); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    padding: 32px;
}
.login-card .brand { margin-bottom: 24px; }
.stack { margin-top: 18px; }

/* ---------- Mail-Attrappe (Vorschau) ---------- */
.mail-mock {
    background: #ffffff;
    color: #333333;
    border-radius: 12px;
    box-shadow: 0 1px 0 rgba(24, 34, 46, .06), 0 18px 40px -12px rgba(24, 34, 46, .28);
    overflow: hidden;
    margin-top: 12px;
}
.mail-head { display: flex; gap: 6px; padding: 12px 16px; background: #eef1f5; }
.mail-head .dot { width: 10px; height: 10px; border-radius: 50%; background: #cfd6de; }
.mail-meta { padding: 6px 22px; border-bottom: 1px solid #e6eaef; }
.mail-meta div { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 12px; color: #8792a0; }
.mail-meta div + div { border-top: 1px solid #f0f2f5; }
.mail-meta span { width: 52px; flex: none; }
.mail-meta i, .fake-text i { display: block; height: 8px; border-radius: 4px; background: #e4e8ee; }
.mail-body { padding: 24px 22px 30px; overflow-x: auto; }
.fake-text { display: grid; gap: 10px; margin-bottom: 26px; }
.example-note {
    display: inline-block; font-size: 12px; font-weight: 600; color: #2b50c8;
    background: #e4eafb; padding: 3px 9px; border-radius: 99px; margin-bottom: 12px;
}
.signature-preview { min-height: 80px; }

details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; font-weight: 600; font-size: 14px; }
details textarea {
    margin-top: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px; line-height: 1.5;
}
.howto { margin-top: 10px; font-size: 14px; }
.howto p { margin-bottom: .7em; }

.logo-current {
    display: inline-block; padding: 14px; margin-bottom: 14px;
    background: #ffffff; border: 1px solid var(--line); border-radius: 6px;
}
.logo-current img { display: block; max-width: 220px; max-height: 90px; }

/* ---------- HTML-Vorlagen-Editor ---------- */
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .88em;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0 4px;
}
.hint-block { font-size: 13.5px; color: var(--muted); max-width: 70ch; }

.template-editor {
    padding: 18px;
    margin-bottom: 26px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.template-editor[hidden] { display: none; }

.var-palette { display: grid; gap: 8px; margin-bottom: 14px; }
.var-group { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.var-group-title { width: 100%; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.chip {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    color: var(--accent);
    cursor: pointer;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

.editor-tools {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin-bottom: 8px; font-size: 13px;
}
.editor-tools label { font-weight: 500; }
.editor-tools select { width: auto; padding: 6px 8px; font-size: 13px; }
.editor-tools .spacer { flex: 1; }
.btn-small { padding: 6px 11px; font-size: 13px; }

textarea.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.6;
    tab-size: 2;
    white-space: pre;
    overflow-x: auto;
    background: var(--surface);
    min-height: 320px;
}

.template-warnings {
    margin: 10px 0 0; padding: 10px 14px 10px 30px;
    background: var(--warn-soft); color: var(--warn);
    border-radius: 6px; font-size: 13.5px;
}

.check.is-dimmed { opacity: .45; }

.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.preview-head h2 { margin: 0; }
.preview-head select { width: auto; padding: 6px 8px; font-size: 13px; }
.preview-empty { color: #8792a0; font-style: italic; margin: 0; }
