:root {
  color-scheme: light;
  --ink: #172a3d;
  --muted: #607184;
  --line: #d7e0e6;
  --canvas: #eef3f5;
  --paper: #ffffff;
  --navy: #173149;
  --green: #1d745d;
  --gold: #a76e0d;
  --red: #ad433a;
  --blue: #3467a4;
  --plum: #725096;
  --teal: #16777c;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
a {
  font: inherit;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(52, 103, 164, 0.32);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--navy);
  font-size: 14px;
  font-weight: 900;
}

.brand-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.brand-copy strong {
  font-size: 21px;
  line-height: 1.1;
}

.brand-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-status {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #bdd8ce;
  border-radius: 6px;
  color: #205d4b;
  background: #edf7f3;
  font-size: 12px;
  font-weight: 800;
}

.header-status svg {
  width: 18px;
  height: 18px;
}

.workspace {
  width: min(1280px, 100%);
  min-height: calc(100vh - 138px);
  margin: 0 auto;
  padding: 24px max(22px, env(safe-area-inset-right)) 36px max(22px, env(safe-area-inset-left));
}

.subject-dashboard {
  display: grid;
  gap: 18px;
  transform-origin: 50% 0;
}

.subject-dashboard.is-exiting {
  pointer-events: none;
  animation: dashboard-out 240ms ease-in both;
}

.subject-dashboard.is-returning {
  animation: dashboard-in 320ms ease-out both;
}

.dashboard-heading {
  display: flex;
  min-height: 68px;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.dashboard-heading p,
.library-title p,
.subject-kicker {
  display: block;
  margin: 0 0 3px;
  color: var(--green);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.dashboard-heading h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.12;
}

.dashboard-heading h1:focus,
.library-title h2:focus {
  outline: none;
}

.dashboard-heading > span {
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.subject-tile {
  --accent: var(--navy);
  position: relative;
  display: grid;
  grid-template-rows: 118px minmax(0, 1fr);
  min-width: 0;
  min-height: 210px;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom: 5px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 7px 18px rgba(23, 49, 73, 0.07);
  cursor: pointer;
  animation: tile-rise 420ms ease-out both;
  animation-delay: calc(var(--order, 0) * 45ms);
  transition: transform 170ms ease, box-shadow 170ms ease, border-color 170ms ease;
}

.subject-tile:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 45%, white);
  box-shadow: 0 11px 24px rgba(23, 49, 73, 0.12);
}

.subject-tile.is-selected {
  z-index: 2;
  transform: translateY(-10px) scale(1.01);
}

.subject-english {
  --accent: #b74852;
}

.subject-science {
  --accent: var(--teal);
}

.subject-mathematics {
  --accent: var(--plum);
}

.subject-geography {
  --accent: var(--green);
}

.subject-history {
  --accent: var(--gold);
}

.subject-chinese-culture {
  --accent: var(--red);
}

.subject-art {
  position: relative;
  display: block;
  min-width: 0;
  overflow: hidden;
  background: #dfe7eb;
}

.subject-art img,
.all-collage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.subject-art img {
  transition: transform 220ms ease;
}

.subject-tile:hover .subject-art img {
  transform: scale(1.025);
}

.subject-icon {
  position: absolute;
  left: 12px;
  bottom: 10px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(23, 42, 61, 0.22);
}

.subject-icon svg {
  width: 19px;
  height: 19px;
}

.subject-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  gap: 2px 12px;
  min-width: 0;
  padding: 13px 14px 14px;
}

.subject-copy > span:first-child {
  min-width: 0;
}

.subject-kicker {
  color: var(--accent);
  font-size: 10px;
}

.subject-copy strong {
  display: block;
  font-size: 19px;
  line-height: 1.15;
}

.subject-copy small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.3;
}

.subject-open {
  display: grid;
  min-width: 40px;
  align-content: center;
  justify-items: end;
  gap: 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 850;
}

.subject-open svg {
  width: 19px;
  height: 19px;
}

.subject-all {
  grid-column: 1 / -1;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.5fr);
  grid-template-rows: 150px;
  min-height: 150px;
  border-bottom-color: var(--navy);
}

.subject-all .subject-copy {
  grid-row: 1;
  grid-column: 1;
  padding: 20px 22px;
}

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

.subject-all .subject-copy small {
  max-width: 420px;
  font-size: 12px;
}

.all-collage {
  display: grid;
  grid-row: 1;
  grid-column: 2;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--line);
}

.all-collage span {
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.65);
}

.all-collage span:last-child {
  border-right: 0;
}

.library {
  min-width: 0;
}

.library.is-entering {
  animation: library-up 330ms ease-out both;
}

.library.is-exiting {
  pointer-events: none;
  animation: library-down 220ms ease-in both;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.library-heading-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.back-button {
  display: inline-flex;
  min-width: 104px;
  min-height: 46px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  color: var(--navy);
  background: #fff;
  border: 1px solid #c9d5dd;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.back-button:hover {
  border-color: var(--navy);
}

.back-button svg {
  width: 17px;
  height: 17px;
}

.library-title {
  min-width: 0;
}

.library-title h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.14;
}

.library-title > span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-field {
  position: relative;
  display: flex;
  min-height: 46px;
  align-items: center;
}

.search-field > svg {
  position: absolute;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  height: 46px;
  padding: 9px 43px 9px 40px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #c9d5dd;
  border-radius: 6px;
  font-size: 14px;
}

.search-field input::placeholder {
  color: #788797;
}

.search-field button {
  position: absolute;
  right: 7px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.search-field button:hover {
  color: var(--ink);
  background: #edf2f5;
}

.search-field button svg {
  width: 17px;
  height: 17px;
}

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

.activity-card {
  --accent: var(--green);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 7px 18px rgba(23, 49, 73, 0.07);
  animation: activity-rise 280ms ease-out both;
}

.activity-card:nth-child(2n) {
  animation-delay: 45ms;
}

.activity-card.subject-english {
  --accent: #b74852;
}

.activity-card.subject-science {
  --accent: var(--teal);
}

.activity-card.subject-mathematics {
  --accent: var(--plum);
}

.activity-card.subject-geography {
  --accent: var(--green);
}

.activity-card.subject-history {
  --accent: var(--gold);
}

.activity-card.subject-chinese-culture {
  --accent: var(--red);
}

.activity-image {
  position: relative;
  display: block;
  aspect-ratio: 16 / 7;
  overflow: hidden;
  background: #e3e9ed;
}

.activity-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.activity-image:hover img {
  transform: scale(1.02);
}

.saved-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  color: #fff;
  background: rgba(23, 49, 73, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 850;
}

.saved-badge svg {
  width: 14px;
  height: 14px;
}

.activity-content {
  display: flex;
  min-width: 0;
  min-height: 218px;
  padding: 16px;
  flex-direction: column;
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.activity-meta span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 4px 7px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, white);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, white);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.activity-card h3 {
  margin: 12px 0 7px;
  font-size: 20px;
  line-height: 1.18;
}

.activity-card p {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.48;
}

.activity-footer {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #e5ebef;
}

.focus {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.open-button {
  display: inline-flex;
  min-width: 92px;
  min-height: 42px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 11px;
  color: #fff;
  background: var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.open-button svg {
  width: 16px;
  height: 16px;
}

.empty-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  background: #fff;
  border: 1px dashed #bdcad3;
  border-radius: 8px;
  text-align: center;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  color: var(--muted);
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  font-size: 17px;
}

.empty-state span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.device-footer {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px max(20px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  color: #554a25;
  background: #fff9e7;
  border-top: 1px solid #d8ca90;
}

.device-footer svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.device-footer p {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}

noscript {
  display: block;
  padding: 20px;
  text-align: center;
}

@keyframes tile-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dashboard-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-30px); }
}

@keyframes dashboard-in {
  from { opacity: 0; transform: translateY(-22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes library-up {
  from { opacity: 0; transform: translateY(36px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes library-down {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(28px); }
}

@keyframes activity-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 1220px) {
  .activity-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .workspace {
    padding: 20px max(18px, env(safe-area-inset-right)) 30px max(18px, env(safe-area-inset-left));
  }

  .subject-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .subject-all {
    grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.2fr);
  }

  .library-toolbar {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .library-title h2 {
    font-size: 24px;
  }

  .activity-image {
    aspect-ratio: 16 / 6;
  }
}

@media (max-width: 680px) {
  .header-status {
    display: none;
  }

  .dashboard-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .dashboard-heading h1 {
    font-size: 28px;
  }

  .subject-board,
  .activity-grid {
    grid-template-columns: 1fr;
  }

  .subject-all {
    grid-column: auto;
    grid-template-columns: 1fr;
    grid-template-rows: 132px auto;
  }

  .subject-all .subject-copy {
    grid-row: 2;
    grid-column: 1;
  }

  .all-collage {
    grid-row: 1;
    grid-column: 1;
    border-bottom: 1px solid var(--line);
    border-left: 0;
  }

  .library-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 13px;
  }

  .library-heading-row {
    align-items: flex-start;
  }

  .activity-image {
    aspect-ratio: 16 / 7;
  }

  .activity-content {
    min-height: 205px;
  }
}

@media (max-width: 430px) {
  .app-header {
    min-height: 64px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .brand-copy strong {
    font-size: 18px;
  }

  .subject-copy strong {
    font-size: 18px;
  }

  .library-heading-row {
    gap: 10px;
  }

  .back-button {
    min-width: 46px;
    width: 46px;
    padding: 0;
  }

  .back-button span {
    display: none;
  }

  .activity-footer {
    align-items: flex-end;
  }

  .focus {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
