/* StudyAI Hub - Apple-inspired minimal design
   Tokens: bg #ffffff / section #f5f5f7 / ink #1d1d1f / muted #6e6e73 / accent #0071e3 */

:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --hairline: #d2d2d7;
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --card-radius: 18px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 12px 36px rgba(0, 0, 0, 0.12);
  --maxw: 1080px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ---------- Nav (Apple frosted glass) ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.nav-links {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  color: rgba(0, 0, 0, 0.72);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 980px;
  white-space: nowrap;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-links a.active { color: var(--ink); font-weight: 500; }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 96px 22px 72px;
  max-width: 860px;
  margin: 0 auto;
}
.hero-kicker {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.08;
}
.hero p.sub {
  font-size: clamp(17px, 2.4vw, 21px);
  color: var(--muted);
  margin-top: 18px;
  letter-spacing: -0.01em;
}

/* ---------- Search ---------- */
.search-wrap {
  max-width: 560px;
  margin: 36px auto 0;
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
}
#search {
  width: 100%;
  padding: 16px 20px 16px 46px;
  font-size: 17px;
  font-family: inherit;
  border: none;
  border-radius: 980px;
  background: var(--bg-alt);
  color: var(--ink);
  outline: none;
  transition: box-shadow 0.2s, background 0.2s;
}
#search:focus {
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.25);
}
#search::placeholder { color: #86868b; }

/* ---------- Filters ---------- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 32px auto 0;
  padding: 0 22px;
  max-width: var(--maxw);
}
.pill {
  border: none;
  background: var(--bg-alt);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 9px 16px;
  border-radius: 980px;
  cursor: pointer;
  transition: all 0.2s;
}
.pill:hover { background: #e8e8ed; }
.pill.active {
  background: var(--ink);
  color: #fff;
}

/* ---------- Sections / categories ---------- */
.section { padding: 28px 22px 8px; max-width: var(--maxw); margin: 0 auto; }
.section-head { margin-bottom: 20px; }
.section-head h2 {
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.section-head p { color: var(--muted); font-size: 15px; margin-top: 6px; }
.section-head a.cat-link { font-size: 14px; }

/* ---------- Tool cards grid (10015 / Product Hunt style) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px 60px;
}
.card {
  background: var(--bg);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}
.card-visual {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg-alt);
  overflow: hidden;
}
.card-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 24px;
  background: #ffffff;
  box-sizing: border-box;
  transition: transform 0.4s ease;
}
.card:hover .card-visual img { transform: scale(1.04); }
.card-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #ffffff 0%, #f5f5f7 100%);
}
.card-fallback span {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.035);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.04);
}
.card-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.card h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.card h3 a { color: var(--ink); }
.card h3 a:hover { text-decoration: none; }
.badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 980px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.free { background: #e8f5e9; color: #1b5e20; }
.badge.freemium { background: #e3f0ff; color: #0d47a1; }
.card-meta {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}
.card-review {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hidden { display: none !important; }

.no-results {
  text-align: center;
  color: var(--muted);
  padding: 60px 22px;
  display: none;
}

/* ---------- Page head (category pages) ---------- */
.page-head {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 72px 22px 12px;
  text-align: center;
}
.breadcrumb {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--muted); }
.page-head h1 {
  font-size: clamp(34px, 5.5vw, 52px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.page-head .sub { color: var(--muted); font-size: 19px; margin-top: 14px; }

/* ---------- Category strip (home) ---------- */
.cat-strip {
  max-width: var(--maxw);
  margin: 24px auto 0;
  padding: 0 22px 64px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.cat-card {
  background: var(--bg-alt);
  border-radius: var(--card-radius);
  padding: 24px;
  color: var(--ink);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.cat-card:hover {
  text-decoration: none;
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  background: #fff;
}
.cat-card h3 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.cat-card p { font-size: 13px; color: var(--muted); }
.cat-card .count { font-size: 12px; color: var(--accent); font-weight: 500; margin-top: 10px; display: block; }

/* ---------- Footer ---------- */
footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--hairline);
  padding: 40px 22px 48px;
  font-size: 12px;
  color: var(--muted);
}
.foot-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: space-between;
  align-items: flex-start;
}
.foot-inner p { max-width: 480px; line-height: 1.6; }
.foot-links { display: flex; gap: 18px; flex-wrap: wrap; }
.foot-links a { color: var(--muted); }

/* ---------- Simple content page (about) ---------- */
.prose {
  max-width: 680px;
  margin: 0 auto;
  padding: 72px 22px 80px;
}
.prose h1 { font-size: 40px; letter-spacing: -0.02em; margin-bottom: 20px; }
.prose h2 { font-size: 26px; letter-spacing: -0.015em; margin: 36px 0 12px; }
.prose p { color: #3a3a3c; font-size: 16.5px; line-height: 1.65; margin-bottom: 16px; }
.prose ul { margin: 0 0 16px 22px; color: #3a3a3c; font-size: 16.5px; line-height: 1.8; }

@media (max-width: 640px) {
  .hero { padding-top: 64px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .card-body { padding: 15px 17px 17px; }
  .card h3 { font-size: 16px; }
  .card-review { -webkit-line-clamp: 2; }
}

/* ---------- Sticky category quick-nav (TOC) ---------- */
.toc {
  position: sticky;
  top: 48px; /* below main nav */
  z-index: 90;
  background: rgba(245, 245, 247, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.toc-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.toc-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.toc-links {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.toc-links::-webkit-scrollbar { display: none; }
.toc-links a {
  color: rgba(0, 0, 0, 0.64);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 980px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.toc-links a:hover { color: var(--ink); text-decoration: none; background: rgba(0, 0, 0, 0.05); }
.toc-links a.active {
  color: #fff;
  background: var(--ink);
}
.toc-n {
  font-size: 10.5px;
  opacity: 0.55;
  margin-left: 2px;
}

/* ---------- Back to top ---------- */
.to-top {
  position: fixed;
  right: 22px;
  bottom: 26px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(29, 29, 31, 0.85);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
  z-index: 80;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { background: var(--ink); }

@media (max-width: 640px) {
  .toc { top: 48px; }
  .toc-label { display: none; }
}

/* ---------- GitHub nav button ---------- */
.nav-gh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 980px;
  background: rgba(0, 0, 0, 0.05);
  transition: background 0.2s, transform 0.15s;
  margin-left: 6px;
  white-space: nowrap;
}
.nav-gh:hover { background: rgba(0, 0, 0, 0.1); text-decoration: none; }
.nav-gh svg { flex-shrink: 0; }

/* ---------- Hero note (humanized intro) ---------- */
.hero-note {
  max-width: 580px;
  margin: 0 auto 28px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
  text-align: center;
}

/* ---------- Perk table (student-perks layout) ---------- */
.perk-table-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.perk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.5;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.06);
  min-width: 720px;
}
.perk-table thead th {
  background: #f5f5f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  white-space: nowrap;
}
.perk-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  vertical-align: top;
}
.perk-table tbody tr.trow {
  transition: background 0.15s;
}
.perk-table tbody tr.trow:hover {
  background: rgba(0, 113, 227, 0.03);
}
.perk-table .td-name a {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.perk-table .td-name a:hover { color: var(--accent); }
.perk-table .td-what { color: var(--muted); max-width: 200px; }
.perk-table .td-benefit { color: var(--ink); max-width: 220px; font-weight: 450; }
.perk-table .td-go a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.perk-table .td-go a:hover { text-decoration: underline; }

/* Group header row */
.perk-table tr.tgroup td {
  background: #fafafa;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}
.perk-table tr.tgroup:first-child td { border-top: none; }

/* ---------- Colored tags for perk table ---------- */
.ptag, .etag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 980px;
  white-space: nowrap;
  line-height: 1.4;
}
.ptag.tag-purple { background: #f3e8ff; color: #7c3aed; }
.ptag.tag-green  { background: #dcfce7; color: #15803d; }
.ptag.tag-blue   { background: #dbeafe; color: #1d4ed8; }
.ptag.tag-teal   { background: #ccfbf1; color: #0f766e; }
.ptag.tag-orange { background: #ffedd5; color: #c2410c; }
.ptag.tag-gray   { background: #f3f4f6; color: #4b5563; }

.etag.elib-student { background: #ede9fe; color: #6d28d9; }
.etag.elib-campus  { background: #fef3c7; color: #b45309; }
.etag.elib-open    { background: #f3f4f6; color: #6b7280; }

@media (max-width: 768px) {
  .perk-table { min-width: 640px; }
  .hero-note { font-size: 13px; }
  .nav-gh span { display: none; }
  .nav-gh { padding: 6px 8px; }
}

/* ---------- Category rail (Apple-style horizontal swipe nav) ---------- */
.cat-rail {
  position: sticky;
  top: 48px;
  z-index: 95;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
}
.cat-rail-track {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 66px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  cursor: grab;
}
.rail-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44px;
  border: none;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  opacity: 1;
  transition: opacity 0.2s, background 0.2s;
}
.rail-arrow:hover { background: rgba(255, 255, 255, 0.98); }
.rail-arrow svg { width: 20px; height: 20px; }
.rail-arrow-left { left: 0; border-right: 1px solid rgba(0,0,0,0.06); }
.rail-arrow-right { right: 0; border-left: 1px solid rgba(0,0,0,0.06); }
.rail-arrow.hidden { opacity: 0; pointer-events: none; }
.cat-rail-track::-webkit-scrollbar { display: none; }
.cat-rail-track:active { cursor: grabbing; }
.cat-rail-track a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 9px 16px 9px 13px;
  border-radius: 980px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid transparent;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  scroll-snap-align: start;
  user-select: none;
}
.cat-rail-track a:hover {
  background: rgba(0, 0, 0, 0.08);
  text-decoration: none;
  transform: translateY(-1px);
}
.cat-rail-track a.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.cat-rail-track a .rail-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  opacity: 0.85;
}
.cat-rail-track a.active .rail-icon { opacity: 1; }
.cat-rail-track a .rail-icon svg { width: 100%; height: 100%; }
.cat-rail-track a .rail-count {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 980px;
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
  margin-left: -2px;
}
.cat-rail-track a.active .rail-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* Edge fades to hint more content */
.cat-rail::before,
.cat-rail::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  z-index: 2;
}
.cat-rail::before {
  left: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.95), rgba(255,255,255,0));
}
.cat-rail::after {
  right: 0;
  background: linear-gradient(270deg, rgba(255,255,255,0.95), rgba(255,255,255,0));
}

/* Adjust hero/page-head because rail sits below nav */
.hero { padding-top: 120px; }
.page-head { padding-top: 96px; }

@media (max-width: 640px) {
  .cat-rail { top: 48px; }
  .cat-rail-track { padding: 8px 44px; gap: 6px; }
  .cat-rail-track a { font-size: 12.5px; padding: 8px 13px 8px 10px; }
  .cat-rail::before,
  .cat-rail::after { width: 18px; }
  .rail-arrow { width: 36px; }
  .rail-arrow svg { width: 18px; height: 18px; }
  .hero { padding-top: 90px; }
  .page-head { padding-top: 78px; }
}

/* ---------- Submit a tool page ---------- */
.submit-page { padding-top: 120px; }
.submit-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 32px;
}
.submit-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}
.submit-form input,
.submit-form select,
.submit-form textarea {
  font: inherit;
  font-size: 15px;
  padding: 13px 15px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.submit-form input:focus,
.submit-form select:focus,
.submit-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.12);
}
.submit-form textarea { resize: vertical; min-height: 100px; }
.submit-form button {
  align-self: flex-start;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 24px;
  border: none;
  border-radius: 980px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}
.submit-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
@media (max-width: 640px) {
  .submit-page { padding-top: 96px; }
  .submit-form button { width: 100%; align-self: stretch; }
}
