/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #eef0f8;
  --surface:     #ffffff;
  --surface-2:   #f4f5fb;
  --border:      #dde0ee;
  --navy:        #1a2155;
  --navy-light:  #2e3a7a;
  --purple:      #7c5cbf;
  --purple-light:#9b7ed4;
  --purple-bg:   #f0ebfa;
  --green:       #22a869;
  --green-bg:    #e8f8f1;
  --red:         #e0445a;
  --red-bg:      #fdedf0;
  --yellow:      #f5c842;
  --text:        #1a2155;
  --text-muted:  #7a80a0;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 2px 12px rgba(26,33,85,.08);
  --shadow-md:   0 4px 24px rgba(26,33,85,.12);
  --transition:  .18s ease;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(26,33,85,.06);
}
.navbar__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--navy);
  text-decoration: none;
  letter-spacing: -.01em;
}
.navbar__actions { display: flex; align-items: center; gap: .75rem; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main { flex: 1; padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .85rem;
  border-top: 1px solid var(--border);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition), opacity var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--primary   { background: var(--navy); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--navy-light); }

.btn--outline   { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn--outline:hover:not(:disabled) { background: var(--navy); color: #fff; }

.btn--purple    { background: var(--purple); color: #fff; }
.btn--purple:hover:not(:disabled) { background: var(--purple-light); }

.btn--purple-outline { background: transparent; color: var(--purple); border-color: var(--purple); }
.btn--purple-outline:hover:not(:disabled) { background: var(--purple); color: #fff; }

.btn--ghost     { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn--danger    { background: var(--red); color: #fff; border-color: var(--red); }
.btn--danger:hover:not(:disabled) { background: #c53349; }

.btn--danger-outline { background: transparent; color: var(--red); border-color: var(--red); }
.btn--danger-outline:hover:not(:disabled) { background: var(--red-bg); }

.btn--green     { background: var(--green); color: #fff; }
.btn--green:hover:not(:disabled) { background: #1b8f58; }

.btn--sm   { padding: .38rem .85rem; font-size: .82rem; border-radius: var(--radius-sm); }
.btn--lg   { padding: .75rem 1.8rem; font-size: 1rem; }
.btn--icon { padding: .5rem; border-radius: var(--radius-sm); }

/* ── Cards / surfaces ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* ── Page header row ─────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.7rem; font-weight: 700; color: var(--navy); }

/* ── Section heading ─────────────────────────────────────────────────────── */
.section-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 1rem;
}

/* ── Dashboard grid ──────────────────────────────────────────────────────── */
.sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}
.set-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: box-shadow var(--transition), transform var(--transition);
  border: 1.5px solid transparent;
}
.set-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border); }
.set-card__name { font-size: 1.05rem; font-weight: 700; color: var(--navy); }
.set-card__meta { font-size: .82rem; color: var(--text-muted); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge--folder  { background: var(--purple-bg); color: var(--purple); }
.badge--public  { background: var(--green-bg);  color: var(--green); }
.badge--private { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.set-card__actions { display: flex; gap: .5rem; margin-top: .4rem; }

.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.folder-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--navy);
  border: 1.5px solid transparent;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.folder-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--purple); }
.folder-card__icon {
  width: 44px; height: 44px;
  background: var(--purple-bg);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--purple);
}
.folder-card__name  { font-weight: 700; font-size: .95rem; }
.folder-card__count { font-size: .78rem; color: var(--text-muted); }

/* ── Empty states ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}
.empty-state svg { opacity: .3; margin-bottom: .75rem; }
.empty-state p { margin-bottom: 1rem; font-size: .95rem; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .4rem; color: var(--navy); }
.form-control {
  width: 100%;
  padding: .65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124,92,191,.15);
  background: var(--surface);
}
select.form-control { cursor: pointer; appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Set Editor ──────────────────────────────────────────────────────────── */
.editor-topbar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.editor-topbar__name {
  flex: 1;
  min-width: 200px;
}
.editor-topbar__name input {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: .2rem .4rem;
  width: 100%;
  transition: border-color var(--transition);
}
.editor-topbar__name input:focus {
  outline: none;
  border-bottom-color: var(--purple);
}
.editor-topbar__meta { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.save-status { font-size: .82rem; color: var(--text-muted); display: flex; align-items: center; gap: .35rem; }
.save-status.saved   { color: var(--green); }
.save-status.saving  { color: var(--yellow); }

.cards-list { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1.5rem; }

.card-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1.5px solid var(--border);
  transition: box-shadow var(--transition);
}
.card-panel.sortable-ghost { opacity: .35; }
.card-panel.sortable-drag  { box-shadow: var(--shadow-md); }

.card-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  cursor: grab;
}
.card-panel__header:active { cursor: grabbing; }
.card-panel__num { font-weight: 800; font-size: 1rem; color: var(--navy); }

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: .15rem;
  flex-wrap: wrap;
}
.rich-toolbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 .25rem; }
.rich-btn {
  width: 30px; height: 30px;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.rich-btn:hover { background: var(--surface-2); color: var(--text); }
.rich-btn.active { background: var(--purple-bg); color: var(--purple); }
.rich-btn svg { pointer-events: none; }

.card-panel__body { display: flex; gap: 0; }

.card-side {
  flex: 1;
  padding: 1.25rem;
  min-width: 0;
}
.card-side + .card-side { border-left: 1px solid var(--border); }
.card-side__label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-content {
  min-height: 70px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  font-size: .93rem;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  word-break: break-word;
  line-height: 1.5;
}
.card-content:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124,92,191,.12);
  background: var(--surface);
}
.card-content ul, .card-content ol { padding-left: 1.3em; }

/* image slots */
.img-slots { display: flex; gap: .6rem; margin-top: .75rem; flex-wrap: wrap; }
.img-slot {
  width: 90px; height: 70px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface-2);
  font-size: .7rem;
  color: var(--text-muted);
  gap: .25rem;
}
.img-slot:hover { border-color: var(--purple); background: var(--purple-bg); color: var(--purple); }
.img-slot img { width: 100%; height: 100%; object-fit: cover; }
.img-slot input[type="file"] { display: none; }
.img-slot__del {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  background: rgba(224,68,90,.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: .75rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.img-slot:hover .img-slot__del,
.img-slot--filled .img-slot__del { display: flex; }

/* ── Study mode ──────────────────────────────────────────────────────────── */
.study-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 1rem 0 2rem;
}
.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.study-header h1 { font-size: 1.25rem; font-weight: 700; color: var(--navy); }
.study-header__actions { display: flex; gap: .5rem; }

/* progress bar */
.study-progress { margin-bottom: 1.25rem; }
.study-progress__bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.study-progress__fill {
  height: 100%;
  background: var(--purple);
  border-radius: 99px;
  transition: width .4s ease;
}
.study-progress__labels {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .3rem;
}
.study-progress__labels span { display: flex; align-items: center; gap: .3rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--know    { background: var(--green); }
.dot--learn   { background: var(--red); }
.dot--unseen  { background: var(--border); }

/* flip card */
.flip-scene {
  perspective: 1200px;
  margin-bottom: 1.5rem;
  cursor: pointer;
}
.flip-card {
  width: 100%;
  min-height: 320px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 320px;
  border: 1.5px solid var(--border);
}
.flip-face--back { transform: rotateY(180deg); }
.flip-face__label {
  position: absolute;
  top: 1rem; left: 1.5rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}
.flip-face__icons {
  position: absolute;
  top: .75rem; right: 1rem;
  display: flex;
  gap: .4rem;
}
.flip-face__content {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--navy);
  text-align: center;
  max-width: 560px;
  line-height: 1.6;
}
.flip-face__images {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
}
.flip-face__images img {
  max-height: 140px;
  max-width: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.flip-hint {
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* bank buttons */
.bank-btns {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.bank-btns.hidden { visibility: hidden; }
.bank-btn {
  flex: 1;
  max-width: 200px;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.bank-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.bank-btn--know  { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.bank-btn--learn { background: var(--red-bg);   color: var(--red);   border-color: var(--red); }

/* study toolbar */
.study-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.study-counter { font-size: 1rem; font-weight: 600; color: var(--navy); min-width: 60px; text-align: center; }
.study-nav { display: flex; align-items: center; gap: .5rem; }
.nav-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.nav-btn:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-bg); }
.nav-btn--next {
  width: 52px; height: 52px;
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}
.nav-btn--next:hover { background: var(--purple-light); border-color: var(--purple-light); color: #fff; }
.nav-btn:disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

.icon-btn {
  width: 38px; height: 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  text-decoration: none;
}
.icon-btn:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-bg); }
.icon-btn.active { background: var(--purple); border-color: var(--purple); color: #fff; }

/* round complete overlay */
.round-complete {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,33,85,.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.round-complete.show { display: flex; }
.round-complete__box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem 3rem;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.round-complete__box h2 { font-size: 1.5rem; color: var(--navy); margin-bottom: .75rem; }
.round-complete__box p  { color: var(--text-muted); margin-bottom: 1.5rem; }
.round-complete__actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ── Folder view ─────────────────────────────────────────────────────────── */
.folder-header-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.folder-icon-lg {
  width: 52px; height: 52px;
  background: var(--purple-bg);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--purple);
  flex-shrink: 0;
}
.folder-header-bar h1 { font-size: 1.6rem; font-weight: 700; color: var(--navy); }
.folder-header-bar p  { font-size: .88rem; color: var(--text-muted); }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,33,85,.45);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  animation: modal-in .2s ease;
}
@keyframes modal-in {
  from { opacity:0; transform: scale(.95) translateY(-8px); }
  to   { opacity:1; transform: none; }
}
.modal h2 { font-size: 1.2rem; color: var(--navy); margin-bottom: 1.25rem; }
.modal__footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  font-size: .75rem;
  padding: .3rem .65rem;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 99;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  font-weight: 500;
}
.alert--error   { background: var(--red-bg);   color: var(--red); }
.alert--success { background: var(--green-bg); color: var(--green); }

/* ── Quizlet-style study layout (sq-*) ──────────────────────────────────── */
.sq-wrap { max-width: 820px; margin: 0 auto; }

.sq-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.sq-header__crumb { font-size: .78rem; color: var(--text-muted); }
.sq-header__crumb a { color: var(--text-muted); text-decoration: none; }
.sq-header__crumb a:hover { color: var(--navy); }
.sq-header__actions { display: flex; gap: .4rem; }

/* Score row */
.sq-score-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .6rem;
}
.sq-score {
  display: flex; align-items: center; gap: .6rem;
  font-size: .88rem; font-weight: 600;
}
.sq-score--learn { color: var(--red); }
.sq-score--know  { color: var(--green); }
.sq-badge {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .9rem;
  border: 2.5px solid currentColor;
}
.sq-counter { font-size: .85rem; font-weight: 600; color: var(--text-muted); }

/* Thin progress bar */
.sq-progress-bar {
  height: 4px; background: var(--border);
  border-radius: 4px; overflow: hidden; margin-bottom: .9rem;
}
.sq-progress-fill {
  height: 100%; background: var(--purple);
  border-radius: 4px; transition: width .35s ease; width: 0%;
}

/* Flip card */
.sq-card-scene {
  perspective: 1200px;
  margin-bottom: 1.1rem;
  cursor: pointer;
  user-select: none;
}
.sq-card {
  position: relative;
  width: 100%; min-height: 340px;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
}
.sq-card.flipped { transform: rotateY(180deg); }
.sq-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 1.25rem 1.75rem 0;
  display: flex; flex-direction: column;
  min-height: 340px;
}
.sq-face--back { transform: rotateY(180deg); }

.sq-face__top {
  display: flex; align-items: flex-start; justify-content: space-between;
  min-height: 34px;
}
.sq-face__side-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
}
.sq-face__images {
  display: flex; gap: .75rem; flex-wrap: wrap;
  margin: .5rem 0;
}
.sq-face__images img {
  max-height: 130px; max-width: 200px; object-fit: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.sq-face__content {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 1.45rem; font-weight: 500; color: var(--navy);
  text-align: center; line-height: 1.5; padding: .75rem 0;
}
.sq-hint-reveal {
  display: none; text-align: center; padding: .45rem .9rem;
  background: var(--purple-bg); border-radius: var(--radius-sm);
  color: var(--purple); font-size: .88rem; font-style: italic;
  margin-bottom: .5rem;
}

/* Flip hint bar — sits at the bottom of each face, flips with the card */
.sq-flip-hint {
  margin-top: auto;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-radius: 0 0 calc(var(--radius) - 1.5px) calc(var(--radius) - 1.5px);
  padding: .55rem 1.5rem;
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem; color: var(--text-muted);
}
.sq-flip-hint strong { color: var(--navy); }
.sq-flip-hint kbd {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 4px; padding: .1rem .45rem;
  font-size: .75rem; font-family: monospace; color: var(--navy);
}

/* Icon buttons on card */
.sq-icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1.5px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  text-decoration: none;
}
.sq-icon-btn:hover { background: var(--purple-bg); color: var(--purple); border-color: var(--purple); }

/* Hint button */
.sq-hint-btn {
  background: transparent; border: none;
  color: var(--text-muted); font-size: .8rem; cursor: pointer;
  display: flex; align-items: center; gap: .3rem;
  padding: 0; transition: color var(--transition);
}
.sq-hint-btn:hover:not(:disabled) { color: var(--purple); }
.sq-hint-btn:disabled { opacity: .4; cursor: default; }

/* Bank buttons */
.sq-bank-row {
  display: flex; gap: 1.25rem; justify-content: center;
  margin-bottom: 1.1rem;
}
.sq-bank-btn {
  flex: 1; max-width: 230px;
  padding: .9rem 1.25rem; border-radius: var(--radius);
  font-size: .95rem; font-weight: 700; cursor: pointer;
  border: 2.5px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.sq-bank-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.sq-bank-btn--learn { background: transparent; color: var(--red);   border-color: var(--red); }
.sq-bank-btn--learn:hover { background: var(--red-bg); }
.sq-bank-btn--know  { background: transparent; color: var(--green); border-color: var(--green); }
.sq-bank-btn--know:hover  { background: var(--green-bg); }

/* Bottom toolbar */
.sq-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 .1rem;
}
.sq-tool-btn {
  display: flex; align-items: center; gap: .4rem;
  background: transparent; border: 1.5px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius-sm);
  padding: .45rem .9rem; font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.sq-tool-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--navy); border-color: var(--navy); }
.sq-tool-btn.active { background: var(--purple-bg); color: var(--purple); border-color: var(--purple); }
.sq-tool-btn:disabled { opacity: .35; cursor: not-allowed; }
.sq-nav { display: flex; align-items: center; gap: .5rem; }
.sq-nav-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.sq-nav-btn:hover:not(:disabled) { border-color: var(--purple); color: var(--purple); background: var(--purple-bg); }
.sq-nav-btn--next {
  width: 46px; height: 46px;
  background: var(--purple); border-color: var(--purple); color: #fff;
}
.sq-nav-btn--next:hover:not(:disabled) { background: var(--purple-light); border-color: var(--purple-light); }
.sq-nav-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Study flat card (replaces flip card) ────────────────────────────────── */
.study-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1.5px solid var(--border);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.study-face { padding: 1.5rem 2rem; }
.study-face--back {
  background: var(--surface-2);
  border-top: 2px dashed var(--border);
}
.study-face__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .75rem;
}
.study-face__actions { display: flex; gap: .4rem; }
.study-face__content {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--navy);
  line-height: 1.6;
}
.study-face__images {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.study-face__images img {
  max-height: 120px;
  max-width: 180px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Drag-over state for image slots */
.img-slot.drag-over {
  border-color: var(--purple);
  background: var(--purple-bg);
  color: var(--purple);
}

/* ── Live score bar (fixed right) ────────────────────────────────────────── */
.score-bar {
  position: fixed;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 23px;
  box-shadow: var(--shadow);
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  z-index: 50;
}
.score-bar__pct {
  font-size: .62rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.02em;
}
.score-bar__track {
  width: 14px;
  height: 120px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.score-bar__fill {
  width: 100%;
  background: var(--green);
  border-radius: 7px;
  transition: height .5s ease;
  height: 0%;
}

/* ── Settings FAB ────────────────────────────────────────────────────────── */
.settings-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .5rem;
}
.settings-fab__btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: background var(--transition), transform var(--transition);
}
.settings-fab__btn:hover { background: var(--navy-light); transform: rotate(25deg); }
.settings-panel {
  display: none;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.1rem 1.2rem;
  width: 260px;
  animation: modal-in .15s ease;
}
.settings-panel.open { display: block; }
.settings-panel__title {
  font-weight: 700;
  font-size: .88rem;
  color: var(--navy);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.settings-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: .3rem;
}
.speed-slider {
  width: 100%;
  accent-color: var(--purple);
  cursor: pointer;
}

/* ── Info FAB (bottom-left shortcuts) ───────────────────────────────────── */
.info-fab {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;
}
.info-fab__btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--navy);
  border: 1.5px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}
.info-fab__btn:hover { background: var(--surface-hover, #f1f5f9); border-color: var(--purple); color: var(--purple); }
.info-panel {
  display: none;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1rem 1.1rem;
  width: 220px;
  animation: modal-in .15s ease;
}
.info-panel.open { display: block; }
.info-panel__title {
  font-weight: 700;
  font-size: .82rem;
  color: var(--navy);
  margin-bottom: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.info-table td { padding: .25rem .4rem; color: var(--text-muted, #64748b); }
.info-table td:first-child { padding-right: .75rem; }
.info-table kbd {
  display: inline-block;
  background: var(--surface-alt, #f1f5f9);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1rem .35rem;
  font-family: monospace;
  font-size: .78rem;
  color: var(--navy);
  box-shadow: 0 1px 0 var(--border);
}

/* ── Pie chart (round complete) ──────────────────────────────────────────── */
.pie-wrap {
  position: relative;
  width: 130px;
  height: 130px;
  margin: 0 auto 1.25rem;
}
.pie-svg {
  width: 100%;
  height: 100%;
}
.pie-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
}
.pie-pct {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}
.pie-sub {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

/* ── Edit modal image slots ──────────────────────────────────────────────── */
.modal-edit-sides {
  display: flex;
  gap: 1.25rem;
  margin-bottom: .5rem;
}
.modal-edit-side { flex: 1; min-width: 0; }
.modal-side-label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .4rem;
}
.modal-img-slot { margin-top: .6rem; }
.modal-img-preview {
  position: relative;
  display: inline-block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.modal-img-preview img {
  display: block;
  max-height: 100px;
  max-width: 100%;
  object-fit: contain;
}
.modal-img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,33,85,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  opacity: 0;
  transition: opacity var(--transition);
}
.modal-img-preview:hover .modal-img-overlay { opacity: 1; }
.modal-img-change,
.modal-img-del {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .55rem;
  border-radius: 5px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.modal-img-change {
  background: rgba(255,255,255,.9);
  color: var(--navy);
  cursor: pointer;
}
.modal-img-change input[type="file"] { display: none; }
.modal-img-del {
  background: rgba(224,68,90,.9);
  color: #fff;
}
.modal-img-empty {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .85rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.modal-img-empty:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-bg); }
.modal-img-empty input[type="file"] { display: none; }

/* ── Print styles ────────────────────────────────────────────────────────── */
@media print {
  .navbar, .footer, .study-toolbar, .bank-btns,
  .study-header__actions, .study-progress,
  .study-face__actions, .round-complete { display: none !important; }

  body { background: #fff; }
  .study-wrap { max-width: 100%; }
  .study-card { box-shadow: none; page-break-inside: avoid; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .main { padding: 1.25rem 1rem; }
  .card-panel__body { flex-direction: column; }
  .card-side + .card-side { border-left: none; border-top: 1px solid var(--border); }
  .bank-btns { gap: .6rem; }
  .study-toolbar { gap: .5rem; }
  .score-bar { display: none; }
  .settings-fab { bottom: 1rem; right: 1rem; }
  .modal-edit-sides { flex-direction: column; gap: .75rem; }
}
