/* ==========================================================================
   MARIE — Design system (Marie × Valaros palette)
   Ivory-dominant surface, Aubergine for nav/emphasis, mid-violet for
   Marie/AI surfaces, gold used sparingly (fine lines, premium, playing-card
   details). Cormorant Garamond for card names/headings only — never for
   longer meaning text (a lot gets read here). See _design/mockup_v3.html
   for the approved reference screens this was extracted from.
   ========================================================================== */

:root {
  --ivory: #FAF7F1;
  --aubergine: #49336B;
  --aubergine-deep: #30253A;
  --violet-mid: #65558C;
  --gold: #D5B45C;
  --gold-deep: #9a7230;
  --text-muted: #8a7d9c;
  --tile-border: #e6e0d5;
  --white: #ffffff;
  --badge-gold-bg: #f1e6c9;
  --badge-gold-text: #7a5c14;
  --badge-violet-bg: #e6e0f0;
  --badge-violet-text: #4a3a72;
  --danger: #a3455f;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ivory);
  color: var(--aubergine-deep);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; }

h1, h2, h3, .font-display { font-family: var(--font-display); font-weight: 600; }

/* ---------- App bar ---------- */
.app-bar {
  padding: calc(18px + var(--safe-top)) 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.app-bar .wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--aubergine);
  display: flex;
  align-items: center;
  gap: 6px;
}
.app-bar .wordmark .spark { color: var(--gold); font-size: 15px; }
.app-bar .actions { display: flex; align-items: center; gap: 10px; }
.avatar-marie {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: url('https://pub-a6a7c0e7705b4da3837979063773dd98.r2.dev/assets/marie-avatar.png') center/cover no-repeat;
  border: 1.5px solid var(--gold);
}
.ask-marie .avatar-marie { width: 22px; height: 22px; margin-right: 4px; border-color: var(--gold); }
.ai-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.ai-toggle .lbl { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.04em; }
.toggle-track {
  width: 34px; height: 20px; border-radius: 999px; background: var(--tile-border);
  position: relative; transition: background 0.2s ease; flex-shrink: 0;
}
.toggle-track.on { background: var(--aubergine); }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: left 0.2s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-track.on .toggle-thumb { left: 16px; }

.lang-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--tile-border);
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--white);
}

/* ---------- Screens / containers ---------- */
.screens { flex: 1; position: relative; overflow: hidden; }
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  color: var(--aubergine-deep);
  margin: 4px 18px 12px;
}

/* ---------- shared card surface ---------- */
.surface {
  background: var(--white);
  border: 0.5px solid var(--tile-border);
  border-radius: 14px;
}

/* ---------- playing-card corner pip ---------- */
.pip {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--aubergine);
}
.pip.red { color: var(--danger); }
.pip .r { font-size: 12px; }
.pip .s { font-size: 10px; margin-top: 1px; }

/* ---------- pills / badges ---------- */
.badge { font-size: 11px; font-weight: 600; padding: 4px 11px; border-radius: 999px; display: inline-block; }
.badge.theme { background: var(--badge-gold-bg); color: var(--badge-gold-text); }
.badge.challenge { background: var(--badge-violet-bg); color: var(--badge-violet-text); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: 10px;
  padding: 12px 20px;
  border: none;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--aubergine); color: #fff; }
.btn-primary:active { background: var(--aubergine-deep); }
.btn-ghost { background: transparent; color: var(--aubergine); border: 1px solid var(--tile-border); }
.btn-block { display: block; width: 100%; }

.field {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--tile-border);
  background: var(--white);
  color: var(--aubergine-deep);
}
.field:focus { outline: none; border-color: var(--gold); }

/* ---------- "Marie" AI surfaces (mid-violet) ---------- */
.ask-marie {
  padding: 15px;
  border-radius: 14px;
  background: var(--violet-mid);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
}
.ask-marie .spark { color: var(--gold); font-size: 17px; flex-shrink: 0; }
.ask-marie .t { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.ask-marie .s { font-size: 11px; color: rgba(255,255,255,0.72); margin-top: 1px; }

/* ---------- bottom tab bar ---------- */
.navbar {
  background: var(--white);
  border-top: 0.5px solid var(--tile-border);
  display: flex;
  padding: 8px 4px calc(10px + var(--safe-bottom));
  flex-shrink: 0;
}
.navbar .item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 4px 0;
  cursor: pointer;
}
.navbar .lbl { font-size: 10px; font-weight: 600; color: var(--text-muted); }
.navbar .item.on .lbl { color: var(--aubergine); }
.navbar .item.on svg { stroke: var(--aubergine); }
.navbar .item svg { stroke: var(--text-muted); width: 21px; height: 21px; }
.navbar .item .dotwrap { position: relative; }
.navbar .item .badge-dot {
  position: absolute; top: -2px; right: -4px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); display: none;
}
.navbar .item .badge-dot.show { display: block; }

/* ---------- loading / toast ---------- */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--tile-border); border-top-color: var(--aubergine);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--aubergine-deep); color: #fff;
  font-size: 13px; padding: 10px 18px; border-radius: 999px;
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none; z-index: 500; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- empty / placeholder state ---------- */
.placeholder {
  margin: 40px 18px; text-align: center; color: var(--text-muted); font-size: 13.5px; line-height: 1.6;
}

/* ---------- Legungen ---------- */
.greeting { padding: 4px 18px 18px; }
.greeting .g-title { font-family: var(--font-display); font-weight: 700; font-size: 27px; color: var(--aubergine); margin: 0 0 3px; }
.greeting .g-sub { font-size: 14px; color: #6b6078; margin: 0; }

.daily-card {
  margin: 0 18px 18px; padding: 17px; display: flex; align-items: center; gap: 13px;
  background: var(--aubergine); border-radius: 14px; color: #fff; cursor: pointer;
}
.daily-card .pip { color: var(--gold); width: 34px; }
.daily-card .dc-t { font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: rgba(255,255,255,0.65); }
.daily-card .dc-n { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin-top: 2px; }

.spread-list { padding: 0 18px 24px; display: flex; flex-direction: column; gap: 10px; }
.spread-row { display: flex; align-items: center; gap: 13px; padding: 15px 15px; cursor: pointer; }
.spread-row .sr-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; color: var(--aubergine-deep); }
.spread-row .sr-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.spread-row .sr-n {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--ivory); border-radius: 999px; padding: 4px 10px; flex-shrink: 0;
}

.drawn-grid { padding: 14px 18px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.drawn-card { padding: 10px; width: 110px; text-align: center; }
.dc-img-wrap { position: relative; border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.dc-img-wrap img { width: 100%; aspect-ratio: 3/4.3; object-fit: cover; }
.dc-img-wrap .pip { position: absolute; top: 5px; left: 5px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.dc-label { font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold-deep); font-weight: 700; }
.dc-name { font-family: var(--font-display); font-weight: 600; font-size: 13.5px; color: var(--aubergine-deep); margin-top: 2px; }
.dc-tap { font-size: 9.5px; color: var(--text-muted); margin-top: 3px; letter-spacing: 0.03em; }
.drawn-card--tappable { cursor: pointer; }

.drawn-grid--small { justify-content: flex-start; padding: 14px 18px 4px; }
.rc-thumb { width: 56px; aspect-ratio: 3/4.3; object-fit: cover; border-radius: 8px; border: 0.5px solid var(--tile-border); }
.rc-thumb--tappable { cursor: pointer; }

.no-ai-hint { margin: 0 18px 14px; padding: 14px 15px; border-radius: 14px; background: var(--ivory); border: 1px dashed var(--tile-border); }
.no-ai-hint-t { font-family: var(--font-display); font-weight: 600; font-size: 13.5px; color: var(--aubergine); margin: 0 0 5px; }
.no-ai-hint p { font-size: 12.5px; line-height: 1.55; color: #6b6078; margin: 4px 0 0; }

.return-link {
  display: block; margin-top: 18px; text-align: center; font-size: 13px; font-weight: 600;
  color: var(--aubergine); text-decoration: none;
}

.loading-row { display: flex; align-items: center; gap: 10px; padding: 20px 0; color: var(--text-muted); font-size: 13.5px; }

/* ---------- Mehr / Auth ---------- */
.auth-tab { font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.auth-tab.on { color: var(--aubergine); }

/* ---------- Kurse ---------- */
.course-list { padding: 0 18px 24px; display: flex; flex-direction: column; gap: 10px; }
.course-card { display: flex; align-items: center; gap: 14px; padding: 16px; cursor: pointer; }
.course-emoji { font-size: 22px; width: 40px; height: 40px; border-radius: 10px; background: var(--ivory); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.course-info { flex: 1; min-width: 0; }
.course-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--aubergine-deep); }
.course-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.course-progress-bar { height: 4px; border-radius: 2px; background: var(--ivory); margin-top: 8px; overflow: hidden; }
.course-progress-fill { height: 100%; background: var(--gold); }
.course-arrow { font-size: 20px; color: var(--text-muted); flex-shrink: 0; }

.lesson-title-block { padding: 4px 18px 14px; }
.lesson-summary { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.lesson-body { padding: 0 18px; }
.exercise-response { padding: 13px 15px; margin: 10px 0 18px; }
.lesson-nav { display: flex; justify-content: space-between; padding: 10px 18px 30px; gap: 10px; }

/* ---------- Quiz ---------- */
.quiz-opt {
  padding: 13px 15px; font-size: 14.5px; color: var(--aubergine-deep); text-align: left;
  cursor: pointer; font-family: var(--font-body);
}
.quiz-opt--correct { border-color: var(--gold) !important; background: var(--badge-gold-bg); }
.quiz-opt--wrong { border-color: var(--danger) !important; background: #fbebee; }

/* ---------- Karten grid ---------- */
.deck-grid {
  padding: 0 14px 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
@media (min-width: 560px) { .deck-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 820px) { .deck-grid { grid-template-columns: repeat(6, 1fr); } }

.mini-card { position: relative; aspect-ratio: 3/4.3; overflow: hidden; cursor: pointer; padding: 0; }
.mini-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mini-card .scrim {
  position: absolute; left: 0; right: 0; bottom: 0; height: 46%;
  background: linear-gradient(to top, rgba(20,10,30,0.82), transparent);
}
.mini-card .pip { position: absolute; top: 6px; left: 7px; color: #fff; }
.mini-card .num {
  position: absolute; top: 6px; right: 7px; font-size: 9px; color: rgba(255,255,255,0.85); font-weight: 700;
  background: rgba(0,0,0,0.28); border-radius: 6px; padding: 1px 5px;
}
.mini-card .name {
  position: absolute; left: 7px; right: 7px; bottom: 6px;
  font-family: var(--font-display); font-weight: 600; font-size: 12.5px; color: #fff; line-height: 1.2;
}

/* ---------- Karten detail ---------- */
.detail-head { padding: 10px 18px 0; display: flex; align-items: center; gap: 12px; }
.detail-head .back { font-size: 22px; color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 0; line-height: 1; }
.detail-head .crumbs { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }

.hero-frame {
  margin: 10px 18px 14px; position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--tile-border);
}
.hero-frame::after {
  content: ""; position: absolute; inset: 6px; border: 0.5px solid rgba(213,180,92,0.55); border-radius: 11px; pointer-events: none;
}
.hero-frame img { display: block; width: 100%; height: 46vw; max-height: 320px; min-height: 200px; object-fit: cover; }
.hero-frame .pip { position: absolute; top: 14px; left: 14px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }

.hero-title { padding: 0 18px; }
.hero-title .name { font-weight: 700; font-size: 25px; color: var(--aubergine-deep); }
.hero-title .kw { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.tabbar { display: flex; gap: 14px; padding: 16px 18px 10px; border-bottom: 0.5px solid var(--tile-border); margin-bottom: 16px; overflow-x: auto; }
.tabbar .t { font-size: 13px; font-weight: 600; color: var(--text-muted); padding: 6px 1px 10px; position: relative; white-space: nowrap; cursor: pointer; }
.tabbar .t.on { color: var(--aubergine); }
.tabbar .t.on::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--gold); }

.detail-body { padding: 0 18px 28px; }

.glance-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.glance-item { padding: 12px 6px; text-align: center; }
.glance-item .v { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--aubergine-deep); }
.glance-item .l { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.lede { font-size: 14px; line-height: 1.65; color: #4a4156; margin: 0 0 16px; }

.combo-cat { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold-deep); margin: 16px 0 8px; }
.combo-item { padding: 11px 13px; margin-bottom: 7px; }
.combo-item b { font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--aubergine-deep); }
.combo-item span { display: block; font-size: 12.5px; color: #5c5268; margin-top: 3px; line-height: 1.5; }

.yn-box { padding: 13px 15px; margin-bottom: 16px; font-size: 13px; line-height: 1.55; color: #4a4156; }
.yn-box b { color: var(--aubergine); }

/* ---------- full combination picker (35-card matrix) ---------- */
.combo-picker-toggle {
  width: 100%; text-align: left; padding: 12px 14px; margin: 4px 0 12px;
  font-family: var(--font-body); font-size: 13px; font-weight: 600; color: var(--aubergine-deep);
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.combo-picker-toggle .arrow { transition: transform .2s; color: var(--gold-deep); }
.combo-picker-toggle.open .arrow { transform: rotate(90deg); }
.combo-picker-search {
  width: 100%; box-sizing: border-box; padding: 9px 12px; margin-bottom: 10px;
  border: 0.5px solid var(--tile-border); border-radius: 10px; font-family: var(--font-body); font-size: 13px;
}
.combo-picker-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.combo-picker-chip {
  display: flex; align-items: center; gap: 6px; padding: 5px 11px 5px 6px;
  background: var(--badge-gold-bg); color: var(--badge-gold-text);
  border: none; border-radius: 999px; font-family: var(--font-body); font-size: 12px; font-weight: 600; cursor: pointer;
}
.combo-picker-chip img { width: 18px; height: 26px; object-fit: cover; border-radius: 2px; }
.combo-picker-chip.active { background: var(--aubergine); color: var(--ivory); }
.combo-picker-chip.hidden { display: none; }
.combo-picker-result { padding: 14px 15px; margin-bottom: 10px; }
.combo-picker-result .title { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--aubergine-deep); margin-bottom: 6px; }
.combo-picker-result p { font-size: 13px; line-height: 1.6; color: #4a4156; margin: 0; }
.combo-picker-empty { font-size: 12.5px; color: #8a7f96; padding: 4px 2px 14px; }

.symbol-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 4px; }
.symbol-table td { padding: 9px 4px; border-bottom: 0.5px solid var(--tile-border); vertical-align: top; }
.symbol-table td:first-child { width: 40%; color: var(--aubergine-deep); }
.symbol-table td:last-child { color: #5c5268; }

.ask-marie { margin-top: 6px; }

/* ---------- Paywall ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(36,26,51,0.55); z-index: 900;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-overlay .modal {
  background: var(--ivory); width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0; padding: 28px 24px calc(24px + var(--safe-bottom));
  position: relative; transform: translateY(16px); transition: transform 0.2s ease;
  max-height: 88vh; overflow-y: auto;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-close {
  position: absolute; top: 14px; right: 16px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--white); border: 0.5px solid var(--tile-border); color: var(--text-muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.paywall-lock { text-align: center; font-size: 30px; color: var(--gold); margin-bottom: 6px; }
.paywall-title { text-align: center; font-size: 22px; font-weight: 700; color: var(--aubergine); margin-bottom: 8px; }
.paywall-desc { text-align: center; font-size: 13.5px; line-height: 1.6; color: var(--text-muted); margin: 0 0 18px; }
.paywall-features { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.paywall-feature {
  display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: var(--aubergine-deep);
  background: var(--white); border: 0.5px solid var(--tile-border); border-radius: 12px; padding: 11px 13px;
}
.paywall-feature span:first-child { font-size: 17px; flex-shrink: 0; }
.paywall-restore {
  display: block; width: 100%; text-align: center; background: none; border: none;
  font-family: var(--font-body); font-size: 12.5px; color: var(--text-muted); text-decoration: underline;
  padding: 14px 0 0; cursor: pointer;
}

/* ---------- Mehr / Premium row ---------- */
.premium-row {
  display: flex; align-items: center; gap: 12px; padding: 15px;
  background: var(--aubergine); border-radius: 14px; color: #fff; cursor: pointer;
}
.premium-row .icon { font-size: 20px; color: var(--gold); flex-shrink: 0; }
.premium-row .t { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.premium-row .s { font-size: 11.5px; color: rgba(255,255,255,0.72); margin-top: 1px; }
.premium-row.is-active { background: var(--white); border: 0.5px solid var(--tile-border); color: var(--aubergine-deep); cursor: default; }
.premium-row.is-active .s { color: var(--text-muted); }

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