*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #ffffff;
  --surface: #f4f6f9;
  --border: #e2e6ec;
  --text: #111111;
  --muted: #5a6a7e;
  --dim: #b0bac8;
  --hover: #f0f3f8;
  --accent: #3d5a8a;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main.main {
  flex: 1;
}

/* ── Header ── */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.header-meta {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.badge {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Hero ── */
.hero {
  padding: 48px 20px 36px;
}

.hero-content {
  max-width: 860px;
  margin: 0 auto;
}

.hero-title {
  font-size: clamp(22px, 5vw, 38px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  color: var(--text);
  line-height: 1.2;
}

.hero-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 24px;
  max-width: 520px;
}

/* Search */
.search-wrap {
  position: relative;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 36px 10px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}

.search-input::placeholder {
  color: var(--dim);
}

.search-input:focus {
  border-color: var(--muted);
}

.clear-btn {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 13px;
}

.clear-btn:hover {
  color: var(--muted);
}

/* ── Tabs ── */
.tabs-wrap {
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tabs-wrap::-webkit-scrollbar {
  display: none;
}

.tabs {
  display: flex;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  padding: 11px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Main ── */
.main {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  width: 100%;
}

/* Semester section */
.sem-section {
  margin-bottom: 36px;
}

.sem-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.sem-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sem-count {
  font-size: 11px;
  color: var(--dim);
}

/* List rows */
.modules-list {
  display: flex;
  flex-direction: column;
}

.module-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}

.module-row:last-child {
  border-bottom: none;
}

.module-row:hover {
  background: var(--hover);
}

.row-num {
  font-size: 11px;
  color: var(--dim);
  font-weight: 500;
  width: 18px;
  flex-shrink: 0;
  text-align: right;
}

.row-code {
  font-size: 10px;
  font-weight: 600;
  font-family: 'Inter', monospace;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.row-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  /* allow truncation on small screens */
}

.row-size {
  font-size: 11px;
  color: var(--dim);
  flex-shrink: 0;
}

.row-view {
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: color 0.12s;
  white-space: nowrap;
}

.module-row:hover .row-view {
  color: var(--accent);
}

.row-view svg {
  transition: transform 0.12s;
}

.module-row:hover .row-view svg {
  transform: translateX(2px);
}

/* highlight */
.highlight {
  background: #dbe8ff;
  color: #1e3a6e;
  border-radius: 2px;
  padding: 0 1px;
}

/* No results */
.no-results {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}

.no-results-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 940px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg);
}

.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.modal-code {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.modal-sem {
  font-size: 11px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-download {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 7px;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn-download:hover {
  opacity: 0.85;
}

.modal-close {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 33px;
  height: 33px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  display: grid;
  place-items: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--hover);
  color: var(--text);
}

.modal-body {
  flex: 1;
  overflow: hidden;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 22px 20px;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-size: 12px;
}

/* ════════════════════════════════
   MOBILE RESPONSIVE
   ════════════════════════════════ */

/* Tablet */
@media (max-width: 720px) {
  .hero {
    padding: 36px 20px 28px;
  }

  .search-wrap {
    max-width: 100%;
  }

  .main {
    padding: 20px 16px 48px;
  }

  .row-size {
    display: none;
  }
}

/* Phone */
@media (max-width: 480px) {
  .header-inner {
    padding: 11px 16px;
  }

  .header-meta {
    display: none;
  }

  .brand-sub {
    display: none;
  }

  .hero {
    padding: 28px 16px 22px;
  }

  .hero-title {
    font-size: 22px;
  }

  .hero-desc {
    font-size: 13px;
    margin-bottom: 18px;
  }

  .tabs {
    padding: 0 12px;
  }

  .tab {
    padding: 10px 11px;
    font-size: 12px;
  }

  .main {
    padding: 16px 12px 48px;
  }

  .module-row {
    gap: 8px;
    padding: 11px 6px;
  }

  .row-num {
    display: none;
  }

  .row-code {
    font-size: 9px;
    padding: 2px 6px;
  }

  .row-name {
    font-size: 13px;
  }

  .row-view {
    font-size: 10px;
  }

  .row-view svg {
    display: none;
  }

  /* Modal slides up from bottom on phones */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    height: 92vh;
    border-radius: 14px 14px 0 0;
    max-width: 100%;
  }

  .modal-header {
    padding: 12px 14px;
  }

  .modal-title {
    font-size: 14px;
  }

  .btn-download {
    padding: 6px 11px;
    font-size: 11px;
  }
}