:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --border: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --danger: #d70015;
  --row-hover: #f5f5f7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --card-bg: #2c2c2e;
    --text: #f5f5f7;
    --text-muted: #a1a1a6;
    --border: #48484a;
    --accent: #0a84ff;
    --accent-hover: #3396ff;
    --row-hover: #3a3a3c;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* --- Login-Karte --- */

body:not(.explorer-body) {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 10px;
}

.field-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

/* --- Buttons --- */

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn-block {
  width: 100%;
  margin-top: 18px;
  padding: 11px 16px;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 6px;
  opacity: 0.7;
}

.icon-btn:hover { opacity: 1; background: var(--row-hover); }

.action-icons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.clipboard-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.clipboard-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Fehler / Fortschritt (gemeinsam) --- */

.error {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 13px;
}

.progress-wrap {
  margin: 12px 0;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.progress-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* --- Explorer --- */

.explorer {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.explorer-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-email {
  font-size: 13px;
  color: var(--text-muted);
}

.scope-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.scope-tab {
  background: none;
  border: none;
  padding: 8px 4px;
  margin-right: 16px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.scope-tab:hover {
  color: var(--text);
}

.scope-tab.active {
  color: var(--text);
  font-weight: 500;
  border-bottom-color: var(--accent);
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 28px 0 14px;
}

.section-title:first-of-type {
  margin-top: 8px;
}

.admin-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
}

.quota-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.quota-bar {
  flex: 1;
  max-width: 220px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.quota-fill-warn {
  background: var(--danger);
}

.quota-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 20px;
  font-size: 14px;
}

.crumb {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}

.crumb:last-child { color: var(--text); font-weight: 500; }
.crumb:hover { background: var(--row-hover); }

.crumb-sep {
  color: var(--text-muted);
  opacity: 0.6;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dropzone-inline {
  flex: 1;
  min-width: 220px;
  padding: 10px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone-inline:hover,
.dropzone-inline.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.file-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.sort-header:hover { color: var(--text); }

.sort-header.active { color: var(--text); }

.sort-arrow {
  font-size: 10px;
  opacity: 0.8;
}

.file-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.file-table tr:hover td { background: var(--row-hover); }

.col-size, .col-date {
  color: var(--text-muted);
  white-space: nowrap;
}

.col-actions {
  width: 1%;
  text-align: right;
}

.col-name { width: 100%; }

.item-icon {
  margin-right: 8px;
}

.name-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.name-link:hover { text-decoration: underline; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px 0;
}

/* --- Mobil --- */

@media (max-width: 640px) {
  .card {
    padding: 24px 20px;
    border-radius: 14px;
  }

  .explorer {
    padding: 20px 16px 48px;
  }

  h1 {
    font-size: 19px;
  }

  .explorer-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .header-right {
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .btn,
  #folder-picker-label {
    text-align: center;
  }

  .dropzone-inline {
    min-width: 0;
    padding: 14px 12px;
  }

  .btn,
  .crumb,
  .scope-tab {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  .name-link {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
  }

  .icon-btn {
    padding: 10px 12px;
    font-size: 17px;
  }

  .file-table .col-date {
    display: none;
  }

  .file-table th,
  .file-table td {
    padding: 10px 8px;
  }

  .col-actions .btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .clipboard-bar {
    flex-wrap: wrap;
  }

  .clipboard-text {
    flex: 1 1 100%;
    white-space: normal;
  }

  .quota-wrap {
    flex-wrap: wrap;
  }

  .quota-bar {
    max-width: none;
    flex: 1 1 100%;
    order: 2;
  }
}
