/* 7 Grades — cyan on ink. Dark by default, optional light mode. */

:root {
  --bg: #05090f;
  --bg-2: #080d16;
  --card: #0b1320;
  --card-2: #0e1828;
  --line: rgba(34, 211, 238, 0.13);
  --line-soft: rgba(148, 197, 210, 0.09);
  --cyan: #22d3ee;
  --cyan-deep: #0e7490;
  --cyan-glow: rgba(34, 211, 238, 0.35);
  --text: #e9f5f9;
  --muted: #8ea6b8;
  --faint: #5b7185;
  --good: #34d399;
  --ok: #a3e635;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --nav-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="light"] {
  --bg: #f2f7fa;
  --bg-2: #e9f1f6;
  --card: #ffffff;
  --card-2: #f4fafc;
  --line: rgba(8, 145, 178, 0.22);
  --line-soft: rgba(8, 145, 178, 0.1);
  --cyan: #0891b2;
  --cyan-deep: #0e7490;
  --cyan-glow: rgba(8, 145, 178, 0.25);
  --text: #0b1c26;
  --muted: #4b6474;
  --faint: #7d93a1;
  --good: #059669;
  --ok: #65a30d;
  --warn: #b45309;
  --bad: #dc2626;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 80% -10%, rgba(34, 211, 238, 0.07), transparent 60%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}

/* ---------- Loader: seven nodes build a geometric 7 ---------- */
.loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  z-index: 100;
  transition: opacity 0.3s;
}
.loader.done { opacity: 0; pointer-events: none; }
.seven-svg { width: 120px; height: 120px; overflow: visible; }
.s-node {
  fill: var(--cyan);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: node-in 2.1s ease-in-out infinite;
  animation-delay: var(--d);
}
.s-line {
  stroke: var(--cyan-deep);
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: line-in 2.1s ease-in-out infinite;
  animation-delay: var(--d);
}
@keyframes node-in {
  0%   { opacity: 0; transform: scale(0); }
  12%  { opacity: 1; transform: scale(1.25); }
  20%  { transform: scale(1); }
  70%  { opacity: 1; }
  88%, 100% { opacity: 0.15; }
}
@keyframes line-in {
  0%   { opacity: 0; stroke-dashoffset: 40; }
  18%  { opacity: 1; stroke-dashoffset: 0; }
  70%  { opacity: 1; }
  88%, 100% { opacity: 0.15; }
}
.loader-text {
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  position: relative;
  overflow: hidden;
}
.login-view[hidden] { display: none !important; }
#app[hidden] { display: none !important; }
/* Subtle dot grid instead of blurry orbs */
.login-grid-bg {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(148, 197, 210, 0.07) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 30%, transparent 75%);
  pointer-events: none;
}
.login-wrap {
  display: flex;
  gap: 56px;
  align-items: center;
  max-width: 860px;
  width: 100%;
  position: relative;
  z-index: 1;
  animation: card-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* Left: brand hero */
.login-hero {
  flex: 1;
  min-width: 0;
}
.brand-badge {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.05));
  border: 1px solid rgba(34, 211, 238, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}
.brand-badge .brand-mark {
  width: 40px;
  height: 34px;
  color: var(--cyan);
}
.login-hero h1 {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}
.login-hero .tagline {
  font-size: 17px;
  color: var(--muted);
  margin: 0;
}
/* Right: sign-in card */
.login-card {
  width: 100%;
  max-width: 380px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 32px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.login-card h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.login-sub {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.5;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Stack vertically on narrow screens */
/* ---------- Trend arrows ---------- */
.trend { font-weight: 800; font-variant-numeric: tabular-nums; }
.trend.up { color: var(--good); }
.trend.down { color: var(--bad); }
.trend-label { color: var(--faint); font-weight: 400; }

/* ---------- Report card period picker (tabs on desktop, dropdown on mobile) ---------- */
.run-select {
  display: none;
  width: 100%;
  padding: 12px 44px 12px 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  margin-bottom: 14px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238ea6b8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
@media (max-width: 699px) {
  .run-tabs { display: none; }
  .run-select { display: block; }
}

/* ---------- GPA scale toggle ---------- */
.scale-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  margin: 4px 0 12px;
}
.scale-toggle .chev { color: var(--faint); transition: transform 0.2s ease; }
.scale-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.scale-editor[hidden] { display: none; }

/* ---------- Refresh button ---------- */
#refresh-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .login-wrap {
    flex-direction: column;
    gap: 36px;
    max-width: 400px;
  }
  .login-hero { text-align: center; }
  .brand-badge { margin: 0 auto 20px; }
  .login-hero h1 { font-size: 36px; }
  .login-preview { margin: 0 auto; }
  .login-card { max-width: 100%; }
}
.brand-mark.sm { width: 30px; height: 26px; }
.field { display: block; margin-bottom: 16px; }
.field span {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}
.field input, .num-input, .text-input, select.text-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .num-input:focus, .text-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}
.btn-primary {
  width: 100%;
  padding: 13px;
  margin-top: 6px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #04121a;
  background: var(--cyan);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: #4be0f7; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.55; cursor: wait; }
/* Fix Chrome autofill painting inputs solid black on dark theme */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus,
.field input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 100px var(--bg-2) inset !important;
  box-shadow: 0 0 0 100px var(--bg-2) inset !important;
  caret-color: var(--text) !important;
  border: 1px solid var(--line-soft) !important;
  border-radius: 10px !important;
  transition: background-color 9999s ease-in-out 0s !important;
}
.login-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--bad);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
}
.fineprint { text-align: center; color: var(--faint); font-size: 12px; margin: 14px 0 0; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.brand-inline { display: flex; align-items: center; gap: 10px; color: var(--cyan); }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; color: var(--text); }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--cyan); border-color: var(--line-soft); background: var(--card); }

.main {
  max-width: 860px;
  margin: 0 auto;
  padding: 18px 16px calc(var(--nav-h) + 28px);
}
.view { animation: view-in 0.25s ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.section-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--muted);
  margin: 24px 4px 10px;
}
.section-title:first-child { margin-top: 4px; }

/* ---------- Summary hero ---------- */
.summary-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 22px;
  margin-bottom: 6px;
  animation: card-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.sum-main { flex: 1; min-width: 0; }
.sum-avg {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sum-label { color: var(--muted); font-size: 15px; font-weight: 600; margin-top: 6px; }
.sum-side { display: flex; gap: 24px; }
.sum-stat { display: flex; flex-direction: column; align-items: flex-end; }
.sum-stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sum-stat .v small { font-size: 15px; color: var(--faint); font-weight: 600; }
.sum-stat .l { font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 2px; }

/* ---------- Course cards ---------- */
.course-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.course-card.open { border-color: var(--line); }
.course-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.course-head .avg {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  min-width: 76px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.course-head .meta { flex: 1; min-width: 0; }
.course-head .name { font-size: 17px; font-weight: 700; }
.course-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.course-head .chev { color: var(--faint); transition: transform 0.2s; flex-shrink: 0; }
.course-card.open .chev { transform: rotate(180deg); color: var(--cyan); }
.avg-bar { height: 4px; background: var(--bg-2); }
.avg-bar i { display: block; height: 100%; border-radius: 0 2px 2px 0; transition: width 0.5s ease; }

/* What-if teaser: visible entry point on collapsed course cards */
.wi-teaser {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--line-soft);
  color: var(--cyan);
  font-size: 14.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
}
.wi-teaser:hover { background: var(--card-2); }
.wi-teaser svg { flex-shrink: 0; }

.course-body { padding: 4px 16px 16px; border-top: 1px solid var(--line-soft); }
.cat-group { margin-top: 14px; }
.cat-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--line-soft);
  margin-bottom: 4px;
}
.cat-name { font-weight: 700; font-size: 14px; }
.cat-stats { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.assign-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.assign-row:last-child { border-bottom: none; }
.assign-row .info { flex: 1; min-width: 0; }
.assign-row .title { font-size: 14.5px; }
.assign-row .date { color: var(--faint); font-size: 13px; margin-top: 2px; }
.assign-row .score {
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.assign-row .score small { color: var(--faint); font-weight: 400; }

/* ---------- What-if ---------- */
.whatif {
  margin-top: 16px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.whatif h4 { margin: 0 0 4px; font-size: 15px; }
.whatif .hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.wi-projected {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 10px;
  margin-bottom: 12px;
}
.wi-projected .val { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wi-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.wi-row label { font-size: 13px; color: var(--muted); min-width: 110px; }
.num-input { width: 76px; padding: 8px 10px; font-size: 15px; }
.wi-cat { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.wi-cat .nm { flex: 1; font-size: 14px; }
.wi-add { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.wi-added { font-size: 13px; color: var(--muted); margin-top: 8px; }
.wi-added button { margin-left: 8px; }
.btn-ghost {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--cyan);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--cyan-glow); }
.btn-small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }

/* ---------- Recently graded ---------- */
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
}
.recent-item .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.recent-item .info { flex: 1; min-width: 0; }
.recent-item .course { font-size: 13.5px; font-weight: 700; color: var(--muted); }
.recent-item .title { font-size: 14.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item .score { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.recent-item .date { color: var(--faint); font-size: 13px; }

/* ---------- Report card ---------- */
.run-tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.run-tab {
  flex: 1;
  min-width: 64px;
  padding: 10px 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.run-tab.active { color: #04121a; background: linear-gradient(180deg, #4be0f7, var(--cyan)); border-color: transparent; }
.report-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 13px 16px;
  margin-bottom: 8px;
}
.report-row .nm { flex: 1; min-width: 0; }
.report-row .nm .course { font-weight: 700; font-size: 15px; }
.report-row .nm .teacher { color: var(--faint); font-size: 13px; margin-top: 1px; }
.report-row .grade { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.empty-note {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 15px;
}

/* ---------- GPA ---------- */
.gpa-hero {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
}
.gpa-tile {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
}
.gpa-tile .v { font-size: 34px; font-weight: 800; color: var(--cyan); font-variant-numeric: tabular-nums; }
.gpa-tile .l { font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 4px; }
.gpa-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.gpa-table th, .gpa-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line-soft); }
.gpa-table th { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 700; }
.gpa-table td.n, .gpa-table th.n { text-align: right; font-variant-numeric: tabular-nums; }
.gpa-card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 6px 14px 12px; margin-bottom: 14px; }
.gpa-card h3 { font-size: 16px; margin: 12px 0 4px; }
.adv-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--cyan);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: 2px;
}
.scale-editor { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 8px; }
.scale-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.scale-row .num-input { width: 90px; }
.scale-row .lbl { font-size: 13px; color: var(--muted); }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line-soft);
  z-index: 20;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--faint);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--cyan); }

@media (min-width: 700px) {
  .main { padding-top: 26px; }
  .course-head .avg { font-size: 38px; }
}
