/*
 * Mathematik-Werkzeuge: Formulare, Vorschau, Kacheln der Startseite. Farben, Schrift, der rote
 * Rahmen, Pfadleiste und Filter kommen aus dem gemeinsamen design.css der Schul-Startseite
 * (/Schule/startseite/design.css, eingebunden über design.php); die Namen hier verweisen darauf.
 */
:root {
  --bg: var(--grund, #f9f8f8);
  --panel: var(--flaeche, #fff);
  --ink: var(--text, #000);
  --muted: var(--grau, #5c5c5c);
  --line: #d4d4d4;
  --accent: var(--rot, #980000);
  --accent-soft: var(--rot-hell, #f6e7e7);
  --good: #1f7a4d;
  --warn: #9a6400;
  --warn-soft: #fdf3e0;
  --bad: #a32b2b;
  --bad-soft: #fbeaea;
}
code { background: #eef0f2; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
[hidden] { display: none !important; }
.werkzeug h2 { font-size: 15px; margin: 0 0 10px; padding: 0; border: 0; }
.werkzeug { margin-top: 18px; }
/* Eingabefelder schmaler als die Seitenschrift (Verdana), damit Platzhalter wie „z. B. 4,5 cm“ passen */
main .werkzeug input:not(.url input):not(.zeile.funktion input), main .werkzeug select, main .werkzeug button, main .werkzeug .btn {
  font-family: Arial, "Liberation Sans", Helvetica, sans-serif;
}

/* Einstiegsseite */
.tools { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.tool > .kachel {
  display: flex; gap: 14px; align-items: flex-start; height: 100%;
  background: var(--karte, #f9f8f8); border: 1px solid var(--rahmen, silver); border-radius: var(--radius, 10px);
  box-shadow: var(--schatten, 4px 4px 4px silver);
  padding: 14px 16px; text-decoration: none; color: inherit;
}
/* Ganze Kachel anklickbar: der Titel-Link deckt sie unsichtbar ab (.ganz) */
.tool > .kachel { position: relative; }
.tool-link { color: inherit !important; }
.tool.ganz .tool-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.tool.ganz .tool-link:focus-visible { outline: none; }
.tool.ganz .tool-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }
.tool.ganz > .kachel:hover { border-color: var(--accent); }
.tool.ganz > .kachel:hover .tool-link { text-decoration: underline; }
/* Mehrere gleichberechtigte Links in einer Kachel (z. B. PDF ohne/mit Schnittmarken) */
.tool-links { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.tool-links a::before { content: "⤓ "; }
.tool.soon > .kachel { opacity: .55; }
.tool-icon {
  font-size: 20px; line-height: 1; width: 40px; height: 40px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); border-radius: 8px;
}
.tool-icon.mit-bild { background: none; }

/* Sammlungen mit 'display' => 'big' | 'huge': große Vorschaubilder (z. B. Poster im Hochformat) */
.tools.anzeige-big .tool-icon { width: 96px; height: 134px; font-size: 40px; }
.tools.anzeige-big .tool-icon img { width: 96px; height: 134px; border-radius: 4px; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.tools.anzeige-huge { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tools.anzeige-huge .tool > .kachel { flex-direction: column; align-items: stretch; }
.tools.anzeige-huge .tool-icon { width: 100%; height: 300px; font-size: 72px; }
.tools.anzeige-huge .tool-icon img { width: 100%; height: 300px; border-radius: 4px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .18)); }
.tool-icon img { display: block; width: 40px; height: 40px; object-fit: contain; border-radius: 8px; }
.tool-body { display: flex; flex-direction: column; gap: 5px; }
.tool-body strong { font-size: 14px; color: var(--accent); }
.tool-ort { font-size: 12px; color: var(--accent); }
.tool-desc { color: var(--muted); font-size: 13px; }

.tool-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 3px; }

/* Filter: siehe design.css */
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #eef1f5; color: var(--muted); }

/* Formularelemente */
button, select, input[type=text], input[type=number], .btn {
  font: inherit; border: 1px solid var(--line); background: var(--panel);
  border-radius: 6px; padding: 6px 10px; color: inherit; min-width: 0;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn, button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { color: var(--muted); }
.btn:hover { border-color: var(--accent); }

.panel { background: var(--panel); border: 1px solid var(--rahmen, silver); border-radius: var(--radius, 10px); padding: 14px 16px; }

/* Dreieck */
.werkzeug { display: grid; gap: 20px; grid-template-columns: minmax(0, 470px) minmax(0, 1fr); align-items: start; }
.eingabe { display: flex; flex-direction: column; gap: 12px; }
.vorschau { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }

.segment { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.segment label { flex: 1 1 auto; position: relative; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span { display: block; text-align: center; padding: 6px 10px; font-size: 14px; color: var(--muted); cursor: pointer; }
.segment label + label span { border-left: 1px solid var(--line); }
.segment input:checked + span { background: var(--accent); color: #fff; font-weight: 600; }
.segment input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }

.kopf, .zeile {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: 116px minmax(0, 1fr) minmax(0, 1fr) 56px;
}
.kopf.vier, .zeile.vier { grid-template-columns: 116px repeat(3, minmax(0, 1fr)); }
.kopf.drei, .zeile.drei { grid-template-columns: 116px repeat(2, minmax(0, 1fr)); }
.zeile.funktion { grid-template-columns: 116px minmax(0, 1fr) 56px; }
.kopf.fuenf, .zeile.fuenf { grid-template-columns: 104px minmax(0, 1fr) minmax(0, 1fr) 40px 56px; }
.kopf.fuenf span:nth-child(4) { font-size: 11px; line-height: 1.1; text-align: center; }
.zeile.fuenf > input[type=checkbox] { justify-self: center; }
.zeile.funktion input[type=text] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.kopf { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.zeile + .zeile, .kopf + .zeile { margin-top: 6px; }
.zeile .titel { font-size: 14px; }
.zeile input[type=text] { width: 100%; }
.zeile .btn { justify-self: start; }

.farbe { display: inline-flex; align-items: center; gap: 4px; }
.farbe input[type=color] { width: 30px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; cursor: pointer; }
.farbe input[type=checkbox]:not(:checked) + input[type=color] { opacity: .3; }

textarea { font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; width: 100%; border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; color: inherit; background: var(--panel); resize: vertical; margin-bottom: 8px; }
.schalterzeile { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; }
.schalterzeile .schalter { margin-bottom: 0; }
.einheit input[type=text], .zeile .einheit input[type=number] { width: 100%; min-width: 0; }
.zeile .einheit { display: flex; align-items: center; gap: 6px; }
input:disabled, .zeile input:disabled { opacity: .45; }
.schalter { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; cursor: pointer; }
.zeile input:disabled { opacity: .45; }
.schalter-klein { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.hilfe { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
details.hilfe summary { cursor: pointer; }
details.hilfe ul { padding-left: 18px; margin: 6px 0 0; }
details.hilfe li + li { margin-top: 4px; }

.optionen { display: grid; gap: 10px 16px; grid-template-columns: 1fr 1fr; }
.optionen > label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.optionen .drehung, .optionen .einheit { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.optionen input[type=range] { flex: 1; min-width: 0; }
.optionen input[type=number] { width: 100px; }
.optionen output { width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

.bild { display: flex; justify-content: center; align-items: center; min-height: 320px;
  background-color: #fff;
  background-image: linear-gradient(45deg, #f0f2f5 25%, transparent 25%, transparent 75%, #f0f2f5 75%),
    linear-gradient(45deg, #f0f2f5 25%, transparent 25%, transparent 75%, #f0f2f5 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.bild img { max-width: 100%; max-height: 62vh; height: auto; display: block; }

.meldungen:empty { display: none; }
.meldung { margin: 0; padding: 8px 12px; border: 0; border-radius: 6px; font-size: 14px; }
main > .meldung { margin-top: 16px; }
.meldung + .meldung { margin-top: 6px; }
.meldung.warn { background: var(--warn-soft); color: var(--warn); }
.meldung.bad { background: var(--bad-soft); color: var(--bad); }

.knoepfe { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.knoepfe .ghost { margin-left: auto; }
.mehrfach { border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 10px; }
.mehrfach-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; font-size: 14px; }
.mehrfach-kopf label { display: inline-flex; align-items: center; gap: 6px; }
.mehrfach-kopf input[type=number] { width: 70px; }
.mehrfach textarea { white-space: pre; overflow-x: auto; font-size: 12px; }
.url { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.url span { display: flex; gap: 6px; }
.url input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink); }

@media (max-width: 900px) {
  .werkzeug { grid-template-columns: minmax(0, 1fr); }
  .vorschau { position: static; order: -1; }
  .bild { min-height: 200px; }
}
@media (max-width: 480px) {
  .kopf, .zeile { grid-template-columns: 84px minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 6px; }
  .kopf.vier, .zeile.vier { grid-template-columns: 70px repeat(3, minmax(0, 1fr)); }
  .kopf.drei, .zeile.drei { grid-template-columns: 84px repeat(2, minmax(0, 1fr)); }
  .zeile.funktion { grid-template-columns: 70px minmax(0, 1fr) 40px; }
  .kopf.fuenf, .zeile.fuenf { grid-template-columns: 70px minmax(0, 1fr) minmax(0, 1fr) 30px 40px; }
  .optionen { grid-template-columns: 1fr; }
}
