/* Sport39 3D-Konfigurator -- Gestaltung uebernommen aus dem Textil-Designer
   (poc-designer/index.html), damit beide Werkzeuge wie ein Haus wirken. */
:root {
  --rot: #e30613;          /* Sport39-Rot, im Textildesigner als --blue gefuehrt */
  --rot-d: #b5000f;
  --gruen: #2db92d;
  --ok: #1a8a3a; --warn: #b8860b; --block: #c12032;
  --bg: #f4f6f9; --panel: #ffffff; --line: #d9e0e8;
  --text: #1f2a37; --muted: #6b7785;
  --schatten: 0 1px 2px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; color: var(--text); background: var(--bg); }
input[type=checkbox], input[type=range] { accent-color: var(--gruen); }

/* ---------------- Kopf ---------------- */
header.kopf {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--line);
}
.kopf .logo { height: 30px; }
.kopf h1 { font-size: 17px; margin: 0; color: var(--rot-d); }
.kopf .sub { font-size: 12px; color: var(--muted); }
.kopf .rechts { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------------- Grundraster ---------------- */
.app { display: grid; grid-template-columns: 1fr 440px; gap: 16px; padding: 16px; align-items: start; }
@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  /* Einspaltig wuerde die klebende Buehne den ganzen Schirm belegen. */
  .buehne { position: static; }
}

.buehne {
  /* Klebt beim Scrollen oben fest: das Modell bleibt sichtbar, waehrend rechts
     durch den Musterkatalog und die Regler gescrollt wird. */
  position: sticky; top: 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--schatten); overflow: hidden;
}
#drei { position: relative; width: 100%; height: min(72vh, 760px); background:
  radial-gradient(circle at 50% 32%, #ffffff 0%, #eef1f5 60%, #e3e8ee 100%); }
#drei canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.buehne-leiste {
  position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px;
  background: rgba(255,255,255,.92); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px; backdrop-filter: blur(4px);
}
.buehne-leiste button {
  border: 0; background: transparent; color: var(--text); font-size: 12px;
  padding: 6px 11px; border-radius: 6px; cursor: pointer; font-weight: bold;
}
.buehne-leiste button:hover { background: #eef1f5; }
.buehne-leiste button.aktiv { background: var(--rot); color: #fff; }
.buehne-info {
  position: absolute; right: 12px; top: 12px; font-size: 11px; color: var(--muted);
  background: rgba(255,255,255,.9); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 10px; line-height: 1.5; text-align: right;
}
.zonenhinweis {
  position: absolute; left: 50%; transform: translateX(-50%); top: 12px;
  font-size: 12px; font-weight: bold; color: #fff; background: var(--rot);
  padding: 5px 14px; border-radius: 999px; opacity: 0; transition: opacity .2s;
}
.zonenhinweis.an { opacity: 1; }

/* ---------------- Schrittleiste ---------------- */
.schritte { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.schritte button {
  flex: 1 1 auto; min-width: 62px; padding: 9px 6px; font-size: 11.5px; font-weight: bold;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 7px; cursor: pointer; line-height: 1.25;
}
.schritte button .nr { display: block; font-size: 10px; opacity: .65; }
.schritte button.aktiv { background: var(--rot); border-color: var(--rot); color: #fff; }
.schritte button.aktiv .nr { opacity: .8; }

.tafel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; box-shadow: var(--schatten);
}
.tafel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.seite { display: none; }
.seite.an { display: block; }
label { font-size: 13px; display: block; margin: 12px 0 4px; font-weight: bold; }
label:first-child { margin-top: 0; }
select, input[type=text], input[type=number], input[type=file] {
  width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: #fff; color: var(--text);
}
input[type=range] { width: 100%; margin: 4px 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.45; }
.reihe { display: flex; justify-content: space-between; margin: 4px 0; font-size: 13px; }
.reihe b { font-variant-numeric: tabular-nums; }

/* Segmentschalter wie im Textildesigner */
.seg { display: flex; border: 1px solid var(--rot); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; padding: 8px 4px; border: 0; background: #fff; color: var(--rot); font-size: 12px; font-weight: bold; cursor: pointer; }
.seg button.aktiv { background: var(--rot); color: #fff; }

button.tat {
  padding: 9px 14px; border: 1px solid var(--rot); background: var(--rot); color: #fff;
  border-radius: 6px; font-size: 13px; cursor: pointer; font-weight: bold;
}
button.tat.geist { background: #fff; color: var(--rot); }
button.tat:disabled { opacity: .45; cursor: not-allowed; }
.tatreihe { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Farbwahl */
.farbfeld { display: flex; align-items: center; gap: 8px; }
.farbfeld input[type=color] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.farbfeld .wert { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kacheln { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin-top: 6px; }
.kacheln button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; padding: 0; }
.kacheln button.aktiv { outline: 2px solid var(--rot); outline-offset: 1px; }

/* Zonenliste */
.zonen { display: grid; gap: 6px; }
.zone {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer; background: #fff;
}
.zone.aktiv { border-color: var(--rot); box-shadow: inset 0 0 0 1px var(--rot); }
.zone .punkt { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(0,0,0,.18); flex: none; }
.zone .name { font-size: 13px; font-weight: bold; }
.zone .masz { font-size: 11px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

/* Musterkatalog */
.gruppe { margin-top: 12px; }
.gruppe > h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }
.katalog { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.katalog button { padding: 0; border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; overflow: hidden; }
.katalog button.aktiv { border-color: var(--rot); box-shadow: 0 0 0 1px var(--rot); }
.katalog canvas { display: block; width: 100%; aspect-ratio: 3/4; background: #fff; }
.katalog .bez { display: block; font-size: 9.5px; padding: 3px 2px 4px; color: var(--muted); line-height: 1.15; }

.lagen { display: grid; gap: 6px; margin-top: 8px; }
.lage { border: 1px solid var(--line); border-radius: 7px; padding: 8px 9px; background: #fff; }
.lage.aktiv { border-color: var(--rot); }
.lage .kopfzeile { display: flex; align-items: center; gap: 8px; }
.lage .kopfzeile b { font-size: 12.5px; flex: 1; cursor: pointer; }
.lage .weg { border: 0; background: none; color: var(--block); font-size: 15px; cursor: pointer; line-height: 1; padding: 0 3px; }
.lage .stell { border: 0; background: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 0 3px; }
.regler { margin-top: 6px; }
.regler .zeile { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 7px; }
.regler .zeile + .zeile { margin-top: 5px; }
.regler input[type=range] + .zeile { margin-top: 9px; }
.regler .zeile b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Tabelle Mannschaft */
/* Ablagefeld fuer die Mannschaftsliste */
.ablage {
  margin-top: 10px; padding: 14px; text-align: center; font-size: 12px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 9px; background: #fbfcfd; line-height: 1.5;
}
.ablage span { font-size: 11px; }
.ablage.bereit { border-color: var(--gruen); background: #f2fbf2; color: var(--text); }

table.kader { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
table.kader th { background: #eef1f5; text-align: left; padding: 5px 6px; font-size: 11px; color: var(--muted); }
table.kader td { border-bottom: 1px solid var(--line); padding: 3px 4px; }
table.kader input, table.kader select { padding: 4px 5px; font-size: 12px; }
table.kader td.weg { width: 24px; text-align: center; }
table.kader td.weg button { border: 0; background: none; color: var(--block); cursor: pointer; font-size: 14px; }

/* Meldungen */
.meldung { border-radius: 7px; padding: 8px 10px; font-size: 12px; margin-top: 8px; line-height: 1.45; }
.meldung.ok { background: #eaf7ee; color: var(--ok); border: 1px solid #bfe3c8; }
.meldung.warn { background: #fdf6e3; color: #7a5b00; border: 1px solid #ecd9a0; }
.meldung.block { background: #fdecee; color: var(--block); border: 1px solid #f2c2c8; }
.abzeichen { display: inline-block; padding: 2px 9px; border-radius: 999px; color: #fff; font-weight: bold; font-size: 11px; }
.a-ok { background: var(--ok); } .a-warn { background: var(--warn); } .a-block { background: var(--block); }

#ausgabe-liste { display: grid; gap: 6px; margin-top: 10px; }
#ausgabe-liste a {
  display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--rot); font-size: 12.5px; font-weight: bold; text-decoration: none;
}
#ausgabe-liste a:hover { background: #fff5f6; }
.lade { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(244,246,249,.9); font-size: 13px; color: var(--muted); z-index: 5; }

/* ---------------- Startbildschirme: Sportart und Textil ---------------- */
.start {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto;
  background: linear-gradient(160deg, #ffffff 0%, #eef1f5 55%, #e4e9ef 100%);
}
.start.weg { display: none; }
.start-innen { max-width: 1080px; margin: 0 auto; padding: 40px 24px 60px; text-align: center; }
.start-logo { height: 42px; margin-bottom: 26px; }
.start-schritt { display: none; }
.start-schritt.an { display: block; animation: einblenden .22s ease-out; }
@keyframes einblenden { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.start h2 { font-size: 24px; color: var(--rot-d); margin: 0 0 6px; }
.start-sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; }

.wahlgitter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.wahlgitter.breit { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 780px) { .wahlgitter, .wahlgitter.breit { grid-template-columns: repeat(2, 1fr); } }

.wahlkachel {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 14px; cursor: pointer; text-align: center;
  box-shadow: var(--schatten); transition: border-color .12s, transform .12s, box-shadow .12s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.wahlkachel:hover { border-color: var(--rot); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(227,6,19,.12); }
/* Sinnbild der Sportart: gezeichnetes, einfarbiges SVG statt Emoji. Die Farbe
   kommt ueber currentColor aus der Kachel -- so folgt das Zeichen dem Zustand. */
.wahlkachel .sinnbild { display: block; line-height: 0; color: var(--muted); transition: color .12s; }
.wahlkachel .sinnbild svg { display: block; }
.wahlkachel:hover .sinnbild { color: var(--rot); }
.wahlkachel.leer .sinnbild { color: var(--line); }
.wahlkachel img { width: 100%; max-width: 150px; aspect-ratio: 4/5; object-fit: contain; background: #f7f9fb; border-radius: 8px; }
.wahlkachel .titel { font-size: 15px; font-weight: bold; color: var(--text); }
.wahlkachel .neben { font-size: 12px; color: var(--muted); }
.wahlkachel.leer { opacity: .4; cursor: not-allowed; }
.wahlkachel.leer:hover { border-color: var(--line); transform: none; box-shadow: var(--schatten); }

.brotkrume {
  margin-left: 18px; font-size: 13px; color: var(--muted);
  display: flex; align-items: center; gap: 7px;
}
.brotkrume b { color: var(--rot-d); }
.brotkrume .trenn { opacity: .45; }

kbd {
  background: #eef1f5; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; font-family: inherit; font-size: 11px;
}
#el-stellwerk { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.buehne.zieht { cursor: grabbing; }

/* ---------------- Beschriftung: Schalter und Vierfach-Segment ---------------- */
.seg.vier button { font-size: 11px; padding: 8px 2px; }
.schalterreihe { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.schalter {
  font-weight: normal; font-size: 13px; margin: 0;
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}
.schalter input { margin: 0; }
#sportregel { margin-top: 8px; }
.groessenband {
  position: absolute; right: 12px; bottom: 12px;
  background: rgba(255,255,255,.92); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; color: var(--muted);
  backdrop-filter: blur(4px);
}
.groessenband b { color: var(--text); }

/* ---------------- Beschriftung: Kopfzeile mit Textil und Größe ---------------- */
.doppelwahl { display: grid; grid-template-columns: 1fr 118px; gap: 10px; align-items: end; margin-bottom: 4px; }
.doppelwahl label { margin-top: 0; }
.seg button:disabled {
  color: var(--block); background: #fdecee; cursor: not-allowed; opacity: 1;
  text-decoration: line-through;
}
.seg button:disabled.aktiv { background: var(--block); color: #fff; }

/* Von der Sportart ausgeblendete Beschriftung */
.lage.aus { opacity: .55; border-style: dashed; }
.ausmarke { color: var(--block); font-weight: bold; }
#sportnachzug { margin-top: 8px; }

/* ---------------- Anfasserrahmen auf dem Modell ----------------
   Liegt als SVG ueber der Leinwand. Die Flaeche laesst Zeiger durch
   (sonst liesse sich das Modell nicht mehr drehen); nur die Griffe fangen sie ab. */
svg.anfasser {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: visible;
}
.af-linie { fill: none; stroke: var(--rot); stroke-width: 1.6; stroke-dasharray: 6 4; }
.af-griff { fill: #fff; stroke: var(--rot); stroke-width: 2; pointer-events: auto; }
.af-ecke { cursor: nwse-resize; }
.af-dreh { cursor: grab; }
.af-dreh:active { cursor: grabbing; }
.af-marke {
  fill: var(--rot); font: bold 12px system-ui, sans-serif; text-anchor: middle;
  paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round;
}

/* ---------------- Zahlenfeld neben einer Skala ---------------- */
.zahlfeld { display: flex; align-items: center; gap: 3px; }
.zahlfeld input[type=number] {
  width: 66px; padding: 3px 5px; font-size: 12px; text-align: right;
  border: 1px solid var(--line); border-radius: 5px; background: #fff;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.zahlfeld input[type=number]:focus { outline: 2px solid var(--rot); outline-offset: -1px; }
.zahlfeld i { font-style: normal; font-size: 11px; color: var(--muted); min-width: 14px; }

/* Links und rechts sind Traegerseiten -- der Hinweis steht in jedem Schritt,
   in dem ein Schnittteil gewaehlt wird, und soll dort nicht schreien. */
.hint.traegerseite {
  margin-top: 8px; padding: 7px 9px; border-radius: 7px;
  background: #f6f8fa; border: 1px solid var(--line); font-size: 11.5px;
}

/* Ansicht zuruecksetzen -- steht neben den Seitenknoepfen, faerbt sich aber nie
   "aktiv" ein: es ist ein Befehl, keine Seite. */
.buehne-leiste button.nurzeichen {
  font-size: 15px; line-height: 1; padding: 5px 9px; color: var(--muted);
  border-left: 1px solid var(--line); border-radius: 0 6px 6px 0; margin-left: 2px;
}
.buehne-leiste button.nurzeichen:hover { color: var(--rot); background: #eef1f5; }

.zeile .klein { font-size: 10.5px; opacity: .8; }
/* Bogengriff: unter dem Rahmen, mit gefuelltem Kern von den anderen zu unterscheiden. */
.af-biege { fill: var(--rot); stroke: #fff; stroke-width: 2.5; cursor: ns-resize; }

/* Fehlt das Vorschaubild eines Textils, steht dort dasselbe gezeichnete Zeichen --
   im selben Kasten, damit die Kacheln in einer Reihe gleich hoch bleiben. */
.wahlkachel .ersatzbild {
  width: 100%; max-width: 150px; aspect-ratio: 4/5; background: #f7f9fb;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.wahlkachel .ersatzbild svg { width: 52px; height: 52px; }
.wahlkachel:hover .ersatzbild { color: var(--rot); }
