/* ==========================================================================
   achterberg.dev — Postfach & Dateien
   Baut auf den Tokens aus style.css auf (--bg, --border, --accent …).
   ========================================================================== */

:root {
  --side-w:  262px;   /* Beschreibungen in der Seitenleiste: bis 26 Zeichen */
  --list-w:  382px;
}

/* Mehrere Bausteine hier sind Flex-Container; ohne diese Regel würde
   display:flex das hidden-Attribut aushebeln. */
[hidden] { display: none !important; }

/* ==========================================================================
   Bedienelemente
   ——— .btn, .field und die Formularfelder stehen in style.css, weil die
       statischen Seiten sie für das Login-Fenster ebenfalls brauchen.
   ========================================================================== */
.chip {
  padding: 6px 11px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.chip:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.chip--tiny { padding: 4px 8px; font-size: 9.5px; }
.chip--danger:hover { color: #f87171; border-color: #f87171; background: rgba(248,113,113,.07); }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ==========================================================================
   Anmeldeseite
   ========================================================================== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-h));
  min-height: calc(100dvh - var(--nav-h));
  padding: 60px 20px;
}
.auth-card { width: 100%; max-width: 430px; padding: 34px 34px 28px; background: var(--panel); }
.auth-title {
  margin: 4px 0 12px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -.02em;
  text-transform: uppercase;
  color: var(--text);
}
.auth-sub { margin: 0 0 28px; color: var(--text-body); font-size: 14px; line-height: 1.6; }
.auth-error {
  margin: 0 0 20px;
  padding: 11px 14px;
  border: 1px solid #f87171;
  background: rgba(248,113,113,.07);
  color: #f87171;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}
.auth-form .btn { margin-top: 6px; }
.auth-note {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* ==========================================================================
   Anwendungsraster
   ========================================================================== */
.app-body { overflow: hidden; }
.app-body .site-nav { position: relative; }

.nav-mid { display: flex; align-items: center; flex: 1; min-width: 0; padding: 0 18px; }
.nav-search {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  max-width: 420px;
  padding: 0 12px;
  border: 1px solid var(--border);
  height: 32px;
  color: var(--muted);
}
.nav-search:focus-within { border-color: var(--accent); color: var(--accent); }
.nav-search input {
  border: 0;
  padding: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}
.nav-search input:focus { outline: none; }
.nav-search input::-webkit-search-cancel-button { filter: grayscale(1); }

.app {
  display: grid;
  grid-template-columns: var(--side-w) var(--list-w) 1fr;
  height: calc(100vh - var(--nav-h));
  height: calc(100dvh - var(--nav-h));
  overflow: hidden;
}
.app.files-open { grid-template-columns: var(--side-w) 1fr; }

/* ---- Seitenleiste ---------------------------------------------------- */
.side {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 16px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.side-head { margin: 20px 0 12px; }
.side-head:first-of-type { margin-top: 24px; }
.compose-btn { padding: 12px 14px; }
.side-loading { margin: 0; padding: 8px 10px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.folder-list { display: flex; flex-direction: column; }
.folder {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text-body);
  font-family: var(--mono);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.folder:hover { background: var(--accent-soft); color: var(--text); }
.folder[aria-current="true"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.folder .f-icon { flex: none; display: flex; color: var(--muted); }
.folder[aria-current="true"] .f-icon { color: var(--accent); }
.folder .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .f-count {
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
}
.folder .f-count.is-unread { border-color: var(--accent); color: var(--accent); }
.folder[data-depth="1"] { padding-left: 26px; }
.folder[data-depth="2"] { padding-left: 40px; }

/* ---- Der große Punkt "Dateien" --------------------------------------- */
.files-entry {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  margin-top: 4px;
  padding: 16px 15px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.files-entry:hover { background: var(--accent-soft); }
.files-entry[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.files-entry-icon { flex: none; display: flex; color: var(--accent); }
.files-entry-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.files-entry-name {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.files-entry-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.files-entry.drag-over { border-color: var(--accent); background: var(--accent-soft); }

/* Benachrichtigung am Eintrag (KI: neue Antworten) */
.files-entry-badge {
  flex: none;
  margin-left: auto;
  min-width: 20px;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}
.files-entry-badge[hidden] { display: none; }
/* Läuft eine Antwort, pulsiert das Symbol */
.files-entry.is-running .files-entry-icon { animation: ai-pulse 1.4s ease-in-out infinite; }
@keyframes ai-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ==========================================================================
   Kopfzeilen der Bereiche
   ========================================================================== */
.pane-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.pane-head-main { min-width: 0; }
.pane-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text);
}
.pane-sub {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.pane-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.pane-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.page-info { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ==========================================================================
   Nachrichtenliste
   ========================================================================== */
.list-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
  overflow: hidden;
}
.msg-list { flex: 1; overflow-y: auto; outline: none; }

/* Zeile über der Liste: das Häkchen steht genau über denen der Nachrichten */
.list-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
  min-height: 42px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.list-tools[hidden] { display: none; }
.list-select-all {
  display: grid;
  grid-template-columns: 18px auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
.list-select-all:hover { color: var(--text); }
.list-select-all .msg-check { margin-top: 0; }
.list-tools .chip[hidden] { display: none; }

.bulk-bar, .files-bulk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
}
.bulk-count { font-family: var(--mono); font-size: 11px; color: var(--accent); white-space: nowrap; }
.bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.msg {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 13px 16px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background .12s ease;
}
.msg:hover { background: var(--accent-soft); }
.msg[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.msg.is-selected { background: color-mix(in srgb, var(--accent) 11%, transparent); }

.msg-check {
  width: 14px; height: 14px;
  margin-top: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}
.msg-main { min-width: 0; }
.msg-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.msg-from {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.is-unread .msg-from { color: var(--text); font-weight: 700; }
.msg-date { flex: none; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.msg-subject {
  margin-bottom: 4px;
  font-size: 13.5px;
  color: var(--text-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.is-unread .msg-subject { color: var(--text); font-weight: 600; }
.msg-meta { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.msg-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.msg.is-unread .msg-dot { opacity: 1; }
.msg:not(.is-unread) .msg-dot { opacity: 0; }
.msg-clip { color: var(--muted); display: inline-flex; }
.msg-star { color: var(--accent); }

.list-empty, .side-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}
.list-empty .headline {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Ladebalken oben an der Liste */
.loading-bar {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: var(--accent);
  transform-origin: left;
  animation: load 1.1s ease-in-out infinite;
}
@keyframes load {
  0%   { transform: scaleX(0);   opacity: 1; }
  60%  { transform: scaleX(1);   opacity: 1; }
  100% { transform: scaleX(1);   opacity: 0; }
}
.list-pane, .files-pane { position: relative; }

/* ==========================================================================
   Leseansicht
   ========================================================================== */
.read-pane { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.empty-reader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty-reader p { margin: 0; max-width: 32ch; line-height: 1.6; }
.empty-mark { width: 9px; height: 9px; background: var(--accent); margin-bottom: 8px; }
.empty-headline {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-body);
}

.reader { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.reader-head { flex: none; padding: 22px 26px 18px; border-bottom: 1px solid var(--border); }
.reader-subject {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
  color: var(--text);
}
.reader-meta { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.reader-line { display: flex; gap: 10px; align-items: baseline; }
.reader-key {
  flex: none;
  width: 62px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.reader-val { color: var(--text-body); min-width: 0; word-break: break-word; }
.reader-val .addr-name { color: var(--text); font-weight: 500; }
.reader-val .addr-mail { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex: none;
  padding: 12px 26px;
  border-bottom: 1px solid var(--border-soft);
}

.reader-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  margin: 0;
  padding: 10px 26px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--accent-soft);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-body);
}

.reader-body { flex: 1; overflow: auto; padding: 24px 26px 60px; }
.reader-body iframe {
  width: 100%;
  border: 0;
  min-height: 320px;
  background: transparent;
  color-scheme: normal;
}
.reader-text {
  margin: 0;
  color: var(--text-body);
  font-size: 14.5px;
  line-height: 1.72;
  word-wrap: break-word;
}
.reader-text a { color: var(--accent); }
.reader-text .quote { color: var(--muted); }

.attach-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: none;
  padding: 12px 26px;
  border-top: 1px solid var(--border);
}
.attach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--text-body);
  text-decoration: none;
  font-size: 12.5px;
  transition: border-color .15s ease, background .15s ease;
}
.attach:hover { border-color: var(--accent); background: var(--accent-soft); }
.attach-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.attach-save {
  border: 0;
  border-left: 1px solid var(--border);
  padding: 0 0 0 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}
.attach-save:hover { color: var(--accent); }

/* ==========================================================================
   Dateien
   ========================================================================== */
.files-pane { display: flex; flex-direction: column; overflow: hidden; grid-column: 2 / -1; }
.files-pane[hidden] { display: none; }

/* Budgetmaxxer: Die App füllt den ganzen Bereich. Ihr Hintergrund ist
   durchsichtig - das Raster der Seite läuft lückenlos weiter. */
.budget-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: transparent;
  color-scheme: normal;
}

/* Budgetmaxxer für App-Nutzer ohne Website-Anmeldung: Kopfzeile der
   Website, darunter die App über die ganze Fläche (app/budgetmaxxer). */
.bmx-shell-main {
  display: flex;
  height: calc(100vh - var(--nav-h));
  height: calc(100dvh - var(--nav-h));
}
.bmx-brand img { margin-right: 10px; border-radius: 5px; }
/* "Abmelden" in der Kopfzeile - sieht aus wie die Links daneben */
.bmx-signout {
  display: flex;
  align-items: center;
  padding: 0 24px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease;
}
.bmx-signout:hover { color: var(--accent); }
.bmx-signout[hidden] { display: none; }
@media (max-width: 900px) {
  .bmx-signout { padding: 0 14px; font-size: 11px; letter-spacing: .08em; }
}
@media (max-width: 860px) {
  .bmx-shell .brand { display: flex; }
}

/* ---- Adminpanel ------------------------------------------------------ */
.admin-stats { margin: 18px 18px 6px; }
.admin-row { cursor: default; }
.admin-row .post-meta { column-gap: 16px; }
.admin-row .admin-premium-note { color: var(--green); }
.admin-row .admin-role-note { color: var(--accent); }
.admin-row .admin-danger-note { color: #f87171; }
.admin-filter {
  width: 200px;
  height: 32px;
  padding: 0 11px;
  font-family: var(--mono);
  font-size: 12px;
}
.admin-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* Eigene Rolle im Kopf, Reiter Konten | Promo-Codes */
.admin-role { margin-left: 10px; vertical-align: 1px; }
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: none;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

/* Kasten "Co-Developer" (nur Developer) */
.admin-box {
  margin: 12px 18px 6px;
  padding: 14px 16px;
  border: 1px solid var(--border);
}
.admin-box-head {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.admin-box-note { margin: 0 0 12px; font-size: 13px; line-height: 1.6; color: var(--text-body); }
.admin-role-list { margin-top: 12px; border-top: 1px solid var(--border-soft); }
.admin-role-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.admin-role-mail {
  flex: 1 1 180px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.admin-role-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.admin-role-empty { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* Formulare: Co-Developer hinzufügen, Promo-Code anlegen */
.admin-form { display: flex; align-items: flex-end; gap: 9px; }
.admin-form input { flex: 1; min-width: 0; }
.admin-form .btn { flex: none; }
#bmx-promo-form { margin: 12px 18px 0; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.admin-field { display: block; flex: 1; min-width: 0; }
.admin-field--small { flex: 0 0 170px; }
.admin-field .field-label { margin-bottom: 6px; }
.promo-input-code { font-family: var(--mono); text-transform: uppercase; }
.promo-input-code::placeholder { text-transform: none; }

/* Promo-Liste mit Einlöse-Protokoll */
.promo-row h3.promo-code { font-family: var(--mono); letter-spacing: .06em; }
.promo-row.is-new { background: var(--accent-soft); }
.promo-row .promo-note { color: var(--text-body); }
.promo-log { margin-top: 9px; }
.promo-log summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--muted);
}
.promo-log summary:hover { color: var(--accent); }
.promo-log-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--border);
}
.promo-log-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  padding: 4px 0 4px 12px;
  font-size: 12.5px;
}
.promo-log-mail { color: var(--text); overflow-wrap: anywhere; }
.promo-log-mail.is-gone { color: var(--muted); font-style: italic; }
.promo-log-at { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

/* Clavichat: Speicher (nur Developer) - zwei Kennzahl-Zeilen am Stück,
   darunter Bereiche mit Balken und die Dateien der Windows-App */
.admin-filter[hidden] { display: none; }
#cc-storage-stats { margin-bottom: 0; }
.cc-counts { margin-top: 0; border-top: 0; }
.admin-box-note:last-child { margin-bottom: 0; }
.cc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(60px, 160px) 72px 78px;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.cc-row:last-of-type { border-bottom: 0; }
.cc-row--file { grid-template-columns: minmax(0, 1fr) auto 72px; }
.cc-row-name { min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.cc-row-note { display: block; margin-top: 2px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.cc-row .quota-bar { max-width: none; }
.cc-row-size, .cc-row-files { font-family: var(--mono); font-size: 11.5px; text-align: right; white-space: nowrap; }
.cc-row-size { color: var(--text); }
.cc-row-files { color: var(--muted); }
.cc-row-tag {
  padding: 2px 7px;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.cc-row-tag.is-current { color: var(--green); border-color: currentColor; }
.cc-old-note { margin-top: 10px; }

@media (max-width: 860px) {
  #bmx-admin-pane .pane-actions { flex-wrap: nowrap; }
  .admin-filter { flex: 1; width: auto; min-width: 0; font-size: 16px; }
  .admin-row { grid-template-columns: 1fr auto; }
  .admin-row .admin-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .admin-form { flex-wrap: wrap; }
  .admin-form input { font-size: 16px; }
  .admin-field, .admin-field--small { flex: 1 1 100%; }
  .admin-form--role input { flex: 1 1 100%; }
  .admin-box { margin: 12px 16px 6px; }
  #bmx-promo-form { margin: 12px 16px 0; }
  .admin-tabs { padding: 10px 16px; }
}
@media (max-width: 560px) {
  /* Zwei Spalten statt vier Zeilen */
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-stats .meta-cell { padding: 12px 14px; }
  .admin-stats .meta-cell:nth-child(2) { border-top: 0; }
  .admin-stats .meta-cell:nth-child(2n) { border-left: 1px solid var(--border); }
  /* Bereiche: Name und Größe, der Balken darunter */
  .cc-row { grid-template-columns: minmax(0, 1fr) 72px; row-gap: 7px; }
  .cc-row .quota-bar { grid-column: 1 / -1; grid-row: 2; }
  .cc-row-files { display: none; }
  .cc-row--file { grid-template-columns: minmax(0, 1fr) auto 64px; }
}

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 7px; }
.crumbs button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}
.crumbs button:hover { color: var(--accent); }
.crumbs button:last-child { color: var(--text-body); }
.crumbs .sep { color: var(--border); font-family: var(--mono); font-size: 11px; }

.drop-zone { position: relative; flex: 1; overflow-y: auto; }
.file-table { display: flex; flex-direction: column; }

.file-row {
  display: grid;
  grid-template-columns: 18px 26px 1fr 110px 150px 30px;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-soft);
  cursor: default;
  transition: background .12s ease;
}
.file-row:hover { background: var(--accent-soft); }
.file-row.is-selected { background: color-mix(in srgb, var(--accent) 11%, transparent); }
.file-row.drag-over { box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.file-row.dragging { opacity: .4; }
.file-row[data-dir="1"] { cursor: pointer; }

.file-head {
  display: grid;
  grid-template-columns: 18px 26px 1fr 110px 150px 30px;
  gap: 12px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.file-check { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }
.file-icon { display: flex; justify-content: center; color: var(--muted); }
.file-row[data-dir="1"] .file-icon { color: var(--accent); }
.file-name {
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size, .file-date { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.file-menu {
  display: flex;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.file-menu:hover { color: var(--accent); }

.files-empty {
  padding: 70px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}
.files-empty .headline {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Ablagefläche */
.drop-hint {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(2px);
  pointer-events: none;
  z-index: 5;
}
.drop-zone.is-dragging .drop-hint { display: flex; }
.drop-hint-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 46px 62px;
  border-color: var(--accent);
  background: var(--panel);
  color: var(--accent);
}
.drop-hint-inner p {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.files-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
  padding: 11px 18px;
  border-top: 1px solid var(--border);
}
.quota { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.quota-bar { flex: 1; height: 3px; background: var(--border-soft); max-width: 260px; }
.quota-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }

/* Upload-Fortschritt */
.upload-row {
  display: grid;
  grid-template-columns: 26px 1fr 110px;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.upload-name { font-size: 13px; color: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-track { grid-column: 1 / -1; height: 2px; background: var(--border-soft); }
.upload-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.upload-pct { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }
.upload-row.is-error .upload-pct { color: #f87171; }

/* ==========================================================================
   Dialoge
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 20px 20px;
  background: rgba(0,0,0,.55);
}
html[data-theme="light"] .modal { background: rgba(40,40,40,.28); }
.modal[hidden] { display: none; }

.modal-panel {
  width: 100%;
  max-width: 720px;
  max-height: 84vh;
  max-height: 84dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.modal--small .modal-panel { max-width: 440px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text);
}

/* ---- Verfassen ------------------------------------------------------- */
.compose-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.compose-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-soft);
}
.compose-row label {
  flex: none;
  width: 58px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.compose-row input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 12px 0;
  font-size: 13.5px;
}
.compose-toggles { display: flex; gap: 5px; flex: none; }

.compose-form textarea {
  flex: 1;
  min-height: 240px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 18px 20px;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.7;
  resize: none;
}

.compose-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex: none;
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft);
}
.compose-att {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-body);
}
.compose-att button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.compose-att button:hover { color: #f87171; }

.compose-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.compose-foot-left { display: flex; align-items: center; gap: 12px; }
.compose-status { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---- Kleiner Dialog -------------------------------------------------- */
.prompt-body { flex: 1; overflow-y: auto; padding: 20px; }
.prompt-body p { margin: 0 0 14px; color: var(--text-body); font-size: 13.5px; line-height: 1.6; }
.prompt-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  flex: none;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.pick-list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.pick {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-body);
  font-family: var(--mono);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.pick:hover { background: var(--accent-soft); color: var(--text); }
.pick[data-depth="1"] { padding-left: 28px; }
.pick[data-depth="2"] { padding-left: 44px; }
.pick[data-depth="3"] { padding-left: 60px; }

/* ==========================================================================
   Hinweise (Toasts)
   ========================================================================== */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
}
.toast {
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  background: var(--panel);
  color: var(--text-body);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 16px 40px rgba(0,0,0,.4);
  animation: toast-in .18s ease;
}
.toast--error { border-left-color: #f87171; color: #f87171; }
.toast--ok    { border-left-color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Kleinere Bildschirme
   ========================================================================== */
@media (max-width: 1100px) {
  :root { --side-w: 226px; --list-w: 320px; }   /* hier bis 20 Zeichen */
  .nav-user { display: none; }
}

/* --------------------------------------------------------------------------
   Handy und kleine Tablets
   Ziel: als installierte App bedienbar — Fingergrößen statt Mausgrößen,
   keine abgeschnittenen Ränder auf Geräten mit Notch, kein Zoom-Sprung
   beim Antippen von Eingabefeldern.
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {

  /* ---- Rahmen ---------------------------------------------------------- */
  .app { grid-template-columns: 1fr; position: relative; }
  .app.files-open { grid-template-columns: 1fr; }

  .list-pane { border-right: 0; }
  .app:not(.reading) .read-pane { display: none; }
  .app.reading .list-pane { display: none; }
  .files-pane { grid-column: 1 / -1; }

  /* Sichere Bereiche (Notch, Home-Indikator) */
  .site-nav { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .pane-foot, .files-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .reader-body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .msg-list, .drop-zone { overscroll-behavior: contain; }

  /* ---- Kopfzeile ------------------------------------------------------- */
  /* Der Markenname weicht, damit die Suche auf dem Handy erhalten bleibt. */
  .brand { display: none; }
  .nav-mid { display: flex; padding: 0 10px; }
  .nav-search { max-width: none; height: 34px; }
  .nav-search input { font-size: 16px; }   /* < 16px löst in Safari Zoom aus */
  .nav-right a { padding: 0 14px; font-size: 11px; }

  /* ---- Seitenleiste als Schublade ------------------------------------- */
  .side {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(280px, 82vw);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .22s ease;
    will-change: transform;
  }
  .app.side-open .side { transform: none; }

  .side-scrim {
    position: absolute;
    inset: 0;
    z-index: 29;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  .app.side-open .side-scrim { opacity: 1; pointer-events: auto; }

  /* ---- Fingerfreundliche Ziele ---------------------------------------- */
  .folder { padding: 13px 12px; font-size: 13.5px; }
  .files-entry { padding: 18px 15px; }
  .compose-btn { padding: 15px 14px; }
  .chip { padding: 10px 14px; font-size: 11px; }
  .icon-btn { width: 40px; height: 40px; }
  .msg { padding: 15px 16px 16px; }
  .msg-check, .file-check { width: 18px; height: 18px; }
  .file-row { padding: 15px 16px; }
  .pick { padding: 14px 14px; }
  .attach { padding: 11px 13px; }

  /* ---- Leseansicht ----------------------------------------------------- */
  .reader-head, .reader-body, .reader-actions, .attach-strip, .reader-notice {
    padding-left: 18px;
    padding-right: 18px;
  }
  .reader-subject { font-size: 18px; }
  .reader-key { width: 54px; }

  /* Zurück-Schaltfläche: ohne sie käme man auf dem Handy nicht zur Liste
     zurück, weil dort die Escape-Taste fehlt. */
  .reader-back {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    width: 100%;
    padding: 13px 18px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
  }
  .reader-back:hover { color: var(--accent); }

  /* ---- Bereichskopf: Titel und Schaltflächen untereinander ------------- */
  .pane-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }
  .pane-actions { flex-wrap: wrap; }
  .crumbs { margin-top: 4px; }

  /* ---- Dateien --------------------------------------------------------- */
  .file-row, .file-head { grid-template-columns: 18px 24px 1fr 84px 34px; }
  .file-date, .col-date { display: none; }
  .drop-hint-inner { padding: 34px 38px; }

  /* ---- Dialoge --------------------------------------------------------- */
  .modal { padding: 0; }
  .modal-panel {
    max-width: none;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-panel.tickbox::before,
  .modal-panel.tickbox::after { display: none; }

  .compose-row input,
  .compose-form textarea { font-size: 16px; }
  .compose-form textarea { min-height: 180px; }

  .toasts { right: 12px; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; }
}

/* Auf dem Handy gibt es keinen Mauszeiger — Hover-Zustände nicht kleben lassen */
@media (hover: none) {
  .msg:hover, .file-row:hover, .folder:hover, .files-entry:hover { background: transparent; }
  .msg[aria-current="true"], .msg.is-selected,
  .file-row.is-selected, .folder[aria-current="true"] { background: var(--accent-soft); }
  * { -webkit-tap-highlight-color: rgba(249, 115, 22, .18); }
}

/* Umschalter für die Seitenleiste und Zurück-Schaltfläche: nur mobil */
.side-toggle, .reader-back, .side-scrim { display: none; }
@media (max-width: 860px) {
  .side-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    flex: none;
    border: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
  }
  .side-toggle:hover { color: var(--accent); }
  .side-scrim { display: block; }
  .reader-back { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  .side, .quota-fill, .upload-fill, .toast { transition: none; animation: none; }
  .loading-bar { animation: none; }
}

/* ==========================================================================
   Speicheranzeige in der Seitenleiste
   ========================================================================== */
.side-foot {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid var(--border-soft);
}
.side-foot .quota-bar { max-width: none; width: 100%; }

/* ==========================================================================
   Blog
   ========================================================================== */
.post-table { flex: 1; overflow-y: auto; }

.post-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background .12s ease;
}
.post-row:hover { background: var(--accent-soft); }

.post-main { min-width: 0; }
.post-row h3 {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-row .post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.post-state {
  flex: none;
  padding: 4px 9px;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.post-state.is-live { border-color: var(--green); color: var(--green); }
.post-state.is-draft { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   Editor
   ========================================================================== */
.modal--wide .modal-panel { max-width: 860px; }

.editor-head-actions { display: flex; align-items: center; gap: 12px; }
.editor-status { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.editor-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px;
}

.editor-title-input {
  width: 100%;
  margin-bottom: 16px;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.editor-title-input:focus { outline: none; border-bottom-color: var(--accent); }

.editor-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.editor-field { display: block; }
.editor-field input { font-size: 13px; padding: 9px 11px; }

.editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-bottom: 0;
  background: var(--panel);
}
.tool {
  min-width: 32px;
  padding: 7px 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-body);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.tool:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.tool[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.tool-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }

.editor-area {
  min-height: 320px;
  padding: 20px 22px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-body);
  font-size: 15px;
  line-height: 1.75;
  overflow-wrap: break-word;
}
.editor-area:focus { outline: none; border-color: var(--accent); }
.editor-area:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}
.editor-area h2 { margin: 26px 0 10px; font-size: 20px; font-weight: 700; color: var(--text); }
.editor-area h3 { margin: 22px 0 8px; font-size: 16.5px; font-weight: 700; color: var(--text); }
.editor-area h2:first-child, .editor-area h3:first-child { margin-top: 0; }
.editor-area p { margin: 0 0 14px; }
.editor-area a { color: var(--accent); }
.editor-area ul, .editor-area ol { margin: 0 0 14px; padding-left: 22px; }
.editor-area li { margin-bottom: 6px; }
.editor-area blockquote {
  margin: 0 0 14px;
  padding: 4px 0 4px 16px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}
.editor-area pre {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 13px;
  overflow-x: auto;
  white-space: pre-wrap;
}
.editor-area img { max-width: 100%; height: auto; border: 1px solid var(--border); }

.editor-info {
  margin: 12px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.editor-foot-right { display: flex; align-items: center; gap: 9px; }
.editor-state { font-family: var(--mono); font-size: 11px; color: var(--muted); }
@media (max-width: 860px) {
  .editor-meta { grid-template-columns: 1fr; gap: 10px; }
  .editor-body { padding: 16px; }
  .editor-area { padding: 16px; min-height: 240px; font-size: 16px; }
  .editor-title-input { font-size: 19px; }
  /* Drei Elemente brauchen drei Spalten — sonst rutscht das Menü um. */
  .post-row { grid-template-columns: 1fr auto auto; gap: 8px; padding: 14px 16px; }
  .post-state { padding: 3px 7px; font-size: 9px; letter-spacing: .08em; }
  .editor-foot { flex-wrap: wrap; }
  .editor-foot-right { width: 100%; justify-content: flex-end; }
}

/* ==========================================================================
   Editor: maximiertes Fenster
   ========================================================================== */
#editor-max .icon-collapse { display: none; }
#editor.is-max #editor-max .icon-expand   { display: none; }
#editor.is-max #editor-max .icon-collapse { display: block; }

#editor.is-max { padding: 0; }
#editor.is-max .modal-panel {
  max-width: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: none;
}
/* Die Eckmarkierungen liegen im Vollbild außerhalb des Sichtbereichs */
#editor.is-max .modal-panel.tickbox::before,
#editor.is-max .modal-panel.tickbox::after { display: none; }

/* Mehr Platz nutzen: Schreibfläche füllt die freie Höhe */
#editor.is-max .editor-body { display: flex; flex-direction: column; }
#editor.is-max .editor-area { flex: 1; min-height: 45vh; }
#editor.is-max .editor-title-input { font-size: 26px; }

/* Auf dem Handy ist der Dialog ohnehin bildschirmfüllend */
@media (max-width: 860px) {
  #editor-max { display: none; }
}

/* ==========================================================================
   Bild einfügen
   ========================================================================== */
.linklike {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.imgpick-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 22px; }
.imgpick-head { margin: 26px 0 14px; }

.imgdrop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 38px 24px;
  border: 1px dashed var(--border);
  color: var(--muted);
  text-align: center;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.imgdrop.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.imgdrop p { margin: 0; color: var(--text-body); font-size: 14px; }
.imgdrop-hint { font-family: var(--mono); font-size: 10.5px; }

.imgpick-progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.imgpick-progress .upload-track { flex: 1; }
.imgpick-status { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }

.imggrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
.imgcard {
  position: relative;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  transition: border-color .15s ease;
}
.imgcard:hover { border-color: var(--accent); }
.imgcard img { display: block; width: 100%; height: 96px; object-fit: cover; }
.imgcard-meta {
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.imgcard-del {
  position: absolute;
  top: 5px; right: 5px;
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, color .15s ease;
}
.imgcard:hover .imgcard-del { opacity: 1; }
.imgcard-del:hover { color: #f87171; border-color: #f87171; }
.imggrid-empty { grid-column: 1 / -1; padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

/* ==========================================================================
   Bild im Editor: Auswahl und schwebende Leiste
   ========================================================================== */
.editor-area .post-figure { position: relative; }
.editor-area .post-figure.is-selected img { outline: 2px solid var(--accent); outline-offset: 2px; }
.editor-area .post-figure figcaption:empty::before {
  content: "Bildunterschrift…";
  color: var(--muted);
}

.imgbar {
  position: fixed;
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
}
.imgbar-row { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.imgbar-label {
  margin-right: 4px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.imgbar-value { font-family: var(--mono); font-size: 10.5px; color: var(--text-body); min-width: 44px; }
.imgbar input[type="range"] { width: 150px; accent-color: var(--accent); }
.tool--danger:hover { color: #f87171; border-color: #f87171; background: rgba(248, 113, 113, .07); }

/* ==========================================================================
   Zuschneiden
   ========================================================================== */
.crop-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
  overflow: hidden;
}
.crop-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  user-select: none;
  touch-action: none;
}
.crop-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 52vh;
}
/* Mehr Fläche zum Zuschneiden als bei den übrigen Dialogen */
#cropper .modal-panel { max-width: 900px; }

.crop-box {
  position: absolute;
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .58);
  cursor: move;
}
/* Drittel-Linien als Hilfe beim Ausrichten */
.crop-box::before, .crop-box::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .45;
}
.crop-box::before {
  background:
    linear-gradient(to right, transparent 33.33%, var(--accent) 33.33%, var(--accent) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
    linear-gradient(to right, transparent 66.66%, var(--accent) 66.66%, var(--accent) calc(66.66% + 1px), transparent calc(66.66% + 1px));
}
.crop-box::after {
  background:
    linear-gradient(to bottom, transparent 33.33%, var(--accent) 33.33%, var(--accent) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
    linear-gradient(to bottom, transparent 66.66%, var(--accent) 66.66%, var(--accent) calc(66.66% + 1px), transparent calc(66.66% + 1px));
}

.crop-handle {
  position: absolute;
  width: 14px; height: 14px;
  background: var(--accent);
  z-index: 2;
}
.crop-handle[data-corner="nw"] { top: -7px;    left: -7px;   cursor: nwse-resize; }
.crop-handle[data-corner="ne"] { top: -7px;    right: -7px;  cursor: nesw-resize; }
.crop-handle[data-corner="sw"] { bottom: -7px; left: -7px;   cursor: nesw-resize; }
.crop-handle[data-corner="se"] { bottom: -7px; right: -7px;  cursor: nwse-resize; }

.crop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.crop-ratios, .crop-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.crop-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.crop-size { font-family: var(--mono); font-size: 11px; color: var(--muted); }

@media (max-width: 860px) {
  .imgbar { left: 8px !important; right: 8px; width: auto; }
  .imgbar input[type="range"] { width: 110px; }
  .crop-stage img { max-height: 42vh; }
}

/* ==========================================================================
   Notizen
   ========================================================================== */
.note-pin {
  flex: none;
  border: 0;
  padding: 4px 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.note-pin:hover { color: var(--accent); }
.note-pin[aria-pressed="true"] { color: var(--accent); }

/* ==========================================================================
   Aufgaben
   ========================================================================== */
.todo-add {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.todo-add input[type="text"] { flex: 1; }
.todo-add select, .todo-add input[type="date"] {
  width: auto;
  flex: none;
  font-family: var(--mono);
  font-size: 12px;
  padding: 10px 11px;
}
.todo-add .btn { flex: none; }

.todo-body { flex: 1; overflow-y: auto; }

.todo-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

.todo-item {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  align-items: start;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
  transition: background .12s ease;
}
.todo-item:hover { background: var(--accent-soft); }
.todo-item.is-done .todo-text { color: var(--muted); text-decoration: line-through; }

.todo-check {
  width: 17px; height: 17px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.todo-main { min-width: 0; }
.todo-text {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  cursor: text;
}
.todo-text:focus { outline: none; border-bottom: 1px solid var(--accent); }
.todo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.todo-due.is-over { color: #f87171; }
.todo-due.is-soon { color: var(--accent); }

.todo-prio {
  flex: none;
  padding: 3px 7px;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.todo-prio.p2 { border-color: var(--accent); color: var(--accent); }
.todo-prio.p0 { opacity: .55; }

.todo-empty { padding: 46px 24px; text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.todo-empty .headline {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ==========================================================================
   KI
   ========================================================================== */
.ai-layout { display: flex; flex: 1; min-height: 0; }

.ai-history {
  flex: none;
  width: 230px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.ai-chat-item {
  position: relative;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border-soft);
  border-left: 2px solid transparent;
  color: var(--text-body);
}
.ai-chat-item:hover { background: var(--accent-soft); }
.ai-chat-item[aria-current="true"] { border-left-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.ai-chat-open {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 12px 6px 12px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.ai-chat-text { display: block; min-width: 0; }
.ai-chat-title {
  display: block;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-chat-meta { display: block; margin-top: 4px; font-family: var(--mono); font-size: 10px; color: var(--muted); }

/* Feld links: leer = gelesen, gefüllt = neue Antwort, pulsierend = läuft */
.ai-chat-mark {
  flex: none;
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border: 1px solid var(--border);
}
.ai-chat-item.is-unread .ai-chat-mark { border-color: var(--accent); background: var(--accent); }
.ai-chat-item.is-unread .ai-chat-title { color: var(--text); font-weight: 700; }
.ai-chat-item.is-unread .ai-chat-meta { color: var(--accent); }
.ai-chat-item.is-pending .ai-chat-mark { border-color: var(--accent); animation: ai-pulse 1.2s ease-in-out infinite; }

.ai-chat-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  opacity: 0;
  transition: opacity .12s ease;
}
.ai-chat-item:hover .ai-chat-actions,
.ai-chat-item:has(:focus-visible) .ai-chat-actions { opacity: 1; }   /* nur Tastatur, nicht nach einem Mausklick */
@media (hover: none) { .ai-chat-actions { opacity: 1; } }
.ai-chat-act {
  display: flex;
  padding: 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.ai-chat-act:hover, .ai-chat-act:focus-visible { color: var(--accent); }

/* Punkt am Knopf „Verlauf“, wenn dort Ungelesenes wartet */
#btn-ai-history.has-unread { position: relative; }
#btn-ai-history.has-unread::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 7px;
  height: 7px;
  background: var(--accent);
}

.ai-main { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.ai-thread { flex: 1; overflow-y: auto; padding: 20px 22px 8px; }

.ai-msg { margin-bottom: 22px; }
.ai-role {
  display: block;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.ai-msg--user .ai-role { color: var(--accent); }

.ai-text {
  color: var(--text-body);
  font-size: 14.5px;
  line-height: 1.75;
  word-wrap: break-word;
}
.ai-msg--user .ai-text {
  padding: 13px 16px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  white-space: pre-wrap;
}
.ai-text p { margin: 0 0 13px; }
.ai-text p:last-child { margin-bottom: 0; }
.ai-text ul, .ai-text ol { margin: 0 0 13px; padding-left: 22px; }
.ai-text li { margin-bottom: 5px; }
.ai-text h2, .ai-text h3 { margin: 20px 0 9px; font-size: 15px; font-weight: 700; color: var(--text); }
.ai-text code {
  padding: 2px 5px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  font-family: var(--mono);
  font-size: .88em;
}
.ai-text pre {
  margin: 0 0 13px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
}
.ai-text pre code { padding: 0; border: 0; background: none; }

/* Denk-Balken: direkt unter der Frage, klappt den Gedankengang auf */
.ai-think {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  background: var(--panel);
}
.ai-think-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}
.ai-think-head:hover, .ai-think-head:focus-visible { color: var(--accent); }
.ai-think-icon {
  flex: none;
  width: 8px;
  height: 8px;
  border: 1px solid currentColor;
}
.ai-think.is-live .ai-think-icon { border-color: var(--accent); background: var(--accent); animation: ai-pulse 1.2s ease-in-out infinite; }
.ai-think.is-live .ai-think-label { color: var(--text); }
.ai-think-time { color: var(--muted); letter-spacing: .04em; }
.ai-think-chev {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s ease;
}
.ai-think.is-open .ai-think-chev { transform: translateY(2px) rotate(-135deg); }

/* Laufende Spur, solange Claude arbeitet */
.ai-think-track {
  position: relative;
  height: 2px;
  overflow: hidden;
  background: var(--border-soft);
}
.ai-think-track span {
  position: absolute;
  top: 0;
  left: -30%;
  width: 30%;
  height: 100%;
  background: var(--accent);
  animation: ai-track 1.6s ease-in-out infinite;
}
.ai-think.is-writing .ai-think-track span { animation-duration: 1s; }
@keyframes ai-track { 0% { left: -30%; } 100% { left: 100%; } }

.ai-think-body {
  max-height: 340px;
  overflow-y: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.ai-think-body:empty::before { content: attr(data-empty); font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  .files-entry.is-running .files-entry-icon,
  .ai-chat-item.is-pending .ai-chat-mark,
  .ai-think.is-live .ai-think-icon { animation: none; }
  .ai-think-track span { left: 0; width: 100%; animation: none; opacity: .6; }
}

.ai-usage { margin-top: 9px; font-family: var(--mono); font-size: 10px; color: var(--muted); }

.ai-compose { flex: none; border-top: 1px solid var(--border); padding: 14px 18px; }
.ai-compose textarea { resize: vertical; min-height: 62px; font-size: 14px; }
.ai-compose-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.ai-status { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.ai-notice {
  margin: 18px 22px;
  padding: 16px 18px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-body);
  font-size: 13.5px;
  line-height: 1.7;
}
.ai-notice strong { color: var(--text); }
.ai-notice code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
}

@media (max-width: 860px) {
  .todo-add { flex-wrap: wrap; }
  .todo-add input[type="text"] { flex: 1 1 100%; }
  .todo-item { grid-template-columns: 20px 1fr auto; }
  .ai-history { position: absolute; z-index: 20; height: 100%; background: var(--bg); }
  .ai-thread { padding: 16px; }
}

/* ==========================================================================
   KI: Modell- und Aufwandswahl
   ========================================================================== */
.ai-settings {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.ai-setting { display: flex; flex-direction: column; gap: 5px; }
.ai-setting-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.ai-setting select {
  width: auto;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 11.5px;
}
.ai-setting select:disabled { opacity: .4; cursor: not-allowed; }

/* ==========================================================================
   KI: Verbrauchsübersicht
   ========================================================================== */
.usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.usage-table th, .usage-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: right;
}
.usage-table th {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}
.usage-table th:first-child, .usage-table td:first-child { text-align: left; }
.usage-table td { font-family: var(--mono); font-size: 12px; color: var(--text-body); }
.usage-table td:first-child { color: var(--text); }
.usage-table tfoot td { border-bottom: 0; border-top: 1px solid var(--border); color: var(--text); }

.usage-head {
  margin: 22px 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.usage-head:first-child { margin-top: 0; }

.usage-note {
  margin: 18px 0 0;
  padding: 13px 15px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-body);
  font-size: 12.5px;
  line-height: 1.65;
}
.usage-note a { color: var(--accent); }
.usage-billing {
  margin: 16px 0 0;
  padding: 13px 15px;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-body);
}
.usage-billing strong { color: var(--text); font-size: 15px; }

@media (max-width: 860px) {
  .ai-compose-foot { flex-direction: column; align-items: stretch; gap: 10px; }
  .ai-settings { justify-content: space-between; }
  .ai-setting select { width: 100%; }
}

/* ==========================================================================
   KI: Guthabenanzeige
   ========================================================================== */
.ai-balance {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--text-body);
  white-space: nowrap;
}
.ai-balance .ai-balance-value { color: var(--text); font-size: 12px; }

/* Knapp und leer heben sich deutlich ab — hier ist Auffallen erwünscht */
.ai-balance.is-low {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.ai-balance.is-low .ai-balance-value { color: var(--accent); }
.ai-balance.is-empty {
  border-color: #f87171;
  background: rgba(248, 113, 113, .08);
  color: #f87171;
}
.ai-balance.is-empty .ai-balance-value { color: #f87171; }

/* Kosten unter einer einzelnen Antwort */
.ai-usage .ai-cost { color: var(--text-body); }

/* Hinweisstreifen bei knappem Guthaben */
.ai-warn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
}
.ai-warn.is-empty { background: rgba(248, 113, 113, .08); color: #f87171; }

/* Guthaben-Dialog */
.balance-current {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.8;
  color: var(--text-body);
}
.balance-current strong { color: var(--text); font-size: 16px; }
.balance-row { display: flex; justify-content: space-between; gap: 14px; }

@media (max-width: 860px) {
  .ai-balance { font-size: 9.5px; padding: 5px 8px; }
}

/* ==========================================================================
   Einstellungen (Zahnrad oben rechts)
   ========================================================================== */
.nav-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease;
}
.nav-gear:hover { color: var(--accent); }
.set-title {
  margin: 0 0 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.prompt-body .set-note { margin-bottom: 12px; font-size: 12.5px; }
.prompt-body .set-warn {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-body);
  font-size: 12px;
  line-height: 1.55;
}
.set-choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.set-choice[data-keep="0"] { grid-column: 1 / -1; }
.set-choice {
  padding: 10px 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-body);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.set-choice:hover { color: var(--text); border-color: var(--accent); }
.set-choice.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.set-choices + .set-warn + .set-title { margin-top: 22px; }

@media (max-width: 900px) {
  .nav-gear { width: 46px; }
  .set-choices { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================================================
   Bildlaufleisten im Stil der Apps
   Kein scrollbar-color in Chromium: Damit nähme es wieder seine eigene Leiste.
   ========================================================================== */
* { --app-thumb: color-mix(in srgb, var(--muted) 55%, transparent); }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track {
  background: linear-gradient(var(--border), var(--border)) center / 1px 100% no-repeat;
}
*::-webkit-scrollbar-track:horizontal { background-size: 100% 1px; }
*::-webkit-scrollbar-thumb {
  min-height: 32px;
  border: 3px solid transparent;
  background: var(--app-thumb) padding-box;
}
*::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:active {
  border-width: 2px;
  background-color: var(--accent);
}
*::-webkit-scrollbar-button,
*::-webkit-scrollbar-corner { display: none; background: transparent; }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--app-thumb) transparent; }
}
