:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1a1d24;
    --muted: #6b7280;
    --accent: #4f46e5;          /* Akzent als Fläche (Buttons, Pills) */
    --accent-hover: #4338ca;
    --accent-text: #4338ca;     /* Akzent als Text – im Dark Mode aufgehellt */
    --accent-soft-bg: rgba(79, 70, 229, 0.10);
    --accent-soft-border: rgba(79, 70, 229, 0.25);
    --radius: 14px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161b;
        --surface: #1d2027;
        --border: #2c303a;
        --text: #e8eaee;
        --muted: #9aa1ad;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
        --accent-text: #a5b4fc;     /* helles Indigo, gut lesbar auf Dunkel */
        --accent-soft-bg: rgba(129, 140, 248, 0.16);
        --accent-soft-border: rgba(129, 140, 248, 0.38);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

.masthead {
    text-align: center;
    padding: 2.4rem 1rem 1rem;
    max-width: 640px;
    margin: 0 auto;
}
.masthead h1 {
    margin: 0 0 .35rem;
    font-size: 1.7rem;
    letter-spacing: -0.02em;
}
.masthead p {
    margin: 0;
    color: var(--muted);
    font-size: .98rem;
}

/* Sticky Suchleiste */
.searchbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: .5rem;
    max-width: 640px;
    margin: 1rem auto;
    padding: .75rem 1rem;
    background: var(--bg);
}
.searchbar input {
    flex: 1;
    min-width: 0;
    padding: .8rem 1rem;
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.searchbar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.searchbar button {
    padding: .8rem 1.4rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s;
}
.searchbar button:hover { background: var(--accent-hover); }
.searchbar button:disabled { opacity: .6; cursor: progress; }

/* Toolbar + Debug-Switch */
.toolbar {
    max-width: 640px;
    margin: -0.5rem auto 0.5rem;
    padding: 0 1rem;
    display: flex;
    justify-content: flex-end;
}
.switch {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    cursor: pointer;
    font-size: .9rem;
    color: var(--muted);
    user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: var(--border);
    position: relative;
    transition: background .15s;
    flex: none;
}
.switch__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
    transition: transform .15s;
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px rgba(79,70,229,.3); }

main { max-width: 1180px; margin: 0 auto; padding: 0 1rem 3rem; }

.status {
    text-align: center;
    color: var(--muted);
    padding: 2rem 1rem;
}
.status.error {
    color: #b42318;
    background: #fef3f2;
    border: 1px solid #fda29b;
    border-radius: var(--radius);
    max-width: 640px;
    margin: 0 auto;
}
@media (prefers-color-scheme: dark) {
    .status.error { background: #3a1d1a; border-color: #7a2d26; color: #ffb4ab; }
}

.warnings {
    max-width: 640px;
    margin: 0 auto 1.5rem;
    padding: .9rem 1.1rem;
    font-size: .88rem;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
}
.warnings ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.warnings li { margin: .15rem 0; }
@media (prefers-color-scheme: dark) {
    .warnings { background: #2e2410; border-color: #6b5618; color: #fcd34d; }
}

/* Debug-Panel */
.debug {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem 1.3rem;
    margin-bottom: 1.6rem;
}
.debug h2 {
    margin: 0 0 .2rem;
    font-size: 1.05rem;
}
.debug__hint { margin: 0 0 1rem; color: var(--muted); font-size: .88rem; }
.debug h3 { margin: 1.4rem 0 .4rem; font-size: .92rem; }
.debug .is-empty { color: var(--muted); }

/* Tabellen horizontal scrollen lassen statt das Layout zu sprengen */
.debug__scroll { overflow-x: auto; }

/* Plattform-Matrix: Zeile = Plattform, Zelle = Quell-Tag des Feldes */
.debug__matrix th.row-head {
    text-transform: none;
    letter-spacing: 0;
    font-size: .86rem;
    color: var(--text);
    white-space: nowrap;
}
.debug__matrix td { white-space: nowrap; }

/* Quell-Tag-Badge */
.tag-badge {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .76rem;
    padding: .12rem .45rem;
    border-radius: 6px;
    background: var(--accent-soft-bg);
    color: var(--accent-text);
    border: 1px solid var(--accent-soft-border);
    word-break: break-all;
}
.tag-badge.is-derived { background: rgba(180,83,9,.10); color: #b45309; border-color: rgba(180,83,9,.3); }
@media (prefers-color-scheme: dark) {
    .tag-badge.is-derived { color: #fbbf24; background: rgba(251,191,36,.14); border-color: rgba(251,191,36,.35); }
}

/* Tabelle aller Tags */
.debug__tags { width: 100%; border-collapse: collapse; font-size: .86rem; }
.debug__tags th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--border);
}
.debug__tags td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.debug__tags td.col-src { white-space: nowrap; }
.debug__tags td.col-val { word-break: break-word; color: var(--text); }
.debug__tags tr.is-used { background: rgba(79,70,229,.06); }
.used-pill {
    display: inline-block;
    margin: .1rem 0 .1rem .4rem;
    font-size: .68rem;
    padding: .08rem .4rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
}

/* Vorschau-Grid */
.previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.4rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.card__head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.card__head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.card__body { padding: 1rem; flex: 1; }

/* gemeinsame Bauteile */
.thumb {
    width: 100%;
    aspect-ratio: 1.91 / 1;
    object-fit: cover;
    background: linear-gradient(135deg, #e5e7eb, #cbd5e1);
    display: block;
}
.thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: .85rem;
}
.truncate-1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- Google ---- */
.g-result { font-family: arial, sans-serif; }
.g-site { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.g-favicon { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); object-fit: contain; padding: 3px; }
.g-host { font-size: 14px; color: var(--text); line-height: 1.2; }
.g-url { font-size: 12px; color: var(--muted); }
.g-title { color: #1a0dab; font-size: 20px; line-height: 1.3; margin: 4px 0 2px; }
.g-desc { color: var(--muted); font-size: 14px; }
@media (prefers-color-scheme: dark) { .g-title { color: #8ab4f8; } }

/* ---- Facebook ---- */
.fb-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.fb-meta { padding: 10px 12px; background: #f2f3f5; }
.fb-host { font-size: 12px; text-transform: uppercase; color: #606770; letter-spacing: .03em; }
.fb-title { font-size: 16px; font-weight: 600; margin: 3px 0; color: #1d2129; }
.fb-desc { font-size: 14px; color: #606770; }
@media (prefers-color-scheme: dark) {
    .fb-meta { background: #2a2d34; }
    .fb-title { color: var(--text); } .fb-host, .fb-desc { color: var(--muted); }
}

/* ---- X / Twitter ---- */
.tw-card { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.tw-card--large .thumb { aspect-ratio: 1.91 / 1; }
.tw-summary { display: flex; }
.tw-summary .thumb { width: 130px; flex: none; aspect-ratio: 1 / 1; }
.tw-meta { padding: 10px 14px; }
.tw-host { font-size: 14px; color: var(--muted); }
.tw-title { font-size: 15px; font-weight: 500; margin: 1px 0; }
.tw-desc { font-size: 14px; color: var(--muted); }

/* ---- LinkedIn ---- */
.li-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.li-meta { padding: 10px 12px; background: var(--surface); }
.li-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.li-host { font-size: 12px; color: var(--muted); }

/* ---- WhatsApp ---- */
.wa-bubble { background: #dcf8c6; border-radius: 12px; padding: 6px; max-width: 320px; }
.wa-inner { background: rgba(255,255,255,.55); border-radius: 8px; overflow: hidden; }
.wa-inner .thumb { aspect-ratio: 1.91 / 1; }
.wa-text { padding: 8px 10px; }
.wa-title { font-size: 14px; font-weight: 600; color: #111; }
.wa-desc { font-size: 13px; color: #555; }
.wa-host { font-size: 12px; color: #8696a0; margin-top: 2px; }
@media (prefers-color-scheme: dark) { .wa-bubble { background: #144d37; } .wa-inner { background: rgba(0,0,0,.2); } .wa-title { color: #e8eaee; } .wa-desc { color: #b8c0cb; } }

/* ---- Slack / Discord ---- */
.sl-card { display: flex; gap: 12px; padding-left: 12px; border-left: 4px solid var(--accent); }
.sl-content { flex: 1; min-width: 0; }
.sl-host { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.sl-title { font-size: 15px; font-weight: 700; color: var(--accent-text); margin-bottom: 3px; }
.sl-desc { font-size: 14px; color: var(--text); }
.sl-card .thumb { margin-top: 8px; border-radius: 8px; aspect-ratio: 1.91 / 1; }
.sl-thumb { width: 72px; height: 72px; flex: none; border-radius: 8px; object-fit: cover; background: linear-gradient(135deg, #e5e7eb, #cbd5e1); }

.footer {
    text-align: center;
    color: var(--muted);
    font-size: .82rem;
    padding: 1.5rem 1rem 2.5rem;
}

@media (max-width: 560px) {
    .masthead { padding-top: 1.6rem; }
    .masthead h1 { font-size: 1.4rem; }
    .previews { grid-template-columns: 1fr; }
}
