:root {
  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #eef1ef;
  --line: #dde2df;
  --text: #1b2421;
  --muted: #5f6b66;
  --accent: #2b7566;
  --accent-ink: #ffffff;
  --accent-soft: #e2efeb;
  --danger: #b3261e;
  --warn-bg: #fff4d6;
  --warn-ink: #5c4300;
  --radius: 10px;
  --shadow: 0 8px 30px rgb(0 0 0 / 0.14);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1a201e;
    --surface-2: #232b28;
    --line: #2f3a36;
    --text: #e8eeeb;
    --muted: #9aa8a2;
    --accent: #5cbba8;
    --accent-ink: #0b1714;
    --accent-soft: #1f322d;
    --danger: #ff8a80;
    --warn-bg: #3a2f10;
    --warn-ink: #f3dc9a;
    --shadow: 0 8px 30px rgb(0 0 0 / 0.5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error-text { color: var(--danger); margin: 0; }
.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 0.5rem 0.75rem; border-radius: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Bedienelemente */
.btn, .icon-btn {
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.45rem 0.85rem; display: inline-flex; align-items: center; gap: 0.4rem;
  transition: background-color 0.12s, border-color 0.12s;
}
.btn:hover, .icon-btn:hover { background: var(--surface-2); }
.btn:active, .icon-btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); }
.icon-btn { padding: 0.35rem; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
.icon { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
.icon svg { width: 100%; height: 100%; }
.btn .icon { width: 1.1em; height: 1.1em; }

input[type=text], input[type=email], input[type=password], input[type=search], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.7rem; width: 100%;
}
label { display: grid; gap: 0.25rem; font-size: 0.9rem; color: var(--muted); }
label input, label select { color: var(--text); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.5rem; box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.narrow { width: min(380px, 100%); }
.card.narrow { display: grid; gap: 0.9rem; }
dialog:not([open]) { display: none; }
.share-card { width: min(520px, 100%); display: grid; gap: 1rem; }

.banner { background: var(--warn-bg); color: var(--warn-ink); padding: 0.4rem 1rem; text-align: center; font-size: 0.85rem; }

/* App-Gerüst */
.app { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.top {
  display: flex; align-items: center; gap: 1rem; padding: 0.6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
#search-form { flex: 1; max-width: 420px; }
#user-email { margin-left: auto; }
.layout { display: grid; grid-template-columns: 190px 1fr; min-height: 0; }
.side { padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); }
.side a {
  padding: 0.5rem 0.75rem; border-radius: 8px; color: var(--text); text-decoration: none;
}
.side a:hover { background: var(--surface-2); }
.side a[aria-current=page] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.main { padding: 1rem 1.5rem 3rem; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; font-size: 1.05rem; }
.crumbs a { color: var(--text); text-decoration: none; padding: 0.1rem 0.3rem; border-radius: 6px; }
.crumbs a:hover { background: var(--surface-2); }
.crumbs .sep { color: var(--muted); }
.crumbs strong { padding: 0.1rem 0.3rem; }
.actions { display: flex; gap: 0.5rem; }

.content { border-radius: var(--radius); min-height: 200px; outline: none; }
.main.dragging { outline: 2px dashed var(--accent); outline-offset: -8px; background: var(--accent-soft); border-radius: var(--radius); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Liste */
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list th { text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--muted); padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); }
.list td { padding: 0.35rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: var(--surface-2); }
.list .col-size, .list .col-date { white-space: nowrap; color: var(--muted); font-size: 0.88rem; }
.list .col-actions { white-space: nowrap; text-align: right; width: 1%; }
.name-cell { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.name-cell .icon { color: var(--muted); }
.name-cell .icon.folder { color: var(--accent); }
.name-link {
  font: inherit; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer;
  text-align: left; text-decoration: none; overflow-wrap: anywhere;
}
.name-link:hover { text-decoration: underline; }
.path-hint { display: block; font-size: 0.8rem; color: var(--muted); }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.section-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }

/* Menü */
.menu {
  position: fixed; z-index: 50; min-width: 190px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  display: grid;
}
.menu button {
  font: inherit; color: var(--text); text-align: left; background: none; border: 0; cursor: pointer;
  padding: 0.5rem 0.75rem; border-radius: 6px;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }

/* Dialoge */
.dlg {
  width: min(480px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 14px; padding: 1.25rem; box-shadow: var(--shadow);
}
.dlg.wide { width: min(920px, calc(100vw - 2rem)); }
.dlg.narrow { width: min(380px, calc(100vw - 2rem)); }
.dlg::backdrop { background: rgb(10 14 12 / 0.55); }
.dlg form { display: grid; gap: 0.9rem; }
.dlg-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.dlg-head h2 { flex: 1; margin: 0; overflow-wrap: anywhere; }
/* Im HTML steht "OK" zuerst (Eingabetaste löst die erste Schaltfläche aus), angezeigt wird es rechts */
.dlg-foot { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 0.5rem; }
.row { display: flex; align-items: end; gap: 0.75rem; }
.row label { flex: 1; }
.preview-body { display: grid; place-items: center; min-height: 160px; max-height: 70vh; overflow: auto; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 68vh; border-radius: 8px; }
.preview-body iframe { width: 100%; height: 68vh; border: 0; border-radius: 8px; background: #fff; }
.preview-body pre {
  width: 100%; margin: 0; padding: 0.75rem; background: var(--surface-2); border-radius: 8px;
  white-space: pre-wrap; overflow-wrap: anywhere; font: 0.85rem/1.5 ui-monospace, Consolas, monospace;
}
.share-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.6rem; }
.share-list li { border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.75rem; display: grid; gap: 0.4rem; }
.share-list .status { font-size: 0.82rem; color: var(--muted); }
.share-list .link-row { display: flex; gap: 0.5rem; }
.share-list input { font-size: 0.82rem; }

/* Freigabeseite */
.share-file { display: flex; align-items: center; gap: 0.9rem; }
.share-file .icon { width: 2.4rem; height: 2.4rem; color: var(--accent); }
.share-file h1 { font-size: 1.2rem; overflow-wrap: anywhere; margin: 0; }
.share-preview { margin: 0.5rem 0 1rem; }
.share-preview img { max-width: 100%; border-radius: 8px; }
.privacy { border-top: 1px solid var(--line); padding-top: 0.75rem; color: var(--muted); }
.privacy summary { cursor: pointer; }
.legal-links { display: flex; gap: 1rem; margin: 0; }

/* Hinweis */
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 0.6rem 1rem; border-radius: 10px; max-width: min(560px, calc(100vw - 2rem));
  transition: opacity 0.18s, transform 0.18s; z-index: 100; font-size: 0.92rem;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); padding: 0.5rem 0.75rem; overflow-x: auto; }
  .main { padding: 1rem 0.75rem 3rem; }
  #user-email { display: none; }
  .top { gap: 0.5rem; }
  #logout { margin-left: auto; }
  .list .col-size, .list .col-date, .list th.col-size, .list th.col-date { display: none; }
  .path-hint { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
