/* Vokabel-Karten — eigenes Design: Tiefes Violett + helles Lavendel, Karten-Flip-Motiv */

:root {
  --vk-violet: #6d28d9;
  --vk-violet-dark: #5b21b6;
  --vk-violet-deep: #4c1d95;
  --vk-lavender: #f5f3ff;
  --vk-lavender-2: #ede9fe;
  --vk-accent: #a78bfa;

  --bg: var(--vk-lavender);
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #faf8ff;
  --text: #2a1a4a;
  --text-soft: #6b5b8a;
  --border: #e4ddf6;
  --shadow: 0 8px 28px rgba(76, 29, 149, 0.12);
  --shadow-sm: 0 2px 8px rgba(76, 29, 149, 0.10);
  --primary: var(--vk-violet);
  --primary-hover: var(--vk-violet-dark);
  --on-primary: #ffffff;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --again: #e11d48;
  --again-bg: #ffe4e6;
  --danger: #dc2626;
  --focus: #8b5cf6;
  --radius: 18px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --bg: #16101f;
  --bg-2: #1d1530;
  --surface: #241a38;
  --surface-2: #2c2046;
  --text: #f3effd;
  --text-soft: #b6a8d6;
  --border: #3a2c56;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4);
  --primary: #8b5cf6;
  --primary-hover: #a78bfa;
  --on-primary: #1a1030;
  --good: #4ade80;
  --good-bg: #14331f;
  --again: #fb7185;
  --again-bg: #3a1721;
  --danger: #f87171;
  --focus: #c4b5fd;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hidden { display: none !important; }

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

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, var(--vk-violet), var(--vk-violet-deep));
  color: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
}
.app-title {
  font-size: 1.2rem; font-weight: 700; margin: 0;
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.app-title span:last-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logo-card {
  width: 26px; height: 32px; flex-shrink: 0;
  background: #fff; border-radius: 5px;
  position: relative; transform: rotate(-8deg);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25);
}
.logo-card::before {
  content: ""; position: absolute; inset: 5px 4px auto 4px; height: 3px;
  background: var(--vk-accent); border-radius: 3px;
  box-shadow: 0 7px 0 var(--vk-lavender-2), 0 14px 0 var(--vk-lavender-2);
}

.icon-btn {
  background: rgba(255,255,255,0.16); border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, transform .1s;
}
.icon-btn:hover { background: rgba(255,255,255,0.28); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
[data-theme="dark"] .ico-moon { display: block; }

/* ---------- Main / Views ---------- */
.app-main {
  max-width: 760px; margin: 0 auto;
  padding: 18px 16px 60px;
}
.view-head, .view-head h2, .deck-summary h2 { margin-top: 0; }
.view-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.view-head h2 { font-size: 1.4rem; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 16px; display: inline-flex; align-items: center; gap: 7px;
  justify-content: center; transition: background .15s, transform .1s, box-shadow .15s;
  color: var(--text); background: var(--surface-2);
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-soft { background: var(--vk-lavender-2); color: var(--vk-violet-deep); }
[data-theme="dark"] .btn-soft { background: var(--surface-2); color: var(--text); }
.btn-soft:hover { filter: brightness(0.97); }
.btn-ghost { background: transparent; color: var(--text-soft); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--again-bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Deck-Liste ---------- */
.deck-list { display: grid; gap: 12px; }
.deck-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  display: flex; align-items: center; gap: 14px;
  transition: transform .12s, box-shadow .15s, border-color .15s;
  text-align: left; width: 100%; font: inherit; color: inherit;
}
.deck-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--vk-accent); }
.deck-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.deck-emblem {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: 14px;
  background: linear-gradient(135deg, var(--vk-violet), var(--vk-accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1.2rem;
}
.deck-info { flex: 1; min-width: 0; }
.deck-name {
  font-weight: 700; font-size: 1.05rem; margin: 0 0 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.deck-meta { font-size: 0.85rem; color: var(--text-soft); display: flex; gap: 10px; flex-wrap: wrap; }
.badge-due {
  background: var(--again-bg); color: var(--again);
  border-radius: 20px; padding: 2px 10px; font-weight: 700; font-size: 0.78rem;
}
.badge-none { background: var(--good-bg); color: var(--good); border-radius: 20px; padding: 2px 10px; font-weight: 700; font-size: 0.78rem; }

/* ---------- Deck-Detail ---------- */
.deck-summary {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.deck-summary h2 { font-size: 1.3rem; margin: 0 0 14px; word-break: break-word; }
.stats-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat {
  flex: 1; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 12px 6px; text-align: center;
}
.stat span { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1; }
.stat small { font-size: 0.75rem; color: var(--text-soft); }
.stat-due span { color: var(--again); }
.stat-learned span { color: var(--good); }
.stat-total span { color: var(--primary); }

.progress-wrap {
  height: 10px; background: var(--surface-2); border-radius: 20px;
  overflow: hidden; margin-bottom: 16px; border: 1px solid var(--border);
}
.progress-bar {
  height: 100%; width: 0%; border-radius: 20px;
  background: linear-gradient(90deg, var(--vk-accent), var(--good));
  transition: width .4s ease;
}
.deck-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card-list-title { font-size: 1.05rem; margin: 0 0 12px; }
.card-list { display: grid; gap: 10px; }
.vcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.vcard-text { flex: 1; min-width: 0; }
.vcard-front { font-weight: 600; overflow-wrap: anywhere; }
.vcard-back { font-size: 0.88rem; color: var(--text-soft); overflow-wrap: anywhere; }
.vcard-state {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 14px; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
}
.state-new { background: var(--vk-lavender-2); color: var(--vk-violet-deep); }
[data-theme="dark"] .state-new { background: var(--surface-2); color: var(--vk-accent); }
.state-due { background: var(--again-bg); color: var(--again); }
.state-ok { background: var(--good-bg); color: var(--good); }
.vcard-btns { display: flex; gap: 4px; flex-shrink: 0; }
.mini-btn {
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
  width: 34px; height: 34px; border-radius: 9px; color: var(--text-soft);
  display: inline-flex; align-items: center; justify-content: center;
}
.mini-btn:hover { color: var(--primary); border-color: var(--vk-accent); }
.mini-btn.del:hover { color: var(--danger); border-color: var(--danger); }
.mini-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.empty-state {
  text-align: center; color: var(--text-soft); padding: 36px 16px;
  background: var(--surface-2); border: 1.5px dashed var(--border);
  border-radius: var(--radius); margin: 4px 0;
}

/* ---------- Lernmodus ---------- */
.learn-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.learn-counter { font-weight: 700; color: var(--text-soft); }

.flashcard-stage {
  perspective: 1200px;
  display: flex; justify-content: center;
  margin: 8px 0 22px;
}
.flashcard {
  width: 100%; max-width: 460px; height: 300px;
  cursor: pointer; position: relative;
  background: transparent; border: none;
}
.flashcard:focus-visible { outline: 3px solid var(--focus); outline-offset: 6px; border-radius: var(--radius); }
.flashcard-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .55s cubic-bezier(.4,.05,.25,1);
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; box-shadow: var(--shadow);
  overflow: hidden;
}
.flashcard-front {
  background: linear-gradient(150deg, var(--surface), var(--surface-2));
  border: 2px solid var(--border);
}
.flashcard-back {
  background: linear-gradient(150deg, var(--vk-violet), var(--vk-violet-deep));
  color: #fff; transform: rotateY(180deg);
  border: 2px solid var(--vk-violet-deep);
}
.face-label {
  position: absolute; top: 14px; left: 16px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; opacity: 0.6;
}
.face-text {
  font-size: 1.5rem; font-weight: 700; margin: 0;
  overflow-wrap: anywhere; max-height: 100%; overflow: auto;
}
.flip-hint {
  position: absolute; bottom: 14px; font-size: 0.78rem;
  color: var(--text-soft); opacity: 0.8;
}

.rate-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 460px; margin: 0 auto; }
.btn-again, .btn-good {
  flex-direction: column; padding: 14px; font-size: 1.05rem; gap: 2px;
}
.btn-again { background: var(--again-bg); color: var(--again); }
.btn-again:hover { filter: brightness(0.96); }
.btn-good { background: var(--good-bg); color: var(--good); }
.btn-good:hover { filter: brightness(0.96); }
.btn-again small, .btn-good small { font-size: 0.72rem; font-weight: 600; opacity: 0.85; }

.learn-done { display: flex; justify-content: center; padding-top: 10px; }
.done-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px 24px; text-align: center;
  box-shadow: var(--shadow); max-width: 420px;
}
.done-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--good-bg); color: var(--good);
  font-size: 2rem; margin-bottom: 12px;
}
.done-card h3 { margin: 0 0 6px; }
.done-card p { color: var(--text-soft); margin: 0 0 18px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 12, 60, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow); max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-head .icon-btn { background: var(--surface-2); color: var(--text-soft); }
.modal-head .icon-btn:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  padding: 14px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.92rem; }
.field input, .field textarea {
  width: 100%; font: inherit; padding: 11px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}
.field textarea { min-height: 120px; line-height: 1.5; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9rem; }
.field-hint { font-size: 0.8rem; color: var(--text-soft); margin: 6px 0 0; }
.confirm-text { margin: 0; color: var(--text); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: max-content; max-width: 92vw; pointer-events: none;
}
.toast {
  background: var(--vk-violet-deep); color: #fff;
  padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow);
  font-weight: 600; font-size: 0.92rem; max-width: 100%;
  overflow-wrap: anywhere; animation: toastIn .25s ease;
}
.toast.toast-good { background: var(--good); color: #06310f; }
.toast.toast-err { background: var(--danger); color: #fff; }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Responsive ---------- */
@media (min-width: 560px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: var(--radius); }
}
@media (max-width: 380px) {
  .face-text { font-size: 1.25rem; }
  .stat span { font-size: 1.3rem; }
  .deck-actions .btn { flex: 1 1 auto; }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .flashcard-inner { transition: none !important; }
}
