/* ==========================================================
   Vokabeltrainer – Gestaltung im Stil von Apple Keynote
   Hell/Dunkel: data-theme="light" | "dark" am <html>-Element,
   ohne Angabe folgt die Seite der Systemeinstellung.
   ========================================================== */

:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --body-bg: linear-gradient(180deg, #fbfbfd, #ececf1);
  --card: #ffffff;
  --fill: #f2f2f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --topbar: rgba(255, 255, 255, 0.82);
  --seg-bg: #e8e8ed;
  --seg-active: #ffffff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --alert-bg: rgba(255, 69, 58, 0.12);
  --alert-text: #c9271d;
  --info-bg: rgba(10, 132, 255, 0.12);
  --info-text: #0060c7;
  --blue: #0a84ff;
  --indigo: #5e5ce6;
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --c1: #ff453a;
  --c2: #ff9f0a;
  --c3: #f5c400;
  --c4: #30d158;
  --c5: #0a84ff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --body-bg: linear-gradient(180deg, #000000, #111114);
  --card: #1c1c1e;
  --fill: #2c2c2e;
  --text: #f5f5f7;
  --muted: #98989f;
  --line: #38383a;
  --topbar: rgba(22, 22, 24, 0.82);
  --seg-bg: #2c2c2e;
  --seg-active: #48484a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  --alert-bg: rgba(255, 69, 58, 0.18);
  --alert-text: #ff6961;
  --info-bg: rgba(10, 132, 255, 0.2);
  --info-text: #64b0ff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --body-bg: linear-gradient(180deg, #000000, #111114);
    --card: #1c1c1e;
    --fill: #2c2c2e;
    --text: #f5f5f7;
    --muted: #98989f;
    --line: #38383a;
    --topbar: rgba(22, 22, 24, 0.82);
    --seg-bg: #2c2c2e;
    --seg-active: #48484a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    --alert-bg: rgba(255, 69, 58, 0.18);
    --alert-text: #ff6961;
    --info-bg: rgba(10, 132, 255, 0.2);
    --info-text: #64b0ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--body-bg);
  background-attachment: fixed;
  transition: background-color 0.3s, color 0.3s;
}

/* ---------- Kopfzeile ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--topbar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--seg-bg);
  scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }
.tab {
  border: 0;
  padding: 8px 14px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.tab.active {
  background: var(--seg-active);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Hell/Dunkel-Schalter */
.theme-switch {
  position: relative;
  flex: none;
  width: 60px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #8fd3ff, #4aa8ff);
  cursor: pointer;
  transition: background 0.35s;
}
.theme-switch[aria-checked="true"] { background: linear-gradient(135deg, #2b2a5c, #5e5ce6); }
.theme-switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.35s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.theme-switch[aria-checked="true"] .knob { transform: translateX(28px); background: #1c1c1e; }
.theme-switch svg { width: 16px; height: 16px; }
.theme-switch .sun { color: #ff9f0a; }
.theme-switch .moon { display: none; color: #ffd60a; }
.theme-switch[aria-checked="true"] .sun { display: none; }
.theme-switch[aria-checked="true"] .moon { display: block; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.view { display: none; }
.view.active { display: block; animation: fade 0.35s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
h3 { margin: 0 0 10px; font-size: 17px; letter-spacing: -0.01em; }
.intro { margin: 0 0 18px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hint { font-size: 14px; }
.small { font-size: 13px; }

/* Hinweisleiste: Admin bearbeitet fremde Vokabeln */
.context-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--info-bg);
  color: var(--info-text);
  font-weight: 600;
}

/* ---------- Panels und Formulare ---------- */

.panel {
  margin-bottom: 22px;
  padding: 20px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-head p { margin: 4px 0 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline > input, .inline > select { flex: 1; min-width: 160px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input, textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 3px solid rgba(10, 132, 255, 0.35);
  border-color: var(--blue);
}
textarea {
  min-height: 140px;
  resize: vertical;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 16px; /* unter 16 px zoomt iOS Safari beim Antippen */
}
input[type="file"] { padding: 9px; background: var(--fill); }

/* ---------- Buttons ---------- */

button.primary, button.ghost, button.wrong, button.right, button.danger, a.button {
  padding: 11px 18px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
.primary { background: var(--blue); color: #fff; }
.ghost { background: var(--fill); color: var(--text); }
.danger { background: var(--alert-bg); color: var(--alert-text); }
.wrong { background: var(--orange); color: #fff; }
.right { background: var(--green); color: #fff; }
.wide { display: block; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.icon {
  flex: none;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}

/* iOS-Schalter für Gruppen: <label class="switch"><input type="checkbox"><span class="slider"></span></label> */
.switch {
  position: relative;
  flex: none;
  display: inline-block;
  width: 46px;
  height: 28px;
  cursor: pointer;
}
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.switch .slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line);
  pointer-events: none;
  transition: background 0.25s;
}
.switch .slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 3px solid rgba(10, 132, 255, 0.45); outline-offset: 2px; }

/* ---------- Gruppen ---------- */

.group-list { display: flex; flex-direction: column; }
.group-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.group-row:last-child { border-bottom: 0; }
.group-row.archived .row-text strong { color: var(--muted); }
.new-group { margin-top: 14px; }

/* ---------- Kästen ---------- */

.box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.box {
  display: flex;
  flex-direction: column;
  min-height: 140px;
  padding: 18px;
  border-radius: 22px;
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.box-1 { background: linear-gradient(145deg, #ff6b61, var(--c1)); }
.box-2 { background: linear-gradient(145deg, #ffb340, var(--c2)); }
.box-3 { background: linear-gradient(145deg, #ffe066, var(--c3)); color: #1d1d1f; }
.box-4 { background: linear-gradient(145deg, #5ee07e, var(--c4)); }
.box-5 { background: linear-gradient(145deg, #3d9bff, var(--c5)); }
.box-count { font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.box-name { margin: auto 0 10px; font-size: 17px; font-weight: 700; }
.mini {
  align-self: flex-start;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Listen ---------- */

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 10px;
  margin-bottom: 14px;
}
.card-list, .user-list {
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.row:last-child { border-bottom: 0; }
.row-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.row-text small { color: var(--muted); }
.row-text strong, .row-text span, .row-text small { overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.row-actions button { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.empty { padding: 18px; margin: 0; }
.chip {
  flex: none;
  max-width: 180px;
  overflow: hidden;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.badge.box-1 { background: var(--c1); }
.badge.box-2 { background: var(--c2); }
.badge.box-3 { background: var(--c3); color: #1d1d1f; }
.badge.box-4 { background: var(--c4); }
.badge.box-5 { background: var(--c5); }
.badge.admin { background: var(--indigo); }

/* ---------- Lernkarte ---------- */

.setup-row { display: flex; gap: 10px; }
.setup-row select { flex: 1; }
.progress {
  height: 6px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
}
#progress-bar {
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 0.4s;
}
#progress-text { margin: 8px 0 0; }
.flashcard {
  position: relative;
  height: 300px;
  margin: 18px 0 8px;
  perspective: 1200px;
  cursor: pointer;
}
.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.face.front #card-front { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.face.back {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, var(--blue), var(--indigo));
  color: #fff;
}
.face.back #card-back { font-size: 34px; font-weight: 600; overflow-wrap: anywhere; }
.face.back #card-example { margin-top: 14px; font-size: 16px; font-style: italic; opacity: 0.85; }
.card-box {
  position: absolute;
  top: 16px;
  right: 18px;
}
.flashcard.flipped .face.front { transform: rotateY(-180deg); }
.flashcard.flipped .face.back { transform: rotateY(0deg); }
.review {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}
.review button { min-width: 160px; }

/* ---------- Zugangsdaten-Anzeige ---------- */

.credentials {
  display: grid;
  gap: 12px;
  margin: 8px 0 4px;
  padding: 16px;
  border-radius: 16px;
  background: var(--fill);
}
.credentials code {
  display: block;
  padding: 10px 12px;
  font-size: 18px;
  user-select: all;
  word-break: break-all;
}
code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--fill);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.credentials code { background: var(--card); }

.alert {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--alert-bg);
  color: var(--alert-text);
  font-weight: 500;
}

/* ---------- Dialog ---------- */

dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: 24px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog h2 { margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Anmeldung und Einrichtung ---------- */

body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 16px 0 4px; font-size: 28px; letter-spacing: -0.02em; }
.auth-card .muted { margin: 0 0 20px; line-height: 1.5; }
.auth-card .stack { margin-top: 8px; }
.auth-logo {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--blue), var(--indigo));
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ---------- Hinweis-Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 140px);
  transition: transform 0.35s, opacity 0.35s, visibility 0.35s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* ---------- Mobil ---------- */

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .topbar h1 { flex: 1; }
  nav { order: 3; width: 100%; margin-left: 0; }
  .form-grid, .filters { grid-template-columns: 1fr; }
  .flashcard { height: 240px; }
  .face.front #card-front { font-size: 34px; }
  .row, .group-row { flex-wrap: wrap; }
  .row .row-text { flex: 1 1 55%; }
  .group-row .row-text { flex: 1 1 calc(100% - 64px); }
  .row-actions { width: 100%; justify-content: flex-start; }
  .group-row .row-actions { padding-left: 60px; }
  .panel-head > button { width: 100%; }
}

/* Aufklappbarer Import-Bereich */
details.panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  list-style: none;
  cursor: pointer;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after {
  content: "›";
  color: var(--muted);
  font-size: 26px;
  transition: transform 0.25s;
}
details.panel[open] > summary::after { transform: rotate(90deg); }
details.panel[open] > summary { margin-bottom: 14px; }
.mt { margin-top: 22px; }

/* Hover nur bei Maus/Trackpad – auf Touchgeräten bleibt er sonst „hängen“ */
@media (hover: hover) {
  .box:hover { transform: translateY(-3px); }
  .mini:hover { background: rgba(255, 255, 255, 0.42); }
  .icon:hover { color: var(--text); background: var(--fill); }
  .icon.del:hover { color: var(--red); }
}

/* Touch: kein Doppeltipp-Zoom auf Bedienelementen, kein grauer Tipp-Blitz */
button, .box, .flashcard, .switch, summary, a.button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Hinweistext passend zum Gerät: Tastaturkürzel nur mit Maus/Trackpad */
.hint-touch { display: none; }
@media (hover: none) {
  .hint-keys { display: none; }
  .hint-touch { display: block; }
}
