/* Tools: mobil zuerst, gleiche Bauweise wie Kochplan. Farben als light-dark(hell, dunkel); color-scheme entscheidet.
   Hell oder dunkel folgt dem System, außer oben rechts ist „hell“ oder „dunkel“ gewählt (data-theme, Cookie tools_theme). */

:root {
    color-scheme: light dark;

    --bg: light-dark(#f5f6f8, #131619);
    --surface: light-dark(#ffffff, #1c2024);
    --surface-2: light-dark(#eef0f4, #252a30);
    --border: light-dark(#dfe2e8, #30363d);
    --text: light-dark(#1b1f24, #e9edf1);
    --muted: light-dark(#5d6670, #9aa4ae);
    --accent: light-dark(#3d5bd9, #8ea2ff);
    --accent-text: light-dark(#ffffff, #10152b);
    --accent-soft: light-dark(#e7ebfc, #232c4d);
    --ok: light-dark(#2f7d5b, #55b98a);
    --ok-bg: light-dark(#e4f3ea, #1d3a2b);
    --warn: light-dark(#a86f05, #e0ad48);
    --warn-bg: light-dark(#fdf1d9, #3d3318);
    --error-bg: light-dark(#fbe4e2, #452221);
    --danger: light-dark(#c0362c, #e0645a);
    --danger-text: light-dark(#ffffff, #1a0d0c);
    --shadow-1: 0 1px 2px light-dark(rgba(20, 30, 50, .06), rgba(0, 0, 0, .3)), 0 2px 8px light-dark(rgba(20, 30, 50, .05), transparent);
    --shadow-2: 0 5px 18px light-dark(rgba(20, 30, 50, .12), rgba(0, 0, 0, .45)), 0 1px 3px light-dark(rgba(20, 30, 50, .08), transparent);

    --r-s: 8px;
    --r-m: 12px;
    --r-l: 18px;
    --tap: 44px;
    --gutter: 16px;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);

    --dur-s: 120ms;
    --dur-m: 220ms;
    --dur-l: 320ms;
    --ease: cubic-bezier(.2, .8, .2, 1);

    --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-reduced-motion: reduce) {
    :root { --dur-s: 0ms; --dur-m: 0ms; --dur-l: 0ms; }
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}
h1 { font-size: 1.9rem; line-height: 1.15; letter-spacing: -.02em; margin: 0; text-wrap: balance; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 0; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack.tight { gap: .5rem; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.icon { width: 20px; height: 20px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Rahmen ---------- */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.content {
    flex: 1; width: 100%; max-width: 760px; margin: 0 auto;
    padding: 1.5rem max(var(--gutter), env(safe-area-inset-right)) calc(2.5rem + var(--safe-b)) max(var(--gutter), env(safe-area-inset-left));
}

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "brand . actions" "tabs tabs tabs";
    align-items: center; gap: .25rem .75rem;
    padding: calc(.5rem + var(--safe-t)) max(var(--gutter), env(safe-area-inset-right)) .5rem max(var(--gutter), env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
}
.brand { grid-area: brand; display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
    background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: .95rem;
}
.brand-mark.big { width: 48px; height: 48px; border-radius: 14px; font-size: 1.3rem; margin-bottom: 1rem; }
.brand-mark.big .icon { width: 26px; height: 26px; }
.topbar-actions { grid-area: actions; display: flex; align-items: center; gap: .15rem; }
.topbar-actions form { margin: 0; }

.tabs { grid-area: tabs; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.tabs a {
    display: inline-flex; align-items: center; gap: .4rem; min-height: 38px; padding: 0 .8rem;
    border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap;
    transition: background-color var(--dur-s) var(--ease), color var(--dur-s) var(--ease);
}
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a.active { color: var(--accent); background: var(--accent-soft); }
.tabs .icon { width: 18px; height: 18px; }

@media (max-width: 719px) {
    .tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
    .tabs a { justify-content: center; padding: 0 .4rem; font-size: .9rem; gap: .3rem; }
}
@media (min-width: 720px) {
    .topbar { grid-template-columns: auto 1fr auto; grid-template-areas: "brand tabs actions"; }
    .tabs { justify-content: center; }
}

.page-head { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.page-eyebrow { margin: 0 0 .1rem; font-size: .85rem; font-weight: 600; color: var(--accent); }
.page-sub { margin: .35rem 0 0; color: var(--muted); }

/* ---------- Karten, Kacheln ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
    padding: 1.25rem; box-shadow: var(--shadow-1);
}
@media (min-width: 600px) { .card { padding: 1.5rem; } }
.card.narrow { width: 100%; max-width: 440px; }
.card h1 { font-size: 1.5rem; margin-bottom: .35rem; }

.tiles { display: grid; gap: .75rem; }
@media (min-width: 640px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile {
    display: flex; align-items: flex-start; gap: 1rem; padding: 1.15rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
    color: var(--text); text-decoration: none; box-shadow: var(--shadow-1);
    transition: transform var(--dur-m) var(--ease), box-shadow var(--dur-m) var(--ease), border-color var(--dur-m) var(--ease);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.tile-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.tile-icon .icon { width: 24px; height: 24px; }
.tile-body { display: flex; flex-direction: column; gap: .2rem; flex: 1; min-width: 0; }
.tile-body strong { font-size: 1.05rem; }
.tile-body .muted { font-size: .92rem; }
.tile-stats { display: flex; gap: 1rem; margin-top: .5rem; font-size: .88rem; color: var(--muted); }
.tile-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.tile-go { color: var(--muted); align-self: center; }

/* ---------- Formulare ---------- */
label { font-size: .9rem; font-weight: 500; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > .field { min-width: 140px; }
.field-row > .field.grow { flex: 1 1 220px; }

input:not([type="checkbox"]), select, textarea {
    width: 100%; min-height: var(--tap); padding: .55rem .8rem;
    font: inherit; font-size: 16px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-s);
    transition: border-color var(--dur-s) var(--ease), box-shadow var(--dur-s) var(--ease);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.45; }
textarea.mono, textarea#secret-text { font-family: var(--mono); font-size: 15px; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 400; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.affix { display: flex; align-items: stretch; }
.affix-text {
    display: inline-flex; align-items: center; padding: 0 .7rem; font-family: var(--mono); font-size: .9rem; color: var(--muted);
    background: var(--surface-2); border: 1px solid var(--border); border-right: 0; border-radius: var(--r-s) 0 0 var(--r-s);
}
.affix input { border-radius: 0 var(--r-s) var(--r-s) 0; font-family: var(--mono); }

.hint { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.hint .icon { width: 17px; height: 17px; color: var(--ok); }

/* ---------- Knöpfe ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    min-height: var(--tap); padding: 0 1rem;
    font: inherit; font-weight: 600; font-size: .95rem; color: var(--text);
    background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-s);
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background-color var(--dur-s) var(--ease), transform var(--dur-s) var(--ease), opacity var(--dur-s) var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--border)); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn.danger { background: var(--danger); color: var(--danger-text); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon { width: 40px; min-height: 40px; padding: 0; }
.btn.block { width: 100%; }

/* ---------- Hinweise und Ergebnis ---------- */
.alert { padding: .7rem .9rem; border-radius: var(--r-s); font-size: .92rem; margin-top: .75rem; }
.stack > .alert, form .alert { margin-top: 0; }
.alert.ok { background: var(--ok-bg); }
.alert.warn { background: var(--warn-bg); }
.alert.error { background: var(--error-bg); }

.result {
    display: flex; flex-direction: column; gap: .6rem; margin-top: 1.25rem; padding: 1rem;
    background: var(--ok-bg); border-radius: var(--r-m);
    animation: rise var(--dur-l) var(--ease);
}
.card > .result:first-child { margin-top: 0; }
.result-label { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--ok); }
.result-row { display: flex; gap: .5rem; align-items: stretch; }
.result-value {
    flex: 1; min-width: 0; display: flex; align-items: center; padding: .55rem .8rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-s);
    font-family: var(--mono); font-size: .95rem; overflow-x: auto; white-space: nowrap;
}
.result p { margin: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Listen ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 2rem 0 .75rem; }
.count {
    display: inline-block; min-width: 1.6em; margin-left: .35rem; padding: 0 .45em; border-radius: 999px;
    background: var(--surface-2); color: var(--muted); font-size: .8rem; text-align: center; font-variant-numeric: tabular-nums;
}
.search { position: relative; display: flex; align-items: center; flex: 0 1 240px; }
.search .icon { position: absolute; left: .7rem; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.2rem; min-height: 38px; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 1rem; border: 1px dashed var(--border); border-radius: var(--r-l); }

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.item {
    display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-m);
}
.item.dim .item-main > :not(.item-title) { opacity: .7; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.item-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-weight: 600; }
.item-title a { text-decoration: none; }
.item-title .icon { width: 16px; height: 16px; }
.item-target { color: var(--muted); font-size: .9rem; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-target:hover { color: var(--text); text-decoration: underline; }
.item-note { font-size: .9rem; }
.item-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-top: .2rem; font-size: .8rem; color: var(--muted); }
.item-meta span { display: inline-flex; align-items: center; gap: .25rem; }
.item-meta .icon { width: 14px; height: 14px; }
.item-actions { display: flex; align-items: center; gap: .1rem; flex: none; margin: -.3rem -.4rem -.3rem 0; }
.item-actions .btn.danger { min-height: 36px; padding: 0 .75rem; font-size: .85rem; }
@media (max-width: 520px) {
    .item { flex-direction: column; align-items: stretch; }
    .item-actions { margin: 0 0 0 -.5rem; }
}

.pill {
    display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600;
    letter-spacing: .02em; text-transform: uppercase;
}
.pill.aktiv { background: var(--ok-bg); color: var(--ok); }
.pill.gelesen { background: var(--accent-soft); color: var(--accent); }
.pill.deaktiviert, .pill.abgelaufen { background: var(--surface-2); color: var(--muted); }

/* ---------- Leere Seiten (Login, Geheimnis abrufen, Fehler) ---------- */
.empty-shell {
    min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
    padding: calc(1.5rem + var(--safe-t)) var(--gutter) calc(1.5rem + var(--safe-b));
}
.empty-shell .card { animation: rise var(--dur-l) var(--ease); }
.empty-shell .card > p { margin: 0 0 1.25rem; }
.empty-shell textarea { margin: .25rem 0 .75rem; min-height: 160px; }
.login-code { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.login-code summary { cursor: pointer; color: var(--muted); font-size: .92rem; }
.login-code form { margin-top: .75rem; }
.code-input { font-family: var(--mono); letter-spacing: .2em; font-size: 1.2rem !important; }

/* ---------- Blazor ---------- */
#blazor-error-ui {
    display: none; position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0;
    padding: .75rem 1rem calc(.75rem + var(--safe-b)); background: var(--warn-bg); box-shadow: var(--shadow-2);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }
