/* ───────────────────────────────────────
   Reset & Base — adapted for full-viewport PWA
   ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #f2f2f7;
  color: #1c1c1e;
  overscroll-behavior: none;
}

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ───────────────────────────────────────
   Screens — full viewport, one visible at a time
   ─────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: #f2f2f7;
  /* Honor safe area on iOS */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.screen.is-active { display: flex; }

.screen-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen-scroll::-webkit-scrollbar { display: none; }

/* ───────────────────────────────────────
   Shared
   ─────────────────────────────────────── */
.large-title {
  font-size: 34px; font-weight: 700; letter-spacing: -0.6px;
  color: #1c1c1e; padding: 12px 20px 10px;
}
.sec-header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 20px 8px;
}
.sec-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; color: #1c1c1e; }
.sec-more  { font-size: 15px; color: #007aff; cursor: pointer; user-select: none; }

/* ───────────────────────────────────────
   LOGIN SCREEN (new — not in preview.html)
   ─────────────────────────────────────── */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 24px 60px;
}
.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo {
  width: 72px; height: 72px;
  border-radius: 20px;
  margin: 0 auto 16px;
  background: linear-gradient(138deg, #0055d4, #5e3ff3);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 32px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 85, 212, 0.25);
}
.login-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; color: #1c1c1e; }
.login-sub   { font-size: 14px; color: #8e8e93; margin-top: 6px; }

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 8px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
}
.login-field {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 0.5px solid #f2f2f7;
}
.login-field:last-child { border-bottom: none; }
.login-field-label {
  width: 76px; flex-shrink: 0;
  font-size: 15px; color: #8e8e93;
}
.login-input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent;
  font-size: 16px;
  color: #1c1c1e;
}
.login-input::placeholder { color: #c7c7cc; }

.login-captcha {
  display: flex; align-items: center; gap: 10px;
}
.login-captcha-input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent;
  font-size: 16px;
  color: #1c1c1e;
  letter-spacing: 2px;
}
.login-captcha-img {
  width: 96px; height: 36px;
  border-radius: 8px;
  background: #f2f2f7;
  object-fit: cover;
  cursor: pointer;
  flex-shrink: 0;
}
.login-captcha-img.loading {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #8e8e93;
}

.login-btn {
  margin-top: 20px;
  height: 50px;
  border: none;
  border-radius: 14px;
  background: #007aff;
  color: #fff;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.login-btn:active { transform: scale(0.98); opacity: 0.88; }
.login-btn:disabled {
  opacity: 0.45; cursor: not-allowed; transform: none;
}

.login-hint {
  margin-top: 14px;
  font-size: 12px; color: #8e8e93; text-align: center; line-height: 1.5;
}
.login-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff1f0;
  color: #cf1322;
  font-size: 13px;
  display: none;
}
.login-error.show { display: block; }

/* ───────────────────────────────────────
   SCHEDULE SCREEN
   ─────────────────────────────────────── */
.sched-top {
  padding: 12px 16px 10px;
  background: #f2f2f7;
  flex-shrink: 0;
}
.sched-week-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.sched-week-label { font-size: 30px; font-weight: 700; letter-spacing: -0.6px; color: #1c1c1e; }
.sched-nav { display: flex; gap: 6px; align-items: center; }
.sched-nav-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,0.1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 14px; color: #1c1c1e;
  user-select: none;
}
.sched-nav-btn:active { background: #e5e5ea; }
.sched-refresh {
  font-size: 13px; color: #007aff; padding: 4px 10px;
  cursor: pointer; user-select: none;
}
.sched-range { font-size: 13px; color: #8e8e93; }

/* 7-column grid (Mon-Sun) */
.day-row {
  display: grid;
  grid-template-columns: 38px repeat(7, 1fr);
  gap: 2px;
  padding: 6px 4px 4px;
  background: #f2f2f7;
  flex-shrink: 0;
}
.day-col { text-align: center; }
.day-wd  { font-size: 11px; color: #8e8e93; font-weight: 500; margin-bottom: 3px; }
.day-num {
  font-size: 15px; font-weight: 600; color: #1c1c1e;
  width: 26px; height: 26px; line-height: 26px;
  margin: 0 auto; border-radius: 50%;
}
.day-col.today .day-num { background: #007aff; color: #fff; }

.sched-grid {
  display: grid;
  grid-template-columns: 38px repeat(7, 1fr);
  gap: 2px;
  padding: 0 4px 20px;
}
.slot-label {
  display: flex; flex-direction: column; align-items: center;
  padding-top: 5px;
}
.slot-n { font-size: 10px; color: #c7c7cc; font-weight: 600; }
.slot-t { font-size: 9px;  color: #c7c7cc; margin-top: 1px; }
.grid-cell { position: relative; }
.course-blk {
  border-radius: 10px;
  padding: 6px 5px;
  position: absolute; left: 1px; right: 1px; top: 2px; bottom: 2px;
  overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.blk-name { font-size: 10px; font-weight: 700; color: #fff; line-height: 1.3; }
.blk-room { font-size: 9px; color: rgba(255,255,255,0.78); margin-top: 2px; line-height: 1.2; }

.sched-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #8e8e93;
  padding: 40px 24px;
  text-align: center;
  gap: 12px;
}
.sched-empty-title { font-size: 16px; font-weight: 600; color: #1c1c1e; }
.sched-empty-sub { font-size: 13px; color: #8e8e93; max-width: 260px; line-height: 1.5; }
.sched-empty-btn {
  margin-top: 6px;
  background: #007aff; color: #fff;
  border: none; border-radius: 14px;
  padding: 10px 24px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
}

/* ───────────────────────────────────────
   Toast / Loading overlay
   ─────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%; bottom: 80px;
  transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 999;
}
.loading-overlay.show { display: flex; }
.loading-spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(0, 122, 255, 0.2);
  border-top-color: #007aff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────────────────────────────────
   Modal (term start date picker)
   ─────────────────────────────────────── */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1100;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  max-width: 320px;
  width: 100%;
}
.modal-title { font-size: 18px; font-weight: 700; color: #1c1c1e; margin-bottom: 6px; }
.modal-sub   { font-size: 13px; color: #8e8e93; margin-bottom: 16px; line-height: 1.5; }
.modal-input {
  width: 100%;
  height: 44px;
  border: 1px solid #e5e5ea;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 16px;
  outline: none;
  margin-bottom: 16px;
}
.modal-input:focus { border-color: #007aff; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn {
  flex: 1; height: 44px; border-radius: 12px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.modal-btn-primary { background: #007aff; color: #fff; }
.modal-btn-ghost   { background: #f2f2f7; color: #1c1c1e; }

/* ───────────────────────────────────────
   Bottom tab bar
   ─────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(249,249,249,0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 0.5px solid rgba(0,0,0,0.13);
  display: flex; align-items: flex-start; justify-content: space-around;
  padding-top: 8px;
  z-index: 200;
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; padding: 0 16px; user-select: none;
  color: #8e8e93;
}
.tab-btn .tab-lbl { font-size: 10px; font-weight: 500; color: #8e8e93; }
.tab-btn.is-active { color: #007aff; }
.tab-btn.is-active .tab-lbl { color: #007aff; }

/* Hide tab bar when login is showing */
body.is-auth .tab-bar { display: none; }

/* Reserve space at bottom of scroll areas so the tab bar doesn't overlap */
body:not(.is-auth) .screen-scroll {
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
/* Schedule grid uses a separate scroll wrapper, pad too */
body:not(.is-auth) #s-schedule .screen-scroll { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

/* ───────────────────────────────────────
   HOME SCREEN
   ─────────────────────────────────────── */
.hero {
  margin: 0 16px 16px;
  background: linear-gradient(138deg, #0055d4, #5e3ff3);
  border-radius: 24px;
  padding: 22px 20px 18px;
  color: #fff;
  position: relative; overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; right: -28px; top: -28px;
  width: 150px; height: 150px;
  background: rgba(255,255,255,0.1); border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute; left: -10px; bottom: -36px;
  width: 110px; height: 110px;
  background: rgba(255,255,255,0.06); border-radius: 50%;
}
.hero-date     { font-size: 13px; opacity: .72; margin-bottom: 4px; position: relative; z-index: 1; }
.hero-greeting { font-size: 28px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 2px; position: relative; z-index: 1; }
.hero-sub      { font-size: 14px; opacity: .88; margin-bottom: 18px; position: relative; z-index: 1; }
.hero-pills    { display: flex; gap: 8px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero-pill {
  background: rgba(255,255,255,0.22);
  border-radius: 20px; padding: 5px 12px;
  font-size: 12px; display: flex; align-items: center; gap: 5px;
  backdrop-filter: blur(6px);
  color: #fff;
}

/* Timeline list */
.tl-list { padding: 0 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.tl-item {
  background: #fff;
  border-radius: 18px;
  padding: 13px 15px 13px 12px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}
.tl-bar { width: 4px; height: 38px; border-radius: 4px; flex-shrink: 0; }
.tl-t { flex-shrink: 0; text-align: right; }
.tl-t .t1 { font-size: 14px; font-weight: 600; color: #1c1c1e; }
.tl-t .t2 { font-size: 11px; color: #8e8e93; }
.tl-info { flex: 1; min-width: 0; }
.tl-name { font-size: 15px; font-weight: 600; color: #1c1c1e; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-sub  { font-size: 12px; color: #8e8e93; display: flex; align-items: center; gap: 3px; }
.tl-badge {
  background: #f2f2f7; border-radius: 8px; padding: 4px 9px;
  font-size: 11px; color: #8e8e93; flex-shrink: 0;
}

.tl-empty {
  margin: 8px 16px;
  padding: 28px 16px;
  text-align: center;
  color: #8e8e93;
  font-size: 13px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

/* ───────────────────────────────────────
   EXAM SCREEN
   ─────────────────────────────────────── */
.exam-sub { padding: 0 20px 10px; font-size: 13px; color: #8e8e93; }
.exam-list { padding: 0 16px 28px; display: flex; flex-direction: column; gap: 12px; }
.exam-card {
  background: #fff; border-radius: 20px; padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  display: flex; gap: 14px; align-items: flex-start;
}
.exam-date {
  background: #f2f2f7; border-radius: 14px;
  padding: 9px 10px; text-align: center; flex-shrink: 0; min-width: 50px;
}
.exam-mon { font-size: 10px; color: #8e8e93; font-weight: 600; letter-spacing: 0.5px; }
.exam-day { font-size: 26px; font-weight: 700; color: #1c1c1e; letter-spacing: -0.5px; line-height: 1.1; }
.exam-body { flex: 1; min-width: 0; }
.exam-name { font-size: 16px; font-weight: 600; color: #1c1c1e; margin-bottom: 8px; }
.exam-rows { display: flex; flex-direction: column; gap: 5px; }
.exam-row  { display: flex; align-items: center; gap: 5px; }
.exam-txt  { font-size: 13px; color: #8e8e93; flex: 1; }
.exam-chip {
  border-radius: 8px; padding: 3px 9px;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.chip-urgent { background: #fff1f0; color: #cf1322; }
.chip-warn   { background: #fff7e6; color: #d46b08; }
.chip-safe   { background: #f6ffed; color: #389e0d; }
.chip-done   { background: #f0f0f0; color: #8e8e93; }
.exam-card.past { opacity: 0.45; }
.exam-card.past .exam-name { text-decoration: line-through; }
.exam-card.past .exam-date { background: #f0f0f0; }
.exam-card.past .exam-mon  { color: #aaa; }
.exam-card.past .exam-day  { color: #aaa; }

.exam-empty {
  margin: 8px 16px;
  padding: 28px 16px;
  text-align: center;
  color: #8e8e93;
  font-size: 13px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

/* ───────────────────────────────────────
   SCORE SCREEN
   ─────────────────────────────────────── */
.term-scroll {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 0 16px 0; margin-bottom: 14px;
}
.term-scroll::-webkit-scrollbar { display: none; }
.term-pill {
  background: #fff; border-radius: 20px; padding: 6px 14px;
  font-size: 13px; color: #8e8e93; white-space: nowrap;
  box-shadow: 0 1px 5px rgba(0,0,0,0.07);
  cursor: pointer; flex-shrink: 0;
  user-select: none;
}
.term-pill.active { background: #007aff; color: #fff; }

.gpa-card {
  margin: 0 16px 16px;
  background: linear-gradient(138deg, #1d4ed8, #7c3aed);
  border-radius: 24px; padding: 22px 20px 18px;
  color: #fff; position: relative; overflow: hidden;
}
.gpa-card::before {
  content: ''; position: absolute; right: -24px; top: -24px;
  width: 130px; height: 130px;
  background: rgba(255,255,255,0.09); border-radius: 50%;
}
.gpa-lbl  { font-size: 13px; opacity: .72; margin-bottom: 5px; position: relative; z-index: 1; }
.gpa-num  { font-size: 56px; font-weight: 700; letter-spacing: -2px; line-height: 1; margin-bottom: 4px; position: relative; z-index: 1; }
.gpa-sub  { font-size: 13px; opacity: .72; margin-bottom: 16px; position: relative; z-index: 1; }
.gpa-stats { display: flex; gap: 24px; position: relative; z-index: 1; }
.gpa-stat .sv { font-size: 20px; font-weight: 700; color: #fff; }
.gpa-stat .sl { font-size: 11px; opacity: .65; margin-top: 1px; color: #fff; }

.score-list { padding: 0 16px 28px; display: flex; flex-direction: column; gap: 1px; }
.score-item {
  background: #fff; padding: 13px 16px;
  display: flex; align-items: center; gap: 12px;
}
.score-item:first-child { border-radius: 18px 18px 0 0; }
.score-item:last-child  { border-radius: 0 0 18px 18px; }
.score-item:only-child  { border-radius: 18px; }
.score-item + .score-item { border-top: 0.5px solid #f2f2f7; }
.score-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.score-name { flex: 1; font-size: 14px; font-weight: 500; color: #1c1c1e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-cred { font-size: 12px; color: #8e8e93; flex-shrink: 0; margin-right: 6px; }
.score-val  { font-size: 16px; font-weight: 600; min-width: 38px; text-align: right; flex-shrink: 0; }
.sv-high { color: #007aff; }
.sv-mid  { color: #34c759; }
.sv-low  { color: #ff9500; }

.score-empty {
  margin: 8px 16px;
  padding: 28px 16px;
  text-align: center;
  color: #8e8e93;
  font-size: 13px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}
