/* ===== Zitier-Helfer · Akademisch Dunkelblau ===== */
:root {
  --navy: #1e3a8a;
  --navy-deep: #0f1f4d;
  --navy-bright: #2f4fb0;
  --accent: #3b82f6;

  --bg: #eef2fb;
  --bg-grad-1: #e7ecf8;
  --bg-grad-2: #dbe3f5;
  --surface: #ffffff;
  --surface-2: #f4f6fc;
  --border: #d4dbee;
  --text: #16213f;
  --text-soft: #4a5878;
  --muted: #6b779a;

  --primary: var(--navy);
  --primary-hover: #1a327a;
  --on-primary: #ffffff;
  --danger: #b42318;
  --danger-hover: #97170d;
  --success: #1f8a4c;

  --ring: rgba(59, 130, 246, 0.45);
  --shadow: 0 6px 22px rgba(15, 31, 77, 0.10);
  --shadow-lg: 0 18px 50px rgba(15, 31, 77, 0.25);
  --radius: 14px;
  --radius-sm: 10px;

  --maxw: 1100px;
}

[data-theme="dark"] {
  --bg: #0a1230;
  --bg-grad-1: #0c1638;
  --bg-grad-2: #08102a;
  --surface: #121d40;
  --surface-2: #0e1838;
  --border: #243463;
  --text: #eaf0ff;
  --text-soft: #b3c0e6;
  --muted: #8493bf;

  --primary: #3b5bd0;
  --primary-hover: #4a6ae0;
  --on-primary: #ffffff;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --success: #4ade80;

  --ring: rgba(96, 165, 250, 0.55);
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: "Georgia", "Iowan Old Style", "Times New Roman", serif;
  background:
    radial-gradient(1200px 600px at 50% -120px, var(--bg-grad-1), transparent),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { font-family: "Georgia", "Times New Roman", serif; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--primary);
  color: var(--on-primary);
  padding: 10px 14px;
  border-radius: 8px;
  z-index: 200;
}
.skip-link:focus { left: 12px; }

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px max(16px, env(safe-area-inset-left)) 14px max(16px, env(safe-area-inset-right));
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(120deg, var(--navy), var(--navy-deep));
  color: #fff;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  font-size: 30px;
  line-height: 1;
  font-weight: 700;
  color: #cdd9ff;
  background: rgba(255, 255, 255, 0.12);
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex: 0 0 auto;
}
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.2px; }
.tagline { margin: 2px 0 0; font-size: 12.5px; opacity: 0.85; font-family: inherit; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== Buttons ===== */
.btn {
  font: inherit;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color .18s ease, transform .12s ease, border-color .18s ease, color .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--navy-bright); }

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: rgba(255, 255, 255, 0.35);
}
.app-header .btn-ghost { color: #fff; }
.btn-ghost:hover { background: rgba(120, 140, 200, 0.14); }

.btn-danger { background: var(--danger); color: #fff; }
[data-theme="dark"] .btn-danger { color: #2a0a08; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-icon {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.26); }

/* ===== Layout ===== */
.layout {
  max-width: var(--maxw);
  margin: 22px auto;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 18px; color: var(--text); }

/* ===== Form ===== */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }

label { font-size: 13px; font-weight: 700; color: var(--text-soft); font-family: system-ui, sans-serif; }
.req { color: var(--danger); }

input, select, textarea {
  font: inherit;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  width: 100%;
  max-width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
.field input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.18); }

.hint { margin: 0; font-size: 12px; color: var(--muted); font-family: system-ui, sans-serif; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* ===== Preview ===== */
.preview {
  margin-top: 18px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}
.preview h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-family: system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.6px; }
.preview-text {
  margin: 0;
  font-size: 15px;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--text);
}

/* ===== List ===== */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.list-head h2 { margin: 0; }
.badge {
  background: var(--navy);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
}
[data-theme="dark"] .badge { background: var(--primary); }

.list-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.inline-field { display: flex; flex-direction: column; gap: 6px; }
.inline-field > span { font-size: 13px; font-weight: 700; color: var(--text-soft); font-family: system-ui, sans-serif; }
.inline-field select { width: auto; min-width: 160px; }
.toolbar-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.bib-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  counter-reset: bib;
}
.bib-item {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius-sm);
  padding: 14px 14px 14px 16px;
}
[data-theme="dark"] .bib-item { border-left-color: var(--primary); }
.bib-text {
  margin: 0 0 10px;
  font-size: 15px;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--text);
}
.bib-meta {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}
.bib-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bib-actions .btn { padding: 7px 12px; font-size: 13px; }

.empty-hint, .auto-note {
  font-family: system-ui, sans-serif;
  color: var(--muted);
  font-size: 13px;
}
.empty-hint {
  margin: 6px 0 0;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.auto-note { margin: 14px 0 0; text-align: center; }

/* ===== Footer ===== */
.app-footer {
  max-width: var(--maxw);
  margin: 28px auto 24px;
  padding: 0 16px;
  text-align: center;
}
.app-footer p { margin: 0; font-family: system-ui, sans-serif; font-size: 12.5px; color: var(--muted); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--navy-deep);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-theme="dark"] .toast { background: #1b2b5e; border: 1px solid var(--border); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 16, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 250;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  width: 100%;
  max-width: 440px;
  animation: pop .18s ease;
}
.modal-wide { max-width: 640px; }
.modal h3 { margin: 0 0 10px; font-size: 18px; }
.modal p { margin: 0 0 18px; color: var(--text-soft); font-family: system-ui, sans-serif; font-size: 14.5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.export-area {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  margin-bottom: 16px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
}

@keyframes pop {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
  .brand h1 { font-size: 18px; }
  .form-actions .btn,
  .toolbar-buttons .btn { flex: 1 1 auto; }
  .list-toolbar { flex-direction: column; align-items: stretch; }
  .inline-field select { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
