/* =========================================================
   PPS+ Grades — Premium Academic Control Center (v3)
   ========================================================= */
/* =========================================================
   Premium Empty/State Cards (Whitelist / Unavailable)
   ========================================================= */
.state-card{
  width: min(720px, calc(100% - 32px));
  margin: 24px auto;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.085), rgba(255,255,255,.05));
  box-shadow: var(--shadow-soft);
  padding: 18px 18px;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.state-card::before{
  content:"";
  position:absolute;
  inset: -60px -80px auto auto;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(124,92,255,.28), transparent 62%);
  pointer-events:none;
}

.state-icon{
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.86);
  box-shadow: 0 16px 36px rgba(0,0,0,.28);
}

.state-title{
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -.01em;
  margin-bottom: 6px;
}

.state-sub{
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  max-width: 62ch;
  margin: 0 auto 14px;
}

.state-actions{
  display:flex;
  gap: 10px;
  justify-content:center;
  flex-wrap: wrap;
}

.state-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  text-decoration:none;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: .15px;
  transition: transform .2s ease, background .2s ease, border-color .2s ease, filter .2s ease;
}

.state-btn.ghost{
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.90);
}

.state-btn.ghost:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.16);
  transform: translateY(-1px);
}

.state-btn.primary{
  background: linear-gradient(90deg, rgba(124,92,255,.95), rgba(124,92,255,.78));
  border-color: rgba(124,92,255,.35);
  color: #0b0b12;
  box-shadow: 0 18px 40px rgba(124,92,255,.18);
}

.state-btn.primary:hover{
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.state-btn:focus-visible{
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

:root{
  --bg0: #070812;
  --bg1: #0b0d1a;
  --panel: rgba(255,255,255,.06);
  --panel-2: rgba(255,255,255,.08);
  --border: rgba(255,255,255,.10);
  --border-2: rgba(255,255,255,.14);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.68);
  --muted-2: rgba(255,255,255,.52);

  /* single accent */
  --accent: #7c5cff;

  --shadow: 0 18px 55px rgba(0,0,0,.40);
  --shadow-soft: 0 10px 30px rgba(0,0,0,.25);
  --radius: 16px;
  --radius-sm: 12px;

  --ringTrack: rgba(255,255,255,.12);
  --focus: rgba(124,92,255,.70);
}

*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 20% 0%, rgba(124,92,255,.22), transparent 60%),
              radial-gradient(900px 600px at 85% 10%, rgba(0, 184, 255, .12), transparent 55%),
              linear-gradient(180deg, var(--bg0), var(--bg1));
  overflow-x:hidden;
}

/* subtle grain */
.bg{
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.25'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* =========================================================
   Loader (kept, upgraded)
   ========================================================= */
#loader{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 1000;
  background: radial-gradient(900px 700px at 30% 0%, rgba(124,92,255,.22), transparent 60%),
              linear-gradient(180deg, var(--bg0), var(--bg1));
  transition: opacity .6s ease;
}
.loader-content{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 14px;
  text-align:center;
}
#loadingLogo{
  width: 84px;
  height: auto;
  filter: drop-shadow(0 18px 38px rgba(0,0,0,.45));
  animation: floaty 1.2s ease-in-out infinite;
}
.loader-sub{
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .2px;
}
@keyframes floaty{
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(-10px); }
}
body.loaded #loader{
  opacity: 0;
  pointer-events:none;
}

/* =========================================================
   Shell + Topbar
   ========================================================= */
.shell{
  width: 100%;
  min-height: 100%;
}
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  padding: 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(10,11,20,.70), rgba(10,11,20,.45));
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}
.topbar-left{
  display:flex;
  align-items:center;
  gap: 14px;
  min-width: 0;
}
.brand{
  display:flex;
  align-items:center;
  gap: 10px;
  text-decoration:none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.brand:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.12);
}
.brand-logo{
  width: 24px;
  height: 24px;
}
.brand-name{
  font-weight: 800;
  letter-spacing: .2px;
  font-size: 13px;
  opacity: .95;
}
.page-title{
  display:flex;
  flex-direction:column;
  gap: 2px;
  min-width: 0;
}
.kicker{
  font-size: 11px;
  color: var(--muted-2);
  letter-spacing: .35px;
  text-transform: uppercase;
}
.headline{
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .2px;
}

.topbar-right{
  display:flex;
  align-items:center;
  gap: 10px;
}

/* icon button */
.icon-btn{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  color: rgba(255,255,255,.88);
  display:grid;
  place-items:center;
  cursor:pointer;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.icon-btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.14);
}
.icon-btn:focus-visible{
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* notifications "on" state (JS toggles .on on #notify-btn today) */
#notify-btn.on{
  border-color: rgba(124,92,255,.35);
  background: linear-gradient(180deg, rgba(124,92,255,.25), rgba(255,255,255,.06));
  box-shadow: 0 10px 26px rgba(124,92,255,.16);
}

/* sandbox switch */
.sb-toggle{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  cursor:pointer;
  user-select:none;
  transition: background .2s ease, border-color .2s ease;
}
.sb-toggle:hover{
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.14);
}
.sb-toggle input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.sb-track{
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.12);
  position: relative;
  transition: background .2s ease, border-color .2s ease;
}
.sb-track::after{
  content:"";
  position:absolute;
  top: 50%;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  transform: translateY(-50%);
  transition: transform .22s ease, background .2s ease;
  box-shadow: 0 10px 18px rgba(0,0,0,.25);
}
.sb-toggle input:checked + .sb-track{
  background: rgba(124,92,255,.25);
  border-color: rgba(124,92,255,.35);
}
.sb-toggle input:checked + .sb-track::after{
  transform: translate(18px, -50%);
  background: rgba(255,255,255,.92);
}
.sb-label{
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,.86);
}

/* =========================================================
   Content
   ========================================================= */
.content{
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 36px;
}
.hero{
  display:grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 16px;
  padding: 18px 0 10px;
  align-items: stretch;
}
@media (max-width: 900px){
  .hero{ grid-template-columns: 1fr; }
}
.hero-title{
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 850;
  letter-spacing: -.02em;
}
.hero-sub{
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
  max-width: 64ch;
}
.sb-help{
  margin-top: 12px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  color: rgba(255,255,255,.80);
  font-size: 12px;
}
.sb-help kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.25);
}

/* metric card (Weighted GPA) */
.metric-card{
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.05));
  box-shadow: var(--shadow-soft);
  padding: 16px 16px;
  position: relative;
  overflow:hidden;
}
.metric-card::before{
  content:"";
  position:absolute;
  inset: -80px -60px auto auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(124,92,255,.35), transparent 65%);
  filter: blur(2px);
  pointer-events:none;
}
.metric-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}
.metric-label{
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: rgba(255,255,255,.78);
}
.metric-pill{
  font-size: 11px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.80);
}
.metric-value{
  margin-top: 12px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -.02em;
}
.metric-note{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted-2);
}

/* =========================================================
   Courses Grid + Cards
   ========================================================= */
.grid-wrap{ padding-top: 8px; }

.grid{
  display:grid;
  gap: 14px;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1100px){ .grid{ grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px){ .grid{ grid-template-columns: 1fr; } }

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.045));
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  position: relative;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease, background .22s ease;
  overflow:hidden;
}
.card::after{
  content:"";
  position:absolute;
  inset: 0;
  pointer-events:none;
  opacity:0;
  background: radial-gradient(600px 200px at 20% 0%, rgba(124,92,255,.10), transparent 60%);
  transition: opacity .25s ease;
}
.card:hover{
  transform: translateY(-4px);
  border-color: rgba(255,255,255,.14);
  box-shadow: 0 18px 50px rgba(0,0,0,.34);
  background: linear-gradient(180deg, rgba(255,255,255,.085), rgba(255,255,255,.055));
}
.card:hover::after{ opacity: 1; }
.card:focus-within{
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* top badge (letter) */
.letter-badge{
  position:absolute;
  top: 12px;
  right: 12px;
  border-radius: 12px;
  padding: 6px 10px;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .3px;
  color:#fff;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
  backdrop-filter: blur(10px);
}

/* subject header */
.subject-head{ display:flex; gap: 12px; }
.subject-meta{
  display:flex;
  gap: 12px;
  align-items:flex-start;
  min-width: 0;
}
.meta-text{
  display:flex;
  flex-direction:column;
  gap: 8px;
  min-width: 0;
}
.name{
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.25;
  padding-right: 72px; /* room for letter badge */
  word-break: break-word;
}
.badge{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  color: rgba(255,255,255,.82);
  font-weight: 800;
  font-size: 12px;
}
.gpa-inline{
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18);
  color: rgba(255,255,255,.86);
  font-weight: 800;
  font-size: 11px;
}

/* ring */
.ring{
  --p: 0;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display:grid;
  place-items:center;
  position: relative;
  flex: 0 0 auto;
}
.ring::before{
  content:"";
  position:absolute;
  inset: 0;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(
    from -90deg,
    var(--accent) 0deg,
    var(--accent) calc(var(--p) * 1deg),
    var(--ringTrack) calc(var(--p) * 1deg),
    var(--ringTrack) 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
}
.ring::after{
  content:"";
  position:absolute;
  inset: 9px;
  border-radius: 50%;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.08);
}
.ring span{
  position: relative;
  z-index: 1;
  font-weight: 900;
  font-size: 14px;
  color: rgba(255,255,255,.92);
}

/* =========================================================
   Tree breakdown
   ========================================================= */
.tree{
  margin: 12px 0 0;
  padding: 10px 0 0;
  list-style:none;
  border-top: 1px solid rgba(255,255,255,.08);
}
.node{
  list-style:none;
  margin: 0;
  padding: 0;
}
.node button{
  all: unset;
  display:flex;
  width:100%;
  cursor:pointer;
  border-radius: 12px;
  padding: 9px 10px;
  border: 1px solid transparent;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.node button:hover{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.10);
}
.node button:active{
  transform: translateY(1px);
}
.node button:focus-visible{
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.row{
  width:100%;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
}
.left{
  display:flex;
  align-items:flex-start;
  gap: 10px;
  min-width: 0;
}
.label{
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,.86);
  word-break: break-word;
}
.right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  min-width: 90px;
}
.score{
  font-size: 12px;
  font-weight: 900;
  color: rgba(255,255,255,.80);
}

/* caret */
.chev{
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: rgba(255,255,255,.55);
  transition: transform .2s ease;
}
details[open] > summary .chev{ transform: rotate(90deg); }
summary{ list-style:none; }
summary::-webkit-details-marker{ display:none; }
details{ padding-left: 18px; }

/* =========================================================
   Unavailable/Banned cards (kept, restyled)
   ========================================================= */
.glass-card{
  width: min(680px, calc(100% - 32px));
  margin: 24px auto;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}
.glass-text{
  margin: 0;
  color: rgba(255,255,255,.86);
  line-height: 1.4;
}

/* iOS modal kept (works with your JS) */
.ios-modal.hidden{ display:none; }
.ios-modal{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.70);
  backdrop-filter: blur(10px);
  z-index: 99999;
}
.ios-modal-content{
  width: min(420px, calc(100% - 32px));
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(18,20,26,.92);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align:center;
  position: relative;
}
.ios-modal-content p{
  margin: 8px 0 12px;
  color: rgba(255,255,255,.84);
  font-size: 13px;
}
.ios-modal-content video{
  width: 100%;
  border-radius: 14px;
  background: #000;
}
.ios-modal-content .close{
  position:absolute;
  right: 14px;
  top: 10px;
  font-size: 26px;
  cursor:pointer;
  color: rgba(255,255,255,.75);
}
body.modal-open{
  overflow:hidden !important;
  position: fixed;
  width: 100%;
}

/* utility */
.hidden{ display:none !important; }
/* =========================================================
   Centered State Overlay (Banned / Unavailable)
   ========================================================= */

.state-card{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9998;
  margin: 0;
}

/* Optional: dim the app behind it (premium feel) */
body.state-lock::after{
  content:"";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9997;
}

/* Prevent scroll when locked */
body.state-lock{
  overflow: hidden;
}
/* Long-press reliability on mobile */
.node button,
.node summary,
.node .label,
.node .score{
  -webkit-touch-callout: none; /* disable iOS callout */
  -webkit-user-select: none;
  user-select: none;
}

.node button{
  touch-action: manipulation; /* better tap/press behavior */
}


/* =========================================================
   Semester toggle (top right)
   ========================================================= */
.term-toggle{
  display:flex;
  align-items:center;
  gap: 0;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  overflow:hidden;
  height: 42px;
}
.term-btn{
  appearance:none;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.78);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .25px;
  padding: 0 12px;
  height: 42px;
  cursor:pointer;
  transition: background .18s ease, color .18s ease;
}
.term-btn:hover{
  background: rgba(255,255,255,.06);
}
.term-btn.active{
  background: linear-gradient(90deg, rgba(124,92,255,.95), rgba(124,92,255,.78));
  color: #0b0b12;
}
.term-btn:focus-visible{
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
@media (max-width: 520px){
  .term-btn{ padding: 0 10px; font-size: 11px; }
}


/* =========================================================
   Mobile top-right layout polish (prevents overlap)
   ========================================================= */
@media (max-width: 520px){
  .topbar{
    padding: 14px 12px;
    gap: 10px;
  }
  .topbar-right{
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  /* Keep controls compact */
  .icon-btn{
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }
  .term-toggle{
    height: 40px;
    border-radius: 13px;
  }
  .term-btn{
    height: 40px;
    padding: 0 10px;
    font-size: 11px;
  }
  /* Sandbox pill gets compact + label hides on very small screens */
  .sb-toggle{
    padding: 8px 10px;
    border-radius: 13px;
  }
  .sb-label{
    font-size: 12px;
  }
}

@media (max-width: 390px){
  /* On super small screens, hide "Sandbox" text so it doesn't collide */
  .sb-label{ display:none; }
  .sb-toggle{ gap: 8px; }
}
