/*
 * FairCAD Prototyp — Oberfläche.
 * Farben und Schriften aus der bokono-Familie. Schriften liegen lokal
 * (keine Anfrage an Google, siehe bokono: LG München I, Az. 3 O 17493/20).
 * Bewusst ohne CSS-Verschachtelung: Zielmarke ist Safari 16.4 (2023).
 */
@font-face { font-family: 'Rubik'; font-weight: 400 600; font-display: swap; src: url(fonts/rubik-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Rubik'; font-weight: 400 600; font-display: swap; src: url(fonts/rubik-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Sanchez'; font-weight: 400; font-display: swap; src: url(fonts/sanchez-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD; }

:root {
  --papier: #F5F5EB;
  --papier-tief: #EDEDE1;
  --weiss: #FFFFFF;
  --akzent: #FA9164;
  --akzent-dunkel: #E07845;
  --akzent-hell: #FDE3D6;
  --text: #1F2124;
  --text-leise: #6B6F76;
  --linie: #DDDDD4;
  --linie-fein: #EAEAE2;
  --blau: #5B7290;
  --gruen: #4F7A5B;
  --schrift: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --schrift-titel: 'Sanchez', Georgia, serif;
  --kopf: 52px;
  --palette: 76px;
  --info: 288px;
  --unten: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--papier); color: var(--text); font-family: var(--schrift); font-size: 14px; -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 1px; }
sup { font-size: 0.62em; line-height: 0; vertical-align: 0.6em; }

.app { position: fixed; inset: 0; display: grid; grid-template-rows: var(--kopf) 1fr; }

/* ---------- Kopfzeile ---------- */
.kopf { display: flex; align-items: center; gap: 18px; padding: 0 14px 0 16px; background: var(--weiss); border-bottom: 1px solid var(--linie); min-width: 0; }
.marke { display: flex; align-items: stretch; gap: 9px; flex: 0 0 auto; }
.marke-zeichen { width: 30px; height: 22px; align-self: center; }
.marke-text { display: flex; flex-direction: column; gap: 2px; }
.marke-wort { font-family: var(--schrift-titel); font-size: 20px; line-height: 1.05; letter-spacing: -0.01em; color: #282828; }
.marke-unter { display: flex; justify-content: space-between; font-size: 7.5px; line-height: 1; color: var(--text-leise); }
.datei { display: flex; flex-direction: column; min-width: 0; padding-left: 16px; border-left: 1px solid var(--linie); }
.datei-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.datei-stand { font-size: 12px; color: var(--gruen); }
.kopf-mitte { display: flex; gap: 4px; }
.kopf-rechts { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.knopf, .knopf-icon, .schalter { height: 32px; padding: 0 12px; border: 1px solid var(--linie); border-radius: 7px; background: var(--weiss); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.knopf:hover, .knopf-icon:hover, .schalter:hover { border-color: #C7C7BA; background: #FBFBF7; }
.knopf-icon { width: 34px; padding: 0; justify-content: center; }
.knopf-icon svg, .knopf svg { width: 18px; height: 18px; }
.knopf-icon:disabled { opacity: 0.35; cursor: default; }
.knopf-haupt { background: var(--akzent); border-color: var(--akzent); font-weight: 500; }
.knopf-haupt:hover { background: var(--akzent-dunkel); border-color: var(--akzent-dunkel); }
.schalter[aria-pressed="true"] { background: var(--akzent-hell); border-color: var(--akzent); }
.feld-klein { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-leise); }
select { height: 32px; border: 1px solid var(--linie); border-radius: 7px; background: var(--weiss); padding: 0 8px; }
.nur-telefon { display: none; }

/* ---------- Körper ---------- */
.koerper { display: grid; grid-template-columns: var(--palette) 1fr var(--info); min-height: 0; }
.palette { background: var(--papier); border-right: 1px solid var(--linie); overflow-y: auto; padding: 8px 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.palette-gruppe { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-leise); text-align: center; margin: 10px 0 4px; }
.palette-gruppe:first-child { margin-top: 2px; }
.werkzeug { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; border: 1px solid transparent; border-radius: 9px; background: none; font-size: 10.5px; color: var(--text); }
.werkzeug svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.werkzeug:hover { background: var(--weiss); border-color: var(--linie); }
.werkzeug[aria-pressed="true"] { background: var(--weiss); border-color: var(--akzent); box-shadow: inset 0 0 0 1px var(--akzent); }
.werkzeug kbd { position: absolute; top: 3px; right: 5px; font: 500 8.5px var(--schrift); color: #A3A69C; }

.buehne { display: grid; grid-template-rows: 40px 1fr auto auto; min-width: 0; min-height: 0; }
.optionen { display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--papier); border-bottom: 1px solid var(--linie); overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.optionen::-webkit-scrollbar { display: none; }
.optionen select { height: 28px; font-size: 13px; }
.optionen .hinweis { margin-left: auto; font-size: 12.5px; color: var(--text-leise); padding-left: 12px; }
.optionen .titel { font-weight: 500; }
.segment { display: inline-flex; border: 1px solid var(--linie); border-radius: 7px; overflow: hidden; background: var(--weiss); }
.segment button { height: 28px; padding: 0 10px; border: 0; border-right: 1px solid var(--linie); background: none; font-size: 12.5px; }
.segment button:last-child { border-right: 0; }
.segment button[aria-pressed="true"] { background: var(--akzent-hell); box-shadow: inset 0 -2px 0 var(--akzent); }
.muster { display: inline-block; width: 26px; height: 12px; border: 1px solid var(--text); vertical-align: -2px; margin-right: 4px; }

.zeichenflaeche { position: relative; min-height: 0; overflow: hidden; touch-action: none; background: #FFFFFF; cursor: crosshair; }
.zeichenflaeche.werkzeug-auswahl { cursor: default; }
.zeichenflaeche.werkzeug-hand, .zeichenflaeche.zieht { cursor: grab; }
canvas { display: block; touch-action: none; }

.geschosse { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; align-items: center; }
.geschosse .segment button { height: 30px; padding: 0 14px; font-weight: 500; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; }
.zoom .knopf-icon, .zoom .knopf { background: rgba(255,255,255,0.94); }

/* Maßeingabe am Cursor */
.blase { position: absolute; z-index: 5; display: flex; gap: 4px; padding: 4px; background: rgba(31,33,36,0.92); border-radius: 9px; color: #FFFFFF; font-size: 13px; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
.blase .feld { display: flex; align-items: baseline; gap: 6px; padding: 4px 8px; border-radius: 6px; border: 1px solid transparent; }
.blase .feld b { font-weight: 500; min-width: 3ch; }
.blase .feld i { font-style: normal; color: var(--akzent); font-size: 12px; }
.blase .feld .k { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: #A9ADB3; }
.blase .feld.aktiv { border-color: var(--akzent); background: rgba(250,145,100,0.14); }
.blase .feld.leise b { color: #C9CCD0; font-weight: 400; }
.blase .feld.fehler b { color: #FF8A80; }
.blase .schloss { font-size: 10px; color: var(--akzent); }

.meldung { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); padding: 8px 14px; border-radius: 8px; background: rgba(31,33,36,0.92); color: #FFFFFF; font-size: 13px; z-index: 6; }

/* Maßtastatur (Touch) */
.tastatur { background: var(--papier); border-top: 1px solid var(--linie); padding: 8px 10px calc(8px + var(--unten)); display: grid; gap: 6px; }
.tastatur-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tastatur-chips::-webkit-scrollbar { display: none; }
.tastatur-chips button { flex: 0 0 auto; height: 34px; padding: 0 12px; border: 1px solid var(--linie); border-radius: 999px; background: var(--weiss); font-size: 14px; }
.tastatur-feld { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 520px; width: 100%; justify-self: center; }
.tastatur-feld button { height: 46px; border: 1px solid var(--linie); border-radius: 9px; background: var(--weiss); font-size: 19px; }
.tastatur-feld button:active, .tastatur-chips button:active { background: var(--akzent-hell); }
.tastatur-feld .t-ok { background: var(--akzent); border-color: var(--akzent); font-weight: 500; font-size: 16px; }
.tastatur-feld .t-neben { font-size: 14px; color: var(--text-leise); }

/* Statuszeile */
.status { display: flex; align-items: center; gap: 14px; height: 32px; padding: 0 12px; background: var(--papier); border-top: 1px solid var(--linie); font-size: 12.5px; color: var(--text-leise); white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.status::-webkit-scrollbar { display: none; }
.koord { font-variant-numeric: tabular-nums; min-width: 168px; color: var(--text); }
.status .schalter { height: 24px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.status .rechts { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.status select { height: 24px; font-size: 12px; padding: 0 4px; }

/* ---------- Objekt-Info ---------- */
.info { background: var(--weiss); border-left: 1px solid var(--linie); overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.info-griff { display: none; }
.info-teil { padding: 14px 16px 16px; border-bottom: 1px solid var(--linie); }
.info-teil h2 { margin: 0 0 12px; font-family: var(--schrift-titel); font-weight: 400; font-size: 18px; }
.info-teil h3 { margin: 16px 0 8px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-leise); font-weight: 500; }
.zeile { display: grid; grid-template-columns: 1fr 1.25fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.zeile label { font-size: 12.5px; color: var(--text-leise); }
.zeile input, .zeile select { width: 100%; height: 32px; border: 1px solid var(--linie); border-radius: 7px; padding: 0 9px; background: var(--weiss); }
.zeile input:focus, .zeile select:focus { border-color: var(--akzent); outline: none; }
.zeile .wert { font-weight: 500; font-variant-numeric: tabular-nums; }
.zeile .segment { width: 100%; }
.zeile .segment button { flex: 1; }
.leise { color: var(--text-leise); font-size: 12.5px; line-height: 1.5; }
.schichten { margin: 6px 0 0; padding: 0; list-style: none; border: 1px solid var(--linie); border-radius: 7px; overflow: hidden; }
.schichten li { display: flex; justify-content: space-between; align-items: center; padding: 6px 9px; border-bottom: 1px solid var(--linie-fein); font-size: 12.5px; }
.schichten li:last-child { border-bottom: 0; }
.stifte { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.stifte td { padding: 5px 0; border-bottom: 1px solid var(--linie-fein); }
.stifte td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.stifte .strich { display: inline-block; width: 34px; background: var(--text); vertical-align: middle; margin-right: 8px; }
.ebene { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.ebene .name { flex: 1; font-size: 13px; }
.ebene .name.aktiv { font-weight: 500; }
.ebene button { width: 30px; height: 28px; border: 1px solid transparent; border-radius: 6px; background: none; display: inline-flex; align-items: center; justify-content: center; color: var(--text-leise); }
.ebene button:hover { border-color: var(--linie); }
.ebene button[aria-pressed="false"] { opacity: 0.35; }
.ebene svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.ebene .punkt { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--text-leise); margin: 0 4px; cursor: pointer; flex: 0 0 auto; }
.ebene .punkt.aktiv { background: var(--akzent); border-color: var(--akzent); }
.loeschen { margin-top: 12px; width: 100%; justify-content: center; color: #B3402F; }
.hilfe { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12.5px; line-height: 1.5; }
.hilfe li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--linie-fein); }
.hilfe code { font-family: var(--schrift); font-weight: 500; background: var(--papier-tief); padding: 0 5px; border-radius: 4px; }

/* ---------- Tablet ---------- */
@media (max-width: 1180px) {
  :root { --info: 0px; }
  .info { position: absolute; top: var(--kopf); right: 0; bottom: 0; width: 300px; z-index: 8; box-shadow: -8px 0 24px rgba(0,0,0,0.08); transform: translateX(100%); transition: transform .2s ease; }
  .app.info-offen .info { transform: none; }
  .optionen .hinweis { display: none; }
}
@media (max-width: 900px) {
  :root { --palette: 62px; }
  .werkzeug span { display: none; }
  .werkzeug { padding: 9px 2px; }
  .werkzeug kbd { display: none; }
  .datei-stand { display: none; }
  .feld-klein span { display: none; }
}

/* ---------- Telefon (auch iPhone Duo zugeklappt) ---------- */
@media (max-width: 640px) {
  :root { --kopf: 48px; }
  .kopf { gap: 10px; padding: 0 10px; }
  .marke-text, .kopf-rechts .nur-gross { display: none; }
  .datei { padding-left: 10px; }
  .nur-telefon { display: inline-flex; }
  .koerper { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .palette { grid-row: 2; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-top: 1px solid var(--linie); padding: 6px 8px calc(6px + var(--unten)); gap: 4px; scrollbar-width: none; }
  .palette::-webkit-scrollbar { display: none; }
  .palette-gruppe { display: none; }
  .werkzeug { flex: 0 0 58px; }
  .werkzeug span { display: block; font-size: 10px; }
  .buehne { grid-row: 1; grid-template-rows: auto 1fr auto auto; }
  .optionen { height: 40px; }
  .status { display: none; }
  .geschosse { left: 8px; top: 8px; }
  .info { top: auto; left: 0; right: 0; width: auto; max-height: 62%; border-left: 0; border-top: 1px solid var(--linie); border-radius: 14px 14px 0 0; transform: translateY(105%); box-shadow: 0 -8px 24px rgba(0,0,0,0.1); }
  .app.info-offen .info { transform: none; }
  .info-griff { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--linie); margin: 8px auto 0; }
}

@media (min-width: 1181px) { #btnInfo { display: none; } }
.zeile.breit { grid-template-columns: 1fr; gap: 4px; }

/* Maßtastatur auf Tablet und Mac schwebend unten links:
   die linke Hand tippt, die rechte zeichnet mit dem Stift. */
.buehne { position: relative; }
@media (min-width: 641px) {
  .tastatur { position: absolute; left: 12px; bottom: 44px; z-index: 7; width: 300px; padding: 10px; border: 1px solid var(--linie); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); }
  .tastatur-feld button { height: 44px; font-size: 18px; }
  .tastatur-feld .t-neben { font-size: 12.5px; }
  .tastatur-chips { flex-wrap: wrap; }
  .tastatur-chips button { height: 30px; padding: 0 10px; font-size: 13px; }
}

/* ---------- Datei ---------- */
button.datei { border: 0; border-left: 1px solid var(--linie); background: none; text-align: left; cursor: pointer; padding-top: 4px; padding-bottom: 4px; border-radius: 0; }
button.datei:hover .datei-name { color: var(--akzent-dunkel); }
.datei-name { display: flex; align-items: center; gap: 4px; }
.datei-name #dateiName { overflow: hidden; text-overflow: ellipsis; }
.datei .pfeil { width: 12px; height: 12px; flex: 0 0 auto; color: var(--text-leise); }
.datei-stand.warnung { color: var(--akzent-dunkel); }
.datei-menue { position: absolute; z-index: 20; top: calc(var(--kopf) - 4px); left: 140px; width: 320px; background: var(--weiss); border: 1px solid var(--linie); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,0.14); padding: 6px; }
.menue-teil { display: flex; flex-direction: column; padding: 4px 0; border-bottom: 1px solid var(--linie-fein); }
.menue-teil button { display: flex; justify-content: space-between; align-items: center; height: 36px; padding: 0 10px; border: 0; border-radius: 7px; background: none; text-align: left; font-size: 14px; }
.menue-teil button:hover { background: var(--papier); }
.menue-teil kbd { font: 12px var(--schrift); color: var(--text-leise); }
.menue-info { display: grid; grid-template-columns: 70px 1fr; gap: 6px 10px; margin: 10px 10px 6px; font-size: 12.5px; line-height: 1.45; color: var(--text-leise); }
.menue-info dt { color: var(--text); font-weight: 500; }
.menue-info dd { margin: 0; }
.gut { color: var(--gruen); font-weight: 500; }
.knopf.klein { height: 26px; padding: 0 10px; font-size: 12.5px; }
.zeichenflaeche.ablage { box-shadow: inset 0 0 0 3px var(--akzent); }
@media (max-width: 640px) { .datei-menue { left: 8px; right: 8px; width: auto; } }
