/* =========================================================
   CRACKERS — Routine Hub
   Design tokens
   ========================================================= */
:root {
  --bg: #0a0b09;
  --bg-soft: #0f110d;
  --surface: #14160f;
  --surface-2: #191c13;
  --border: rgba(214, 255, 62, 0.14);
  --border-soft: rgba(255, 255, 255, 0.06);
  --accent: #d6ff3e;
  --accent-dim: #9dbe2e;
  --accent-soft: rgba(214, 255, 62, 0.1);
  --text: #f3f5ec;
  --text-muted: #8d9488;
  --text-faint: #5c6156;
  --danger: #ff6b57;
  --radius: 2px;
  --grid-size: 44px;
  --font-display: "Chakra Petch", sans-serif;
  --font-body: "Inter", sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* =========================================================
   App WebView Touch & Vertical Scroll Fix
   ========================================================= */
html {
  height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch !important;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  touch-action: pan-y !important;
}

/*-------- toggle button --------*/
.view-toggle {
  display: inline-flex;
  margin-top: 18px;
  padding: 4px;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  max-width: 100%;
}

.view-toggle-opt {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  border-radius: 999px;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.view-toggle-opt:hover {
  color: rgba(255, 255, 255, 0.85);
}

.view-toggle-opt.is-active {
  color: #0a0a0a;
  background: linear-gradient(135deg, #7CFC9B, #4ADE80);
  box-shadow: 0 0 16px rgba(76, 222, 128, 0.45);
}

/* ---------- grid background ---------- */
.grid-backdrop {
  position: absolute !important;
  inset: 0;
  z-index: 0;
  pointer-events: none !important;
  background-image:
    linear-gradient(to right, rgba(214, 255, 62, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(214, 255, 62, 0.055) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 40%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 40%, transparent 90%);
}

.grid-glow {
  position: absolute !important;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 900px;
  max-width: 100vw;
  background: radial-gradient(circle, rgba(214, 255, 62, 0.16) 0%, rgba(214, 255, 62, 0) 65%);
  z-index: 0;
  pointer-events: none !important;
}

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

/* ---------- layout shells ---------- */
.page {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: visible !important;
}

.wrap {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(10, 11, 9, 0.72);
  border-bottom: 1px solid var(--border-soft);
  width: 100%;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  padding-bottom: 16px;
}

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

.brand-mark {
  width: auto;
  height: 22px;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.header-clock {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-align: right;
}

.header-clock strong { color: var(--text); font-weight: 600; }

/* ---------- hero (index page) ---------- */
.hero {
  padding: 64px 0 28px;
  text-align: center;
}

.hero-mark {
  width: auto;
  height: 50px;
  margin: 0 auto 22px;
  object-fit: contain;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-dim);
  margin: 0 0 14px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1.12;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.hero p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 460px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ---------- course chevron buttons ---------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 36px 0 80px;
}

.course-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 22px 22px 26px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 16px 100%, 0 calc(100% - 16px));
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.course-btn:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateX(2px);
}

.course-btn .cname {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  word-break: break-word;
}

.course-btn .ccount {
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: var(--font-body);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
}

.course-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--accent);
  transition: transform 0.18s ease;
}

.course-btn:hover svg { transform: translateX(3px); }

/* ---------- routine page ---------- */
.course-title-block {
  padding: 40px 0 8px;
}

.course-title-block .eyebrow { margin-bottom: 10px; }

.course-title-block h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 5vw, 34px);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  margin: 0;
  word-break: break-word;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
  transition: color 0.15s ease;
}

.back-link:hover { color: var(--accent); }
.back-link svg { width: 12px; height: 12px; }

/* ---------- next class spotlight ---------- */
.next-class {
  margin: 26px 0 8px;
  position: relative;
  padding: 26px 26px 26px 30px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(214,255,62,0.05), 0 18px 40px -20px rgba(214,255,62,0.25);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 22px 100%, 0 calc(100% - 22px));
  width: 100%;
}

.next-class-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(214, 255, 62, 0.6);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(214, 255, 62, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(214, 255, 62, 0); }
  100% { box-shadow: 0 0 0 0 rgba(214, 255, 62, 0); }
}

.next-class h2 {
  font-family: var(--font-display);
  font-size: clamp(19px, 4vw, 24px);
  font-weight: 600;
  margin: 0 0 16px;
  line-height: 1.3;
  word-break: break-word;
}

.next-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.meta-item .label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.meta-item .value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

/* ---------- upcoming list ---------- */
.list-section { 
  padding: 40px 0 120px;
}

.list-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.list-heading h3 {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
  font-weight: 600;
}

.list-count {
  font-size: 12px;
  color: var(--text-faint);
}

.class-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 16px 18px 16px 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  margin-bottom: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  width: 100%;
}

.class-row:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.row-notch {
  height: 100%;
  min-height: 36px;
  background: var(--accent-dim);
  opacity: 0.55;
}

.class-row.is-uploaded .row-notch { background: var(--accent); opacity: 1; }

.row-main { min-width: 0; }

.row-topic {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 5px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.row-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.row-sub span { white-space: normal; word-break: break-word; }

.row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.status-pill {
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.status-pill.uploaded {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

.status-pill.upcoming {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.row-date {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ---------- empty / loading / error states ---------- */
.state-block {
  text-align: center;
  padding: 60px 20px 90px;
  color: var(--text-muted);
}

.state-block .state-mark {
  width: 30px;
  height: 33px;
  margin: 0 auto 18px;
  opacity: 0.7;
}

.state-block .state-mark path { fill: var(--accent-dim); }

.state-block h3 {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.state-block p {
  font-size: 13.5px;
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ---------- footer ---------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-soft);
  padding: 18px 0 26px;
  width: 100%;
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

/* ==========================================
   Batch Switcher Bar & Button Styling
   ========================================== */

.batch-switcher-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin: 20px 0 28px 0;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid #f39c12;
  border-radius: 10px;
  backdrop-filter: blur(8px);
  width: 100%;
}

.batch-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f39c12;
  letter-spacing: 0.5px;
}

.btn-batch-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  outline: none;
}

.btn-batch-toggle:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-batch-toggle:active {
  transform: translateY(0);
}

.btn-batch-toggle.is-active {
  background: #f39c12;
  color: #000000;
  border-color: #f39c12;
  box-shadow: 0 0 12px rgba(243, 156, 18, 0.4);
}

.btn-batch-toggle.is-active:hover {
  background: #e08e0b;
  border-color: #e08e0b;
  color: #000000;
}

/* =========================================================
   COMPACT EMBED LAYOUT (Strict 650px Height Optimization)
   ========================================================= */
@media (max-width: 649px) {
  html, body {
    height: 650px !important;
    max-height: 650px !important;
    overflow-y: auto !important;
  }

  .wrap { 
    padding: 0 10px; 
  }

  .site-header {
    padding: 2px 0;
  }

  .site-header .wrap { 
    padding-top: 6px; 
    padding-bottom: 6px; 
  }

  .brand-mark {
    height: 16px;
  }

  .brand-word {
    font-size: 13px;
  }

  .header-clock { 
    font-size: 10px; 
  }

  .course-title-block { 
    padding: 8px 0 2px; 
  }

  .course-title-block p { 
    font-size: 11px; 
    margin-bottom: 2px; 
  }

  .course-title-block h1 { 
    font-size: 17px; 
  }

  .batch-switcher-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    margin: 8px 0;
    gap: 8px;
  }
  
  .batch-badge { 
    font-size: 0.78rem; 
  }

  .btn-batch-toggle { 
    width: auto; 
    font-size: 0.72rem; 
    padding: 5px 10px; 
  }

  /* Compact Next Up Spotlight Box */
  .next-class { 
    padding: 10px 12px; 
    margin: 6px 0 10px; 
  }

  .next-class-tag {
    font-size: 9.5px;
    margin-bottom: 6px;
  }

  .next-class h2 { 
    font-size: 14.5px; 
    margin-bottom: 8px; 
    line-height: 1.25;
  }

  .next-meta { 
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px 8px; 
  }

  .meta-item .label { 
    font-size: 8.5px; 
  }

  .meta-item .value { 
    font-size: 11px; 
  }

  /* Compact Class List Items */
  .list-section { 
    padding: 6px 0 40px !important; 
  }

  .list-heading {
    margin-bottom: 8px;
  }

  .list-heading h3 {
    font-size: 11px;
  }

  .list-count {
    font-size: 10.5px;
  }

  .class-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    margin-bottom: 5px;
    gap: 8px;
  }

  .row-notch {
    width: 3px;
    min-height: 28px;
  }

  .row-topic {
    font-size: 12.5px;
    margin-bottom: 2px;
  }

  .row-sub {
    font-size: 10.5px;
    gap: 4px 8px;
  }

  .row-right {
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 65px;
  }

  .status-pill {
    font-size: 8.5px;
    padding: 1px 6px;
  }

  .row-date {
    font-size: 10px;
  }

  .site-footer {
    padding: 10px 0;
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .pulse-dot { animation: none; }
  .course-btn, .course-btn svg, .class-row { transition: none; }
}

/* ---------- focus states ---------- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}