:root {
  color-scheme: light;
  --paper: #f7f5fc;
  --card: #ffffff;
  --ink: #17152a;
  --muted: #716d84;
  --brand: #6d4aff;
  --brand-dark: #5233e2;
  --lilac: #ede8ff;
  --mint: #bff2de;
  --mint-ink: #135b44;
  --border: #e5e1ee;
  --danger-bg: #ffeaec;
  --danger: #a12537;
  --shadow: 0 18px 45px rgba(49, 37, 95, .10);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 7% 0%, rgba(109, 74, 255, .09), transparent 30rem),
    var(--paper);
  color: var(--ink);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-shell,
.detail-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 20px max(34px, env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.centered-view {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.centered-view h1 { margin: 22px 0 7px; font-size: 25px; }
.centered-view p { margin: 0; color: var(--muted); }

.brand-header,
.dashboard-topbar,
.section-heading,
.top-actions,
.subject-card-top,
.detail-result,
.weight-row,
.prediction,
.grade-row {
  display: flex;
  align-items: center;
}

.brand-header { gap: 13px; }
.brand-header strong,
.dashboard-topbar strong { display: block; letter-spacing: .1em; font-size: 17px; }
.brand-header small,
.dashboard-topbar small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }

.brand-mark {
  width: 53px;
  height: 53px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #7c5cff, #5737e4);
  color: white;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 13px 30px rgba(109, 74, 255, .27);
}

.brand-mark span { color: var(--mint); }
.brand-mark.large { width: 76px; height: 76px; border-radius: 23px; font-size: 30px; }

.loader {
  width: 26px;
  height: 26px;
  margin-top: 28px;
  border: 3px solid #ded8f2;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.login-copy { margin: 50px 2px 27px; }
.login-copy h1,
.welcome h1,
.detail-shell > h1 {
  margin: 6px 0 8px;
  font-size: clamp(32px, 8vw, 43px);
  line-height: 1.06;
  letter-spacing: -.035em;
}
.login-copy > p:last-child { max-width: 560px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.55; }

.eyebrow {
  margin: 0;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}

.panel,
.subject-card,
.grade-row {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 5px 20px rgba(36, 29, 67, .035);
}

.login-panel { padding: 19px; }
.login-panel label,
.what-if label {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.login-panel label:not(:first-child) { margin-top: 19px; }

input {
  width: 100%;
  min-height: 54px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: #faf9fc;
  color: var(--ink);
  font-size: 16px;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(109, 74, 255, .10); }

.button {
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  font-weight: 750;
}
.button.primary {
  width: 100%;
  min-height: 55px;
  margin-top: 20px;
  background: linear-gradient(145deg, #7958ff, var(--brand-dark));
  box-shadow: 0 12px 26px rgba(109, 74, 255, .20);
  color: white;
}
.button:disabled { cursor: wait; opacity: .62; }
.button.ghost { background: var(--lilac); color: var(--brand-dark); }
.button.text { background: transparent; color: var(--muted); }
.button.compact { min-height: 40px; padding: 0 12px; font-size: 12px; }

.error-message {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 20px 6px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.privacy-note span { color: #2fa27d; font-size: 10px; margin-top: 4px; }
.privacy-note p { margin: 0; }

.dashboard-topbar { justify-content: space-between; gap: 12px; }
.top-actions { gap: 6px; }
.welcome { margin-top: 34px; }
.welcome h1 { font-size: clamp(28px, 7vw, 38px); }
.welcome > p:last-child { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }

.install-hint {
  position: relative;
  margin-top: 20px;
  padding: 15px 42px 15px 16px;
  border: 1px solid #d8cffc;
  border-radius: 17px;
  background: #f1edff;
  color: #3f2a9e;
}
.install-hint strong { font-size: 14px; }
.install-hint p { margin: 4px 0 0; font-size: 12px; line-height: 1.45; }
.install-hint button { position: absolute; top: 6px; right: 7px; border: 0; background: none; color: #6956b4; font-size: 23px; }

.hero-card {
  min-height: 142px;
  margin-top: 23px;
  padding: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 87% 10%, rgba(191, 242, 222, .32), transparent 36%),
    linear-gradient(145deg, #7857ff, #5232dc);
  box-shadow: 0 18px 40px rgba(82, 51, 226, .22);
  color: white;
}
.hero-card small { display: block; color: #ded6ff; font-weight: 800; letter-spacing: .1em; }
.hero-card strong { display: block; margin-top: 7px; font-size: 39px; line-height: 1; }
.hero-card span { display: block; margin-top: 5px; color: #ded6ff; font-size: 13px; }
.hero-card .class-stat { text-align: right; }
.hero-card .class-stat strong { font-size: 24px; }

.section-heading { justify-content: space-between; margin: 31px 1px 12px; }
.section-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.section-heading span {
  padding: 6px 11px;
  border-radius: 999px;
  background: #ebe8f2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.subject-list,
.grade-list { display: grid; gap: 11px; }

.subject-card {
  width: 100%;
  padding: 17px;
  border: 1px solid var(--border);
  text-align: left;
  color: inherit;
  cursor: pointer;
  appearance: none;
}
.subject-card:active { transform: scale(.992); }
.subject-card-top { gap: 12px; }
.subject-badge {
  width: 49px;
  height: 49px;
  flex: 0 0 49px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: white;
  font-size: 13px;
  font-weight: 800;
}
.subject-names { min-width: 0; flex: 1; }
.subject-names strong { display: block; font-size: 16px; line-height: 1.25; }
.subject-names span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.subject-average { text-align: right; }
.subject-average strong { display: block; font-size: 23px; }
.subject-average span { color: var(--muted); font-size: 11px; }
.mark-strip { display: flex; gap: 7px; margin-top: 15px; overflow: hidden; }
.mark-chip { flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; background: #f5f3f9; font-size: 12px; font-weight: 750; }
.mark-chip:first-child { background: var(--lilac); }

.version-button {
  width: 100%;
  margin: 25px 0 3px;
  padding: 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.detail-view {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
}
.back-button { margin-bottom: 24px; }
.detail-shell > h1 { margin-top: 7px; font-size: clamp(29px, 7vw, 40px); }
.detail-shell > .muted { margin: 0; font-size: 14px; }

.detail-result {
  justify-content: space-between;
  gap: 16px;
  min-height: 108px;
  margin-top: 22px;
  padding: 20px;
  border-radius: 23px;
  background: var(--accent, var(--brand));
  color: white;
  box-shadow: var(--shadow);
}
.detail-result small { display: block; color: rgba(255,255,255,.78); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.detail-result span { display: block; margin-top: 6px; color: rgba(255,255,255,.78); font-size: 12px; }
.detail-result > strong { font-size: 39px; }

.what-if { margin-top: 17px; padding: 19px; }
.what-if h2 { margin: 0; font-size: 20px; }
.what-if > p { margin: 5px 0 19px; font-size: 12px; }
.what-if label:not(:first-of-type) { margin-top: 17px; }
.mark-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.mark-picker button,
.weight-row button {
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: #f2eff8;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}
.mark-picker button.selected { background: var(--accent, var(--brand)); color: white; }
.weight-row button { width: 46px; color: var(--brand-dark); font-size: 22px; }
.weight-row > strong { width: 57px; text-align: center; font-size: 21px; }
.weight-row > span { margin-left: 11px; color: var(--muted); font-size: 11px; }
.prediction {
  justify-content: space-between;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 17px;
  background: var(--mint);
  color: var(--mint-ink);
}
.prediction small { display: block; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.prediction span { display: block; margin-top: 3px; font-size: 11px; }
.prediction > strong { font-size: 30px; }
.target-help { margin-bottom: 0 !important; line-height: 1.5; }
.grades-heading { margin-top: 29px; }

.grade-row { gap: 12px; padding: 13px 14px; }
.grade-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--lilac);
  color: var(--accent, var(--brand));
  font-size: 20px;
  font-weight: 800;
}
.grade-info { min-width: 0; flex: 1; }
.grade-info strong { display: block; font-size: 13px; line-height: 1.3; }
.grade-info span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.grade-weight { padding: 5px 8px; border-radius: 999px; background: #f4f2f8; color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }
.excluded-note { margin: 17px 3px; font-size: 11px; line-height: 1.5; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  width: min(calc(100% - 36px), 540px);
  transform: translateX(-50%);
  padding: 13px 16px;
  border-radius: 14px;
  background: #211d38;
  box-shadow: var(--shadow);
  color: white;
  text-align: center;
  font-size: 13px;
}

.background-orb { position: fixed; z-index: 0; border-radius: 50%; filter: blur(2px); pointer-events: none; }
.orb-one { width: 330px; height: 330px; top: -220px; right: -170px; background: rgba(109, 74, 255, .10); }
.orb-two { width: 280px; height: 280px; bottom: -210px; left: -170px; background: rgba(54, 188, 145, .08); }

@media (min-width: 650px) {
  .app-shell, .detail-shell { padding-left: 30px; padding-right: 30px; }
  .subject-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subject-card { min-height: 144px; }
}

@media (max-width: 390px) {
  .button.compact { padding-inline: 9px; }
  .dashboard-topbar strong { font-size: 15px; }
  .hero-card { min-height: 132px; }
  .top-actions { gap: 1px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
