@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800;900&family=Archivo+Expanded:wght@500;600;700;800&display=swap");

/* ============================================================
   OneNightPrep — Dark Neon Brutalist Design System
   Academic · Technical · Dark · Neon · Brutalist · Clean
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #0a0c10;
  --bg-elev: #0f1218;
  --surface: #12151c;
  --surface-light: #181c25;
  --surface-2: #1d2230;

  /* Accent — warm orange / amber */
  --accent: #ff8a2a;
  --accent-strong: #ff9e3d;
  --accent-deep: #d96a12;
  --accent-light: #ffb45e;
  --accent-glow: rgba(255, 138, 42, 0.22);
  --accent-line: rgba(255, 138, 42, 0.55);

  /* Text */
  --text: #f4f2ee;
  --text-strong: #ffffff;
  --muted: #9aa3b2;
  --muted-2: #6d7583;
  --faint: #3a414d;

  /* Borders */
  --border: #262c38;
  --border-strong: #3a4252;
  --border-bright: #ff8a2a;

  /* Status */
  --success: #7fd88f;
  --danger: #ff6b6b;
  --warn: #f2ca99;
  --urgent: #ff8a2a;

  /* Misc */
  --max-width: 1120px;
  --radius: 3px;
  --radius-lg: 6px;
  --ff-display: "Archivo Expanded", "Archivo", sans-serif;
  --ff-body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --grid-size: 26px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  position: relative;
  z-index: 0;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  font-family: var(--ff-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* cursor light (warm) */
body.cursor-active::after {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle 200px at var(--cursor-x) var(--cursor-y),
    rgba(255, 138, 42, 0.05),
    transparent 70%);
}

/* =================================================------------
   NIGHT SKY — atmospheric background (replaces grid + ambient glow)
   Stars and moon created via js/night-sky.js; CSS drives rendering
   ------------------------------------------------------------ */

.night-sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: #0c0e14;
  overflow: hidden;
}

/* far star layer — slower parallax */
.night-sky::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  box-shadow: var(--stars-1);
  transform: translate(calc(var(--sky-x, 0) * -4px), calc(var(--sky-y, 0) * -4px));
  will-change: transform;
  transition: transform 0.3s ease-out;
}

/* near star layer — faster parallax */
.night-sky::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  box-shadow: var(--stars-2);
  transform: translate(calc(var(--sky-x, 0) * -8px), calc(var(--sky-y, 0) * -8px));
  will-change: transform;
  transition: transform 0.3s ease-out;
}

/* crescent moon — large, warm ivory; crescent rendered via inset shadow */
.night-moon {
  position: absolute;
  top: 22%;
  right: 7%;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #0c0e14;
  box-shadow:
    inset 17px 7px 0 0 rgba(255, 228, 175, 0.36),
    inset 30px 16px 30px 2px rgba(255, 215, 155, 0.08);
  transform: translate(calc(var(--sky-x, 0) * -2px), calc(var(--sky-y, 0) * -2px));
  will-change: transform;
  transition: transform 0.4s ease-out;
}

/* tight atmospheric halo */
.night-moon::before {
  content: "";
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 230, 180, 0.07), transparent 62%);
}

@media (prefers-reduced-motion: reduce) {
  .night-sky::before,
  .night-sky::after,
  .night-moon {
    transform: none !important;
    transition: none !important;
  }
}

@media (max-width: 850px) {
  .night-sky::before {
    transform: translate(calc(var(--sky-x, 0) * -2px), calc(var(--sky-y, 0) * -2px));
  }
  .night-sky::after {
    transform: translate(calc(var(--sky-x, 0) * -4px), calc(var(--sky-y, 0) * -4px));
  }
  .night-moon {
    top: 16%;
    right: 5%;
    width: 64px;
    height: 64px;
    transform: translate(calc(var(--sky-x, 0) * -1px), calc(var(--sky-y, 0) * -1px));
  }
}

@media (max-width: 600px) {
  .night-moon {
    top: 19%;
    right: 12%;
    width: 46px;
    height: 46px;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
  font: inherit;
}

.site-shell {
  display: flex;
  position: relative;
  z-index: 1;
  width: min(100% - 40px, var(--max-width));
  min-height: 100vh;
  margin: 0 auto;
  flex-direction: column;
}

/* ------------------------------------------------------------
   Advertisement banner
   ------------------------------------------------------------ */
#ad-banner {
  display: flex;
  width: 100%;
  aspect-ratio: 5.5 / 1;
  max-height: 96px;
  margin: 18px 0 0;
  padding: 12px 20px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 1px dashed var(--border-strong);
  color: var(--muted-2);
  background: rgba(18, 21, 28, 0.8);
  text-align: center;
  overflow: hidden;
}

.ad-link {
  display: block;
  width: 100%;
  height: 100%;
  animation: ad-fade-in 260ms ease;
}

.ad-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes ad-fade-in {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

#ad-banner span {
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  color: var(--muted-2);
  font-family: var(--ff-display);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#ad-banner p {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: var(--muted-2);
}

/* ------------------------------------------------------------
   Home / landing
   ------------------------------------------------------------ */
.home-main {
  display: grid;
  flex: 1;
  place-items: center;
  padding: 72px 0 54px;
}

.hero {
  width: min(100%, 860px);
  text-align: center;
}

.logo-mark {
  display: grid;
  width: 60px;
  height: 60px;
  margin: 0 auto 26px;
  place-items: center;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.03)),
    var(--surface);
  box-shadow: inset 0 0 0 1px var(--bg-elev), 0 0 0 3px var(--bg), 0 8px 28px rgba(0, 0, 0, 0.4);
}

.logo-mark svg {
  width: 34px;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 15px;
  align-items: center;
  gap: 8px;
  color: var(--accent-light) !important;
  font-family: var(--ff-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.eyebrow::before,
.eyebrow::after {
  content: "";
  width: 14px;
  height: 1px;
  background: var(--accent-line);
}

h1 {
  margin: 0;
  font-family: var(--ff-display);
  letter-spacing: -0.035em;
  line-height: 1;
  font-weight: 800;
}

.hero h1 {
  font-size: clamp(3rem, 9vw, 6rem);
}

.hero h1 span,
.mini-logo span {
  color: var(--accent);
}

.tagline {
  margin: 24px 0 0;
  color: var(--text);
  font-family: var(--ff-display);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hero-copy {
  max-width: 540px;
  margin: 16px auto 36px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.terms-link {
  color: var(--muted-2);
  font-size: 0.74rem;
  text-decoration: none;
  transition: color 180ms ease;
}

.terms-link:hover,
.terms-link:focus-visible {
  color: var(--accent-light);
}

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

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.button {
  display: flex;
  position: relative;
  min-height: 80px;
  padding: 0 26px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--ff-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button:focus-visible,
.subject-card:focus-visible,
.time-card:focus-visible,
.back-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.button-primary {
  color: #1a0f05;
  background: linear-gradient(180deg, var(--accent-light), var(--accent) 55%, var(--accent-deep));
  border-color: var(--accent-light);
  box-shadow: 0 0 0 1px var(--bg) inset, 0 10px 26px rgba(255, 120, 20, 0.18);
}

.button-primary:hover {
  box-shadow: 0 0 0 1px var(--bg) inset, 0 16px 34px rgba(255, 120, 20, 0.3);
}

.button-secondary {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface);
}

.button-secondary:hover {
  border-color: var(--accent-line);
  color: var(--accent-light);
  background: var(--surface-2);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
}

.button-arrow {
  position: absolute;
  right: 24px;
  font-size: 1.05rem;
  transition: transform 160ms ease;
}

.button:hover .button-arrow {
  transform: translate(2px, -2px);
}

/* landing year buttons — numbered brutalist treatment */
.button-large {
  min-height: 92px;
  justify-content: flex-start;
  padding: 0 28px;
  text-align: left;
  border-radius: var(--radius);
}

.button-num {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  margin-right: 4px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0.85;
}

.button-label {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

@media (max-width: 600px) {
  .button-large {
    min-height: 76px;
    padding: 0 20px;
  }
}

footer {
  padding: 0 0 22px;
  color: var(--muted-2);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-align: center;
}

/* ------------------------------------------------------------
   Topbar / navigation / auth
   ------------------------------------------------------------ */
.topbar {
  display: flex;
  padding: 28px 0 18px;
  align-items: center;
  justify-content: space-between;
}

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

.back-link {
  display: inline-flex;
  min-height: 42px;
  padding: 0 14px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.back-link:hover {
  border-color: var(--accent-line);
  color: var(--text);
  transform: translateX(-2px);
}

.share-button {
  display: inline-grid;
  width: 42px;
  min-width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.share-button:hover {
  border-color: var(--accent-line);
  color: var(--text);
  transform: translateY(-1px);
}

.share-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.share-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.share-toast {
  position: fixed;
  z-index: 20;
  bottom: 20px;
  left: 50%;
  padding: 10px 14px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-2);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.share-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mini-logo {
  font-family: var(--ff-display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-auth {
  display: inline-flex;
  position: relative;
  align-items: center;
  gap: 12px;
}

.auth-profile {
  position: relative;
}

.auth-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.auth-avatar:hover {
  border-color: var(--accent-line);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.auth-avatar:active {
  transform: translateY(0);
}

.auth-avatar:focus-visible {
  border-color: var(--accent-line);
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.auth-avatar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.auth-avatar.is-signed-in {
  border-color: var(--accent-line);
}

.auth-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 5;
  min-width: 112px;
  padding: 7px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.auth-menu button {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
}

.auth-menu button:hover,
.auth-menu button:focus-visible {
  color: var(--text);
  background: rgba(255, 138, 42, 0.12);
}

/* ------------------------------------------------------------
   Content / page scaffolding
   ------------------------------------------------------------ */
.content-main,
.time-main {
  flex: 1;
  padding: 54px 0 80px;
}

.terms-main {
  flex: 1;
  padding: 54px 0 80px;
}

.terms-content {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: clamp(26px, 5vw, 48px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--bg), 4px 4px 0 0 var(--bg-elev);
}

.terms-content h1 {
  margin: 8px 0 38px;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
}

.terms-content section + section {
  margin-top: 32px;
}

.terms-content h2 {
  margin: 0 0 12px;
  color: var(--accent-light);
  font-family: var(--ff-display);
  font-size: 1.1rem;
}

.terms-content p:not(.eyebrow) {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.75;
}

.page-heading {
  margin-bottom: 38px;
}

.page-heading h1 {
  font-size: clamp(2.6rem, 7vw, 4.6rem);
}

.page-heading > p:last-child {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

/* ------------------------------------------------------------
   Subject / branch / exam grids + cards
   ------------------------------------------------------------ */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.branch-grid,
.exam-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.subject-card {
  display: flex;
  position: relative;
  min-height: 168px;
  padding: 20px;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--bg), 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.subject-card::before {
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  content: "";
  background: var(--accent);
  opacity: 0;
  transition: opacity 160ms ease;
}

.subject-card:hover,
.subject-card:focus-visible {
  border-color: var(--accent-line);
  transform: translateY(-4px);
  box-shadow: 0 0 0 1px var(--bg), 0 16px 30px rgba(0, 0, 0, 0.35), 3px 3px 0 0 var(--accent-line);
}

.subject-card:hover::before {
  opacity: 1;
}

.subject-card > span {
  color: var(--muted-2);
  font-family: var(--ff-display);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.subject-card strong {
  margin-top: 10px;
  font-family: var(--ff-display);
  font-size: 1.15rem;
  line-height: 1.2;
}

.subject-card i {
  color: var(--accent-light);
  font-size: 0.72rem;
  font-style: normal;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.subject-card:hover i {
  opacity: 1;
  transform: translateY(0);
}

#material-description.study-intro {
  font-size: 1.1rem;
  line-height: 1.8;
}

#material-description.night-intro {
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.5;
}

/* ------------------------------------------------------------
   Probability meter
   ------------------------------------------------------------ */
.probability-meter {
  margin: -14px 0 28px;
  color: var(--muted-2);
  font-size: 0.8rem;
}

.probability-meter > span {
  display: block;
  margin-bottom: 12px;
  color: var(--accent-light);
  font-family: var(--ff-display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.probability-meter div {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.probability-meter div span {
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--ff-display);
  font-size: 0.86rem;
  font-weight: 600;
}

.probability-meter div span.high-probability {
  border-color: var(--accent-line);
  color: var(--accent-light);
}

/* paper section / questions */
.paper-section {
  justify-content: flex-start;
  gap: 18px;
}

.paper-section ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.9;
}

.question-card {
  gap: 18px;
  justify-content: flex-start;
}

.material-card .question-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------
   Material folders / action cards / viewer shell
   ------------------------------------------------------------ */
.material-folder {
  display: grid;
  grid-column: 1 / -1;
  gap: 14px;
}

.material-folder h2,
.material-viewer h2 {
  margin: 0;
  font-family: var(--ff-display);
  font-size: 1.18rem;
  letter-spacing: -0.02em;
}

.material-action-card {
  width: 100%;
  cursor: pointer;
  color: inherit;
  text-align: left;
}

.material-viewer {
  display: grid;
  grid-column: 1 / -1;
  gap: 14px;
  margin-top: 10px;
}

.material-viewer iframe {
  width: 100%;
  min-height: 560px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

/* PDF viewer */
.pdf-viewer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  font-family: var(--ff-display);
  font-size: 0.86rem;
}

.pdf-toolbar button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 11px;
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.pdf-toolbar button:hover {
  background: var(--surface-2);
  border-color: var(--accent-line);
  color: var(--accent-light);
}

.pdf-page-info {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 2px;
  color: var(--muted);
}

.pdf-page-info input {
  width: 52px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 3px 6px;
  font: inherit;
  text-align: center;
}

.pdf-page-info input:focus {
  border-color: var(--accent-line);
  outline: none;
}

.pdf-sep {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  margin: 0 4px;
  opacity: 0.6;
}

.pdf-scroll {
  overflow: auto;
  max-height: 80vh;
  padding: 12px;
  display: grid;
  justify-items: center;
}

.pdf-scroll canvas {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  border-radius: var(--radius);
  background: #fff;
}

.pdf-viewer:-webkit-full-screen {
  background: #0c0e12;
}

.pdf-viewer:fullscreen {
  background: #0c0e12;
  gap: 12px;
}

.pdf-viewer:fullscreen .pdf-scroll {
  max-height: calc(100vh - 64px);
}

.pdf-error {
  color: var(--danger);
}

/* Image viewer */
.image-viewer {
  display: grid;
  place-items: center;
  min-height: 340px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  overflow: auto;
}

.image-viewer img {
  max-width: min(100%, 1100px);
  max-height: 70vh;
  height: auto;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  background: #fff;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.image-viewer img.image-loaded {
  opacity: 1;
}

.image-viewer img.image-error {
  display: none;
}

.image-viewer-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-family: var(--ff-display);
}

.image-viewer-status.image-error {
  color: var(--danger);
}

.image-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: image-spin 0.8s linear infinite;
}

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

.material-folder .question-image {
  max-height: none;
}

/* ------------------------------------------------------------
   Time selection
   ------------------------------------------------------------ */
.time-main {
  display: flex;
  padding-top: 50px;
  flex-direction: column;
  justify-content: center;
}

.time-heading {
  text-align: center;
}

.time-heading h1 {
  font-size: clamp(2.5rem, 6vw, 4.2rem);
}

.time-heading > p:last-child span {
  color: var(--text);
}

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

.time-card {
  display: flex;
  position: relative;
  min-height: 285px;
  padding: 28px;
  flex-direction: column;
  align-items: flex-start;
  overflow: visible;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--bg), 0 8px 22px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.time-card:hover,
.time-card.selected {
  border-color: var(--accent-line);
  transform: translateY(-4px);
  box-shadow: 0 0 0 1px var(--bg), 0 18px 34px rgba(0, 0, 0, 0.35), 4px 4px 0 0 var(--accent-line);
}

.time-card.featured {
  border-color: var(--border-strong);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.time-card.featured:hover,
.time-card.featured.selected {
  border-color: var(--accent-line);
}

.time-card.urgent {
  order: -2;
  border-color: rgba(255, 138, 42, 0.5);
  background: linear-gradient(180deg, #1b1510, #141210 55%, var(--surface));
  box-shadow: 0 0 0 1px var(--bg), 0 10px 26px rgba(255, 90, 10, 0.1);
}

.time-card.urgent:hover,
.time-card.urgent.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--bg), 0 18px 36px rgba(255, 90, 10, 0.2), 4px 4px 0 0 var(--accent-line);
}

.time-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 30px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--accent-light);
  font-size: 1.15rem;
}

.time-card.urgent .time-icon {
  color: var(--accent);
  border-color: rgba(255, 138, 42, 0.4);
}

.time-label {
  margin-bottom: 7px;
  color: var(--accent-light);
  font-family: var(--ff-display);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.time-card strong {
  margin-bottom: 11px;
  font-family: var(--ff-display);
  font-size: 1.38rem;
}

.time-card small {
  max-width: 220px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.time-card i {
  position: absolute;
  right: 25px;
  bottom: 23px;
  color: var(--accent-light);
  font-style: normal;
  transition: transform 160ms ease;
}

.time-card:hover i {
  transform: translateX(4px);
}

.popular-tag {
  position: absolute;
  top: -1px;
  right: -1px;
  padding: 6px 10px;
  border: 1px solid var(--accent-line);
  border-bottom-left-radius: var(--radius);
  color: var(--accent-light);
  background: rgba(255, 138, 42, 0.12);
  font-family: var(--ff-display);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.time-card > * {
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------------
   JUST NIGHT — locked / unlocked (driven by .premium-unlocked)
   ------------------------------------------------------------ */

/* Decorative chain wraps the locked card edge */
.jn-chains {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.jn-chain {
  position: absolute;
  top: 0;
  height: 100%;
  width: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='26' viewBox='0 0 22 26'%3E%3Crect x='1' y='1' width='20' height='24' rx='4' fill='none' stroke='%23404048' stroke-width='2'/%3E%3Ccircle cx='11' cy='9' r='5' fill='none' stroke='%23404048' stroke-width='1.5'/%3E%3Cpath d='M11 14v5' stroke='%23404048' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: repeat-y;
  transition: transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 400ms ease;
}

.jn-chain--l { left: -12px; }
.jn-chain--r { right: -12px; }

/* lock shown while locked */
.lock-icon {
  position: absolute;
  top: 48px;
  right: 17px;
  z-index: 3;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 138, 42, 0.45);
  border-radius: var(--radius);
  color: var(--accent-light);
  background: rgba(26, 16, 8, 0.8);
  font-size: 0.74rem;
  line-height: 1;
  box-shadow: 0 0 0 1px var(--bg), 3px 3px 0 0 rgba(255, 138, 42, 0.25);
  transition: transform 400ms ease, opacity 400ms ease;
}

.lock-icon[hidden] {
  display: none;
}

/* Crown shows above the card once unlocked */
.jn-crown {
  position: absolute;
  top: -30px;
  left: 24px;
  z-index: 4;
  display: grid;
  width: 48px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 200, 100, 0.45);
  border-radius: var(--radius);
  color: transparent;
  background: linear-gradient(160deg, #e8b440 0%, #d49a20 35%, #c08418 60%, #a06810 100%);
  background-clip: padding-box;
  font-size: 1.3rem;
  line-height: 1;
  box-shadow:
    0 0 0 1px var(--bg),
    inset 0 1px 0 rgba(255, 230, 160, 0.4),
    4px 4px 0 0 rgba(180, 120, 20, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 500ms ease, transform 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Unlocked state — glow is INTERNAL only (inset shadows, clipped to the card) */
.just-night-card.premium-unlocked,
.time-card.urgent.premium-unlocked {
  border-color: rgba(255, 176, 60, 0.9);
  background: linear-gradient(180deg, #241b10, #16130d 60%, var(--surface));
  box-shadow:
    0 0 0 1px var(--bg),
    4px 4px 0 0 var(--accent-line),
    inset 0 0 18px rgba(255, 150, 40, 0.1),
    inset 0 0 42px rgba(255, 120, 20, 0.05),
    inset 0 1px 0 rgba(255, 200, 110, 0.2);
}

.time-card.urgent.premium-unlocked:hover,
.time-card.urgent.premium-unlocked.selected {
  border-color: #ffca7a;
  box-shadow:
    0 0 0 1px var(--bg),
    4px 4px 0 0 rgba(255, 176, 60, 0.9),
    inset 0 0 22px rgba(255, 150, 40, 0.15),
    inset 0 0 46px rgba(255, 120, 20, 0.07),
    inset 0 1px 0 rgba(255, 220, 150, 0.22);
}

/* unlock transition: chains break apart, crown appears */
.time-card.urgent.premium-unlocked .jn-chain--l {
  transform: translateX(-16px);
  opacity: 0.35;
}

.time-card.urgent.premium-unlocked .jn-chain--r {
  transform: translateX(16px);
  opacity: 0.35;
}

.time-card.urgent.premium-unlocked .jn-crown {
  opacity: 1;
  transform: translateY(0);
  color: #fff4d0;
}

/* contained shimmer — inset:0 keeps the pseudo-element exactly card-sized;
   background-position animation moves only the gradient, not the element */
.time-card.urgent.premium-unlocked::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    105deg,
    transparent 42%,
    rgba(255, 210, 120, 0.09) 46%,
    rgba(255, 210, 120, 0.14) 50%,
    rgba(255, 210, 120, 0.09) 54%,
    transparent 58%
  );
  background-size: 250% 100%;
  animation: just-night-shimmer 8s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes just-night-shimmer {
  0%, 100% { background-position: 250% 0; }
  50%      { background-position: -50%  0; }
}

/* unavailable (frozen) */
.just-night-card.just-night-unavailable,
.time-card.urgent.just-night-unavailable {
  filter: grayscale(0.7);
  opacity: 0.75;
}

.selection-message {
  min-height: 24px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ------------------------------------------------------------
   Just Night purchase modal
   ------------------------------------------------------------ */
.just-night-modal {
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--bg), 0 26px 80px rgba(0, 0, 0, 0.55);
}

.just-night-modal::backdrop {
  background: rgba(5, 6, 9, 0.78);
}

.just-night-modal section {
  padding: 28px;
}

.just-night-modal h2 {
  margin: 8px 0 12px;
}

.just-night-modal p {
  color: var(--muted);
}

.just-night-modal .eyebrow {
  margin: 0;
}

/* ------------------------------------------------------------
   Admin
   ------------------------------------------------------------ */
.admin-panel {
  display: grid;
  gap: 18px;
}

.admin-card {
  gap: 16px;
  justify-content: flex-start;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-field {
  display: grid;
  gap: 7px;
}

.admin-field label {
  color: var(--muted);
  font-family: var(--ff-display);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.admin-field input,
.admin-field select {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font: inherit;
  transition: border-color 160ms ease;
}

.admin-field input:focus,
.admin-field select:focus {
  border-color: var(--accent-line);
  outline: 2px solid rgba(255, 138, 42, 0.18);
}

.admin-field input::placeholder {
  color: var(--muted-2);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-actions .button {
  min-height: 44px;
  padding: 0 16px;
  font-size: 0.86rem;
}

.upload-progress {
  display: grid;
  gap: 6px;
}

.upload-progress-track {
  height: 8px;
  border-radius: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 0;
  background: var(--accent);
  transition: width 0.15s ease;
}

.upload-progress-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-family: var(--ff-display);
  letter-spacing: 0.04em;
}

.admin-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.82rem;
}

.premium-records {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.premium-record {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 160ms ease;
}

.premium-record:hover {
  border-color: var(--accent-line);
}

.premium-status-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: var(--radius);
  font-family: var(--ff-display);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.premium-status-active { color: var(--success); background: rgba(127, 216, 143, 0.12); }
.premium-status-expired { color: var(--warn); background: rgba(242, 202, 153, 0.12); }
.premium-status-revoked { color: #f1aab1; background: rgba(241, 170, 177, 0.12); }

.premium-details {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1.3fr);
  gap: 8px 14px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.premium-details dt { color: var(--text); font-weight: 700; }
.premium-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }

.ad-active-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-ad-list {
  display: grid;
  gap: 10px;
}

.admin-ad-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.admin-ad-row img {
  display: block;
  width: 80px;
  height: 48px;
  object-fit: contain;
}

.admin-ad-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-ad-row small { color: var(--muted); overflow-wrap: anywhere; }
.admin-ad-row > div:last-child { display: flex; flex-wrap: wrap; }

/* ------------------------------------------------------------
   AKTU hub
   ------------------------------------------------------------ */
.hub-intro {
  margin: 18px 0 34px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.8;
  max-width: 62ch;
}

.hub-section {
  margin-top: 34px;
}

.hub-section h2 {
  margin: 0 0 8px;
  color: var(--accent-light);
  font-family: var(--ff-display);
  font-size: 1.4rem;
}

.hub-section h3 {
  margin: 22px 0 10px;
  color: var(--text);
  font-family: var(--ff-display);
  font-size: 1rem;
  font-weight: 600;
}

.hub-section > p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.75;
}

.subject-chip {
  display: inline-flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--ff-display);
  font-size: 0.88rem;
  font-weight: 500;
  transition: border-color 160ms ease, color 160ms ease;
}

.subject-chip:hover {
  border-color: var(--accent-line);
  color: var(--accent-light);
}

.hub-section .button {
  margin-top: 6px;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
}

.footer-links a {
  color: var(--muted-2);
  text-decoration: none;
  transition: color 160ms ease;
}

.footer-links a:hover {
  color: var(--accent-light);
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 850px) {
  .subject-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .time-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .time-main {
    justify-content: flex-start;
  }

  .time-card {
    min-height: 220px;
  }
}

@media (max-width: 600px) {
  .site-shell {
    width: min(100% - 28px, var(--max-width));
  }

  #ad-banner {
    aspect-ratio: 4 / 1;
    max-height: 76px;
    margin-top: 12px;
  }

  #ad-banner p {
    display: none;
  }

  .home-main {
    padding: 54px 0 42px;
  }

  .logo-mark {
    width: 54px;
    height: 54px;
    margin-bottom: 22px;
  }

  .hero h1 {
    font-size: clamp(2.5rem, 13vw, 3.6rem);
  }

  .hero-copy {
    font-size: 0.92rem;
  }

  .year-actions {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .button {
    min-height: 70px;
    font-size: 1rem;
  }

  .topbar {
    padding-top: 20px;
    gap: 8px;
  }

  .content-main,
  .time-main {
    padding: 38px 0 60px;
  }

  .terms-main {
    padding: 38px 0 60px;
  }

  .page-heading {
    margin-bottom: 28px;
  }

  .subject-grid {
    gap: 10px;
  }

  .subject-card {
    min-height: 138px;
    padding: 16px;
  }

  .subject-card i {
    display: none;
  }

  .time-card {
    min-height: 200px;
    padding: 24px;
  }

  .time-icon {
    margin-bottom: 22px;
  }

  .mini-logo {
    font-size: 0.94rem;
  }

  .back-link {
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .jn-crown {
    left: 18px;
    top: -24px;
    width: 40px;
    height: 36px;
    font-size: 1.1rem;
  }

  .jn-chain--l { left: -10px; }
  .jn-chain--r { right: -10px; }
}

@media (max-width: 400px) {
  .subject-grid,
  .branch-grid,
  .exam-grid {
    grid-template-columns: 1fr;
  }
}

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