:root {
  --bg: #f4f7fb; --surface: #fff; --ink: #0f2438; --muted: #5b6f84; --line: #d8e1ec;
  --brand: #0263BE; --brand-hover: #014E97; --on-brand: #fff; --navy: #012A53; --accent: #2DB9D9;
  --danger: #b3261e; --ok: #11785a;
  --int-bg: #e6f0fa; --int-ink: #0263BE; --pub-bg: #e2f6fa; --pub-ink: #0b6d82; --exp-bg: #fbe9e7; --exp-ink: #b3261e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1520; --surface: #13212f; --ink: #e8eff6; --muted: #93a6b8; --line: #243648;
    --brand: #4aa3f0; --brand-hover: #7bbcf5; --on-brand: #04121f; --navy: #012A53; --accent: #5fd0ea;
    --danger: #ff8a80; --ok: #5fd6a8;
    --int-bg: #16314d; --int-ink: #8cc4f5; --pub-bg: #103a44; --pub-ink: #7fdcef; --exp-bg: #45201d; --exp-ink: #ff8a80;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* ---- Kopf und Rahmen ---- */
header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-top: 3px solid var(--accent); border-bottom: 1px solid var(--line); }
header .logo { height: 28px; width: auto; display: block; }
header h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { color: var(--muted); font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: 960px; margin: 0 auto; padding: 20px 16px 64px; }
h2 { font-size: 17px; margin: 0 0 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.muted { color: var(--muted); }

/* ---- Knöpfe und Eingaben ---- */
button, input, select { font: inherit; color: inherit; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 7px 14px; cursor: pointer; text-decoration: none; line-height: 1.3; }
button:hover, .btn:hover { border-color: var(--brand); }
.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.small { padding: 4px 10px; font-size: 13px; }
.danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input[type=text], input[type=url], input[type=search], input[type=date], select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; width: 100%; min-width: 0; }

/* ---- Formular ---- */
.form { display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; }
.field { display: grid; gap: 4px; min-width: 0; }
.label { font-weight: 600; font-size: 14px; }
.opt { color: var(--muted); font-weight: 400; }
.prefixed { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 0; }
.prefixed:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.prefix { padding-left: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.prefixed input[type=text] { border: 0; background: transparent; padding-left: 1px; flex: 1 1 110px; }
.prefixed input:focus-visible { outline: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 4px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.choice input { margin-top: 4px; accent-color: var(--brand); }
.choice strong { display: block; }
.choice small { display: block; color: var(--muted); font-size: 13px; }
.choice .note { margin-top: 4px; font-style: italic; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
dialog .choices.three { grid-template-columns: 1fr; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }
.created { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--pub-bg); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.created a { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }

/* ---- Liste ---- */
.tools { display: flex; gap: 12px; margin: 24px 0 12px; align-items: center; flex-wrap: wrap; }
.tools input[type=search] { flex: 1 1 220px; max-width: 360px; }
.toggle { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.count { color: var(--muted); margin-left: auto; font-size: 14px; }
.list { display: grid; gap: 10px; }
.link { display: grid; gap: 4px; padding: 14px 16px; }
.link > * { min-width: 0; }
.link .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link .short { font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.link .short:hover { text-decoration: underline; }
.link .title { font-weight: 600; }
.link .target { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link .target a { color: inherit; }
.link .meta { color: var(--muted); font-size: 13px; }
.link .actions { margin-top: 6px; }
.badge { font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; }
.badge.internal { background: var(--int-bg); color: var(--int-ink); }
.badge.public { background: var(--pub-bg); color: var(--pub-ink); }
.badge.expired { background: var(--exp-bg); color: var(--exp-ink); }
.badge.matomo { background: var(--bg); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---- Anmeldekarte und Hinweisseiten ---- */
.login, .notice { width: min(440px, calc(100% - 32px)); margin: 12vh auto 0; padding: 32px 24px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.login h1, .notice h1 { margin: 6px 0 0; font-size: 22px; }
.login p, .notice p { margin: 0 0 8px; }
.logo-lg { height: 56px; width: auto; }

/* ---- Dialog und Meldungen ---- */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 20px; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(1 42 83 / 0.5); }
dialog h2 { margin-bottom: 2px; }
dialog p { margin: 0; overflow-wrap: anywhere; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }

/* ---- QR-Generator ---- */
dialog.qr-dialog { width: min(860px, calc(100vw - 32px)); }
.qr-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.qr-side { display: grid; gap: 10px; position: sticky; top: 0; }
.qr-preview { width: min(300px, 100%); aspect-ratio: 1; display: grid; place-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.qr-preview.transparent { background: repeating-conic-gradient(#d9dee5 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.qr-preview img { width: 100%; max-width: 280px; height: auto; display: block; }
.qr-preview img:not([src]) { visibility: hidden; }
.qr-preview.stale img { opacity: .25; filter: grayscale(1); }
.qr-error { color: var(--danger); font-size: 14px; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.shapes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shape { display: grid; justify-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px 8px; cursor: pointer; font-size: 14px; position: relative; }
.shape:has(input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.shape:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.shape input { position: absolute; opacity: 0; pointer-events: none; }
.shape svg { width: 28px; height: 28px; fill: currentColor; }
.swatches, .options { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.options label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.options input[type=radio] { accent-color: var(--brand); }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.swatch { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.swatch.navy { background: #012a53; }
.swatch.blue { background: #0263be; }
.swatch.black { background: #000; }
input[type=file] { max-width: 100%; font-size: 14px; }

@media (max-width: 640px) {
  .grid2, .choices, .choices.three { grid-template-columns: 1fr; }
  dialog { padding: 16px; }
  .qr-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .qr-side { position: static; justify-items: center; }
  .card { padding: 16px; }
  .who { display: none; }
  .count { margin-left: 0; width: 100%; }
  .tools input[type=search] { max-width: none; }
}
.legal { width: min(720px, calc(100% - 32px)); margin: 6vh auto 48px; padding: 32px 28px; }
.legal h1 { margin: 12px 0 14px; font-size: 22px; }
.legal h2 { margin: 24px 0 8px; }
.legal p { margin: 0 0 10px; }
.legal-link { font-size: 13px; }
.legal-link a { color: var(--muted); }
