:root {
  --ink: #21183f;
  --purple: #5a3ca6;
  --purple-light: #eee9fb;
  --paper: #faf9fd;
  --white: #fff;
  --muted: #6f6a7d;
  --line: #e6e1ef;
  --teal: #b8eee2;
  --radius: 18px;
  --shadow: 0 12px 35px rgba(33,24,63,.08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--paper); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .btn { cursor: pointer; }
.container { width: min(1120px, calc(100% - 36px)); margin: 0 auto; }

/* Top bar – always visible */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(250,249,253,.95); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 850; letter-spacing: -.04em; }
.logo-img { width: 42px; height: 42px; border-radius: 12px; object-fit: contain; background: var(--ink); box-shadow: 0 4px 12px #21183f2b; }
.brand small { display: block; color: var(--muted); font-weight: 550; font-size: 10px; letter-spacing: .02em; }
.nav-home-btn { background: var(--purple); color: white; border: none; padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: 13px; display: none; }
.nav-home-btn.visible { display: inline-flex; }

/* ===== ENTRY SCREEN (button grid only) ===== */
#entryScreen { min-height: calc(100vh - 68px); display: flex; flex-direction: column; padding: 28px 0 50px; }
.entry-banner { width: 100%; max-height: 160px; object-fit: cover; display: block; border-radius: 0 0 20px 20px; margin-bottom: 28px; }
.entry-intro { text-align: center; margin-bottom: 32px; }
.entry-intro h1 { font-size: clamp(28px, 5vw, 40px); letter-spacing: -.05em; margin: 0 0 8px; }
.entry-intro p { color: var(--muted); margin: 0; font-size: 15px; }
.button-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; max-width: 520px; margin: 0 auto; }
.launch-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: white; border: 1px solid var(--line); border-radius: 20px; padding: 28px 16px;
  font-weight: 800; font-size: 15px; text-align: center; box-shadow: 0 6px 20px rgba(33,24,63,.06);
  transition: transform .2s, box-shadow .2s, border-color .2s; min-height: 120px;
}
.launch-btn:hover, .launch-btn:focus { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--purple); outline: none; }
.launch-btn .icon { font-size: 28px; line-height: 1; }
.launch-btn span { color: var(--ink); }
.launch-btn small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Content sections – hidden by default */
.content-section { display: none; padding: 28px 0 60px; }
.content-section.active { display: block; }
.section-back { display: inline-flex; align-items: center; gap: 6px; background: white; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-weight: 700; font-size: 13px; margin-bottom: 22px; }
.section-back:hover { border-color: var(--purple); color: var(--purple); }

/* Nested views (semester list ↔ year/subject detail) */
.nested-view { display: none; }
.nested-view.active-view { display: block; }
.clickable-card { cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s; }
.clickable-card:hover, .clickable-card:focus { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--purple); outline: none; }
.clickable-card .btn-secondary { pointer-events: none; margin-top: auto; width: 100%; justify-content: center; }

/* Shared card & button styles */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 999px; padding: 12px 18px; font-weight: 800; font-size: 14px; transition: transform .2s, box-shadow .2s; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-primary { background: var(--purple); color: white; }
.btn-secondary { background: white; border-color: var(--line); color: var(--ink); }
.btn-download { background: var(--purple); color: white; padding: 11px 16px; font-size: 13px; width: 100%; justify-content: center; margin-top: auto; }
.btn-download:hover { background: #4a2f8f; }

h2 { font-size: clamp(26px, 4vw, 36px); letter-spacing: -.05em; line-height: 1.15; margin: 0 0 8px; }
.kicker { color: var(--purple); font-size: 12px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.muted { color: var(--muted); margin: 0; }
.section-head { margin-bottom: 24px; }
.card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 5px 18px rgba(33,24,63,.025); }
.tag { display: inline-block; border-radius: 99px; padding: 4px 9px; background: var(--purple-light); color: var(--purple); font-size: 11px; font-weight: 800; }

/* Syllabus / Papers shared */
.semester-block { margin-bottom: 36px; }
.semester-heading { font-size: 18px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.semester-heading::before { content: ""; width: 8px; height: 8px; background: var(--teal); border-radius: 50%; }
.syllabus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.syllabus-card { display: flex; flex-direction: column; gap: 10px; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-height: 160px; }
.syllabus-card.large { grid-column: 1 / -1; max-width: 480px; }
.syllabus-card h3 { margin: 0; font-size: 15px; letter-spacing: -.02em; line-height: 1.3; }
.syllabus-card p { margin: 0; color: var(--muted); font-size: 13px; flex-grow: 1; }

/* Papers */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.toolbar input, .toolbar select { background: white; border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; min-width: 160px; color: var(--ink); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.resource-card { display: flex; flex-direction: column; gap: 10px; min-height: 160px; }
.resource-meta { display: flex; flex-wrap: wrap; gap: 6px; }

/* Gallery */
.gallery-tile { min-height: 160px; display: flex; flex-direction: column; justify-content: end; border-radius: 16px; padding: 16px; color: white; overflow: hidden; position: relative; }
.gallery-tile:nth-child(1) { background: linear-gradient(150deg,#34225f,#8e79c6); }
.gallery-tile:nth-child(2) { background: linear-gradient(150deg,#234d55,#7fc5b9); }
.gallery-tile:nth-child(3) { background: linear-gradient(150deg,#4c4055,#c79ab5); }
.gallery-tile:nth-child(4) { background: linear-gradient(150deg,#6b4d2f,#dbb879); }
.gallery-tile:nth-child(5) { background: linear-gradient(150deg,#263c5a,#7ea2c8); }
.gallery-tile:nth-child(6) { background: linear-gradient(150deg,#3c5542,#a6c8a2); }
.gallery-tile strong, .gallery-tile span { position: relative; z-index: 1; }
.gallery-tile span { font-size: 12px; opacity: .85; }

/* Notices */
.notice-list { display: grid; gap: 12px; }
.notice { display: grid; grid-template-columns: 70px 1fr; gap: 14px; padding: 16px; background: white; border: 1px solid var(--line); border-radius: 14px; }
.notice-date { display: grid; place-items: center; align-content: center; background: var(--purple-light); border-radius: 11px; color: var(--purple); font-weight: 850; font-size: 11px; text-align: center; }
.notice-date b { font-size: 20px; line-height: 1.1; }
.notice h3 { margin: 0 0 4px; font-size: 15px; }
.notice p { margin: 0; color: var(--muted); font-size: 13px; }

/* Portal & Contribute */
.portal-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
.steps { display: grid; gap: 12px; margin-top: 18px; }
.step { display: flex; gap: 12px; align-items: start; color: var(--muted); font-size: 14px; }
.step b { flex: 0 0 28px; width: 28px; height: 28px; display: grid; place-items: center; background: var(--purple-light); border-radius: 8px; color: var(--purple); font-size: 13px; }
.form-card { background: white; border-radius: 18px; padding: 22px; border: 1px solid var(--line); }
.form-card h3 { margin: 0 0 6px; font-size: 20px; }
.form-card > p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.field { display: grid; gap: 5px; }
label { font-size: 12px; font-weight: 800; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fdfcff; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px #5a3ca61a; }
textarea { min-height: 90px; resize: vertical; }
.notice-box { background: #fff5d9; color: #5c4711; border: 1px solid #f0dfa9; padding: 11px 12px; border-radius: 10px; font-size: 12px; margin: 12px 0; }
.form-card .btn { width: 100%; border: 0; }
.form-message { display: none; margin-top: 12px; padding: 12px; border-radius: 10px; background: #fff5d9; color: #5c4711; font-size: 13px; }
.disclaimer { font-size: 11px; color: var(--muted); margin-top: 16px; }

/* Footer */
.footer { background: #17112d; color: white; padding: 28px 0; margin-top: 20px; }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; align-items: center; flex-wrap: wrap; }
.footer p { margin: 4px 0 0; color: #b8b1ca; font-size: 12px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: #ded9ea; }

@media (min-width: 600px) {
  .button-grid { grid-template-columns: repeat(3, 1fr); max-width: 640px; }
  .portal-grid { grid-template-columns: .9fr 1.1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field.full { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .button-grid { grid-template-columns: 1fr; max-width: 320px; }
  .launch-btn { min-height: 100px; padding: 22px 14px; }
}

/* ========== FAr AI ASSISTANT ========== */
.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 14px 18px;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 8px 28px rgba(90, 60, 166, 0.45);
  transition: transform .2s, box-shadow .2s;
}
.ai-fab:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(90, 60, 166, 0.55); }
.ai-fab-icon { font-size: 18px; line-height: 1; }
.ai-fab-label { letter-spacing: -.02em; }

.ai-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 51;
  width: min(380px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 140px));
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(33, 24, 63, 0.18);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity .25s, transform .25s, visibility .25s;
}
.ai-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--purple-light);
  border-radius: 20px 20px 0 0;
}
.ai-panel-title { display: flex; align-items: center; gap: 10px; }
.ai-avatar {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--purple); color: white;
  border-radius: 12px; font-size: 16px;
}
.ai-panel-title strong { display: block; font-size: 15px; letter-spacing: -.02em; }
.ai-panel-title small { color: var(--muted); font-size: 11px; }
.ai-close {
  width: 32px; height: 32px;
  border: none; background: white;
  border-radius: 10px; font-size: 20px;
  color: var(--muted); line-height: 1;
  display: grid; place-items: center;
}
.ai-close:hover { color: var(--ink); background: var(--line); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 180px;
}
.ai-msg {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}
.ai-msg p { margin: 0 0 6px; }
.ai-msg p:last-child { margin-bottom: 0; }
.ai-bot {
  background: var(--purple-light);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.ai-user {
  background: var(--purple);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.ai-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.ai-form input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  background: #fdfcff;
  font-size: 14px;
}
.ai-form input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px #5a3ca61a;
  outline: none;
}
.ai-send {
  width: 44px; height: 44px;
  border: none;
  background: var(--purple);
  color: white;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.ai-send:hover { background: #4a2f8f; }

@media (max-width: 480px) {
  .ai-fab { bottom: 18px; right: 18px; padding: 12px 14px; }
  .ai-fab-label { display: none; }
  .ai-panel { right: 12px; bottom: 76px; width: calc(100vw - 24px); }
}
