/* =============================================
   Dateien — Gleisbau OS (core/dateien.js, Regeln: DESIGN.md)
   Im Programmrahmen (bauteile.css): in der Spalte Neu, Hochladen, Programme und die Orte, unten Ansicht und „⋯“;
   innen oben Zurück/Vor, Pfad und Suche, darunter der Inhalt als Symbole oder Liste, unten Anzahl und was gewählt
   ist. Richtet sich nach der Breite des Inhalts (@container dtflaeche), nicht des Bildschirms.
   ============================================= */

.dateien.view.active { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--flaeche); color: var(--text); }

/* ---------- Spalte: Neu, Hochladen, Programme ---------- */
.dt-tun { display: flex; flex-direction: column; gap: var(--a1); padding: 0 var(--a1); }
.dateien .rahmen-abschnitt[data-abschnitt="neu"]:not(:has(.knopf:not([hidden]))) { display: none; }   /* hier lässt sich nichts anlegen */

/* ---------- Innen oben: Zurück/Vor, Pfad, Suche ---------- */
.dt-pfad {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--a1) var(--a2);
  min-height: calc(var(--h-klein) + 2 * var(--a2));
  padding: var(--a1) var(--a2);
  border-bottom: 1px solid var(--linie);
}
.dt-pfeile { display: flex; flex: none; }
.dt-krumen { display: flex; flex: 1; align-items: center; min-width: 0; overflow: hidden; }
.dt-krume {
  flex: 0 1 auto;
  min-width: 0;
  height: var(--h-klein);
  padding: 0 var(--a2);
  overflow: hidden;
  border: 0;
  border-radius: var(--r-klein);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 500;
  line-height: var(--h-klein);
  white-space: nowrap;
  text-overflow: ellipsis;
}
button.dt-krume { cursor: default; }
button.dt-krume:hover { background: var(--akzent-hover); color: var(--text); }
.dt-krume[aria-current="page"] { flex-shrink: 0; max-width: 100%; color: var(--text); font-weight: 600; }
.fenster:not(.aktiv) .dt-krume[aria-current="page"] { color: var(--text-2); }
.dt-trenner { display: grid; flex: none; color: var(--text-2); opacity: 0.6; }
.dt-trenner .ic { width: 14px; height: 14px; }
.dt-suche { width: 200px; }
.dt-suche .feld { height: var(--h-klein); }

/* ---------- Seite und Inhalt ---------- */
.dt { position: relative; display: flex; flex: 1; flex-direction: column; min-height: 0; container: dtflaeche / inline-size; }
/* Beim Ziehen in der App: was beim Loslassen geschieht, am Zeiger */
.dt-zieh-hinweis { position: absolute; z-index: 5; max-width: 280px; padding: var(--a1) var(--a2); overflow: hidden; border-radius: var(--r-klein); color: var(--text); font-size: var(--s-klein); font-weight: 500; white-space: nowrap; text-overflow: ellipsis; pointer-events: none; }
/* Ordnerwahl (Bewegen nach, Kopieren nach) */
.dt-ordnerwahl { width: min(420px, 100%); }
.dt-ow-kopf { display: flex; align-items: center; gap: var(--a2); min-width: 0; }
.dt-ow-kopf b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dt-ow-liste { display: flex; flex-direction: column; gap: 1px; height: 280px; padding: var(--a1); overflow: auto; border-radius: var(--r-knopf); background: var(--flaeche-2); }
.dt-ow-liste .dt-ort > .ic:last-child { width: 14px; height: 14px; }
/* Die Orte füllen die Spalte nach unten, damit der Papierkorb unten steht (bei vielen Projekten am Ende der Liste) */
#view-dateien .rahmen-abschnitt[data-abschnitt="orte"] { flex: 1 0 auto; }
.dt-seite { display: flex; flex: 1 0 auto; flex-direction: column; gap: 1px; }
.dt-gruppe { padding: var(--a3) var(--a2) var(--a1); color: var(--text-2); font-size: var(--s-hinweis); font-weight: 600; }
.dt-gruppe:first-child { padding-top: var(--a0); }
.dt-ort {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--a2);
  width: 100%;
  min-height: var(--h-klein);
  padding: 0 var(--a2);
  border: 0;
  border-radius: var(--r-klein);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: default;
}
.dt-ort > .t { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dt-ort > .ic { width: 16px; height: 16px; color: var(--text-2); }
.dt-ort:hover { background: var(--akzent-hover); }
.dt-ort[aria-current="true"] { background: var(--flaeche); color: var(--akzent); font-weight: 500; box-shadow: var(--schatten-klein); }   /* wie .rahmen-eintrag */
.dt-ort[aria-current="true"] > .ic { color: var(--akzent); }
.dt-ort[data-unten] { margin-top: auto; }   /* der Papierkorb ganz unten */

.dt-haupt { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.dt-inhalt { position: relative; flex: 1; min-height: 0; overflow: auto; padding: var(--a3); }
.dt-inhalt:focus-visible { outline: none; }
.dt-inhalt > .leer { min-height: 220px; }
.dt-fuss {
  display: flex;
  flex: none;
  gap: var(--a3);
  min-width: 0;
  padding: var(--a1) var(--a3);
  border-top: 1px solid var(--linie);
  color: var(--text-2);
  font-size: var(--s-hinweis);
}
.dt-zahl { flex: none; }
.dt-hochladen { display: inline-flex; flex: none; align-items: center; gap: var(--a1); color: var(--akzent); font-weight: 600; }
.dt-hochladen .ic { width: 13px; height: 13px; }
.dt-details { min-width: 0; margin-left: auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- Einträge: gemeinsam ---------- */
.dt-eintrag { position: relative; border-radius: var(--r-knopf); outline-offset: -2px; cursor: default; -webkit-user-select: none; user-select: none; }
.dt-eintrag:hover { background: var(--akzent-hover); }
.dt-eintrag[aria-selected="true"] { background: var(--flaeche-3); }
.dt-stern, .dt-schloss { display: grid; flex: none; place-items: center; }
.dt-stern .ic { width: 14px; height: 14px; color: var(--warnung); fill: currentColor; }
.dt-schloss .ic { width: 13px; height: 13px; color: var(--text-2); }
/* Aus dem Explorer hereinziehen: Ziel ist der Ordner unter dem Zeiger (auch links) oder die ganze Fläche */
.dt-eintrag.dt-ziel, .dt-ort.dt-ziel { background: var(--akzent-hover); box-shadow: inset 0 0 0 2px var(--akzent); }
.dt-inhalt.dt-ablegen { box-shadow: inset 0 0 0 2px var(--akzent); background: var(--akzent-hover); }
/* Umbenennen an Ort und Stelle */
.dt-umbenennen.feld { width: 100%; min-width: 0; height: auto; padding: 1px var(--a1); font-size: inherit; text-align: inherit; }
.dt-symbol .dt-umbenennen.feld { font-size: var(--s-klein); text-align: center; }
.dt-inhalt .leer .knoepfe { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--a2); margin-top: var(--a2); }
/* Ausgeschnitten (Strg+X): blass, bis es eingefügt ist */
.dt-eintrag.dt-ausgeschnitten :is(.bild, .dt-name > :first-child) { opacity: 0.45; }
/* Versionen einer Datei */
.dt-versionen { width: min(520px, 100%); }
.dt-fassungen { display: flex; flex-direction: column; max-height: 360px; overflow: auto; }
.dt-fassung { display: flex; align-items: center; gap: var(--a2); padding: var(--a2) 0; border-bottom: 1px solid var(--linie); }
.dt-fassung:last-child { border-bottom: 0; }
.dt-fassung .w { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.dt-fassung .w span { color: var(--text-2); font-size: var(--s-klein); }

/* Als Symbole */
.dt-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--a1); align-content: start; }
.dt-symbol { display: flex; flex-direction: column; align-items: center; gap: var(--a2); padding: var(--a3) var(--a1) var(--a2); text-align: center; }
.dt-symbol .bild { display: grid; place-items: center; width: 72px; height: 62px; }
.dt-symbol .name {
  display: -webkit-box;
  max-width: 100%;
  padding: 1px var(--a1);
  overflow: hidden;
  border-radius: var(--r-klein);
  font-size: var(--s-klein);
  line-height: 1.3;
  overflow-wrap: break-word;
  hyphens: auto;   /* lange Wörter mit Trennstrich (lang="de") */
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.fenster.aktiv .dt-symbol[aria-selected="true"] .name { background: var(--akzent); color: var(--auf-akzent); }
.dt-symbol .dt-stern { position: absolute; top: var(--a2); right: var(--a2); }
.dt-symbol .dt-schloss { position: absolute; top: var(--a2); left: var(--a2); }

/* Als Liste */
.dt-liste-kopf, .dt-zeile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px 112px 150px var(--h-klein);
  align-items: center;
  gap: var(--a2);
  padding: 0 var(--a1) 0 var(--a2);
}
.dt-liste-kopf {
  position: sticky;
  top: calc(-1 * var(--a3));
  z-index: 1;
  height: 30px;
  margin-top: calc(-1 * var(--a3));
  border-bottom: 1px solid var(--linie);
  background: var(--flaeche);
  color: var(--text-2);
  font-size: var(--s-klein);
  font-weight: 500;
}
.dt-zeile { min-height: var(--h-normal); }
.fenster.aktiv .dt-zeile[aria-selected="true"] { background: var(--akzent); color: var(--auf-akzent); }
.fenster.aktiv .dt-zeile[aria-selected="true"] :is(.dt-sp, .dt-unter, .knopf.leise, .dt-stern .ic, .dt-schloss .ic) { color: inherit; }
.dt-sp { overflow: hidden; color: var(--text-2); white-space: nowrap; text-overflow: ellipsis; }
.dt-sp.zahl { font-variant-numeric: tabular-nums; }
.dt-name { display: flex; align-items: center; gap: var(--a2); min-width: 0; }
.dt-nz { display: flex; flex-direction: column; min-width: 0; }
.dt-nz .n { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dt-unter { display: none; overflow: hidden; color: var(--text-2); font-size: var(--s-klein); white-space: nowrap; text-overflow: ellipsis; }
.dt-unter:empty { display: none !important; }

/* ---------- Schmaler Inhalt ---------- */
@container dtflaeche (max-width: 700px) {
  .dt-liste-kopf, .dt-zeile { grid-template-columns: minmax(0, 1fr) 112px 140px var(--h-klein); }
  .dt-liste-kopf .art, .dt-zeile .art { display: none; }
}
/* Handy und schmale Fenster: die Suche in eigener Zeile, die Liste nur mit Namen (darunter die Info) */
@container dtflaeche (max-width: 600px) {
  .dt-suche { flex: 1 1 100%; order: 9; width: auto; }
  .dt-liste-kopf, .dt-zeile .dt-sp { display: none; }
  .dt-zeile { grid-template-columns: minmax(0, 1fr) var(--h-klein); }
  .dt-unter { display: block; }
  .dt-details { display: none; }
}
@container dtflaeche (max-width: 460px) {
  .dt-vor { display: none; }
  .dt-krumen > :nth-last-child(n+4) { display: none; }
  .dt-raster { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* ---------- Projekt anlegen bzw. bearbeiten (Dialog #modal-project-form, projects.js): zwei Felder nebeneinander,
   Farbwahl als Punkte, gewählt mit Ring im Akzent ---------- */
.dialog.projekt-dialog { width: min(480px, 100%); }
.projekt-zwei { display: grid; grid-template-columns: 1fr 1fr; gap: var(--a3); }
.projekt-dialog .feldgruppe .feld { box-sizing: border-box; width: 100%; }
.projekt-farben { display: flex; flex-wrap: wrap; gap: var(--a2); }
.projekt-farbe {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--r-rund);
  background: var(--projekt-farbe);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 20%, transparent);
  cursor: default;
}
.projekt-farbe:hover { box-shadow: 0 0 0 2px var(--flaeche), 0 0 0 3.5px var(--linie-stark); }
.projekt-farbe.aktiv { box-shadow: 0 0 0 2px var(--flaeche), 0 0 0 4px var(--akzent); }
@media (max-width: 480px) {
  .projekt-zwei { grid-template-columns: 1fr; }
}

/* Vorschaubild statt des Blatts (PDF und Bilder; Teleskop rechnet es, dateien.js dtBild), die Endung bleibt daneben */
.datei.dt-mit-vorschau { display: grid; width: 64px; height: 58px; place-items: center; }
.dt-vorschau { display: block; max-width: 64px; max-height: 58px; border-radius: var(--r-klein); background: var(--papier); box-shadow: var(--schatten-klein); object-fit: contain; }

/* ---------- Handy-App (core/dateien-handy.js): oben ‹ und der Name, unten fest die Knöpfe zum Anlegen, in der
   Liste kleine Vorschaubilder ---------- */
.dt-handy-band .t b { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dt-handy-band .knopf:disabled { visibility: hidden; }   /* ganz oben geht es nicht höher */
.dt-handy-platz { flex: none; width: var(--h-normal); }   /* so breit wie ‹: der Name steht in der Mitte */
[data-handy] .dt-pfad { padding: var(--a2) var(--a3); }
[data-handy] .dt-fuss { padding: 0; font-size: var(--s-klein); }
[data-handy] .dt-fuss[hidden] { display: none; }
[data-handy] .dt-fuss > .dt-hochladen { padding: var(--a3); }
[data-handy] .dt-fuss > .handy-knoepfe { flex: 1; padding: var(--a2) var(--a3); }
/* Liste: die Bilder in einer festen Spalte (die Namen stehen untereinander), Fotos und PDFs klein als Vorschau */
[data-handy] .dt-zeile .dt-name { display: grid; grid-template-columns: 40px minmax(0, 1fr); grid-auto-columns: auto; grid-auto-flow: column; }
[data-handy] .dt-zeile .dt-name > :first-child { justify-self: center; }
[data-handy] .dt-zeile .datei.dt-mit-vorschau { width: 40px; height: 40px; }
[data-handy] .dt-zeile .dt-vorschau { max-width: 40px; max-height: 40px; }
[data-handy] .dt-zeile .dt-mit-vorschau .endung { display: none; }
