@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: rgb(15, 15, 15);
  font-family: 'Outfit', sans-serif;
}

a { text-decoration: none; color: inherit; }

.background-image {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: 0;
}

/* ================= SIDEBAR (unchanged) ================= */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 85px;
  height: 100vh;
  background-color: rgb(23, 23, 23);
  border-right: 1px solid rgb(87, 87, 87);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.sidebar-top {
  position: absolute;
  top: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.sidebar-bottom {
  position: absolute;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.sidebar-icon { width: 60px; height: 60px; perspective: 1000px; }

.flip-box {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
  border-radius: 20%;
}

.flip-front, .flip-back {
  cursor: pointer;
  position: absolute;
  inset: 0;
  border-radius: 20%;
  display: flex;
  justify-content: center;
  align-items: center;
  backface-visibility: hidden;
  background-color: rgb(59, 59, 59);
}

.flip-front img { width: 30px; height: auto; }

.flip-back {
  transform: rotateY(180deg);
  color: rgb(82, 235, 223);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  text-align: center;
}

.sidebar-icon:hover .flip-box { transform: rotateY(180deg); }

.icon-offset-left { position: absolute; left: 18px; }
.icon-label-small { font-size: 10px; }

.sidebar-icon.active .flip-front { background-color: rgb(77, 220, 211); }
.sidebar-icon.active .flip-front img { filter: brightness(0) saturate(100%); }

/* ================= NAVBAR (unchanged) ================= */
.top-navbar {
  position: fixed;
  top: 0;
  left: 85px;
  width: calc(100% - 85px);
  height: 70px;
  background-color: rgb(23, 23, 23);
  border-bottom: 1px solid rgb(87, 87, 87);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 25px;
  z-index: 150;
}

.nav-left { display: flex; align-items: center; gap: 20px; flex: 1 1 auto; min-width: 0; }

.logo { height: 40px; width: auto; margin-left: 5px; margin-top: 5px; }
.logo-mobile { display: none; }

.search-form {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 480px;
  max-width: clamp(260px, 40vw, 850px);
  margin-right: 20px;
}

.search-input {
  width: 100%;
  height: 40px;
  border-radius: 100px;
  padding-left: 20px;
  padding-right: 40px;
  font-size: 15px;
  box-shadow: 0 0 0 4px rgb(58, 58, 58);
  border: 2px solid rgb(77, 220, 211);
  background-color: rgb(36, 36, 36);
  color: white;
  font-family: 'Outfit', sans-serif;
  transition: max-width 0.2s ease, width 0.2s ease;
}

.search-input::placeholder { color: rgba(255, 255, 255, 0.5); font-family: 'Outfit', sans-serif; }

.search-submit {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgb(77, 220, 211);
  background-color: rgb(77, 220, 211);
  cursor: pointer;
}

.nav-right { display: flex; align-items: center; gap: 25px; flex: 0 0 auto; }

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  color: rgb(82, 235, 223);
  font-size: 16px;
}

.user-info img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgb(67, 186, 176);
  object-fit: cover;
  background: rgb(59,59,59);
}

.notification img { display: block; cursor: pointer; }

/* ================= PAGE LAYOUT ================= */
.main-content-area {
  position: fixed;
  top: 70px;
  left: 85px;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 110;
  padding: 32px 40px 60px;
}

.page-header { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 28px; }

.page-header-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(82, 235, 223, 0.08);
  border: 1px solid rgb(67, 186, 176);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.page-header-icon img { width: 28px; height: auto; }

.page-header h1 {
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 34px;
  color: rgb(82, 235, 223);
  margin: 0 0 6px;
}

.page-header p {
  font-family: 'Outfit', sans-serif;
  font-weight: 300;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.65);
  margin: 0;
}

.panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgb(87, 87, 87);
  border-radius: 18px;
  padding: 24px 28px;
  margin-bottom: 24px;
}

.panel-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 18px;
  color: rgb(82, 235, 223);
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.view-all-btn {
  font-size: 13px;
  font-weight: 400;
  color: rgb(82, 235, 223);
  background: rgba(82, 235, 223, 0.08);
  border: 1px solid rgb(67, 186, 176);
  border-radius: 10px;
  padding: 6px 14px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
}
.view-all-btn:hover { background: rgba(82, 235, 223, 0.16); }

.btn {
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgb(87, 87, 87);
  background: rgb(30, 30, 30);
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: rgb(42, 42, 42); }

.btn-primary {
  border: none;
  background: linear-gradient(90deg, rgb(67, 186, 176), rgb(82, 235, 223));
  color: rgb(10, 20, 20);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

/* ============================================================
   1. FILTER RAIL — Year Group -> Module, as tappable chip rows
   (replaces the old dropdown filter grid)
   ============================================================ */
.filter-rail { }

.filter-step { margin-bottom: 18px; }
.filter-step:last-child { margin-bottom: 0; }

.filter-step-label {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 10px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  border: 1px solid rgb(87, 87, 87);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 100px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: rgba(77, 220, 211, 0.7); }
.chip.active {
  border-color: rgb(77, 220, 211);
  background: rgb(82, 235, 223);
  color: rgb(10, 20, 20);
  font-weight: 500;
}

.chip-row.disabled { opacity: 0.35; pointer-events: none; }

.filter-empty-hint {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.4);
  padding: 4px 0 2px;
}

.filter-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.6);
}

.filter-breadcrumb b { color: rgb(82, 235, 223); font-weight: 500; }

.breadcrumb-reset {
  margin-left: auto;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  background: none;
  border: 1px solid rgb(87, 87, 87);
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
}
.breadcrumb-reset:hover { border-color: rgba(255,255,255,0.4); color: white; }

.quick-picks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.quick-picks-label {
  font-size: 13px;
  color: rgb(82, 235, 223);
  font-weight: 500;
  margin-right: 4px;
}
.pill {
  border: 1px solid rgb(87, 87, 87);
  background: rgba(255, 255, 255, 0.03);
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 13.5px;
  padding: 8px 16px;
  border-radius: 100px;
  cursor: pointer;
}
.pill:hover { border-color: rgb(77, 220, 211); background: rgba(82, 235, 223, 0.1); color: rgb(82, 235, 223); }

/* ---- Progress panel (stats + chart) ---- */
.progress-layout { display: grid; grid-template-columns: 1fr 1.1fr; gap: 28px; align-items: center; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 20px; }

.stat-card { display: flex; align-items: center; gap: 12px; }

.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(82, 235, 223, 0.08);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.stat-icon img { width: 22px; height: auto; }

.stat-label { font-size: 13px; color: rgba(255, 255, 255, 0.6); margin: 0 0 2px; }
.stat-value { font-size: 24px; font-weight: 500; color: white; margin: 0; }

.chart-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgb(60, 60, 60);
  border-radius: 14px;
  padding: 16px 20px 10px;
}
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chart-header span { font-size: 14px; color: rgba(255,255,255,0.7); }
.chart-badge {
  background: rgb(82, 235, 223); color: rgb(10, 20, 20);
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 8px;
}
#accuracyChart { width: 100%; height: auto; display: block; }

/* ============================================================
   2. TOPIC GRID — the core redesign: topics as clickable tiles
   with a mastery ring, instead of a dropdown + separate mode panel
   ============================================================ */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.topic-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  border: 1px solid rgb(87, 87, 87);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.topic-card:hover {
  border-color: rgb(77, 220, 211);
  background: rgba(82, 235, 223, 0.05);
  transform: translateY(-1px);
}

.mastery-ring {
  --pct: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(rgb(82,235,223) calc(var(--pct) * 1%), rgba(255,255,255,0.08) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.mastery-ring::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgb(20, 20, 20);
}
.mastery-ring span {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.topic-card-text { flex: 1 1 auto; min-width: 0; }
.topic-card-text h4 {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 500;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topic-card-text p {
  margin: 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.5);
}

.topic-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 14.5px;
}
.topic-grid-empty img { width: 40px; height: auto; margin-bottom: 12px; opacity: 0.6; }

/* ============================================================
   MODAL — step 1 (topic detail) / step 2 (mode + settings)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 8, 0.65);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  background: rgb(23, 23, 23);
  border: 1px solid rgb(87, 87, 87);
  border-radius: 20px;
  padding: 28px;
  position: relative;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgb(87, 87, 87);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.modal-close:hover { border-color: rgba(255,255,255,0.4); color: white; }

.modal-back {
  background: none;
  border: none;
  color: rgb(82, 235, 223);
  font-family: 'Outfit', sans-serif;
  font-size: 13.5px;
  cursor: pointer;
  padding: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-eyebrow {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  margin: 0 0 6px;
}

.modal-title {
  font-size: 22px;
  font-weight: 500;
  color: white;
  margin: 0 0 14px;
  padding-right: 30px;
}

.modal-mastery-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.modal-mastery-row .mastery-ring { width: 54px; height: 54px; }
.modal-mastery-row .mastery-ring span { font-size: 13px; }
.modal-mastery-text { font-size: 13px; color: rgba(255, 255, 255, 0.55); }
.modal-mastery-text b { color: white; font-weight: 500; }

.modal-description {
  font-size: 14.5px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.72);
  margin: 0 0 26px;
}

/* mode cards inside step 2 */
.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border: 1px solid rgb(87, 87, 87);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mode-card:hover { border-color: rgba(77, 220, 211, 0.6); }
.mode-card.selected { border-color: rgb(77, 220, 211); background: rgba(82, 235, 223, 0.06); }

.mode-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 17px;
}
.mode-card.selected .mode-icon { background: rgba(82, 235, 223, 0.15); }

.mode-text { flex: 1 1 auto; min-width: 0; }
.mode-text h4 { margin: 0 0 2px; font-size: 15px; font-weight: 500; color: white; }
.mode-text p { margin: 0; font-size: 12.5px; color: rgba(255, 255, 255, 0.55); line-height: 1.45; }

.mode-radio {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgb(87, 87, 87);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.mode-card.selected .mode-radio { border-color: rgb(77, 220, 211); background: rgb(77, 220, 211); }
.mode-radio::after {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: rgb(10, 20, 20); display: none;
}
.mode-card.selected .mode-radio::after { display: block; }

/* mode settings (revealed under the selected mode card) */
.mode-settings {
  margin: 4px 0 22px;
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.015);
}
.mode-settings-label {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 10px;
}

.time-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.time-chip {
  border: 1px solid rgb(87, 87, 87);
  background: rgba(255,255,255,0.03);
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 13.5px;
  padding: 7px 14px;
  border-radius: 100px;
  cursor: pointer;
}
.time-chip.active { border-color: rgb(77, 220, 211); background: rgb(82, 235, 223); color: rgb(10,20,20); font-weight: 500; }

.stepper-row { display: flex; align-items: center; gap: 16px; }
.stepper-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid rgb(87, 87, 87);
  background: rgba(255,255,255,0.03);
  color: white; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.stepper-btn:hover { border-color: rgb(77, 220, 211); }
.stepper-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.stepper-value { font-size: 22px; font-weight: 500; color: white; min-width: 70px; text-align: center; }
.stepper-cap { font-size: 12px; color: rgba(255,255,255,0.4); margin-top: 6px; }

.modal-start-btn { width: 100%; height: 48px; font-size: 15.5px; }

/* ---- Continue where you left off ---- */
.continue-item { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.continue-item:last-of-type { border-bottom: none; }
.continue-text { flex: 1 1 auto; min-width: 0; }
.continue-text h4 { margin: 0 0 4px; font-size: 15.5px; font-weight: 500; color: white; }
.continue-text p { margin: 0 0 8px; font-size: 13px; color: rgba(255, 255, 255, 0.55); }
.progress-bar-track { width: 100%; height: 6px; border-radius: 100px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 100px; background: linear-gradient(90deg, rgb(67, 186, 176), rgb(82, 235, 223)); }
.continue-percent { font-size: 13px; color: rgba(255, 255, 255, 0.6); width: 40px; text-align: right; flex-shrink: 0; }
.continue-item .btn { flex-shrink: 0; background: rgba(82, 235, 223, 0.08); border-color: rgb(67, 186, 176); color: rgb(82, 235, 223); }
.continue-item .btn:hover { background: rgba(82, 235, 223, 0.18); }

.recommended-panel { margin-top: 24px; }
.recommended-topics { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- tip bar ---- */
.tip-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; }
.tip-left { display: flex; align-items: center; gap: 12px; }
.tip-left img { width: 20px; height: auto; }
.tip-left span { font-size: 14.5px; color: rgba(255, 255, 255, 0.75); }
.tip-bar .link-arrow { color: rgb(82, 235, 223); font-size: 14.5px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ================= RESPONSIVE ================= */
@media (max-width: 1150px) {
  .progress-layout { grid-template-columns: 1fr; }
}

@media (max-width: 1000px) {
  .sidebar {
    top: auto; bottom: 0; left: 0; width: 100vw; height: 60px;
    flex-direction: row; justify-content: center; align-items: center; gap: 10px;
    padding: 0; border-right: none; border-top: 1px solid rgb(87, 87, 87);
  }
  .sidebar-top, .sidebar-bottom { display: contents; }
  .sidebar-icon { width: 42px; height: 42px; }
  .flip-front img { width: 22px; }
  .icon-offset-left { position: static; left: auto; }

  .top-navbar { left: 0; width: 100%; height: 60px; padding: 0 12px; }
  .logo-desktop { display: none; }
  .logo-mobile { display: block; height: 40px; width: auto; }
  .user-info span { display: none; }
  .user-info img { width: 30px; height: 30px; }

  .main-content-area { left: 0; top: 60px; bottom: 60px; padding: 20px 16px 40px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .topic-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 620px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .page-header h1 { font-size: 26px; }
  .topic-grid { grid-template-columns: 1fr 1fr; }
}