:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e5e9;
  --primary: #30357f;
  --primary-dark: #242964;
  --link: #30357f;
  --link-hover: #242964;
  --answered: #16a34a;
  --answered-bg: #dcfce7;
  --open: #d97706;
  --open-bg: #fef3c7;
  --claimed: #2563eb;
  --claimed-bg: #dbeafe;
  --overdue: #dc2626;
  --overdue-bg: #fee2e2;
  --tag: #7c3aed;
  --tag-bg: #ede9fe;
  --error: #dc2626;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.sr-only {
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

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

/* Einheitliche, gut erkennbare Controls statt Browser-Standardoptik. */
input, textarea, select {
  background: var(--surface);
  color: var(--text);
  color-scheme: light dark;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select {
  border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 1px 2px rgba(31, 36, 48, 0.04); font: inherit;
  min-height: 42px; padding: 9px 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover, textarea:hover, select:hover { border-color: #b8bdc8; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus, textarea:focus, select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); outline: none;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%234f46e5' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8'%3E%3Cpath d='m3 6 5 5 5-5'/%3E%3C/svg%3E");
  background-position: right 12px center; background-repeat: no-repeat; padding-right: 40px;
}
input[type="checkbox"] {
  appearance: none; background: var(--surface); border: 1.5px solid #aeb4c0; border-radius: 5px;
  cursor: pointer; flex: 0 0 19px; height: 19px; margin: 0; transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease; width: 19px;
}
input[type="checkbox"]:hover { border-color: var(--primary); }
input[type="checkbox"]:checked {
  background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m3.1 8.2 3 3 6.8-6.7' fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.1'/%3E%3C/svg%3E");
  background-position: center; background-repeat: no-repeat; border-color: var(--primary);
}
input[type="checkbox"]:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); outline: none; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: 9px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--link);
  text-decoration: none;
}
.brand-logo { border-radius: 50%; height: 34px; object-fit: cover; width: 34px; }

.nav-links { align-items: center; display: flex; flex-wrap: wrap; gap: 4px; }
.nav-links a, .nav-dropdown-toggle {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 10px;
  text-decoration: none;
}

.nav-group { align-items: center; display: flex; gap: 4px; }
.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}
.nav-links a:hover, .nav-dropdown-toggle:hover { background: var(--bg); color: var(--text); }
.nav-user { color: var(--text) !important; }
.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 8px;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  z-index: 20;
}
.nav-dropdown-menu a {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
}
.nav-dropdown-menu a:hover { background: var(--bg); }
.nav-divider-h { height: 1px; background: var(--border); margin: 4px 0; }
.nav-links a[aria-current="page"] { background: color-mix(in srgb, var(--link) 12%, transparent); color: var(--link); }
.site-footer {
  text-align: center;
  padding: 24px 20px;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px;
}
body.is-embedded .container { padding: 20px; }

h1 { margin-top: 0; font-size: 1.6rem; }
.muted { color: var(--muted); }
.error { color: var(--error); font-weight: 500; }

.button {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.button:hover { background: var(--primary-dark); }
.button-small { padding: 8px 14px; font-size: 0.85rem; }
.button-secondary {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}
.button-secondary:hover { background: var(--bg); color: var(--text); border-color: var(--muted); }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  max-width: 360px;
  margin: 40px auto;
}
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.welcome-actions { display: flex; gap: 10px; }
.auth-card-wide { max-width: 480px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.auth-card textarea { resize: vertical; }

.password-field {
  position: relative;
  display: flex;
}
.password-field input {
  flex: 1;
  padding-right: 40px;
}
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 6px;
}

.compose-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 640px;
  margin-top: 16px;
}
.compose-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.compose-form textarea { resize: vertical; }
.feature-toggle-list { gap: 8px; margin-top: 16px; max-width: 640px; }
.feature-toggle-list .switch {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  min-height: 74px;
  padding: 12px 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.feature-toggle-list .switch:hover { border-color: var(--link); }
.feature-toggle-list .switch:has(input:focus-visible) { border-color: var(--link); box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 18%, transparent); }
.feature-toggle-list .switch-copy { min-width: 0; }
.feature-toggle-list .switch-copy strong { color: var(--text); }
.feature-toggle-list .switch-state { color: var(--muted); }

main p a, main li a, main td a { color: var(--link); }
main p a:hover, main li a:hover, main td a:hover { color: var(--link-hover); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); transform: translateY(-1px); }
.card-icon { font-size: 1.6rem; }
.card-title { font-weight: 600; }
.card-desc { font-size: 0.85rem; color: var(--muted); }

.upload-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 4px; }
.rename-form { display: flex; align-items: center; gap: 6px; }
.rename-form input[type="text"] { min-height: 34px; padding: 4px 8px; width: 160px; }
.list-pagination { display: flex; align-items: center; gap: 12px; margin-top: 10px; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  min-width: 220px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
}
.dropzone:hover { border-color: var(--primary); }
.dropzone:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; border-color: var(--primary); }
.dropzone.is-dragover { border-color: var(--primary); background: var(--claimed-bg); }
[data-drop-folder].is-dragover { outline: 2px dashed var(--primary); outline-offset: 2px; }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.dropzone-text { font-size: 0.85rem; color: var(--muted); }
.dropzone-files { font-size: 0.8rem; }

.quota-bar {
  height: 6px;
  max-width: 280px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 2px 0 12px;
}
.quota-bar-fill { height: 100%; background: var(--primary); }
.quota-bar-fill.is-warning { background: var(--open); }
.quota-bar-fill.is-critical { background: var(--overdue); }

.bulk-checkbox { align-self: center; margin-right: 4px; width: 18px; height: 18px; }
.select-all-label { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-size: 0.85rem; }

.thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  vertical-align: middle;
  margin-right: 6px;
  background: var(--bg);
}

.mail-list { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.mail-triage-list {
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.mail-card {
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 0;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(120px, auto);
  min-height: 92px;
  padding: 12px 14px;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.mail-card:last-child { border-bottom: 0; }
.mail-card:hover { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.mail-card.is-open { border-left-color: var(--open); }
.mail-card.is-answered { border-left-color: var(--answered); }
.mail-card.is-overdue { border-left-color: var(--overdue); }
.mail-card:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
.shortcut-hint { font-size: 0.8rem; margin: 4px 0 0; }

.live-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--claimed-bg);
  color: var(--claimed);
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.live-banner button {
  background: var(--claimed);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}
.mail-main { min-width: 0; }
.mail-subject { margin: 0; font-size: 0.96rem; font-weight: 650; line-height: 1.35; }
.mail-subject a {
  color: inherit;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-decoration: none;
}
.mail-subject a:hover { text-decoration: underline; }
.mail-meta { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mail-row-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  align-self: end;
  max-width: 156px;
  text-align: right;
}
.mail-row-assignee { color: var(--muted); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-answered { background: var(--answered-bg); color: var(--answered); }
.badge-open { background: var(--open-bg); color: var(--open); }
.badge-claimed { background: var(--claimed-bg); color: var(--claimed); }
.badge-overdue { background: var(--overdue-bg); color: var(--overdue); }
.badge-tag { background: var(--tag-bg); color: var(--tag); margin-left: 6px; font-size: 0.7rem; vertical-align: middle; }

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}
.filter-form input[type="search"] { flex: 1; min-width: 180px; }
.filter-form select {
  font-size: 0.9rem;
}
.mail-filter {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
}
.mail-filter-primary, .mail-filter-secondary { min-width: 0; }
.mail-filter input[type="search"], .mail-filter select { min-width: 0; width: 100%; }
.mail-filter-secondary {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(120px, 1fr) auto auto;
}
.mail-filter-details { align-self: center; color: var(--muted); font-size: 0.84rem; }
.mail-filter-details summary { cursor: pointer; list-style: none; white-space: nowrap; }
.mail-filter-details summary::-webkit-details-marker { display: none; }
.mail-filter-details summary::after { content: "⌄"; margin-left: 6px; }
.mail-filter-details[open] { position: relative; }
.mail-filter-dates {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px color-mix(in srgb, #000 20%, transparent);
  display: grid;
  gap: 8px;
  padding: 10px;
  position: absolute;
  right: 0;
  top: 28px;
  width: 260px;
  z-index: 10;
}
.mail-filter-dates label { align-items: center; display: grid; gap: 7px; grid-template-columns: auto minmax(0, 1fr); }
.mail-filter-dates input { min-width: 0; width: 100%; }
.mail-filter-secondary > .button { justify-self: end; white-space: nowrap; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.stats-table th, .stats-table td {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.stats-table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.stats-table tr:last-child td { border-bottom: none; }
.stats-table .timestamp { min-width: 145px; white-space: nowrap; }
.stats-table code { font-size: 0.82rem; white-space: nowrap; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.table-scroll .stats-table { min-width: 720px; }
.stat-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin: 20px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; gap: 3px; padding: 17px; }
.stat-card strong { font-size: 1.75rem; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.stat-card small { color: var(--muted); }
.stat-card-good { border-top: 4px solid var(--answered); }
.stat-card-open { border-top: 4px solid var(--open); }
.stats-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-section { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-top: 18px; padding: 18px; }
.stats-section h2 { font-size: 1.05rem; margin: 0 0 4px; }
.stats-section .stats-table { margin-bottom: 0; }
.stats-section-heading { align-items: start; display: flex; gap: 12px; justify-content: space-between; }
.stats-section-heading p { margin: 4px 0 0; }
.rank-badge { background: var(--claimed-bg); border-radius: 999px; color: var(--claimed); font-size: 0.82rem; font-weight: 700; padding: 6px 10px; white-space: nowrap; }
.personal-stat { align-items: baseline; display: flex; gap: 8px; margin-top: 16px; }
.personal-stat strong { color: var(--primary); font-size: 2rem; }
.personal-stat span { color: var(--muted); }
.is-own-row td { background: color-mix(in srgb, var(--claimed-bg) 42%, transparent); }
.tag-stats { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.tag-stat { align-items: center; display: grid; gap: 8px; grid-template-columns: minmax(105px, 1fr) 2fr auto; }
.tag-stat span { font-size: 0.88rem; }
.tag-stat-track { background: var(--bg); border-radius: 999px; height: 8px; overflow: hidden; }
.tag-stat-track i { background: var(--primary); border-radius: inherit; display: block; height: 100%; min-width: 0; }
.tag-stat strong { font-size: 0.85rem; min-width: 18px; text-align: right; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}

.mail-layout { align-items: flex-start; display: grid; gap: 24px; grid-template-columns: minmax(420px, 1fr) minmax(580px, 1.45fr); }
.mail-list-pane {
  min-width: 320px;
}
.mail-list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.mail-list-header h1 { margin-bottom: 4px; }
.mail-list-header .button { white-space: nowrap; }
.mail-detail-pane {
  position: sticky;
  top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.mail-detail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 75vh;
  text-align: center;
  padding: 20px;
}
.mail-detail-frame {
  width: 100%;
  height: 85vh;
  border: none;
  display: block;
}

.drive-frame {
  width: 100%;
  height: 80vh;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.mail-card.is-selected {
  border-left-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--primary);
}

@media (max-width: 1020px) {
  .mail-layout { grid-template-columns: 1fr; }
  .mail-list-pane, .mail-detail-pane { max-width: none; width: 100%; }
  .mail-detail-pane { position: static; }
  .mail-detail-frame, .mail-detail-placeholder { height: 60vh; }
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; padding: 12px 16px; }
  .brand { padding: 6px 0; }
  .nav-links { gap: 6px 10px; width: 100%; }
  .nav-links a, .nav-dropdown-toggle { min-height: 36px; padding: 7px 2px; }
  .nav-group { gap: 10px; }
  .nav-group-mail { order: -1; }
  .nav-user { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-dropdown-menu { min-width: min(250px, calc(100vw - 32px)); right: auto; left: 0; }
  .container { padding: 22px 14px; }
  .mail-list-header { align-items: stretch; flex-direction: column; }
  .mail-list-header .button { align-self: flex-start; }
  .mail-card { align-items: start; gap: 10px; padding: 12px; }
  .mail-main { min-width: 0; }
  .mail-row-status { max-width: 110px; }
  .filter-form > input, .filter-form > select { flex: 1 1 145px; min-width: 0; }
  .filter-form label { display: flex; flex: 1 1 145px; flex-direction: column; font-size: 0.82rem; gap: 3px; }
  .mail-filter-secondary { grid-template-columns: minmax(0, 1fr) auto auto; }
  .mail-filter-details { justify-self: start; }
  .mail-filter-secondary > .button { align-self: flex-start; }
  .upload-form > input:not([type="hidden"]), .upload-form > select { max-width: 100%; width: 100%; }
  .rename-form { align-items: stretch; flex-direction: column; width: 100%; }
  .rename-form input[type="text"] { width: 100%; }
  .mail-detail-header { padding: 18px; }
  .mail-toolbar { align-items: stretch; flex-direction: column; }
  .mail-toolbar form, .mail-toolbar button, .mail-toolbar .button { width: 100%; }
  .mail-toolbar .button { text-align: center; }
  .mail-body { padding: 16px; }
  .attachment-list li { align-items: flex-start; }
  .attachment-list .button { width: 100%; text-align: center; }
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { padding: 14px; }
  .stats-section { padding: 15px; }
  .tag-stat { grid-template-columns: 100px 1fr auto; }
}

.mail-body {
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-top: 12px;
  line-height: 1.6;
  max-width: 760px;
}
.mail-view { margin: 0 auto; max-width: 860px; }
.mail-back { margin: 0 0 14px; }
.mail-back a { color: var(--muted); font-size: 0.9rem; text-decoration: none; }
.mail-back a:hover { color: var(--primary); text-decoration: underline; }
.mail-detail-header { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; }
.mail-detail-header h1 { font-size: clamp(1.35rem, 3vw, 1.85rem); line-height: 1.25; margin: 4px 0 12px; overflow-wrap: anywhere; }
.mail-detail-kicker { color: var(--primary); font-size: 0.78rem; font-weight: 750; letter-spacing: 0.08em; margin: 0; text-transform: uppercase; }
.mail-sender { color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.mail-sender strong { color: var(--text); font-weight: 600; }
.mail-content-section { margin-top: 22px; }
.mail-content-section h2 { font-size: 1rem; margin: 0 0 8px; }

.attachment-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attachment-list li {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
}
.attachment-icon { background: var(--bg); border-radius: 8px; font-size: 1.1rem; padding: 7px; }
.attachment-info { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 160px; }
.attachment-info a { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.attachment-preview { flex-basis: 100%; margin-top: 8px; }
.attachment-preview img {
  max-width: 320px;
  max-height: 320px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.mail-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 0;
}

.mail-actions-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 12px;
  padding: 10px 12px;
}
.mail-workflow {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding-bottom: 10px;
}
.mail-workflow-status, .mail-workflow-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mail-workflow-actions form { margin: 0; }
.mail-workflow-actions select { font-size: 0.84rem; min-height: 34px; padding: 4px 30px 4px 8px; }

@media (max-width: 640px) {
  .mail-workflow { align-items: stretch; flex-direction: column; }
  .mail-workflow-actions { align-items: stretch; }
  .mail-workflow-actions form { flex: 1 1 140px; }
  .mail-workflow-actions select, .mail-workflow-actions .button { box-sizing: border-box; width: 100%; }
  .mail-toolbar { align-items: stretch; flex-direction: column; padding-inline: 0; }
  .mail-toolbar form, .mail-toolbar button, .mail-toolbar .button { width: 100%; }
}

.reply-panel {
  margin-top: 16px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.reply-panel .compose-form { margin-top: 0; }

.ai-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: -4px;
}
.ai-inline select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
}
.ai-inline-btn {
  padding: 7px 12px;
  border: 1px dashed var(--muted);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.ai-inline-btn:hover { color: var(--text); border-color: var(--text); }

.ai-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 12px;
}
.ai-result h3 { margin: 0 0 6px; font-size: 0.9rem; color: var(--text); }
.ai-result p { margin: 0; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c;
    --surface: #1d2027;
    --text: #e6e7eb;
    --muted: #9aa0ab;
    --border: #2a2e37;
    --link: #a5b4fc;
    --link-hover: #c7d2fe;
    --answered-bg: #113321;
    --open-bg: #3a2a08;
    --claimed-bg: #122447;
    --overdue-bg: #3a1414;
    --tag-bg: #2c1f47;
  }
}

:root[data-theme="dark"] {
  --bg: #14161c;
  --surface: #1d2027;
  --text: #e6e7eb;
  --muted: #9aa0ab;
  --border: #2a2e37;
  --link: #a5b4fc;
  --link-hover: #c7d2fe;
  --answered-bg: #113321;
  --open-bg: #3a2a08;
  --claimed-bg: #122447;
  --overdue-bg: #3a1414;
  --tag-bg: #2c1f47;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e5e9;
  --answered-bg: #dcfce7;
  --open-bg: #fef3c7;
  --claimed-bg: #dbeafe;
  --overdue-bg: #fee2e2;
  --tag-bg: #ede9fe;
}

.theme-toggle { background: transparent; border: 1px solid var(--border); color: var(--muted); font-size: 1rem; min-height: 34px; min-width: 34px; padding: 4px; }
.theme-toggle:hover { background: var(--bg); }

html.is-loading::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 50% 100%;
  z-index: 9999;
  animation: loading-bar 1s ease-in-out infinite;
}

@keyframes loading-bar {
  0% { background-position: -50% 0; }
  100% { background-position: 150% 0; }
}

.offline-banner {
  background: var(--overdue-bg);
  color: var(--overdue);
  border: 1px solid var(--overdue);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9998;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  animation: toast-in 0.2s ease;
}
.toast-out { animation: toast-out 0.3s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

/* Studien-Boerse (/studien) */
.checkbox-label { align-items: center !important; cursor: pointer; flex-direction: row !important; gap: 9px !important; }
.nav-avatar, .profile-avatar-preview { border-radius: 50%; object-fit: cover; }
.nav-avatar { height: 22px; margin-right: 3px; vertical-align: middle; width: 22px; }
.profile-avatar-preview { display: block; height: 72px; margin: 6px 0; width: 72px; }

.manual-vp, .new-study {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 14px 0;
}

.external-db-tile {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 14px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.external-db-tile p { margin: 0; flex: 1 1 320px; }
.manual-vp summary, .new-study summary { cursor: pointer; font-weight: 600; }
.manual-vp[open] summary, .new-study[open] summary { margin-bottom: 10px; }

.study-form { display: flex; flex-direction: column; gap: 10px; max-width: 480px; }
.study-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.study-form input, .study-form textarea, .study-form select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.tag-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.mode-online, .mode-remote { color: var(--claimed); background: var(--claimed-bg); }
.mode-praesenz, .mode-termin { color: var(--tag); background: var(--tag-bg); }
.mode-hybrid { color: var(--open); background: var(--open-bg); }
.mode-studie { color: var(--claimed); background: var(--claimed-bg); }
.mode-praktikum { color: var(--primary); background: var(--bg); border: 1px solid var(--primary); }
.vp-badge { color: var(--primary); background: var(--bg); border: 1px solid var(--primary); }
.rating-badge { color: var(--primary); background: var(--bg); border: 1px solid var(--primary); letter-spacing: 1px; }
.star-rating {
  border: 0;
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}
.star-rating legend { margin-bottom: 4px; }
.star-rating input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}
.star-rating label {
  color: var(--muted);
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  padding: 4px;
}
.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label { color: #f2b01e; }
.star-rating input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }
.feature-toggle-list .switch input { height: 1px; opacity: 0; position: absolute; width: 1px; }
.feature-toggle-list .switch-track {
  background: #aeb4c0;
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.16); flex: 0 0 52px; height: 28px;
  position: relative;
}
.feature-toggle-list .switch-track::after {
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  content: "";
  height: 22px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 120ms ease;
  width: 22px;
}
.feature-toggle-list .switch input:checked + .switch-track { background: var(--primary); }
.feature-toggle-list .switch input:checked + .switch-track::after { transform: translateX(24px); }
.feature-toggle-list .switch input:focus-visible + .switch-track { outline: 2px solid var(--link); outline-offset: 2px; }
.feature-toggle-list .switch small { color: var(--muted); display: block; font-weight: 400; margin-top: 2px; }
.feature-toggle-list .switch-state { background: var(--bg); border-radius: 999px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em; min-width: 58px; padding: 5px 8px; text-align: center; }
.feature-toggle-list .switch:has(input:checked) .switch-state { background: var(--claimed-bg); color: var(--link); }
.file-area-tabs { display: flex; gap: 8px; margin: 18px 0; overflow-x: auto; }
.file-area-tabs a {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 8px 14px;
  text-decoration: none;
  white-space: nowrap;
}
.file-area-tabs a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: white; }
.session-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  max-width: 440px;
  padding: 24px;
}
.session-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.is-closed-badge { color: var(--muted); background: var(--bg); }
.is-expired-badge { color: var(--overdue); background: var(--overdue-bg); }
.is-expiring-badge { color: var(--open); background: var(--open-bg); }
.study-description { white-space: pre-line; }
.is-done-badge { color: var(--answered); background: var(--answered-bg); }
.topic-tag {
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  text-decoration: none;
  margin-left: 0;
  margin-right: 6px;
}
.topic-tag:hover { color: var(--primary); border-color: var(--primary); }
.lecturer-profile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.lecturer-profile h1 { margin: 5px 0 10px; }
.lecturer-score { color: var(--muted); margin: 0; }
.lecturer-score strong { color: var(--primary); font-size: 1.35rem; }
.course-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.course-chips span { background: var(--bg); border-radius: 999px; font-size: .86rem; padding: 7px 10px; }
.course-chips b { background: var(--claimed-bg); border-radius: 999px; color: var(--claimed); margin-left: 4px; padding: 2px 6px; }
.review-card { align-items: start; background: var(--bg); border-radius: 10px; display: flex; gap: 12px; justify-content: space-between; padding: 14px; }
.review-card p { margin-bottom: 0; }

.study-flyer {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--bg);
}

.study-card.is-closed, .study-card.is-expired { opacity: 0.7; }

/* Kalender: Das Monatsraster gibt den Terminrhythmus auf einen Blick wieder;
   die Liste darunter bleibt für Details und weit entfernte Termine erhalten. */
.calendar-month-title { margin: 28px 0 10px; }
.calendar-wrap { overflow-x: auto; }
.calendar-weekdays, .calendar-month-grid { min-width: 700px; }
.calendar-weekdays {
  color: var(--muted);
  display: grid;
  font-size: 0.8rem;
  font-weight: 600;
  gap: 1px;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 1px;
  text-align: center;
}
.calendar-month-grid {
  background: var(--border);
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(7, 1fr);
}
.calendar-day {
  background: var(--surface);
  min-height: 112px;
  padding: 7px;
}
.calendar-day-outside { background: var(--bg); color: var(--muted); }
.calendar-day-today { box-shadow: inset 0 0 0 2px var(--primary); }
.calendar-day-number { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 5px; }
.calendar-item {
  border-radius: 4px;
  display: block;
  font-size: 0.72rem;
  line-height: 1.25;
  margin-top: 3px;
  overflow: hidden;
  padding: 3px 4px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-item-termin { background: var(--tag-bg); color: var(--tag); }
.calendar-item-studie { background: var(--claimed-bg); color: var(--claimed); }
.calendar-item-praktikum { background: var(--open-bg); color: var(--open); }
.calendar-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
