:root {
  --bg: #14161a;
  --panel: #1d2026;
  --panel-2: #23262e;
  --border: #32363f;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #d99a3d;
  --accent-2: #b27c2c;
  --danger: #d05555;
  font-size: 15px;
}

* { box-sizing: border-box; }

/* Das hidden-Attribut muss IMMER gewinnen: Autoren-Regeln wie
   #app-view { display: flex } überstimmen sonst die UA-Default-Regel
   [hidden] { display: none } — beide Views wären dauerhaft sichtbar
   (Login oben, App eine Bildschirmhöhe darunter). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  height: 100vh;
}

button, .button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
button:hover, .button:hover { border-color: var(--accent); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); }

input[type="text"], input[type="password"], input[type="search"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
}
input:focus { outline: none; border-color: var(--accent); }

.muted { color: var(--muted); }
.error { color: var(--danger); }
.spacer { flex: 1; }
.linklike { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* --- Login --- */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
#login-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 320px;
}
#login-form h1 { margin: 0; text-align: center; }
#login-form .subtitle { margin: -10px 0 10px; text-align: center; color: var(--muted); }
#login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
#login-form button { background: var(--accent); color: #1a1a1a; font-weight: 600; border: none; }
#login-form button:hover { background: var(--accent-2); }

/* --- App layout --- */
#app-view { display: flex; flex-direction: column; height: 100vh; }

header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; white-space: nowrap; }
#search { width: 34%; min-width: 220px; }
#me { color: var(--muted); white-space: nowrap; }

main { display: flex; flex: 1; min-height: 0; }

#browser {
  width: 44%;
  min-width: 340px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.browser-bar {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-right: 8px;
}
.browser-bar #btn-newdir { white-space: nowrap; }

#breadcrumb {
  flex: 1;
  padding: 10px 14px;
  white-space: nowrap;
  overflow-x: auto;
}
#breadcrumb a { color: var(--accent); text-decoration: none; }
#breadcrumb a:hover { text-decoration: underline; }
#breadcrumb .sep { color: var(--muted); margin: 0 2px; }

#dropzone { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
#dropzone.drag { outline: 2px dashed var(--accent); outline-offset: -8px; }
.drop-hint { text-align: center; color: var(--muted); padding: 14px; margin-top: auto; }

#filelist, #resultlist { list-style: none; margin: 0; padding: 6px; }
#filelist li, #resultlist li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
#filelist li:hover, #resultlist li:hover { background: var(--panel-2); }
#filelist li.note { color: var(--muted); cursor: default; font-style: italic; }
#filelist li.note:hover { background: transparent; }
#filelist li.selected { background: var(--panel-2); outline: 1px solid var(--border); }
.entry-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-size, .entry-score { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.entry-excerpt { display: block; color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#search-results { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

/* --- Preview --- */
#preview { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#preview-empty { display: flex; align-items: center; justify-content: center; flex: 1; }
#preview-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.preview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
#preview-path { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#preview-meta {
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  flex-wrap: wrap;
}
#preview-meta div { display: flex; gap: 6px; }
#preview-meta dt { font-weight: 600; }
#preview-meta dd { margin: 0; }

#preview-body { flex: 1; overflow: auto; padding: 14px; min-height: 0; }
#preview-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.88rem;
}
#preview-body img { max-width: 100%; height: auto; border-radius: 6px; }
#preview-body iframe { width: 100%; height: 100%; min-height: 70vh; border: 1px solid var(--border); border-radius: 6px; background: #fff; }

footer {
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}
