:root {
  color-scheme: light;
  --paper: #f3f0e7;
  --surface: #fffdf8;
  --ink: #17332e;
  --ink-soft: #50645f;
  --muted: #7c8985;
  --line: #d8ddd6;
  --math: #1f6658;
  --math-soft: #dcebe5;
  --cs: #3b5bdb;
  --cs-soft: #e8edff;
  --gold: #d6a632;
  --orange: #ed6a3a;
  font-family: "Noto Sans SC", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(23, 51, 46, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 51, 46, 0.035) 1px, transparent 1px);
  background-size: 30px 30px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.portal-shell {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 max(34px, env(safe-area-inset-bottom));
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 5px 18px rgba(23, 51, 46, 0.07);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #ffffff;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 20px;
  font-weight: 800;
  background: var(--ink);
  border-radius: 50%;
}

.portal-brand strong,
.portal-brand small {
  display: block;
}

.portal-brand strong {
  font-size: 16px;
}

.portal-brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
}

.portal-date {
  color: var(--ink-soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.portal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-action-button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 750;
  background: #f5f4ee;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.portal-action-button:hover {
  color: #ffffff;
  background: var(--ink);
  border-color: var(--ink);
}

.portal-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(270px, 0.75fr);
  gap: 20px;
  align-items: end;
  margin: 48px 0 24px;
}

.portal-eyebrow {
  margin-bottom: 8px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.portal-intro h1 {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  font-size: 42px;
  line-height: 1.2;
}

.portal-intro p {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.8;
}

.portal-streak {
  padding: 16px 18px;
  color: #684e19;
  background: #f7ecc9;
  border: 1px solid #ead9a1;
  border-radius: 8px;
}

.portal-streak span,
.portal-streak strong {
  display: block;
}

.portal-streak span {
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.portal-streak strong {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.65;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.subject-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  min-height: 540px;
  overflow: hidden;
  padding: 26px;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 8px solid var(--math);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(23, 51, 46, 0.09);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.subject-card.cs408-card {
  border-top-color: var(--cs);
}

.subject-card:hover {
  transform: translateY(-3px);
  border-color: var(--math);
  box-shadow: 0 18px 44px rgba(23, 51, 46, 0.13);
}

.subject-card.cs408-card:hover {
  border-color: var(--cs);
}

.subject-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subject-topline img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(23, 51, 46, 0.13);
}

.subject-label {
  padding: 5px 9px;
  color: var(--math);
  font-size: 10px;
  font-weight: 800;
  background: var(--math-soft);
  border-radius: 999px;
}

.cs408-card .subject-label {
  color: var(--cs);
  background: var(--cs-soft);
}

.subject-copy h2 {
  margin: 24px 0 10px;
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  font-size: 29px;
}

.subject-copy p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.8;
}

.subject-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 20px;
}

.subject-tags span {
  padding: 5px 9px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  background: #f5f4ee;
  border: 1px solid #e4e3da;
  border-radius: 999px;
}

.subject-progress {
  align-self: end;
  margin-top: 30px;
  padding: 15px;
  background: #faf9f4;
  border: 1px solid #e7e5dc;
  border-radius: 8px;
}

.subject-progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--ink-soft);
  font-size: 11px;
}

.subject-progress-copy strong {
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.subject-progress-track {
  height: 7px;
  overflow: hidden;
  background: #e3e7e2;
  border-radius: 999px;
}

.subject-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--math);
  border-radius: inherit;
  transition: width 380ms ease;
}

.cs408-card .subject-progress-track span {
  background: var(--cs);
}

.subject-enter {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 0 16px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  background: var(--math);
  border-radius: 8px;
}

.cs408-card .subject-enter {
  background: var(--cs);
}

.subject-enter span {
  font-size: 20px;
}

.portal-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.portal-notes article {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.note-number {
  color: var(--orange);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
}

.portal-notes h3 {
  margin: 0;
  font-size: 12px;
}

.portal-notes p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.portal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding: 18px 4px 0;
  color: var(--muted);
  font-size: 10px;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .portal-shell {
    width: min(100% - 28px, 760px);
    padding-top: 14px;
  }

  .portal-intro {
    grid-template-columns: 1fr;
    margin-top: 34px;
  }

  .portal-intro h1 {
    font-size: 34px;
  }

  .subject-grid,
  .portal-notes {
    grid-template-columns: 1fr;
  }

  .subject-card {
    min-height: 0;
    padding: 22px;
  }
}

@media (max-width: 560px) {
  .portal-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .portal-header-actions {
    width: 100%;
  }

  .portal-date {
    flex: 1;
  }

  .portal-action-button {
    padding-inline: 9px;
  }

  .portal-intro h1 {
    font-size: 30px;
  }

  .subject-copy h2 {
    font-size: 25px;
  }

  .portal-footer {
    display: block;
  }

  .portal-footer span {
    display: block;
    margin-top: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
