:root {
  --bg: #fbf8f5; --card: #ffffff; --ink: #1f1a24; --muted: #6b6470; --line: #e8e1e6;
  --brand: #7a2e5c; --brand-2: #b0477f; --ok: #1d7a4a; --warn: #8a4b00; --err: #b3261e;
  --radius: 16px; --shadow: 0 10px 30px rgba(60, 20, 50, .10);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17131a; --card: #221c26; --ink: #f3eef5; --muted: #b3a9b8; --line: #3a3140;
          --brand: #e07ab3; --brand-2: #f29cc9; --shadow: 0 10px 30px rgba(0, 0, 0, .4); }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.55;
       font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--brand); }
img { max-width: 100%; height: auto; display: block; }
h1, h2 { line-height: 1.15; letter-spacing: -.01em; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); text-align: center; margin: 0 0 1.2rem; }
section { max-width: 1120px; margin: 0 auto; padding: 3rem 16px; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
       padding: .7rem 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
       backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.logo { color: var(--brand); }
.top nav { margin-left: auto; display: flex; gap: 1rem; }
.top nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
@media (max-width: 640px) { .top nav { display: none; } .top .btn { margin-left: auto; } }

.btn { display: inline-block; border: 0; border-radius: 999px; background: var(--brand); color: #fff;
       font-weight: 700; padding: .8rem 1.4rem; font-size: 1rem; cursor: pointer; text-decoration: none;
       transition: transform .1s, background .2s; }
.btn:hover { background: var(--brand-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: .5rem 1rem; font-size: .9rem; }
.btn.big { width: 100%; padding: 1.05rem; font-size: 1.15rem; }
.btn.ghost { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.btn.dl { margin: .3rem .4rem .3rem 0; }

.hero > *, .fields > *, .result-grid > * { min-width: 0; }  /* lange Maschinennamen sprengen sonst die Breite */
select { max-width: 100%; text-overflow: ellipsis; }
.mini-ba { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.2rem; }
.mini-ba img { width: 120px; height: 120px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.mini-ba span { font-size: 1.6rem; color: var(--brand); }
.mini-ba p { margin: 0; font-weight: 700; color: var(--muted); font-size: .9rem; max-width: 9rem; }
@media (max-width: 860px) { .mini-ba img { width: 92px; height: 92px; } }
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 2.5rem; align-items: center; padding-top: 2.2rem; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; gap: 1.4rem; padding-top: 1.2rem; } }
.hero h1 { font-size: clamp(2rem, 5.2vw, 3.4rem); margin: 0 0 .8rem; }
.hero h1 em { font-style: normal; color: var(--brand); }
.lead { font-size: clamp(1.05rem, 2.2vw, 1.25rem); color: var(--muted); margin: 0 0 1rem; }
.trust { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 1.2rem; }
.upload { display: grid; gap: 1rem; }
.drop { position: relative; display: grid; place-items: center; text-align: center; gap: .3rem; min-height: 190px;
        border: 2px dashed var(--brand); border-radius: 12px; padding: 1rem; cursor: pointer;
        background: color-mix(in srgb, var(--brand) 6%, transparent); transition: background .2s; }
.drop.over { background: color-mix(in srgb, var(--brand) 16%, transparent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { font-size: 2rem; color: var(--brand); }
.drop-title { font-weight: 700; font-size: 1.1rem; }
.drop-sub, .fine { color: var(--muted); font-size: .88rem; margin: 0; }
.drop img { max-height: 150px; border-radius: 8px; }
.fields { display: grid; gap: .8rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
select, input[type=range] { width: 100%; }
select { font: inherit; padding: .65rem; border-radius: 10px; border: 1px solid var(--line);
         background: var(--bg); color: var(--ink); }
input[type=range] { accent-color: var(--brand); height: 2rem; }
.more summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.more[open] { display: grid; gap: .8rem; grid-template-columns: minmax(0, 1fr); }  /* Inhalt nicht breiter als die Karte */
.center { text-align: center; }

.result .card { max-width: 900px; margin: 0 auto; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 5%; background: linear-gradient(90deg, var(--brand), var(--brand-2));
            transition: width .5s; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 720px) { .result-grid { grid-template-columns: 1fr; } }
#vorschau { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #faf8f4; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.price { font-size: 2rem; font-weight: 800; margin: .3rem 0 .6rem; }
.note { color: var(--warn); font-weight: 600; }
.error { color: var(--err); font-weight: 700; }

.ba { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.ba figure, .gallery figure { margin: 0; text-align: center; }
.ba img, .gallery img { width: min(320px, 80vw); aspect-ratio: 1; object-fit: contain; border-radius: 14px; border: 1px solid var(--line); background: #fff; }
.arrow { font-size: 2.2rem; color: var(--brand); }
figcaption { color: var(--muted); font-weight: 600; margin-top: .4rem; }
.gallery { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; margin-top: 2rem; }

.steps { list-style: none; counter-reset: s; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }
.steps li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
            padding: 1.2rem; display: grid; gap: .3rem; }
.steps li::before { content: counter(s); width: 2rem; height: 2rem; border-radius: 50%; background: var(--brand); color: #fff;
                    display: grid; place-items: center; font-weight: 800; }
.steps span { color: var(--muted); }

.price-group { margin: 1.6rem 0 .7rem; font-size: 1.15rem; }
.prices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (max-width: 480px) { .prices { grid-template-columns: 1fr; } }
.prices article { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.prices article.top-pick { border: 2px solid var(--brand); }
.prices h4 { margin: 0 0 .3rem; font-size: 1.05rem; }
.prices .amount { font-size: 1.8rem; font-weight: 800; }
.prices p { color: var(--muted); margin: .3rem 0 0; font-size: .92rem; }
.prices .deal { margin-top: .2rem; font-size: .95rem; }
.prices .deal strong { color: var(--brand); }
.price-note { color: var(--muted); margin: .5rem 0 0; font-size: .85rem; }

#faq details { max-width: 800px; margin: 0 auto .6rem; background: var(--card); border: 1px solid var(--line);
               border-radius: 12px; padding: .9rem 1.1rem; }
#faq summary { font-weight: 700; cursor: pointer; }
#faq p { color: var(--muted); margin: .6rem 0 0; }

footer { text-align: center; color: var(--muted); padding: 2rem 16px 3rem; border-top: 1px solid var(--line); }
.legal { max-width: 800px; }

/* Größe: Breite oder Höhe festlegen */
fieldset.groesse { border: 0; margin: 0; padding: 0; display: grid; gap: .4rem; min-width: 0; grid-template-columns: minmax(0, 1fr); }
fieldset.groesse legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: .3rem; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line, #ddd); border-radius: 999px; overflow: hidden;
       width: max-content; max-width: 100%; }
@media (max-width: 420px) { .seg { border-radius: 12px; } }  /* umbrechende Wahl („Motiv freistellen | Mit Hintergrund“) */
.seg label { display: flex; align-items: center; gap: .35rem; padding: .35rem .9rem; font-weight: 500; cursor: pointer; }
.seg label:has(input:checked) { background: var(--brand); color: #fff; }
.seg input { accent-color: var(--brand); margin: 0; }
.seg input:checked { accent-color: #fff; }
#mass-andere { font-weight: 400; color: var(--muted, #666); margin-left: .4rem; }

/* Ergebnis: Garnliste, Nachbearbeiten, Stickablauf */
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.actions .btn { padding: .6rem 1.1rem; }
.result h3 { margin: 0 0 .6rem; font-size: 1.15rem; }
.garne-box, .nb, .sim { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.garne { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .5rem; }
.garne li { display: grid; gap: .15rem; }
.garn-kopf { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .6rem; }
.garn-stiche { color: var(--muted); font-size: .92rem; }
.garn-codes { margin: 0 0 0 2.1rem; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.swatch { display: inline-block; width: 1.5rem; height: 1.5rem; border-radius: 6px; flex: none;
          border: 1px solid rgba(0, 0, 0, .25); vertical-align: middle; }
.nb { display: grid; gap: .9rem; }
.nb fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: .6rem; min-width: 0; }
.nb legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: .3rem; }
.nb small { font-weight: 400; color: var(--muted); }
.nb-liste { display: grid; gap: .5rem; }
.nb-zeile { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .6rem; }
.nb-zeile select { flex: 1 1 12rem; width: auto; min-width: 0; }
.nb-hex { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.nb-pfeil { color: var(--muted); }
.nb-zeile input[type=color] { width: 3rem; height: 2.4rem; padding: 0; border: 1px solid var(--line); border-radius: 8px;
                              background: var(--bg); cursor: pointer; }
.nb-zeile :disabled { opacity: .45; cursor: not-allowed; }
.sim canvas { display: block; width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #f6f2ea; }
.sim-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem 1rem; margin-top: .7rem; }
.sim-speed { display: flex; align-items: center; gap: .5rem; flex: 1 1 12rem; }
.sim-pos { margin-top: .3rem; }
.sim-info { display: flex; align-items: center; gap: .5rem; margin: .2rem 0 0; color: var(--muted); font-size: .92rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.version { font-size: .85rem; margin: .4rem 0 0; }
#ergebnis, .nb, .sim { scroll-margin-top: 4.5rem; }  /* nicht unter der festen Kopfzeile */
[hidden] { display: none !important; }  /* sonst überschreiben display-Regeln (label, img, .nb) das hidden-Attribut */

/* Patch-Auswahl */
fieldset.patch-opt { border: 1px solid var(--line); border-radius: 12px; margin: 0; padding: .6rem .9rem .9rem; display: grid; gap: .6rem; min-width: 0; grid-template-columns: minmax(0, 1fr); }
fieldset.patch-opt legend { font-weight: 600; font-size: .95rem; padding: 0 .3rem; }
.randfarbe { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
label.check input { accent-color: var(--brand); width: 1.1rem; height: 1.1rem; margin: 0; }
.randfarbe input[type=color] { width: 3rem; height: 2.4rem; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; }
.randfarbe input[type=color]:disabled { opacity: .45; cursor: not-allowed; }
.garn-schritt { font-size: .8rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .03em; }

#aufzeichnung-hinweis { position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 20; max-width: 34rem; margin-inline: auto;
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: 1rem 1.1rem; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
#aufzeichnung-hinweis p { flex-basis: 100%; margin: 0; font-size: .95rem; }

/* Hilfe-Chat: unter dem Aufzeichnungs-Hinweis (z-index 20), über der Kopfzeile */
#support-knopf { position: fixed; right: 16px; bottom: 16px; z-index: 15; border: 0; border-radius: 999px; padding: .55rem 1rem;
  background: var(--brand); color: #fff; font: inherit; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
#support-knopf:hover { background: var(--brand-2); }
@media (max-width: 900px) { body:has(#aufzeichnung-hinweis) #support-knopf { display: none; } }
#support { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 15; max-width: 24rem; margin-left: auto;
  height: min(36rem, calc(100vh - 32px)); height: min(36rem, calc(100dvh - 32px)); display: flex; flex-direction: column;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.support-kopf { display: flex; align-items: flex-start; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.support-kopf div { flex: 1; min-width: 0; }
.support-kopf strong { display: block; }
.support-kopf small { color: var(--muted); }
.support-zu { border: 0; background: none; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: .1rem .3rem; }
.support-hinweis { margin: 0; padding: .6rem .9rem; color: var(--muted); font-size: .86rem; border-bottom: 1px solid var(--line); }
.support-log { flex: 1; min-height: 0; overflow-y: auto; padding: .7rem .9rem; display: flex; flex-direction: column; gap: .5rem; }
.support-nachricht { max-width: 88%; padding: .45rem .7rem; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem;
  align-self: flex-start; background: color-mix(in srgb, var(--brand) 9%, transparent); }
.support-nachricht.ich { align-self: flex-end; background: var(--brand); color: #fff; }
.support-nachricht small { display: block; margin-top: .2rem; color: var(--muted); font-size: .76rem; }
.support-eingabe { display: grid; gap: .4rem; padding: .6rem .9rem .7rem; border-top: 1px solid var(--line); }
.support-zeile { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; }
.support-zeile .btn { margin-left: auto; }
.support-link { border: 0; background: none; color: var(--brand); font: inherit; font-size: .88rem; cursor: pointer; padding: .2rem 0; text-decoration: underline; }
#support textarea, #support input { width: 100%; font: inherit; font-size: 16px; padding: .5rem .6rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); resize: none; }
.support-form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.support-felder { flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: .6rem; align-content: start; padding: .7rem .9rem; }
.support-form > .support-zeile .error { flex-basis: 100%; margin: 0; }
.support-form > .support-zeile { padding: .5rem .9rem .7rem; border-top: 1px solid var(--line); }
