/* Tresor – Oberfläche (Handy zuerst, Rechner mit drei Spalten) */
:root {
  --bg: #0c1016; --pane: #121821; --card: #18202b; --card2: #1e2835; --rand: #263243; --text: #e7edf5; --dim: #8b99ab;
  --akzent: #5b8cff; --akzent2: #3d6fe6; --gut: #3fb96b; --warn: #e2a93b; --schlecht: #ef5b5b; --gold: #f0c04a;
  --r: 12px; --schatten: 0 10px 30px rgba(0,0,0,.35);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #eef2f7; --pane: #f8fafc; --card: #fff; --card2: #f1f4f9; --rand: #d9e0ea; --text: #17202c; --dim: #5d6b7e; --schatten: 0 10px 30px rgba(20,30,50,.15); color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--akzent); }
.dim { color: var(--dim); }
.klein { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.versteckt { display: none !important; }
#app { min-height: 100%; }

/* ---------- Knöpfe & Felder ---------- */
.knopf { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--rand); background: var(--card2); border-radius: 10px; padding: 9px 14px; min-height: 40px; font-weight: 550; transition: background .15s, border-color .15s; white-space: nowrap; }
.knopf:hover { border-color: var(--akzent); }
.knopf:disabled { opacity: .5; cursor: default; }
.knopf.haupt { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.knopf.haupt:hover { background: var(--akzent2); }
.knopf.gefahr { color: var(--schlecht); }
.knopf.gefahr.voll { background: var(--schlecht); border-color: var(--schlecht); color: #fff; }
.knopf.breit { width: 100%; }
.knopf.flach { background: transparent; border-color: transparent; }
.knopf.flach:hover { background: var(--card2); }
.ikon { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 9px; border: 1px solid transparent; background: transparent; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; color: var(--dim); flex: none; }
.ikon:hover { background: var(--card2); color: var(--text); }
.ikon.an { color: var(--gold); }
label.feld { display: block; margin: 12px 0; }
label.feld > span { display: block; font-size: 13px; color: var(--dim); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=search], input[type=number], input[type=tel], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--rand); border-radius: 10px; padding: 10px 12px; min-height: 42px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--akzent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--akzent) 25%, transparent); }
textarea { min-height: 90px; resize: vertical; }
.zeile { display: flex; gap: 8px; align-items: center; }
.zeile > input { flex: 1; min-width: 0; }
.haken { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
.haken input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--akzent); }
.schalter { position: relative; width: 46px; height: 28px; flex: none; }
.schalter input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.schalter i { position: absolute; inset: 0; border-radius: 99px; background: var(--rand); transition: .2s; }
.schalter i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.schalter input:checked + i { background: var(--gut); }
.schalter input:checked + i::after { transform: translateX(18px); }

/* ---------- Start-/Sperrbildschirm ---------- */
.mitte { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--sat)) 18px calc(24px + var(--sab)); }
.karte { background: var(--pane); border: 1px solid var(--rand); border-radius: 18px; padding: 26px 22px; width: 100%; max-width: 430px; box-shadow: var(--schatten); }
.karte h1 { margin: 6px 0 4px; font-size: 22px; text-align: center; }
.karte .unter { text-align: center; color: var(--dim); margin: 0 0 18px; font-size: 14px; }
.logo { width: 64px; height: 64px; margin: 0 auto; display: block; }
.hinweis { background: var(--card2); border: 1px solid var(--rand); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--dim); margin: 12px 0; }
.hinweis.warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--rand)); color: var(--text); }
.hinweis.gefahr { border-color: color-mix(in srgb, var(--schlecht) 55%, var(--rand)); color: var(--text); }
.hinweis b { color: var(--text); }
.fehlertext { color: var(--schlecht); font-size: 14px; min-height: 20px; margin: 8px 0 0; text-align: center; }
.verweis { background: none; border: none; color: var(--akzent); padding: 6px; font-size: 14px; }
.lade { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: dreh .8s linear infinite; vertical-align: middle; }
@keyframes dreh { to { transform: rotate(360deg); } }
.pinfeld { letter-spacing: .5em; text-align: center; font-size: 22px; }

/* Stärke-Balken */
.staerke { height: 6px; border-radius: 9px; background: var(--rand); overflow: hidden; margin-top: 6px; }
.staerke i { display: block; height: 100%; width: 0; border-radius: 9px; transition: width .2s, background .2s; }
.staerke-text { font-size: 12px; color: var(--dim); margin-top: 4px; display: flex; justify-content: space-between; }
.s0 { background: var(--schlecht); } .s1 { background: #f07d3b; } .s2 { background: var(--warn); } .s3 { background: #7cc35a; } .s4 { background: var(--gut); }

/* ---------- Hauptansicht ---------- */
.ansicht { display: grid; grid-template-columns: 230px minmax(300px, 380px) 1fr; grid-template-rows: auto 1fr; height: 100dvh; }
.kopf { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--sat)) 14px 10px; background: var(--pane); border-bottom: 1px solid var(--rand); }
.kopf .marke { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; min-width: 200px; }
.kopf .marke img { width: 26px; height: 26px; }
.suche { flex: 1; max-width: 560px; position: relative; }
.suche input { padding-left: 36px; border-radius: 99px; background: var(--card); }
.suche::before { content: '⌕'; position: absolute; left: 13px; top: 50%; transform: translateY(-52%); color: var(--dim); font-size: 18px; pointer-events: none; }
.kopf .rechts { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.navi { background: var(--pane); border-right: 1px solid var(--rand); overflow-y: auto; padding: 10px 8px calc(10px + var(--sab)); }
.navi button { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: transparent; padding: 8px 10px; border-radius: 9px; text-align: left; color: var(--text); }
.navi button:hover { background: var(--card); }
.navi button.an { background: color-mix(in srgb, var(--akzent) 18%, transparent); color: var(--text); font-weight: 600; }
.navi button i { font-style: normal; width: 22px; text-align: center; }
.navi button .zahl { margin-left: auto; font-size: 12px; color: var(--dim); }
.navi h4 { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); font-weight: 650; }
.liste { border-right: 1px solid var(--rand); overflow-y: auto; background: var(--bg); }
.liste .leer { padding: 40px 20px; text-align: center; color: var(--dim); }
.listenkopf { display: flex; align-items: center; gap: 8px; padding: 10px 14px; position: sticky; top: 0; background: var(--bg); z-index: 1; border-bottom: 1px solid var(--rand); font-weight: 650; }
.listenkopf .dim { font-weight: 400; font-size: 13px; }
.listenkopf .knopf { margin-left: auto; min-height: 32px; padding: 5px 10px; }
.eintrag { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid color-mix(in srgb, var(--rand) 50%, transparent); cursor: pointer; }
.eintrag:hover { background: var(--card); }
.eintrag.an { background: color-mix(in srgb, var(--akzent) 16%, var(--card)); }
.eintrag .txt { min-width: 0; flex: 1; }
.eintrag .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eintrag .u { font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eintrag .zeichen { font-size: 13px; color: var(--dim); display: flex; gap: 4px; }
.avatar { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex: none; font-size: 16px; text-transform: uppercase; }
.avatar.gross { width: 54px; height: 54px; font-size: 24px; border-radius: 14px; }
.detail { overflow-y: auto; background: var(--pane); }
.detail .leer { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--dim); gap: 8px; padding: 30px; text-align: center; }
.detail .leer img { width: 80px; opacity: .35; }
.dkopf { display: flex; align-items: center; gap: 14px; padding: 20px 22px 12px; }
.dkopf h2 { margin: 0; font-size: 21px; word-break: break-word; }
.dkopf .dim { font-size: 13px; }
.dkopf .zurueck { display: none; }
.dknoepfe { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 22px 14px; }
.block { margin: 0 22px 16px; background: var(--card); border: 1px solid var(--rand); border-radius: var(--r); overflow: hidden; }
.frow { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--rand); min-height: 58px; }
.frow:last-child { border-bottom: none; }
.frow .fl { flex: 1; min-width: 0; }
.frow .fl small { display: block; color: var(--dim); font-size: 12px; }
.frow .fl .w { word-break: break-all; white-space: pre-wrap; }
.frow .fl .w.pw { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
.zf { color: #6fa8ff; } .zs { color: #f0a050; }
@media (prefers-color-scheme: light) { .zf { color: #1f5fd1; } .zs { color: #c05a00; } }
.totp { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 24px; letter-spacing: .12em; font-weight: 600; }
.uhr { width: 26px; height: 26px; flex: none; }
.uhr circle { fill: none; stroke-width: 3; }
.uhr .hg { stroke: var(--rand); } .uhr .vg { stroke: var(--akzent); transition: stroke-dashoffset 1s linear; transform: rotate(-90deg); transform-origin: center; }
.uhr.knapp .vg { stroke: var(--schlecht); }
.meta { margin: 0 22px 22px; color: var(--dim); font-size: 12.5px; display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; }
.marker { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--card2); border: 1px solid var(--rand); color: var(--dim); }
.marker.gut { color: var(--gut); } .marker.warn { color: var(--warn); } .marker.schlecht { color: var(--schlecht); }
details.verlauf summary { cursor: pointer; padding: 12px 14px; color: var(--dim); font-size: 13px; }
.unten { display: none; }

/* ---------- Bereiche (Generator, Sicherheit, Einstellungen) ---------- */
.bereich { padding: 18px 22px 40px; max-width: 820px; }
.bereich h2 { margin: 4px 0 14px; font-size: 21px; display: flex; align-items: center; gap: 10px; }
.bereich h3 { margin: 26px 0 8px; font-size: 16px; }
.bereich p { margin: 6px 0; }
.abschnitt { background: var(--card); border: 1px solid var(--rand); border-radius: var(--r); padding: 14px 16px; margin: 12px 0; }
.abschnitt h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.abschnitt .zeile { flex-wrap: wrap; }
.knopfreihe { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.genaus { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 22px; word-break: break-all; padding: 18px; background: var(--bg); border: 1px solid var(--rand); border-radius: var(--r); min-height: 70px; text-align: center; user-select: all; }
input[type=range] { width: 100%; accent-color: var(--akzent); }
.seg { display: inline-flex; border: 1px solid var(--rand); border-radius: 10px; overflow: hidden; }
.seg button { border: none; background: transparent; padding: 8px 14px; }
.seg button.an { background: var(--akzent); color: #fff; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.kachel { background: var(--card); border: 1px solid var(--rand); border-radius: var(--r); padding: 14px; cursor: pointer; text-align: left; }
.kachel b { display: block; font-size: 26px; }
.kachel.schlecht b { color: var(--schlecht); } .kachel.warn b { color: var(--warn); } .kachel.gut b { color: var(--gut); }
.kachel.an { border-color: var(--akzent); }
.prot { display: grid; grid-template-columns: 26px 1fr; gap: 2px 8px; padding: 8px 0; border-bottom: 1px solid var(--rand); font-size: 14px; }
.prot .dim { grid-column: 2; font-size: 12.5px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: var(--bg); border: 1px solid var(--rand); border-radius: 8px; padding: 8px 10px; word-break: break-all; font-size: 12.5px; max-height: 120px; overflow: auto; }
.notfallcode { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 19px; letter-spacing: .06em; text-align: center; padding: 16px; background: var(--bg); border: 2px dashed var(--gold); border-radius: var(--r); word-spacing: .3em; user-select: all; }
ol.schritte { padding-left: 22px; } ol.schritte li { margin: 6px 0; }

/* ---------- Dialoge ---------- */
.schleier { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; animation: ein .15s; }
@keyframes ein { from { opacity: 0; } }
.dlg { background: var(--pane); border: 1px solid var(--rand); border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: var(--schatten); }
.dlg.breit { max-width: 640px; }
.dlg header { padding: 16px 18px 6px; font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.dlg header .ikon { margin-left: auto; }
.dlg .inhalt { padding: 4px 18px 10px; overflow-y: auto; }
.dlg footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px calc(14px + var(--sab)); border-top: 1px solid var(--rand); flex-wrap: wrap; }
.dlg .inhalt p { margin: 6px 0 10px; }
.mehrfeld { display: flex; flex-direction: column; gap: 6px; }
.zusatz { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.zusatz .opt { grid-column: 1 / -1; display: flex; gap: 14px; font-size: 13px; color: var(--dim); }
.zusatz .opt label { display: flex; gap: 5px; align-items: center; }

/* ---------- Mitteilung ---------- */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%) translateY(30px); background: var(--card2); border: 1px solid var(--rand); color: var(--text); padding: 10px 16px; border-radius: 12px; box-shadow: var(--schatten); opacity: 0; transition: .25s; z-index: 99; pointer-events: none; max-width: calc(100vw - 30px); text-align: center; }
#toast.an { opacity: 1; transform: translateX(-50%); }
#toast.fehler { border-color: var(--schlecht); }

/* ---------- Füllen (Lesezeichen) ---------- */
.fuellen .karte { max-width: 480px; }
.fuellen .eintrag { border-radius: 10px; border: 1px solid var(--rand); margin: 6px 0; background: var(--card); }

/* ---------- Handy ---------- */
.nurhandy { display: none !important; }
@media (max-width: 900px) {
  .ansicht { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .kopf .marke span { display: none; }
  .kopf .marke { min-width: 0; }
  .navi { display: none; }
  .nurhandy { display: inline-flex !important; }
  .nurdesk { display: none; }
  .ansicht.navi-offen .navi { display: block; position: fixed; inset: 0; z-index: 40; padding-top: calc(14px + var(--sat)); }
  .liste { border-right: none; }
  .detail { position: fixed; inset: 0; z-index: 30; transform: translateX(100%); transition: transform .22s ease; padding-top: var(--sat); padding-bottom: calc(70px + var(--sab)); }
  .ansicht.detail-offen .detail { transform: none; }
  .dkopf .zurueck { display: inline-flex; }
  .unten { display: flex; position: sticky; bottom: 0; background: var(--pane); border-top: 1px solid var(--rand); padding: 4px 4px calc(4px + var(--sab)); z-index: 35; }
  .ansicht.detail-offen .unten { position: fixed; left: 0; right: 0; bottom: 0; }
  .unten button { flex: 1; border: none; background: none; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; color: var(--dim); }
  .unten button i { font-style: normal; font-size: 20px; }
  .unten button.an { color: var(--akzent); }
  .bereich { padding: 14px 14px 30px; }
  .block, .dknoepfe, .meta { margin-left: 14px; margin-right: 14px; }
  .dknoepfe { padding: 0 14px 12px; margin: 0; }
  .dkopf { padding: 14px; }
  .dlg { max-height: calc(100dvh - 20px); border-radius: 16px 16px 0 0; align-self: flex-end; }
  .schleier { padding: 10px 0 0; align-items: flex-end; }
  .kachel b { font-size: 22px; }
  #toast { bottom: calc(76px + var(--sab)); }
  .eintrag { padding: 11px 14px; }
}
@media (max-width: 900px) and (min-width: 600px) { .dlg { border-radius: 16px; align-self: center; } .schleier { align-items: center; padding: 16px; } }
/* eingebettet im Admin-Tool: eigene Kopfzeile schlanker */
.eingebettet .kopf { padding-top: 10px; }
.eingebettet .mitte { min-height: 100vh; }
