/* „App bearbeiten“ – mobiles Bottom-Sheet. Nutzt die Farbvariablen der Lernapp, mit Rückfallwerten. */
.ed-fab, .ed-root, .ed-pickbar, .ed-banner {
  --e-surface: var(--surface, #fff); --e-bg: var(--bg, #f6f4ef); --e-text: var(--text, #1d2430); --e-muted: var(--muted, #5e6675);
  --e-line: var(--line, #ddd8cc); --e-accent: var(--accent, #0d5eaf); --e-ink: var(--accent-ink, #fff); --e-soft: var(--accent-soft, #e2edf9);
  --e-ok: var(--ok, #1e8a4c); --e-bad: var(--bad, #c0392b);
  font-family: var(--font, -apple-system, system-ui, sans-serif);
}

/* ---------- Schwebender Knopf ---------- */
.ed-fab {
  position: fixed; right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 30;
  width: 50px; height: 50px; border-radius: 50%; border: 1px solid var(--e-line); background: var(--e-surface);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18); display: grid; place-items: center; cursor: pointer; padding: 0;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: transform .15s, opacity .2s;
}
.ed-fab:active { transform: scale(.92); }
.ed-fab.hide { opacity: 0; pointer-events: none; }
.ed-fab-i { font-size: 1.35rem; line-height: 1; }
.ed-fab-ring { position: absolute; inset: -3px; border-radius: 50%; border: 3px solid transparent; pointer-events: none; }
.ed-fab.busy .ed-fab-ring { border-top-color: var(--e-accent); animation: ed-spin 1s linear infinite; }
.ed-fab.done::after { content: ''; position: absolute; top: 2px; right: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--e-ok); border: 2px solid var(--e-surface); }
html.ed-open .ed-fab { opacity: 0; pointer-events: none; }
@keyframes ed-spin { to { transform: rotate(360deg); } }

/* ---------- Sheet ---------- */
html.ed-open, html.ed-open body { overflow: hidden; }
.ed-root[hidden] { display: none; }
.ed-backdrop { position: fixed; inset: 0; z-index: 59; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .2s; }
.ed-sheet {
  position: fixed; left: 0; right: 0; z-index: 60; margin: 0 auto; max-width: 600px;
  bottom: var(--ed-kb, 0px);
  height: min(92dvh, calc(var(--ed-vh, 100dvh) - 12px)); max-height: calc(var(--ed-vh, 100dvh) - 12px);
  display: flex; flex-direction: column; background: var(--e-surface); color: var(--e-text);
  border-radius: 18px 18px 0 0; box-shadow: 0 -6px 30px rgba(0, 0, 0, .2);
  transform: translateY(105%); transition: transform .22s ease-out;
}
.ed-root.open .ed-sheet { transform: none; }
.ed-root.open .ed-backdrop { opacity: 1; }
@media (min-width: 640px) { .ed-sheet { bottom: max(16px, var(--ed-kb, 0px)); border-radius: 18px; height: min(86vh, 780px); } }

.ed-head { padding: 6px 16px 0; border-bottom: 1px solid var(--e-line); flex: none; touch-action: none; }
.ed-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--e-line); margin: 2px auto 6px; }
.ed-titlebar { display: flex; align-items: center; gap: 8px; }
.ed-titlebar h2 { flex: 1; margin: 0; font-size: 1.1rem; }
.ed-x { width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.2rem; color: var(--e-muted); cursor: pointer; border-radius: 50%; }
.ed-tabs { display: flex; gap: 4px; margin-top: 4px; }
.ed-tabs button { flex: 1; min-height: 42px; border: 0; background: transparent; color: var(--e-muted); font: inherit; font-weight: 600; font-size: .9rem; border-bottom: 3px solid transparent; cursor: pointer; }
.ed-tabs button[aria-selected="true"] { color: var(--e-accent); border-bottom-color: var(--e-accent); }

.ed-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 14px 16px 20px; }
.ed-foot { flex: none; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--e-line); background: var(--e-surface); }
.ed-foot:empty { display: none; }
@media (min-width: 640px) { .ed-foot { padding-bottom: 12px; border-radius: 0 0 18px 18px; } }

/* ---------- Bausteine ---------- */
.ed-label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
.ed-muted { color: var(--e-muted); font-weight: 400; }
.ed-root .small { font-size: .85rem; }
.ed-hint { color: var(--e-muted); font-size: .82rem; margin: 6px 0 0; }
.ed-grow { flex: 1; min-width: 0; }
.ed-ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ed-ta, .ed-in {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; /* 16 px: kein Auto-Zoom auf iOS */
  color: var(--e-text); background: var(--e-bg); border: 1px solid var(--e-line); border-radius: 12px; padding: 10px 12px; min-height: 44px;
}
.ed-ta { resize: none; line-height: 1.45; }
.ed-ta:focus, .ed-in:focus { outline: none; border-color: var(--e-accent); box-shadow: 0 0 0 3px var(--e-soft); }
.ed-btn {
  min-height: 44px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--e-line); background: var(--e-surface);
  color: var(--e-text); font: inherit; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.ed-btn.primary { background: var(--e-accent); border-color: var(--e-accent); color: var(--e-ink); }
.ed-btn.big { width: 100%; min-height: 52px; font-size: 1.05rem; }
.ed-btn:disabled { opacity: .5; }
.ed-check { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; font-size: .92rem; }
.ed-check input { width: 22px; height: 22px; flex: none; margin: 0; }

.ed-ctx { display: flex; gap: 6px; flex-wrap: wrap; }
.ed-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 36px; padding: 4px 12px; border-radius: 18px;
  background: var(--e-bg); border: 1px solid var(--e-line); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ed-chip.btn { cursor: pointer; color: var(--e-accent); font: inherit; font-size: .85rem; font-weight: 600; }
.ed-chip.el { background: var(--e-soft); border-color: var(--e-accent); }
.ed-chip button { border: 0; background: transparent; color: inherit; font-size: 1rem; min-width: 28px; min-height: 28px; cursor: pointer; padding: 0; }

.ed-attach { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ed-attach button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; padding: 8px 4px; border-radius: 14px;
  border: 1px dashed var(--e-line); background: var(--e-bg); color: var(--e-text); font: inherit; font-size: .8rem; cursor: pointer; touch-action: manipulation;
}
.ed-attach button span { font-size: 1.4rem; line-height: 1.1; }
.ed-attach button:active { background: var(--e-soft); }
.ed-textbox { margin-top: 10px; padding: 10px; border: 1px solid var(--e-line); border-radius: 14px; display: grid; gap: 8px; }
.ed-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-top: 10px; }
.ed-thumbs:empty, .ed-files:empty { display: none; }
.ed-thumb { position: relative; margin: 0; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--e-line); }
.ed-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-thumb button, .ed-file button {
  border: 0; border-radius: 50%; width: 30px; height: 30px; background: rgba(0, 0, 0, .6); color: #fff; font-size: .85rem; cursor: pointer; padding: 0; flex: none;
}
.ed-thumb button { position: absolute; top: 4px; right: 4px; }
.ed-files { display: grid; gap: 6px; margin-top: 10px; }
.ed-file { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--e-line); border-radius: 12px; font-size: .9rem; }
.ed-file button { background: var(--e-bg); color: var(--e-text); }

.ed-opts { margin-top: 16px; border: 1px solid var(--e-line); border-radius: 14px; padding: 0 12px; }
.ed-opts summary { min-height: 46px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.ed-opts[open] { padding-bottom: 12px; }

.ed-note { padding: 10px 12px; border-radius: 12px; background: var(--e-soft); margin: 0 0 12px; font-size: .92rem; }
.ed-note.bad { background: color-mix(in srgb, var(--e-bad) 14%, transparent); color: var(--e-text); border-left: 4px solid var(--e-bad); }
.ed-body > .ed-note[data-err] { margin-top: 12px; }
.ed-spin { width: 30px; height: 30px; margin: 30px auto; border: 3px solid var(--e-line); border-top-color: var(--e-accent); border-radius: 50%; animation: ed-spin 1s linear infinite; }

/* ---------- Auftrag ---------- */
.ed-status { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px; background: var(--e-bg); }
.ed-status.ok { background: color-mix(in srgb, var(--e-ok) 14%, transparent); }
.ed-status.bad { background: color-mix(in srgb, var(--e-bad) 14%, transparent); }
.ed-sicon { font-size: 1.4rem; width: 32px; display: grid; place-items: center; flex: none; }
.ed-dot { width: 22px; height: 22px; border: 3px solid var(--e-line); border-top-color: var(--e-accent); border-radius: 50%; animation: ed-spin 1s linear infinite; }
.ed-quote { margin: 12px 0 8px; padding: 8px 12px; border-left: 3px solid var(--e-line); color: var(--e-muted); white-space: pre-wrap; max-height: 9em; overflow: auto; }
.ed-summary { margin: 12px 0; padding: 12px; border-radius: 12px; background: var(--e-soft); line-height: 1.45; }
.ed-live { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.ed-live li { font-size: .88rem; padding: 6px 10px; border-radius: 10px; background: var(--e-bg); overflow-wrap: anywhere; }
.ed-live li:last-child { border-left: 3px solid var(--e-accent); }
.ed-log, .ed-files-changed { margin-top: 12px; }
.ed-log summary, .ed-files-changed summary { min-height: 40px; display: flex; align-items: center; color: var(--e-muted); font-size: .9rem; cursor: pointer; }
.ed-log ul, .ed-files-changed ul { margin: 0; padding-left: 0; list-style: none; font-size: .82rem; display: grid; gap: 4px; overflow-wrap: anywhere; }
.ed-files-changed code { font-size: .8rem; }

/* ---------- Verlauf ---------- */
.ed-hist { list-style: none; margin: 0; padding: 0; }
.ed-hist li + li { border-top: 1px solid var(--e-line); }
.ed-hist button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 12px 2px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; min-height: 56px; }
.ed-hist .ed-grow { display: grid; gap: 2px; }
.ed-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Element antippen ---------- */
.ed-picked { outline: 3px solid var(--accent, #0d5eaf) !important; outline-offset: 2px; border-radius: 4px; }
.ed-pickbar {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 61; max-width: 600px; margin: 0 auto;
  background: var(--e-surface); color: var(--e-text); border: 2px solid var(--e-accent); border-radius: 16px; padding: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.ed-picktext { font-weight: 600; margin-bottom: 8px; overflow-wrap: anywhere; }

/* ---------- Hinweis „fertig“ ---------- */
.ed-banner {
  position: fixed; left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top)); z-index: 62; max-width: 600px; margin: 0 auto;
  display: flex; gap: 8px; align-items: center; padding: 10px 10px 10px 14px; border-radius: 14px;
  background: var(--e-surface); color: var(--e-text); border: 1px solid var(--e-line); box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
  transform: translateY(-140%); transition: transform .25s;
}
.ed-banner.show { transform: none; }
.ed-banner.ok { border-left: 5px solid var(--e-ok); }
.ed-banner.bad, .ed-banner.meh { border-left: 5px solid var(--e-bad); }

/* Fußleiste: Knöpfe gleich breit in einer Zeile */
.ed-foot .ed-row { flex-wrap: nowrap; }
.ed-foot .ed-row .ed-grow { display: none; }
.ed-foot .ed-row > .ed-btn { flex: 1 1 0; min-width: 0; padding-inline: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
