[hidden]{display:none !important;}
.noscript{padding:14px;margin:14px;border:1px solid rgba(255,255,255,.2);border-radius:14px;background:rgba(0,0,0,.35);color:#fff;}
/* PSP Flashcard v9 - responsive, no build */
:root{
  --bg:#0b1220;
  --panel:#0f1a2f;
  --panel2:#101e37;
  --text:#e9eefb;
  --muted:#a7b4d6;
  --border:rgba(255,255,255,.08);
  --shadow: 0 14px 40px rgba(0,0,0,.35);
  --good: rgba(40, 198, 121, .18);
  --bad: rgba(255, 90, 90, .18);
  --good2: rgba(40, 198, 121, .34);
  --bad2: rgba(255, 90, 90, .34);
  --safeTop: env(safe-area-inset-top, 0px);
  --safeBottom: env(safe-area-inset-bottom, 0px);
  --topbarH: 0px;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1100px 700px at 20% 10%, rgba(77,163,255,.18), transparent 60%),
              radial-gradient(900px 600px at 80% 0%, rgba(154,245,184,.14), transparent 60%),
              var(--bg);
  color:var(--text);
}

a{ color:inherit; }

.app{
  display:grid;
  grid-template-columns: 280px 1fr;
  min-height:100vh;
}

.sidebar{
  position:sticky;
  top:0;
  height:100vh;
  padding:14px;
  border-right:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.00));
  backdrop-filter: blur(8px);
}

.sideHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:12px;
}
.brand{
  font-weight:800;
  letter-spacing:.2px;
}
.sideTools{
  display:flex;
  gap:8px;
  align-items:center;
  margin-bottom:10px;
}

.setList{
  display:flex;
  flex-direction:column;
  gap:8px;
  overflow:auto;
  height: calc(100vh - 170px);
  padding-right:4px;
}
.setItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(255,255,255,.03);
  cursor:pointer;
  user-select:none;
}
.setItem:hover{ background: rgba(255,255,255,.05); }
.setItem.isActive{ outline:2px solid rgba(77,163,255,.55); }
.setName{ font-weight:650; line-height:1.15; }
.setCount{ font-size:12px; color:var(--muted); white-space:nowrap; }

.sideFooter{
  margin-top:10px;
  font-size:12px;
  color:var(--muted);
}

.main{
  position:relative;
  padding:14px 14px calc(18px + var(--safeBottom)) 14px;
}

.topbar{
  position:sticky;
  top:0;
  z-index:50;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  padding:10px 10px;
  border:1px solid var(--border);
  border-radius:16px;
  background: rgba(15,26,47,.72);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.modes{ display:flex; gap:8px; align-items:center; }
.toggles{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.actions{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.spacer{ flex:1; }

.content{
  padding-top:14px;
  max-width: 1050px;
  margin: 0 auto;
}

.modePanel{ width:100%; }
.panelHeader{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:12px;
}
.panelTitle{ display:flex; flex-direction:column; gap:4px; }
.h1{ font-size:22px; font-weight:850; }
.muted{ color:var(--muted); }
.panelBtns{ display:flex; gap:10px; flex-wrap:wrap; }

.progressWrap{
  display:flex;
  align-items:center;
  gap:10px;
  margin: 10px 0 16px 0;
}
.progressBar{
  flex:1;
  height:10px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  overflow:hidden;
}
.progressFill{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, rgba(77,163,255,.95), rgba(154,245,184,.95));
}
.progressText{ font-size:12px; color:var(--muted); min-width:64px; text-align:right; }

.card{position:relative;
  border:1px solid var(--border);
  border-radius:20px;
  background: rgba(255,255,255,.03);
  box-shadow: var(--shadow);
  padding:18px;
  min-height: 260px;
  display:flex;
  flex-direction:column;
  gap:12px;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.card.isClickable{ cursor:pointer; }
.card:hover{ transform: translateY(-1px); }
.cardText{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  font-size:26px;
  line-height:1.25;
  padding:6px;
  white-space:pre-wrap;
  word-break:break-word;
}
.cardTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.badge{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  background: rgba(255, 191, 0, .18);
  border:1px solid rgba(255, 191, 0, .35);
}
.tintDot{
  width:14px;
  height:14px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
}

.cardBottom{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.chipRow{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.chip{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
}

.testBox{
  border:1px solid var(--border);
  border-radius:20px;
  background: rgba(255,255,255,.03);
  box-shadow: var(--shadow);
  padding:16px;
}
.testQuestion{position:relative;
  font-size:22px;
  font-weight:800;
  padding:10px 8px 14px 8px;
  text-align:center;
  white-space:pre-wrap;
  word-break:break-word;
}
.options{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
}
.option{
  border:1px solid var(--border);
  border-radius:16px;
  background: rgba(255,255,255,.03);
  padding:12px 12px;
  cursor:pointer;
  user-select:none;
  display:flex;
  gap:10px;
  align-items:flex-start;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.option:hover{ transform: translateY(-1px); background: rgba(255,255,255,.05); }
.optionKey{
  font-weight:900;
  color: rgba(154,245,184,.95);
}
.optionText{
  flex:1;
  white-space:pre-wrap;
  word-break:break-word;
}

.matchStats{ display:flex; gap:10px; flex-wrap:wrap; margin: 8px 0 12px 0; }
.matchGrid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:10px;
}
.tile{
  border:1px solid var(--border);
  border-radius:16px;
  background: rgba(255,255,255,.03);
  padding:12px;
  min-height:72px;
  cursor:pointer;
  user-select:none;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  white-space:pre-wrap;
  word-break:break-word;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.tile:hover{ transform: translateY(-1px); background: rgba(255,255,255,.05); }
.tile.isFlipped{ outline:2px solid rgba(77,163,255,.55); }
.tile.isMatched{ background: var(--good); border-color: rgba(40,198,121,.55); }
.tile.isHidden{ visibility:hidden; }

.emptyState{
  border:1px dashed rgba(255,255,255,.2);
  border-radius:20px;
  padding:18px;
  background: rgba(255,255,255,.02);
}
.emptyTitle{ font-size:18px; font-weight:850; margin-bottom:6px; }
.emptyHint{ color:var(--muted); }

.btn{
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px 12px;
  background: rgba(255,255,255,.03);
  color:var(--text);
  cursor:pointer;
  user-select:none;
  font-weight:650;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,.05); }
.btn:disabled{ opacity:.45; cursor:not-allowed; transform:none; }
.btnSmall{ padding:8px 10px; border-radius:12px; font-size:13px; }
.btnIcon{ padding:8px 10px; border-radius:12px; }
.btnPrimary{
  background: rgba(77,163,255,.22);
  border-color: rgba(77,163,255,.55);
}
.btnSuccess{
  background: rgba(40,198,121,.20);
  border-color: rgba(40,198,121,.55);
}
.btnDanger{
  background: rgba(255,90,90,.18);
  border-color: rgba(255,90,90,.55);
}
.btnGhost{
  background: rgba(255,255,255,.02);
}
.btnTab{
  padding:10px 12px;
  border-radius:999px;
}
.btnTab.isActive{
  background: rgba(77,163,255,.20);
  border-color: rgba(77,163,255,.55);
}
.btnPill{
  padding:8px 10px;
  border-radius:999px;
  font-size:13px;
}

.input{
  width:100%;
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px 12px;
  background: rgba(255,255,255,.03);
  color:var(--text);
  outline:none;
}
.input::placeholder{ color: rgba(167,180,214,.7); }

.fileBtn input{ display:none; }

.fab{
  position:fixed;
  right:16px;
  bottom: calc(16px + var(--safeBottom));
  border-radius:999px;
  width:54px;
  height:54px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:18px;
  z-index:60;
  box-shadow: var(--shadow);
}

.menu{
  position:fixed;
  right:16px;
  bottom: calc(78px + var(--safeBottom));
  min-width:160px;
  border:1px solid var(--border);
  border-radius:16px;
  background: rgba(15,26,47,.92);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index:60;
  overflow:hidden;
}
.menuItem{
  width:100%;
  text-align:left;
  padding:12px 12px;
  border:0;
  color:var(--text);
  background: transparent;
  cursor:pointer;
  font-weight:650;
}
.menuItem:hover{ background: rgba(255,255,255,.06); }


/* Mobile: move export FAB to top-right (avoid covering bottom UI) */
@media (max-width: 980px){
  .fab{
    top: calc(var(--topbarH) + 10px + var(--safeTop));
    bottom: auto;
  }
  .menu{
    top: calc(var(--topbarH) + 78px + var(--safeTop));
    bottom: auto;
  }
}

.overlay{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.45);
  z-index:55;
}

.modalHost{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:80;
}
.modal{
  width:min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow:auto;
  border:1px solid var(--border);
  border-radius:20px;
  background: rgba(15,26,47,.92);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.modalHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:14px 14px;
  border-bottom:1px solid var(--border);
}
.modalTitle{ font-size:16px; font-weight:850; }
.modalBody{ padding:14px; display:flex; flex-direction:column; gap:12px; }
.modalFooter{
  padding:14px;
  border-top:1px solid var(--border);
  display:flex;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
}

.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
.textarea{
  width:100%;
  min-height:180px;
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px 12px;
  background: rgba(255,255,255,.03);
  color:var(--text);
  outline:none;
  resize:vertical;
  white-space:pre;
}
.kv{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(255,255,255,.03);
}
.kv b{ font-weight:850; }

.hr{ height:1px; background: var(--border); margin:6px 0; }

.feedback-correct{
  background: var(--good) !important;
  border-color: rgba(40,198,121,.55) !important;
}
.feedback-wrong{
  background: var(--bad) !important;
  border-color: rgba(255,90,90,.55) !important;
}

.shake{
  animation: shake .35s ease-in-out;
}
@keyframes shake{
  0%{ transform: translateX(0); }
  20%{ transform: translateX(-7px); }
  40%{ transform: translateX(7px); }
  60%{ transform: translateX(-5px); }
  80%{ transform: translateX(5px); }
  100%{ transform: translateX(0); }
}

@media (max-width: 980px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{
    position:fixed;
    left:0;
    top:0;
    height:100vh;
    width:min(320px, 88vw);
    transform: translateX(-102%);
    transition: transform .2s ease;
    z-index:70;
    background: rgba(11,18,32,.92);
  }
  .sidebar.isOpen{ transform: translateX(0); }
  .main{ padding:12px 12px calc(18px + var(--safeBottom)) 12px; }
  .topbar{ gap:8px; }
  .actions{ width:100%; }
  .actions .btn, .actions label.btn{ flex:1 1 auto; justify-content:center; }
  .modes{ width:100%; }
  .modes .btn{ flex:1 1 auto; }
  .matchGrid{ grid-template-columns: repeat(3, 1fr); }
  .cardText{ font-size:24px; }
}

@media (max-width: 520px){
  .matchGrid{ grid-template-columns: repeat(2, 1fr); }
  .cardText{ font-size:22px; }
  .grid2{ grid-template-columns: 1fr; }
}

/* Match: facedown tiles should look clean */
.tile{min-height:56px;}
.tile.isFlipped{font-weight:600;}

/* Match: tiles are always visible; matched tiles disappear */
.tile{cursor:pointer; user-select:none;}
.tile.isMatched{visibility:hidden; pointer-events:none;}
.tile.isSelected{outline:2px solid rgba(255,255,255,.35); box-shadow:0 0 0 6px rgba(255,255,255,.06);}


/* ===== Mobile readability (iOS Safari friendly) =====
   Problem: heavy glass/blur + multiple gradients can cause banding/dirty tones on OLED/iOS.
   Fix: reduce blur, simplify surfaces, increase contrast, tighten spacing.
*/
@media (max-width: 980px){
  :root{
    --bg1:#060b16;
    --bg2:#0a1327;
    --panel: rgba(255,255,255,.06);
    --panel2: rgba(255,255,255,.08);
    --border: rgba(255,255,255,.14);
    --shadow: 0 10px 30px rgba(0,0,0,.38);
  }

  body{
    background: radial-gradient(1200px 700px at 50% 0%, rgba(80,140,255,.10), transparent 55%),
                linear-gradient(180deg, var(--bg1), var(--bg2));
  }

  /* Disable glass blur on mobile for cleaner colors */
  .topbar,
  .sidebar,
  .card,
  .testBox,
  .tile,
  .option,
  .menu,
  .modal{
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  /* Make surfaces more solid and readable */
  .topbar,
  .sidebar{
    background: rgba(8,14,28,.92) !important;
    border-color: var(--border) !important;
  }

  .btn,
  .input,
  .textarea,
  .option,
  .tile{
    background: rgba(12,20,40,.92) !important;
    border-color: var(--border) !important;
    box-shadow: none !important;
  }

  .btnTab{
    background: rgba(12,20,40,.72) !important;
  }
  .btnTab.isActive{
    background: rgba(80,140,255,.22) !important;
    border-color: rgba(80,140,255,.40) !important;
  }

  .card,
  .testBox{
    background: rgba(10,18,36,.92) !important;
    box-shadow: var(--shadow) !important;
  }

  .h1{
    letter-spacing: -0.2px;
  }

  /* Options: clearer separation */
  .option{
    background: rgba(12,20,40,.92) !important;
  }

  /* Reduce visual clutter in top area */
  .actions{
    gap: 10px !important;
  }
  .toggles{
    gap: 10px !important;
  }

  /* FAB button: keep readable */
  .fab{
    background: rgba(16,26,52,.95) !important;
    border-color: rgba(255,255,255,.20) !important;
  }
}

/* Contrast tweaks */
.optionKey{ opacity: .95; }
.muted{ opacity: .88; }

/* ===== Theme: flat vs glass ===== */
body.theme-flat{
  /* disable glass/blur everywhere */
}
body.theme-flat .topbar,
body.theme-flat .sidebar,
body.theme-flat .card,
body.theme-flat .testBox,
body.theme-flat .tile,
body.theme-flat .option,
body.theme-flat .menu,
body.theme-flat .modal{
  -webkit-backdrop-filter:none !important;
  backdrop-filter:none !important;
}
body.theme-flat .topbar,
body.theme-flat .sidebar{
  background: rgba(8,14,28,.92) !important;
}
body.theme-flat .btn,
body.theme-flat .input,
body.theme-flat .textarea,
body.theme-flat .option,
body.theme-flat .tile{
  background: rgba(12,20,40,.92) !important;
  box-shadow:none !important;
}

/* Mobile: collapse top controls */
@media (max-width: 980px){
  #btnControlsToggle{ display:inline-flex !important; }
  .topControls{ width:100%; }
  body.controls-collapsed .topControls{ display:none; }
}

.chipInline{display:inline-flex; align-items:center; padding:4px 10px; border-radius:999px; border:1px solid rgba(255,255,255,.16); background:rgba(255,255,255,.06); margin-left:8px; font-size:12px;}

/* Sidebar: favorites sub-item under each set */
.setSubItem{
  margin-left: 10px;
  margin-top: 6px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  cursor:pointer;
}
.setSubItem:hover{ background: rgba(255,255,255,.05); }
.setSubItem.isActive{
  border-color: rgba(80,140,255,.45);
  background: rgba(80,140,255,.12);
}
.setSubMeta{ font-size:12px; opacity:.82; }

/* Favorites star styling */
.btnFav{ font-weight:900; min-width: 64px; }
.btnFav.isStarred{ color:#ffd54a !important; text-shadow: 0 0 12px rgba(255,213,74,.7); }
.btnFavIcon{ font-size:18px; line-height:1; }
.btnFavIcon.isStarred{ color:#ffd54a !important; text-shadow: 0 0 14px rgba(255,213,74,.8); }
@keyframes starPulse{
  0%{ transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,213,74,0)); }
  50%{ transform: scale(1.10); filter: drop-shadow(0 0 12px rgba(255,213,74,.85)); }
  100%{ transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,213,74,0)); }
}
.btnFav.isStarred, .btnFavIcon.isStarred{ animation: starPulse .55s ease-in-out; }

/* Overlay star on cards/tests */
.starOverlay{
  position:absolute;
  top:12px;
  right:12px;
  z-index:50;
  border:1px solid var(--border);
  background: rgba(10,18,36,.75);
  padding:10px 12px;
  border-radius: 14px;
  cursor:pointer;
  font-size:18px;
  line-height:1;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.starOverlay.isStarred{
  color:#ffd54a !important;
  text-shadow: 0 0 14px rgba(255,213,74,.85);
  border-color: rgba(255,213,74,.35);
}
.starOverlay:hover{ background: rgba(10,18,36,.88); }
.starOverlayTest{ top:10px; right:10px; }

/* Nav strip */
.navStrip{
  display:flex;
  gap:8px;
  overflow-x:auto;
  padding:10px 6px;
  margin: 8px 0 2px 0;
  scrollbar-width: none;
}
.navStrip::-webkit-scrollbar{ display:none; }

.navDot{
  flex:0 0 auto;
  min-width:28px;
  height:28px;
  border-radius:10px;
  font-size:11px;
  padding:0;
}
@media(max-width:600px){
  .navStrip{
    gap:4px;
    padding:6px 4px;
  }
  .navDot{
    min-width:24px;
    height:24px;
    font-size:10px;
  }
}

.navDot:hover{ background: rgba(255,255,255,.06); }
.navDot.isActive{
  border-color: rgba(80,140,255,.55);
  background: rgba(80,140,255,.18);
}
.navDot.isStarred{
  border-color: rgba(255,213,74,.35);
  box-shadow: 0 0 0 4px rgba(255,213,74,.08);
}

/* Nav status colors */
.navDot.isCorrect{ border-color: rgba(80,220,140,.55); background: rgba(80,220,140,.18); }
.navDot.isWrong{ border-color: rgba(255,90,90,.55); background: rgba(255,90,90,.16); }
.navDot.isUnanswered{ opacity:.65; }

/* Premium feel */
.modePanel{ animation: fadeIn .18s ease-out; }
@keyframes fadeIn{ from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:translateY(0);} }
.btn{ transition: transform .12s ease, filter .12s ease; }
.btn:active{ transform: scale(.98); }
.card{ border-radius: 24px; box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.testBox{ border-radius: 20px; }

/* Pro Match */
.proMatchWrap{ display:grid; grid-template-columns: 1fr 1fr; gap:14px; margin-top:14px; }
@media (max-width: 860px){ .proMatchWrap{ grid-template-columns: 1fr; } }
.proCol{ border:1px solid var(--border); border-radius: 18px; padding:12px; background: rgba(255,255,255,.03); }
.proColTitle{ font-weight:700; opacity:.9; margin-bottom:10px; }
.proList{ display:flex; flex-direction:column; gap:10px; min-height: 140px; }
.proItem{
  border:1px solid var(--border);
  border-radius: 16px;
  padding:12px 12px;
  background: rgba(255,255,255,.04);
  cursor: grab;
  user-select:none;
}
.proItem:active{ cursor: grabbing; }
.proSlot{ position:relative; }
.proSlot .slotHint{ opacity:.7; font-size:12px; margin-top:6px; }
.proItem.isGone{ opacity:0; transform: scale(.98); pointer-events:none; height:0; margin:0; padding:0; border:0; }
.proItem.isCorrect{ border-color: rgba(80,220,140,.55); background: rgba(80,220,140,.12); }
.proItem.isWrong{ border-color: rgba(255,90,90,.55); background: rgba(255,90,90,.10); }
.shakeOnce{ animation: shake .25s linear; }
@keyframes shake{
  0%,100%{ transform: translateX(0); }
  25%{ transform: translateX(-6px); }
  75%{ transform: translateX(6px); }
}

/* Nav paging arrows + status colors */
.navArrow{
  flex:0 0 auto;
  width:28px;
  height:28px;
  border-radius:10px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:14px;
  opacity:.95;
}
.navArrow:disabled{
  opacity:.35;
  cursor:not-allowed;
}
.navDot.isCorrect{
  border-color: rgba(46, 190, 110, .55);
  background: rgba(46, 190, 110, .18);
}
.navDot.isWrong{
  border-color: rgba(240, 70, 70, .55);
  background: rgba(240, 70, 70, .18);
}
@media(max-width:600px){
  .navArrow{
    width:24px;
    height:24px;
    border-radius:9px;
    font-size:13px;
  }
}

#btnProMatch{ display:none !important; }

/* Ensure nav strip clickable */
.navStrip{ position:relative; z-index:20; pointer-events:auto; }
.navStrip *{ pointer-events:auto; }
