:root {
  --front1:#a63dff;
  --front2:#ff3d81;
  --back1:#3ddc97;
  --back2:#3dd6d6;
  --back-text:#0c2b23;
  --sun:#ffd93d;
  --coral:#ff6b6b;
  --bg1:#0d0a1f;
  --bg2:#1c1240;
  --bg3:#2a1a5c;
  --muted:#cbb8ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100vh;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  transition: background 0.4s ease;
}

/* ---- Top-level site header ---- */
.site-header {
  text-align: center;
  margin-bottom: 6px;
}
.site-title {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(90deg, #ff3d81, #ff9a3d, #ffd93d, #3ddc97, #3d8bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 4px 0;
}
.site-subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ---- Deck switcher tabs ---- */
.deck-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 14px 0 10px;
  max-width: 680px;
}
.deck-tab {
  border: none;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  color: #12082b;
  background: #cbb8ff;
  opacity: 0.55;
  transition: transform .15s, opacity .15s;
}
.deck-tab.active { opacity: 1; transform: scale(1.05); box-shadow: 0 4px 14px rgba(0,0,0,0.35); }
.deck-tab:active { transform: scale(0.95); }

.deck-subtitle {
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
  min-height: 1.1em;
}

/* ---- Category chips ---- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 14px;
  max-width: 520px;
}
.chip {
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  color: #14102b;
  opacity: 0.55;
  transition: transform .15s, opacity .15s;
}
.chip.active { opacity: 1; transform: scale(1.05); }
.chip:active { transform: scale(0.95); }

.progress {
  font-size: 0.8rem;
  color: var(--sun);
  font-weight: 700;
  margin-bottom: 8px;
}

/* ---- Flip card ---- */
.scene {
  width: 100%;
  max-width: 420px;
  height: 320px;
  perspective: 1400px;
}
.card {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(.4,.2,.2,1);
}
.card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 26px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.front {
  background: linear-gradient(135deg, var(--front1), var(--front2));
}
.back {
  background: linear-gradient(135deg, var(--back1), var(--back2));
  transform: rotateY(180deg);
  color: var(--back-text);
}
.tag {
  position: absolute;
  top: 14px;
  left: 14px;
  font-size: 0.63rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.25);
  letter-spacing: 0.03em;
}
.qtext { font-size: 1.12rem; font-weight: 700; line-height: 1.4; }
.atext { font-size: 1rem; font-weight: 600; line-height: 1.5; }
.hint {
  position: absolute;
  bottom: 14px;
  font-size: 0.66rem;
  opacity: 0.8;
  font-weight: 600;
}

/* ---- Controls ---- */
.controls {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  align-items: center;
}
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  color: #14102b;
  transition: transform .1s;
}
.btn:active { transform: scale(0.93); }
.btn.nav { background: var(--sun); }
.btn.shuffle { background: var(--coral); color: #fff; }
.btn.big { padding: 14px 22px; font-size: 1.3rem; }

footer {
  margin-top: 22px;
  font-size: 0.7rem;
  color: #9c8ac9;
  text-align: center;
}

/* ---- Grouped multiple-true/false cards (EDAIC Type A) ----
   Used when a deck card supplies {stem, opts[], ans[]} instead of {q, a}.
   Decks using the simple {q, a} shape are unaffected. */
.scene.mcq { max-width: 660px; height: min(660px, 72vh); }
#app-root { width: 100%; display: flex; flex-direction: column; align-items: center; }
.face.mcqface {
  justify-content: flex-start;
  text-align: left;
  overflow-y: auto;
  padding: 46px 20px 38px;
  -webkit-overflow-scrolling: touch;
}
.mcqface .mcq-stem {
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 12px;
}
.mcqface .mcq-list { list-style: none; margin: 0; padding: 0; width: 100%; }
.mcqface .mcq-list li {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 9px;
  padding: 9px 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.42;
}
.mcqface .mcq-list li + li { border-top: 1px solid rgba(255,255,255,0.22); }
.face.back.mcqface .mcq-list li + li { border-top: 1px solid rgba(0,0,0,0.14); }
.mcqface .mcq-let { font-weight: 800; opacity: 0.75; }
.mcqface .mcq-v {
  display: inline-block;
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.4px;
  border-radius: 5px;
  padding: 1px 7px;
  margin-bottom: 4px;
}
.mcqface .mcq-v.t { background: #0a7d4d; color: #fff; }
.mcqface .mcq-v.f { background: #b3123c; color: #fff; }
.mcqface .mcq-opt { display: block; font-weight: 700; }
.mcqface .mcq-exp { display: block; font-weight: 500; opacity: 0.9; margin-top: 3px; }

/* ---- Search (notes + cards) ---- */
#searchWrap { width: 100%; max-width: 760px; margin: 0 auto 14px; padding: 0 16px; box-sizing: border-box; }
#searchRow { position: relative; }
#searchBox {
  width: 100%; box-sizing: border-box;
  padding: 11px 40px 11px 16px;
  border-radius: 12px;
  border: 1px solid rgba(203,184,255,.3);
  background: rgba(203,184,255,.14);
  color: #fff; font-size: 15px; font-weight: 600;
  font-family: inherit; outline: none;
  -webkit-appearance: none;
}
#searchBox::placeholder { color: rgba(255,255,255,.55); font-weight: 600; }
#searchBox:focus { border-color: rgba(203,184,255,.75); background: rgba(203,184,255,.2); }
#searchClear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: rgba(255,255,255,.6);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 6px;
}
#searchResults {
  margin-top: 8px; background: #221a3a;
  border: 1px solid rgba(203,184,255,.28); border-radius: 12px;
  max-height: 58vh; overflow-y: auto; text-align: left;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.sr-group {
  font-size: 11.5px; font-weight: 800; letter-spacing: .5px;
  color: #ffd93d; padding: 10px 14px 6px; text-transform: uppercase;
}
.sr-item {
  display: block; width: 100%; text-align: left; box-sizing: border-box;
  background: none; border: none; border-top: 1px solid rgba(255,255,255,.07);
  color: #fff; font-family: inherit; font-size: 13.5px;
  padding: 10px 14px; cursor: pointer; line-height: 1.45;
}
.sr-item:hover, .sr-item:focus { background: rgba(203,184,255,.14); outline: none; }
.sr-title { font-weight: 700; display: block; }
.sr-sub { display: block; font-size: 11.5px; color: #a99cc9; margin-top: 2px; }
.sr-item mark { background: rgba(255,217,61,.32); color: #ffe98a; border-radius: 3px; padding: 0 2px; }
.sr-empty { padding: 14px; font-size: 13.5px; color: #a99cc9; text-align: center; }
