:root {
    --bg: #faf8f5;
    --surface: #ffffff;
    --surface-2: #f3f0ea;
    --text: #17161d;
    --muted: #6d6a73;
    --border: #e6e1d8;
    --accent: #ff5a36;
    --accent-ink: #ffffff;
    --accent-soft: #ffe7e0;
    --ok: #127a4b;
    --ok-soft: #e3f5ec;
    --danger: #c42b1c;
    --danger-soft: #fdebe9;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(23, 22, 29, .04), 0 6px 24px rgba(23, 22, 29, .05);
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121117;
        --surface: #1b1a22;
        --surface-2: #24232d;
        --text: #f1eff4;
        --muted: #a29fab;
        --border: #2f2d39;
        --accent: #ff6b4a;
        --accent-soft: #3a1f19;
        --ok: #4ccf91;
        --ok-soft: #12291e;
        --danger: #ff7a6b;
        --danger-soft: #3a1c19;
        --shadow: none;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 var(--sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .6em; }
h1 { font-size: clamp(1.6rem, 3vw, 2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); letter-spacing: -.01em; }
.center { text-align: center; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 32px; padding-bottom: 64px; }

/* Kopfzeile */
.site-header { border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.logo { font-weight: 800; font-size: 1.4rem; letter-spacing: -.04em; text-decoration: none; }
.logo span { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 18px; font-size: .95rem; }
.nav a { text-decoration: none; }
.nav a:not(.btn):hover { color: var(--accent); }
.inline { display: inline; margin: 0; }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; padding-top: 20px; padding-bottom: 20px; flex-wrap: wrap; }
.footer-inner nav { display: flex; gap: 18px; }
.footer-inner a { text-decoration: none; }
.footer-inner a:hover { color: var(--text); }

/* Buttons und Formulare */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--accent); color: var(--accent-ink);
    border: 1px solid transparent; border-radius: 10px;
    padding: 12px 20px; font: 600 1rem var(--sans); text-decoration: none; cursor: pointer;
    transition: transform .08s ease, filter .15s ease;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn-small { padding: 7px 12px; font-size: .88rem; border-radius: 8px; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn.copied { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.link-button:hover { color: var(--accent); }
.link-button.danger { color: var(--danger); }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=search] {
    width: 100%; padding: 12px 14px; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
label small { font-weight: 400; color: var(--muted); }
label.checkbox { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
label.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-weight: 500; overflow-wrap: anywhere; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }

/* Startseite */
.hero { text-align: center; padding: 40px 0 56px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--accent); margin: 0 0 12px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); letter-spacing: -.045em; margin-bottom: 20px; }
.accent { color: var(--accent); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 620px; margin: 0 auto 36px; }
.hero-demo { max-width: 560px; margin: 0 auto 36px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.demo-long { font-family: var(--mono); font-size: .82rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: 10px; padding: 10px 14px; overflow-wrap: anywhere; }
.demo-arrow { color: var(--accent); font-size: 1.2rem; }
.demo-short { font-family: var(--mono); font-size: clamp(1.3rem, 4vw, 1.8rem); background: var(--surface); border: 2px solid var(--accent); border-radius: 12px; padding: 10px 22px; box-shadow: 6px 6px 0 var(--accent-soft); }
.demo-short b { color: var(--accent); }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.feature h3 { margin-bottom: 6px; }
.feature p { margin: 0; color: var(--muted); font-size: .95rem; }

/* Anmeldung */
.auth-card { max-width: 420px; margin: 24px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.auth-card .muted { margin-top: 20px; margin-bottom: 0; }
.preview-target { font-family: var(--mono); background: var(--surface-2); padding: 12px 14px; border-radius: 10px; overflow-wrap: anywhere; }

/* Dashboard */
.create-panel { margin-bottom: 32px; }
.create-main { display: flex; gap: 10px; }
.create-main input { font-size: 1.05rem; padding: 14px 16px; }
.create-options { margin-top: 14px; }
.create-options summary { cursor: pointer; color: var(--muted); font-size: .92rem; width: fit-content; }
.create-options summary:hover { color: var(--text); }
.create-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.prefix-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.prefix-input span { display: flex; align-items: center; padding: 0 4px 0 14px; color: var(--muted); font-family: var(--mono); font-weight: 400; font-size: .9rem; }
.prefix-input input { border: 0; padding-left: 2px; font-family: var(--mono); }
.prefix-input input:focus { box-shadow: none; }
.prefix-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.links-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.links-head h2 { margin: 0; }
.count { color: var(--muted); font-weight: 500; font-size: 1rem; margin-left: 4px; }
.search { width: min(280px, 100%); }
.search input { padding: 9px 12px; }
.empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--muted); }

.link-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.link-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 20px; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px;
}
.link-row.is-new { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.link-row.is-inactive { opacity: .6; }
.link-title { font-weight: 700; margin-bottom: 2px; }
.link-short { font-family: var(--mono); color: var(--accent); font-weight: 600; text-decoration: none; font-size: 1.05rem; }
.link-short:hover { text-decoration: underline; }
.link-target { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-meta { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.badge { background: var(--surface-2); padding: 1px 8px; border-radius: 99px; }
.link-clicks { text-align: right; min-width: 70px; }
.link-clicks strong { display: block; font-size: 1.4rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.link-clicks span { color: var(--muted); font-size: .8rem; }
.link-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Statistik */
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 18px; font-size: .92rem; }
.back:hover { color: var(--text); }
.stats-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.stats-head > div:first-child { min-width: 0; flex: 1; }
.stats-head h1 { margin-bottom: 4px; overflow-wrap: anywhere; }
.stats-head .eyebrow { margin-bottom: 6px; }
.stats-head .link-target { white-space: normal; overflow-wrap: anywhere; }

.range-tabs { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.range-tabs a { padding: 6px 14px; border-radius: 7px; text-decoration: none; font-size: .9rem; color: var(--muted); font-weight: 600; }
.range-tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.kpi span { color: var(--muted); font-size: .85rem; font-weight: 600; }
.kpi strong { display: block; font-size: 2rem; letter-spacing: -.03em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }

.chart-panel { margin-bottom: 14px; }
.chart { width: 100%; height: 180px; display: block; }
.chart rect.has { fill: var(--accent); }
.chart rect.zero { fill: var(--border); }
.chart rect:hover { opacity: .75; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 8px; }

.breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.breakdown ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.breakdown li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 8px; overflow: hidden; font-size: .93rem; }
.breakdown .bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); z-index: 0; border-radius: 8px; }
.breakdown .label, .breakdown .num { position: relative; z-index: 1; }
.breakdown .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown .num { font-variant-numeric: tabular-nums; font-weight: 600; }

.edit-panel { max-width: 640px; }
.delete-form { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.attribution { margin-top: 24px; }

/* QR-Dialog */
.qr-dialog { border: 0; border-radius: var(--radius); padding: 28px; width: min(380px, calc(100vw - 32px)); background: var(--surface); color: var(--text); text-align: center; }
.qr-dialog::backdrop { background: rgba(10, 10, 15, .5); }
.qr-close { position: absolute; top: 10px; right: 14px; margin: 0; }
.qr-close button { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.qr-url { font-family: var(--mono); font-size: .9rem; overflow-wrap: anywhere; }
.qr-image { background: #fff; border-radius: 10px; padding: 8px; margin: 12px 0 18px; }
.qr-image svg { width: 100%; height: auto; display: block; }
.qr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.prose { max-width: 720px; }
.prose h2 { margin-top: 1.6em; }

@media (max-width: 760px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .link-row { grid-template-columns: minmax(0, 1fr) auto; }
    .link-actions { grid-column: 1 / -1; justify-content: flex-start; }
    .create-extra { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .create-main { flex-direction: column; }
    .nav { gap: 12px; }
    .auth-card { padding: 24px 20px; }
    .panel { padding: 18px; }
    .kpi strong { font-size: 1.6rem; }
}
