:root {
  --bg: #fafaf8;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #2c5a8a;
  --accent-dark: #1f4266;
  --danger: #b03030;
  --warn-bg: #fff4cc;
  --ok-bg: #d9f0d9;
  --err-bg: #f8d7da;
  --border: #d8d4cc;
  --bubble-user: #e6efef;
  --bubble-model: #ffffff;
  --radius: 6px;
}

* { box-sizing: border-box; }
html {
  margin: 0;
  min-height: 100%;
  background-color: #f4efdf;
  background-image: repeating-linear-gradient(0deg, transparent 0 36px, rgba(0,0,0,0.025) 36px 37px);
  background-attachment: fixed;
}
body {
  margin: 0; padding: 0;
  min-height: 100vh;
  background: transparent;
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
}

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

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem 1.2rem;
  background: linear-gradient(to right, #fdfaf0, #f6ecd0);
  border-bottom: 2px solid #0b1a3a;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.topbar .brand {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.05;
  color: #0b1a3a;
  text-decoration: none;
}
.topbar .brand:hover { text-decoration: none; color: #2d1b4e; }
.topbar .brand-name {
  font-family: "Special Elite", "Courier Prime", Courier, monospace;
  font-weight: normal;
  font-size: 1.35rem;
  letter-spacing: 2px;
}
.topbar .brand-subtitle {
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 0.82rem;
  color: #6a5832;
  letter-spacing: 0.5px;
  margin-top: 1px;
}
@media (max-width: 520px) {
  .topbar .brand-subtitle { display: none; }
}
.topbar nav { display: flex; gap: 0.8rem; align-items: center; margin-left: auto; }
.topbar nav > a {
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 1.15rem;
  color: #0b1a3a;
  padding: 0.25rem 0.55rem;
  border-radius: 5px;
  transition: background 0.15s, color 0.15s;
}
.topbar nav > a:hover {
  background: rgba(11, 26, 58, 0.08);
  color: #2d1b4e;
  text-decoration: none;
}
.topbar .user {
  font-family: "Patrick Hand", cursive;
  color: #6a5832; font-size: 1.05rem;
}
.topbar form.inline button.link {
  font-family: "Patrick Hand", cursive;
  font-size: 1.1rem;
  color: #b03030;
}
.topbar form.inline button.link:hover { color: #8b1515; text-decoration: underline; }

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }

.card { background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.5rem; margin-bottom: 1rem; }
.card.narrow { max-width: 480px; margin: 2rem auto; }

h1 { margin-top: 0; font-size: 1.4rem; }
h2 { font-size: 1.1rem; margin-top: 1.5rem; }
.muted { color: var(--muted); }

form label { display: block; margin-bottom: 0.8rem; }
form label span { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.2rem; }
form input, form select, form textarea {
  width: 100%; padding: 0.5rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-family: inherit; font-size: 1rem;
  background: #fff;
}
form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }
form button, .btn {
  padding: 0.5rem 1rem; background: var(--accent); color: #fff;
  border: 0; border-radius: var(--radius); cursor: pointer; font-size: 1rem;
  text-decoration: none; display: inline-block;
}
form button:hover, .btn:hover { background: var(--accent-dark); }
form button.primary { background: var(--accent); }
form button.danger { background: var(--danger); }
form button.link, .link {
  background: transparent; color: var(--accent); padding: 0;
  font-size: inherit; text-decoration: underline;
}
form.inline, .inline { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }

.flashes { list-style: none; padding: 0; margin: 0; max-width: 1100px; margin: 0.5rem auto; }
.flashes li { padding: 0.6rem 1rem; margin: 0 1rem 0.4rem; border-radius: var(--radius); }
.flash-success { background: var(--ok-bg); }
.flash-error   { background: var(--err-bg); }
.flash-warn    { background: var(--warn-bg); }

.callout { padding: 0.8rem 1rem; border-radius: var(--radius); margin: 1rem 0; }
.callout.warn { background: var(--warn-bg); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin: 1rem 0; }
.kpi { padding: 1rem; background: #fafafa; border: 1px solid var(--border); border-radius: var(--radius); text-align: center; }
.kpi .n { display: block; font-size: 2rem; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 0.85rem; }

.list { list-style: none; padding: 0; }
.list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.list li .meta { margin-left: 0.5rem; color: var(--muted); font-size: 0.85rem; }

.tbl { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.tbl th, .tbl td { padding: 0.5rem 0.6rem; text-align: left; border-bottom: 1px solid var(--border); }
.tbl th { background: #f2efea; font-size: 0.85rem; text-transform: uppercase; color: var(--muted); }
.tbl tr.inactive td { color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }

.spark { list-style: none; padding: 0; display: flex; gap: 2px; align-items: flex-end; height: 80px; margin: 1rem 0; }
.spark li { display: flex; flex-direction: column; align-items: center; }
.spark .bar { width: 12px; height: var(--h); background: var(--accent); max-height: 70px; }
.spark em { font-style: normal; font-size: 0.6rem; color: var(--muted); transform: rotate(-60deg); margin-top: 4px; white-space: nowrap; }

/* chat session — detective case-file theme */
.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 130px);
  background: #faf6ed;
  background-image:
    linear-gradient(#faf6ed 0%, #faf6ed 100%),
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(0,0,0,0.04) 28px 29px);
  background-blend-mode: multiply;
  border: 1px solid #d8cfb6;
  border-radius: 10px;
  padding: 1.1rem 1.5rem 1rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 0.6rem;
  margin-bottom: 0.4rem;
  border-bottom: 2px solid #0b1a3a;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.chat-header h1 {
  font-family: "Special Elite", "Courier Prime", Courier, monospace;
  font-size: 1.6rem;
  letter-spacing: 1.2px;
  color: #0b1a3a;
  margin: 0;
}
.chat-header > form.inline button.link,
.chat-header > form.inline button {
  font-family: "Patrick Hand", cursive;
  font-size: 1.1rem;
  color: #b03030;
}

.messages {
  flex: 1; overflow-y: auto;
  padding: 1rem 0.2rem;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.messages.readonly { max-height: none; height: auto; }

.bubble {
  max-width: 78%;
  padding: 0.75rem 1.1rem;
  border-radius: 14px;
  border: 1px solid #d8cfb6;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.bubble .content {
  white-space: pre-wrap; word-wrap: break-word;
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 1.15rem;
  line-height: 1.5;
  color: #2a2514;
}
.bubble .meta {
  font-family: "Special Elite", Courier, monospace;
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: #8a7d5a;
  margin-top: 0.4rem;
  text-transform: uppercase;
}
.bubble.user  {
  align-self: flex-end;
  background: linear-gradient(135deg, #fff7d4, #fce9b5);
  border-color: #e4c77a;
}
.bubble.model {
  align-self: flex-start;
  background: #ffffff;
  border-color: #cfc6ad;
}
.bubble.err   { border-color: var(--danger); background: #fde8e8; }

.composer {
  display: flex; gap: 0.6rem;
  padding: 0.7rem 0 0.2rem;
  border-top: 2px dashed #0b1a3a;
  margin-top: 0.4rem;
}
.composer textarea {
  flex: 1; resize: vertical; min-height: 52px;
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 1.1rem;
  line-height: 1.4;
  background: #fffef9;
  border: 1.5px solid #cfc6ad;
  border-radius: 7px;
  padding: 0.55rem 0.8rem;
  color: #2a2514;
}
.composer textarea:focus {
  outline: none;
  border-color: #0b1a3a;
  box-shadow: 0 0 0 3px rgba(11, 26, 58, 0.12);
}
.composer button {
  padding: 0 1.6rem;
  background: #0b1a3a;
  color: #fff;
  font-family: "Patrick Hand", cursive;
  font-size: 1.15rem;
  border: 0; border-radius: 7px;
  letter-spacing: 0.5px;
  transition: background 0.15s, transform 0.1s;
}
.composer button:hover:not(:disabled) { background: #2d1b4e; }
.composer button:active { transform: translateY(1px); }
.composer button:disabled { background: #8a8478; cursor: wait; }

.results { list-style: none; padding: 0; }
.results li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.results li .role { display: inline-block; font-size: 0.75rem; padding: 2px 6px; border-radius: 4px; background: #eee; margin-left: 0.5rem; }
.results li time { color: var(--muted); font-size: 0.8rem; margin-left: 0.5rem; }
.results li .snip { margin: 0.3rem 0 0; color: #333; }
mark { background: #ffe066; padding: 0 2px; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f2efea; padding: 2px 4px; border-radius: 3px; }

/* ============================================================
   Inspector A.I. Clue — Student experience theme
   ============================================================ */

:root {
  --clue-navy:    #0b1a3a;
  --clue-navy-2:  #1a2d5c;
  --clue-purple:  #2d1b4e;
  --clue-gold:    #f7d68a;
  --clue-gold-2:  #d4af37;
  --clue-red:     #c23e3e;
  --clue-paper:   #faf6ed;
  --clue-paper-2: #f0e9d6;
  --clue-ink:     #2a2514;
}

/* --- Hero --- */
.hero-inspector {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--clue-navy) 0%, var(--clue-navy-2) 45%, var(--clue-purple) 100%);
  color: #f5f1e8;
  border-radius: 12px;
  padding: 2rem 2rem 2rem 1rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 6px 24px rgba(10, 20, 50, 0.3);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 260px;
}
.hero-glow {
  position: absolute; inset: -40%;
  background:
    radial-gradient(circle at 25% 30%, rgba(255, 200, 90, 0.18), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(120, 160, 255, 0.15), transparent 50%);
  pointer-events: none;
}

.hero-figure {
  position: relative;
  flex: 0 0 210px;
  max-width: 210px;
  animation: figure-bob 5s ease-in-out infinite;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.4));
}
.inspector-svg { width: 100%; height: auto; display: block; }
@keyframes figure-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.hero-text {
  position: relative;
  flex: 1;
  min-width: 0;
}
.hero-title {
  font-family: "Special Elite", "Courier Prime", Courier, monospace;
  font-size: 2.6rem;
  margin: 0 0 0.7rem;
  letter-spacing: 2px;
  color: var(--clue-gold);
  text-shadow: 0 2px 10px rgba(0,0,0,0.55), 0 0 1px rgba(255, 220, 140, 0.7);
  line-height: 1.1;
}
.hero-tagline {
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 1.2rem;
  line-height: 1.55;
  color: #ece7d7;
  margin: 0 0 1rem;
  max-width: 52ch;
}
.avatar-cta {
  display: inline-block;
  font-family: "Patrick Hand", cursive;
  font-size: 1.1rem;
  background: rgba(247, 214, 138, 0.18);
  color: var(--clue-gold);
  padding: 0.5rem 1rem;
  border: 1.5px dashed var(--clue-gold);
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s;
}
.avatar-cta:hover { background: rgba(247, 214, 138, 0.3); text-decoration: none; }

/* --- Case files section --- */
.case-file-section {
  background: var(--clue-paper);
  background-image:
    linear-gradient(var(--clue-paper) 0%, var(--clue-paper) 100%),
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(0,0,0,0.04) 28px 29px);
  background-blend-mode: multiply;
  border: 1px solid #d8cfb6;
  border-radius: 10px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.case-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  border-bottom: 2px solid var(--clue-navy);
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
}
.case-title {
  font-family: "Special Elite", Courier, monospace;
  font-size: 1.4rem;
  margin: 0;
  color: var(--clue-navy);
  letter-spacing: 1px;
}
.folder-icon { font-size: 1.4rem; }
.btn-new-case {
  background: var(--clue-navy);
  font-family: "Patrick Hand", cursive;
  font-size: 1.1rem;
  padding: 0.55rem 1.1rem;
  letter-spacing: 0.3px;
}
.btn-new-case:hover { background: var(--clue-purple); }

.case-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.case-item {
  background: #fff;
  border: 1px solid #e4dbc2;
  border-radius: 7px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.case-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(10, 20, 50, 0.12);
  border-color: var(--clue-navy);
}
.case-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  color: var(--clue-ink);
  text-decoration: none;
}
.case-link:hover { text-decoration: none; }
.case-folder-icon { font-size: 1.8rem; }
.case-body { min-width: 0; }
.case-id {
  font-family: "Special Elite", Courier, monospace;
  font-size: 0.75rem;
  color: var(--clue-navy);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.case-name {
  font-family: "Patrick Hand", cursive;
  font-size: 1.25rem;
  color: var(--clue-ink);
  line-height: 1.2;
}
.case-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: #6a6154;
}
.case-status {
  font-family: "Patrick Hand", cursive;
  font-size: 0.95rem;
  padding: 2px 8px;
  border-radius: 10px;
}
.status-active  { background: #d9f0d9; color: #1a5a1a; }
.status-ended   { background: #e8e0f5; color: #4a2e82; }
.status-abandoned { background: #f0e0d0; color: #7a4a2a; }

.consent-callout {
  background: linear-gradient(to right, #fff4cc, #ffe6a3);
  border: 1.5px dashed var(--clue-gold-2);
  border-radius: 7px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.consent-callout button { background: var(--clue-navy); font-family: "Patrick Hand", cursive; font-size: 1.05rem; }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: #6a6154;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 0.5rem; }
.empty-text {
  font-family: "Patrick Hand", cursive;
  font-size: 1.2rem;
  line-height: 1.5;
  margin: 0;
}

/* --- Avatar picker --- */
.avatar-card { max-width: 560px; margin: 1.5rem auto; }
.avatar-heading {
  font-family: "Special Elite", Courier, monospace;
  color: var(--clue-navy);
  letter-spacing: 1.5px;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin: 1.2rem 0;
}
.avatar-choice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 2px solid #e0d8bd;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.avatar-choice:hover { transform: translateY(-2px); border-color: var(--clue-navy); }
.avatar-choice.selected,
.avatar-choice:has(input:checked) {
  border-color: var(--clue-gold-2);
  background: #fff8e0;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.3);
}
.avatar-choice input {
  position: absolute; opacity: 0;
  width: 100%; height: 100%; cursor: pointer; margin: 0;
}
.avatar-emoji { font-size: 2.5rem; line-height: 1; }
.avatar-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}
.avatar-actions .primary {
  background: var(--clue-navy);
  font-family: "Patrick Hand", cursive;
  font-size: 1.1rem;
}
.link-back { color: var(--clue-navy); font-family: "Patrick Hand", cursive; }

/* --- Avatar badge in topbar --- */
.avatar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f0e6cc, #d4c497);
  font-size: 1.3rem;
  text-decoration: none;
  line-height: 1;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.avatar-badge:hover { border-color: var(--clue-navy); transform: scale(1.1); text-decoration: none; }

/* --- Responsive --- */
@media (max-width: 720px) {
  .hero-inspector {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem 1.2rem;
    min-height: 0;
  }
  .hero-figure { flex: 0 0 auto; max-width: 160px; margin: 0 auto; }
  .hero-title  { font-size: 2rem; letter-spacing: 1px; }
  .hero-tagline { font-size: 1.05rem; margin-left: auto; margin-right: auto; }
  .hero-text { text-align: center; }

  .case-link { grid-template-columns: auto 1fr; }
  .case-meta { grid-column: 2; align-items: flex-start; }

  .avatar-grid { grid-template-columns: repeat(4, 1fr); }
  .avatar-emoji { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-figure { animation: none; }
  .case-item:hover { transform: none; }
  .avatar-choice:hover, .avatar-badge:hover { transform: none; }
}

/* --- Gems admin --- */
.badge-default {
  display: inline-block;
  background: var(--clue-gold-2, #d4af37);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 1px;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.small { font-size: 0.85rem; }
.danger-text { color: var(--danger); }

.inline-assign {
  background: #fafaf5;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.inline-assign label { flex: 1; margin: 0; min-width: 240px; }
.inline-assign button { height: 2.3rem; }

.assign-mode {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
}
.assign-mode legend { font-weight: 600; padding: 0 0.4rem; }
.inline-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 1.2rem;
  margin-bottom: 0.3rem;
}
.inline-radio input[type="radio"] { margin: 0; width: auto; }
.inline-radio select { width: auto; display: inline-block; }

tr.already-assigned { background: #fff8e0; }
tr.already-assigned td { color: #6b5a20; }

/* --- Search help (collapsible FTS5 guide) --- */
.search-help {
  margin: 1rem 0 1.5rem;
  background: #fffdf4;
  border: 1px solid #e4dbc2;
  border-radius: 8px;
  padding: 0.6rem 1rem;
}
.search-help > summary {
  cursor: pointer;
  font-family: "Patrick Hand", cursive;
  font-size: 1.15rem;
  color: var(--clue-navy);
  padding: 0.3rem 0;
  list-style: none;
  position: relative;
  padding-left: 1.2rem;
}
.search-help > summary::-webkit-details-marker { display: none; }
.search-help > summary::before {
  content: "▸";
  position: absolute;
  left: 0; top: 0.35rem;
  transition: transform 0.15s;
  color: var(--clue-gold-2);
}
.search-help[open] > summary::before { transform: rotate(90deg); }
.search-help-body { padding: 0.5rem 0 0.3rem; }

.syntax-tbl {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  font-size: 0.9rem;
}
.syntax-tbl th, .syntax-tbl td {
  padding: 0.45rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #e4dbc2;
  vertical-align: top;
}
.syntax-tbl th {
  background: #f2efea;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.syntax-tbl code {
  background: #f2efea;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.88rem;
}

.nested-help {
  margin: 0.6rem 0;
  padding: 0.5rem 0.8rem;
  background: #faf6ed;
  border-left: 3px solid var(--clue-gold-2);
  border-radius: 0 4px 4px 0;
}
.nested-help > summary {
  cursor: pointer;
  font-family: "Patrick Hand", cursive;
  font-size: 1rem;
  color: var(--clue-navy);
  list-style: none;
  padding-left: 1.1rem;
  position: relative;
}
.nested-help > summary::-webkit-details-marker { display: none; }
.nested-help > summary::before {
  content: "▸";
  position: absolute; left: 0; top: 0.15rem;
  transition: transform 0.15s;
  color: var(--clue-gold-2);
}
.nested-help[open] > summary::before { transform: rotate(90deg); }

.example-list {
  margin: 0.5rem 0 0 0;
  padding-left: 1.2rem;
  line-height: 1.7;
}
.example-list li { margin-bottom: 0.35rem; }
.example-list code {
  background: #fff;
  padding: 2px 6px;
  border: 1px solid #e4dbc2;
  border-radius: 3px;
  font-size: 0.88rem;
}

/* --- Gem pills (in knowledge list) --- */
.gem-pill {
  display: inline-block;
  background: #e8e0f5;
  color: #4a2e82;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin: 1px 2px;
  white-space: nowrap;
}
.gem-pill-global {
  background: #d9f0d9;
  color: #1a5a1a;
}

.gem-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
}
.gem-select legend { font-weight: 600; padding: 0 0.4rem; }
.stacked-radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
  cursor: pointer;
  font-weight: normal;
}
.stacked-radio input[type="radio"] { width: auto; margin: 0; }
.gem-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.4rem 0 0.4rem 2rem;
  padding: 0.6rem 1rem;
  border-left: 2px solid #d8cfb6;
  background: rgba(0,0,0,0.02);
  border-radius: 0 4px 4px 0;
}
.gem-checkbox {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: normal;
  cursor: pointer;
}
.gem-checkbox span { display: inline; }
.gem-checkbox input[type="checkbox"] { width: auto; margin: 0; }

/* --- Inline rename (session header) --- */
.chat-title-wrap {
  display: flex; align-items: center; gap: 0.4rem;
  flex-wrap: wrap;
}
.editable-title { margin: 0; }
.rename-btn {
  font-size: 1.05rem;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}
.rename-btn:hover { opacity: 1; background: rgba(0,0,0,0.04); }
.rename-form {
  display: flex; align-items: center; gap: 0.3rem;
}
.rename-form input[type="text"] {
  flex: 1; min-width: 240px; padding: 0.4rem 0.6rem;
  font-size: 1.1rem; font-family: "Patrick Hand", cursive;
  border: 1.5px solid var(--clue-navy); border-radius: 5px;
}
.rename-form button { padding: 0.35rem 0.7rem; font-size: 1rem; }
.rename-form button[type="submit"] { background: var(--clue-navy); color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
.rename-form .link { color: var(--danger); padding: 0 0.4rem; }
.hidden { display: none !important; }

/* --- Fluent Emoji detective fits a natural 1:1 box --- */
img.inspector-svg {
  width: 100%;
  height: auto;
  max-width: 220px;
  display: block;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.4));
}

/* --- Student profile page --- */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.profile-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
}
.profile-card h3 {
  margin-top: 0;
  font-family: "Special Elite", monospace;
  color: var(--clue-navy);
  font-size: 1.05rem;
  letter-spacing: 1px;
}
.profile-avatar-preview {
  font-size: 3rem;
  text-align: center;
  margin: 0.5rem 0;
}
@media (max-width: 720px) {
  .profile-grid { grid-template-columns: 1fr; }
}
