:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #e1e4e8;
  --color-text: #1f2328;
  --color-muted: #6b7280;
  --color-primary: #0969da;
  --color-primary-hover: #0550ae;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.topbar h1 {
  font-size: 1.25rem;
  margin: 0;
}

main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.status {
  color: var(--color-muted);
}

.status.error {
  color: #b42318;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.file-table th,
.file-table td {
  text-align: left;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.file-table th {
  background: #fafbfc;
  color: var(--color-muted);
  font-weight: 600;
}

.file-table tr:last-child td {
  border-bottom: none;
}

.file-name {
  font-weight: 500;
}

.file-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-ghost:hover {
  background: #f0f2f4;
}

/* --- Viewer --- */

.viewer-body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.viewer-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.viewer-topbar h1 {
  font-size: 1rem;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-frame-wrap {
  flex: 1;
  position: relative;
}

#collabora-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.viewer-overlay {
  position: absolute;
  inset: 0;
  background: var(--color-bg);
  color: var(--color-muted);
  padding: 1rem;
  text-align: center;
}

/* Author-Styles überschreiben sonst das [hidden]-Attribut (gleiche Spezifität, aber
   Autor-Regeln schlagen User-Agent-Regeln unabhängig davon) - daher display explizit
   an ":not([hidden])" binden, damit "overlay.hidden = true" wirklich greift. */
.viewer-overlay:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
}
