:root {
  --kellogg-purple: #4e2a84;
  --kellogg-purple-dark: #341a5b;
  --kellogg-purple-light: #f3eef9;
  --ink: #1f1f1f;
  --ink-soft: #555;
  --bg: #fafafa;
  --card: #ffffff;
  --border: #e3e3e8;
  --ai-bg: #fff8e6;
  --ai-border: #f5d77a;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}

body > header {
  background: var(--kellogg-purple);
  color: white;
  padding: 9px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
body > header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.user-bar {
  font-size: 13px;
  opacity: .9;
}
.link-btn {
  background: none;
  border: none;
  color: white;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  margin-left: 8px;
  padding: 0;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 22px 60px;
}

#welcome-banner {
  margin: 4px 0 14px;
  font-size: 18px;
  font-weight: 600;
  color: var(--kellogg-purple-dark);
  letter-spacing: -0.01em;
}
#welcome-banner:empty { display: none; }

/* Search */
.search-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  margin: 0 auto 14px;
  max-width: 1000px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  background: #eee;
  border: 1px solid #ddd;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  color: var(--ink-soft);
  transition: all .12s;
}
.chip.on {
  background: var(--kellogg-purple-light);
  border-color: var(--kellogg-purple);
  color: var(--kellogg-purple-dark);
  font-weight: 500;
}

#search-form {
  display: flex;
  gap: 8px;
}
#q {
  flex: 1;
  padding: 9px 12px;
  font-size: 16px; /* >=16 prevents iOS Safari auto-zoom on focus */
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: white;
}
#q:focus {
  border-color: var(--kellogg-purple);
  box-shadow: 0 0 0 3px rgba(78,42,132,.15);
}
#go {
  padding: 0 18px;
  background: var(--kellogg-purple);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
#go:hover { background: var(--kellogg-purple-dark); }
#go:disabled { opacity: .5; cursor: wait; }

#clear {
  padding: 0 14px;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
#clear:hover { background: #f3f3f5; color: var(--ink); }

#status {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
  min-height: 16px;
}

/* Landing area — shown when no results displayed */
#landing {
  max-width: 1000px;
  margin: 16px auto 0;
}
body.has-results #landing { display: none; }

/* Frameworks index */
#frameworks-index {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--kellogg-purple);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.fwx-header {
  background: var(--kellogg-purple-light);
  padding: 12px 18px 11px;
  border-bottom: 1px solid var(--border);
}
.fwx-header h2 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
  color: var(--kellogg-purple-dark);
  letter-spacing: -0.005em;
}
.fwx-header h2::before {
  content: "📚";
  margin-right: 6px;
  font-size: 14px;
}
.fwx-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.45;
}
#frameworks-body {
  padding: 14px 18px 16px;
}
.fwx-subject {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.fwx-subject:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.fwx-subject h3 {
  margin: 0 0 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--kellogg-purple);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
}
.fwx-subject h3::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--kellogg-purple);
  border-radius: 2px;
  margin-right: 8px;
}
.fwx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fwx-chip {
  display: inline-block;
  padding: 3px 10px;
  background: var(--kellogg-purple-light);
  border: 1px solid #e3d7f0;
  border-radius: 999px;
  color: var(--kellogg-purple-dark);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s, transform .08s;
  white-space: nowrap;
}
.fwx-chip:hover {
  background: #e3d7f0;
  border-color: var(--kellogg-purple);
  transform: translateY(-1px);
}

/* Cohort photo */
.cohort-photo {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  text-align: center;
}
.cohort-photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}
.cohort-photo figcaption {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  font-style: italic;
}


/* Results */
section.section-block {
  margin-top: 18px;
}
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--kellogg-purple-dark);
}
.section-header .meta { font-size: 12px; color: var(--ink-soft); }

.hits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  max-width: 1000px;
}
.hit {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.hit:hover {
  border-color: var(--kellogg-purple);
  box-shadow: 0 6px 18px rgba(78,42,132,.18);
  transform: translateY(-1px);
}
.hit .thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;        /* crops away the white margins above/below the slide content */
  object-position: center;
  background: #f3f3f5;
  border-bottom: 1px solid var(--border);
  display: block;
}
.hit .body { padding: 7px 10px 9px; }
.hit .citation {
  font-size: 12px;
  color: var(--kellogg-purple-dark);
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hit .file-meta { font-size: 11px; color: var(--ink-soft); }
.hit .score-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef;
  font-size: 11px;
  color: var(--ink-soft);
  margin-left: 6px;
  font-weight: 400;
}

/* AI section */
.ai-block {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 4px;
}
.ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ai-badge {
  display: inline-block;
  background: #b8860b;
  color: white;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: .04em;
}
.ai-header h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}
.ai-header .note {
  font-size: 12px;
  color: var(--ink-soft);
  margin-left: 4px;
}
#ai-toggle {
  background: var(--kellogg-purple);
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
#ai-content {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
#ai-content strong { color: var(--kellogg-purple-dark); }

.empty {
  text-align: center;
  padding: 30px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* Modals */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.4); }

#name-modal { padding: 28px 28px 22px; max-width: 380px; }
#name-modal h2 { margin: 0 0 8px; color: var(--kellogg-purple-dark); }
#name-modal p { margin: 0 0 14px; color: var(--ink-soft); font-size: 14px; }
#name-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
}
#name-modal button {
  width: 100%;
  padding: 10px;
  background: var(--kellogg-purple);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

/* Deck viewer modal — only rendered when [open] is set */
#deck-modal {
  width: 96vw;
  max-width: 1200px;
  height: 92vh;
  padding: 0;
  background: #1a1a1f;
  color: white;
}
#deck-modal[open] {
  display: flex;
  flex-direction: column;
}
#deck-modal::backdrop { background: rgba(0,0,0,.7); }
.deck-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: #25252b;
  border-bottom: 1px solid #2f2f37;
  font-size: 13px;
  flex-shrink: 0;
}
.deck-title-block { flex: 1; min-width: 0; }
.deck-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.deck-counter { color: #aaa; font-variant-numeric: tabular-nums; font-size: 12px; }
.deck-tools { display: flex; align-items: center; gap: 6px; }
.deck-tools button, .deck-tools a {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: white;
  width: 34px;
  height: 32px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 500;
  transition: background .12s;
}
.deck-tools button:hover, .deck-tools a:hover { background: rgba(255,255,255,.16); }
.deck-tools .pdf-link {
  width: auto;
  padding: 0 12px;
  font-size: 12.5px;
  background: var(--kellogg-purple);
  border-color: var(--kellogg-purple);
}
.deck-tools .pdf-link:hover { background: var(--kellogg-purple-dark); }
.deck-tools .deck-close { background: transparent; border-color: transparent; font-size: 22px; }
.deck-tools .deck-close:hover { background: rgba(255,255,255,.16); }
.deck-stage {
  flex: 1;
  padding: 16px;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.deck-stage.zoomed {
  align-items: flex-start;
  justify-content: flex-start;
}
.deck-stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.deck-stage.zoomed img {
  max-width: none;
  max-height: none;
}
.deck-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.12);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.deck-arrow:hover { background: rgba(255,255,255,.22); }
.deck-arrow:disabled { opacity: .25; cursor: default; }
.deck-arrow.prev { left: 16px; }
.deck-arrow.next { right: 16px; }
.deck-strip {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  background: #25252b;
  border-top: 1px solid #2f2f37;
  flex-shrink: 0;
  scroll-behavior: smooth;
}
.deck-strip img {
  height: 64px;
  width: auto;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  background: white;
  flex-shrink: 0;
}
.deck-strip img.active { border-color: var(--kellogg-purple); }
.deck-strip img:hover { border-color: #888; }

@media (max-width: 700px) {
  .hits-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 600px) {
  header { padding: 9px 14px; }
  header h1 { font-size: 15px; }
  .user-bar { font-size: 11.5px; }
  .link-btn { font-size: 11.5px; }
  main { padding: 12px 12px 60px; }
  .search-box { padding: 10px; margin-bottom: 12px; }
  #search-form { gap: 6px; }
  #q { padding: 10px 12px; font-size: 16px; }
  #go { padding: 0 14px; font-size: 13px; }
  .hits-grid { grid-template-columns: 1fr; gap: 10px; }
  .hit .thumb { aspect-ratio: 16/10; }
  .ai-block { padding: 10px 12px; }
  /* deck modal: full screen on phones */
  #deck-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    border-radius: 0;
    margin: 0;
  }
  .deck-header { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .deck-title { font-size: 12.5px; }
  .deck-counter { font-size: 11.5px; }
  .deck-tools { gap: 4px; }
  .deck-tools button, .deck-tools a {
    width: 32px; height: 30px; font-size: 14px;
  }
  .deck-tools .pdf-link { padding: 0 8px; font-size: 11.5px; }
  .deck-tools .deck-close { font-size: 20px; }
  .deck-arrow { width: 38px; height: 38px; font-size: 18px; }
  .deck-arrow.prev { left: 6px; }
  .deck-arrow.next { right: 6px; }
  .deck-strip img { height: 44px; }
}
