/* ==========================================================================
   Digitalberater Deals
   ========================================================================== */

:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --surface-2: #f1efea;
    --text: #1a1b1f;
    --muted: #6a6b73;
    --border: #e4e1da;
    --accent: #e8590c;
    --accent-hover: #c94d0a;
    --accent-text: #ffffff;
    --accent-soft: #fdeee5;
    --whatsapp: #128c4a;
    --danger: #c92a2a;
    --success-bg: #e6f6ec;
    --success-text: #146c3b;
    --error-bg: #fdecec;
    --error-text: #a61e1e;
    --shadow: 0 1px 2px rgb(20 20 20 / 0.04), 0 4px 16px rgb(20 20 20 / 0.05);
    --radius: 16px;
    --radius-sm: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #121316;
        --surface: #1b1c21;
        --surface-2: #24252b;
        --text: #ececf0;
        --muted: #9c9da8;
        --border: #2c2d34;
        --accent: #ff8a3d;
        --accent-hover: #ffa262;
        --accent-text: #1a1206;
        --accent-soft: #33221a;
        --whatsapp: #25d366;
        --danger: #ff6b6b;
        --success-bg: #14301f;
        --success-text: #7ee2a3;
        --error-bg: #3a1a1a;
        --error-text: #ffaaaa;
        --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #121316;
    --surface: #1b1c21;
    --surface-2: #24252b;
    --text: #ececf0;
    --muted: #9c9da8;
    --border: #2c2d34;
    --accent: #ff8a3d;
    --accent-hover: #ffa262;
    --accent-text: #1a1206;
    --accent-soft: #33221a;
    --whatsapp: #25d366;
    --danger: #ff6b6b;
    --success-bg: #14301f;
    --success-text: #7ee2a3;
    --error-bg: #3a1a1a;
    --error-text: #ffaaaa;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
    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-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

main { flex: 1; width: 100%; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }

code { background: var(--surface-2); padding: .1em .35em; border-radius: 6px; font-size: .9em; }

.wrap {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}

.muted { color: var(--muted); }
.small { font-size: .875rem; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0; padding: 0; margin: -1px;
}

.skip-link {
    position: absolute; left: -999px; top: 8px;
    background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100;
}
.skip-link:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Header ----------------------------------------------------------------- */

.site-header {
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}

.header-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 64px;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    color: var(--text); text-decoration: none; min-width: 0;
}
.brand:hover { color: var(--text); }
.brand-mark { border-radius: 9px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 750; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tld { color: var(--muted); font-weight: 600; }
.brand-sub { font-size: .75rem; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }

.header-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.header-actions form { margin: 0; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--text);
    cursor: pointer;
}
.icon-btn:hover { color: var(--accent); }
.icon-btn[hidden] { display: none; }

.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun { display: block; }
    :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* Buttons ---------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 0 16px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; font-size: .95rem;
    text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background-color .15s, color .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn[hidden] { display: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }

.btn-whatsapp { background: var(--whatsapp); border-color: var(--whatsapp); color: #fff; }
.btn-whatsapp:hover { color: #fff; filter: brightness(1.08); border-color: var(--whatsapp); }
:root[data-theme="dark"] .btn-whatsapp { color: #062b16; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-whatsapp { color: #062b16; } }

.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn-block { width: 100%; min-height: 48px; font-size: 1rem; }
.btn.copied { background: var(--success-bg); color: var(--success-text); border-color: transparent; }

@media (max-width: 480px) {
    .site-header .btn-whatsapp span { display: none; }
    .site-header .btn-whatsapp { padding: 0; width: 40px; }
}

/* Intro ------------------------------------------------------------------ */

.intro { padding: 32px 0 20px; max-width: 640px; }
.intro h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
.intro p { color: var(--muted); margin: 0; }

/* Feed ------------------------------------------------------------------- */

.feed {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding-bottom: 40px;
}
/* Ab zwei Spalten: alle Karten gleich hoch, Button sitzt immer unten */
@media (min-width: 760px) { .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; } }
@media (min-width: 1040px) { .feed { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.deal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex; flex-direction: column;
}

.deal-media { display: block; background: #fff; border-bottom: 1px solid var(--border); }
.deal-media img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; padding: 12px; }

.deal-body {
    padding: 16px 18px 4px;
    overflow-wrap: anywhere;
    font-size: .975rem;
}
.deal-body a { font-weight: 600; }
.deal-body s { color: var(--muted); }

.deal-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 18px 16px;
    margin-top: auto;
}
.deal-footer time { color: var(--muted); font-size: .85rem; }
.btn sup { font-size: .8em; line-height: 0; margin-left: -3px; }
.deal-permalink { color: var(--muted); font-size: .85rem; text-decoration: none; }
.deal-permalink time { color: inherit; }
.deal-permalink:hover { color: var(--accent); text-decoration: underline; }

/* Deal-Einzelseite ------------------------------------------------------- */

.breadcrumbs {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 20px 0 12px;
    font-size: .875rem; color: var(--muted);
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs [aria-current] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70vw; }

.deal-single { max-width: 1000px; margin-bottom: 32px; }
.deal-single-content { padding: 4px 6px 4px; }
.deal-single h1 { font-size: clamp(1.3rem, 3vw, 1.7rem); padding: 18px 18px 0; margin: 0; }
.deal-single .alert { margin: 12px 18px 0; }
.deal-single .deal-body { font-size: 1.02rem; }
.deal-disclaimer { padding: 0 18px 12px; margin: 0; }
@media (min-width: 760px) {
    .deal-single.has-media { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
    .deal-single .deal-media { border-bottom: 0; border-right: 1px solid var(--border); }
    .deal-single .deal-media img { height: 100%; aspect-ratio: auto; min-height: 320px; }
}

.related { max-width: 1000px; padding-bottom: 40px; }
.related-list {
    list-style: none; margin: 0 0 16px; padding: 0;
    display: grid; gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.related-list a {
    display: flex; gap: 12px; align-items: center;
    padding: 10px; border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); text-decoration: none;
}
.related-list a:hover { border-color: var(--accent); color: var(--text); }
.related-thumb { width: 64px; height: 64px; flex: none; border-radius: 8px; background: #fff; overflow: hidden; }
.related-thumb:empty { background: var(--surface-2); }
.related-thumb img { width: 100%; height: 100%; object-fit: contain; }
.related-text { display: flex; flex-direction: column; min-width: 0; }
.related-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }

.empty {
    text-align: center;
    padding: 56px 16px;
    color: var(--muted);
}
.empty h1 { color: var(--text); }
.empty .btn { margin-top: 8px; }

.cta {
    text-align: center;
    background: var(--accent-soft);
    border-radius: var(--radius);
    padding: 28px 16px;
    margin-bottom: 40px;
}
.cta p { color: var(--muted); }
.deal-single-cta { max-width: 1000px; }

/* Legal pages ------------------------------------------------------------ */

.legal { max-width: 720px; padding: 32px 0 48px; overflow-wrap: anywhere; }
.legal h2 { margin-top: 1.8em; font-size: 1.1rem; }
.legal ul { padding-left: 1.2em; }

/* Footer ----------------------------------------------------------------- */

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 28px 0 calc(28px + env(safe-area-inset-bottom));
    font-size: .875rem;
    color: var(--muted);
}
.affiliate-note {
    margin: 0 0 16px;
    padding: 14px 16px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    max-width: 820px;
}
.affiliate-note strong { color: var(--text); }
.affiliate-note p { margin: 0; }
.affiliate-note p + p { margin-top: 8px; }
.footer-nav { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-nav a { color: var(--text); font-weight: 600; text-decoration: none; }
.footer-nav a:hover { color: var(--accent); }
.copyright { margin: 12px 0 0; }

/* ==========================================================================
   Admin
   ========================================================================== */

.admin main.wrap { max-width: 820px; padding-top: 20px; padding-bottom: 48px; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.panel.narrow { max-width: 440px; margin: 40px auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-head h1, .panel-head h2 { margin: 0; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 600; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }

.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field > span:first-child { font-weight: 600; font-size: .95rem; }

input[type="text"], input[type="url"], input[type="password"], textarea {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    font-size: 16px; /* verhindert Zoom auf iOS */
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.prefixed {
    display: flex; align-items: stretch;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg); overflow: hidden;
}
.prefixed:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.prefixed .prefix {
    display: flex; align-items: center;
    padding: 0 4px 0 13px; color: var(--muted);
    white-space: nowrap; font-size: .95rem;
}
.prefixed input { border: 0; border-radius: 0; padding-left: 0; min-width: 0; }
.prefixed input:focus { box-shadow: none; }
@media (max-width: 420px) { .prefixed .prefix { font-size: .8rem; } }

.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.image-field { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.image-field img { width: 88px; height: 88px; object-fit: contain; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.image-field img[hidden] { display: none; }
.image-field input[type="file"] { font: inherit; font-size: .9rem; max-width: 100%; }
.image-field .check { margin-top: 8px; font-weight: 500; }

.saved { border-color: var(--accent); background: var(--accent-soft); }
.saved-link { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; overflow-wrap: anywhere; }
.saved-link a { font-size: 1.15rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.copy-box { display: grid; gap: 10px; margin: 12px 0; }
.copy-box textarea { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.deal-list { list-style: none; margin: 0; padding: 0; }
.deal-row {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 4px 12px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}
.deal-row:first-child { border-top: 0; }
.deal-thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--surface-2); overflow: hidden; grid-row: span 2; }
.deal-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.deal-info { display: flex; flex-direction: column; min-width: 0; }
.deal-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-slug { font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.deal-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.deal-actions form { margin: 0; }

@media (min-width: 680px) {
    .deal-row { grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; }
    .deal-thumb { grid-row: auto; }
}

/* Admin-Navigation & API-Testseite ------------------------------------ */

.admin-nav { display: flex; gap: 2px; margin-right: 6px; }
.admin-nav a {
    padding: 8px 12px; border-radius: 10px;
    color: var(--muted); font-weight: 600; font-size: .9rem; text-decoration: none;
}
.admin-nav a:hover { color: var(--text); }
.admin-nav a[aria-current] { color: var(--text); background: var(--surface-2); }
@media (max-width: 560px) {
    .admin .brand-text { display: none; }
    .admin-nav a { padding: 8px; }
}

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 4px 0 20px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.mono, pre { font-family: ui-monospace, Menlo, Consolas, monospace; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; justify-self: start; }
.segmented label { padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--accent); }

.field-row { display: grid; gap: 12px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
[data-mode][hidden] { display: none; }

select {
    font: inherit; font-size: 16px; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; width: 100%;
}
.advanced summary, .step summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 4px 0; }
.advanced[open] { display: grid; gap: 12px; }

.alert-info { background: var(--surface-2); color: var(--text); font-weight: 500; overflow-wrap: anywhere; }

.step-ok { border-left: 4px solid var(--success-text); }
.step-fail { border-left: 4px solid var(--danger); }
.step-message { margin: 0 0 8px; font-weight: 600; overflow-wrap: anywhere; }
.step details { margin-top: 6px; }
pre {
    margin: 8px 0 0; padding: 12px; max-height: 420px; overflow: auto;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--success-bg); color: var(--success-text); }
.badge-fail { background: var(--error-bg); color: var(--error-text); }

.api-items { list-style: none; margin: 0; padding: 0; }
.api-item { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.api-item:first-child { border-top: 0; }
.api-thumb { width: 88px; height: 88px; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.api-thumb img { width: 100%; height: 100%; object-fit: contain; }
.api-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.api-info .btn-row { margin-top: 6px; }
.api-info form { margin: 0; }
