/* TIFAQM Companion — Claude-inspired minimal aesthetic. */

:root {
  --bg: #f7f4ee;
  --bg-elev: #ffffff;
  --ink: #1a1613;
  --ink-soft: #524b45;
  --ink-mute: #8b827a;
  --line: #ece7dd;
  --accent: #c96442;
  --accent-soft: #f2d9cf;
  --user-bg: #ffffff;
  --assistant-bg: #f0ebe0;
  --citation-bg: #fbf9f4;
  --danger: #b0453a;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(30, 22, 14, 0.04);
  --shadow-md: 0 8px 24px rgba(30, 22, 14, 0.06);
  --font-serif: "Copernicus", "Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-sans: "Styrene B", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.shell {
  height: 100dvh;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

/* Top bar --------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 4px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: 0.01em;
}

.brand-mark {
  color: var(--accent);
  font-size: 20px;
  transform: translateY(-1px);
}

.brand-name {
  color: var(--ink);
  font-weight: 500;
}

.course-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.course-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-mute);
}

.course-picker select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 32px 8px 14px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b827a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s ease;
}

.course-picker select:hover,
.course-picker select:focus {
  border-color: var(--accent);
  outline: none;
}

/* Transcript ------------------------------------------------------------ */
.transcript {
  overflow-y: auto;
  padding: 32px 4px 24px;
  scroll-behavior: smooth;
}

.welcome {
  padding-top: 40px;
  max-width: 520px;
}

.welcome h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.15;
  margin: 0 0 12px 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.welcome p {
  color: var(--ink-soft);
  margin: 0;
  font-size: 15px;
  max-width: 46ch;
}

.msg {
  padding: 18px 20px;
  border-radius: var(--radius);
  margin: 12px 0;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.msg.user {
  background: var(--user-bg);
  color: var(--ink);
}

.msg.assistant {
  background: var(--assistant-bg);
  color: var(--ink);
  border-color: transparent;
}

.msg .role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-mute);
  margin-bottom: 6px;
}

.msg .content {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 15px;
}

.msg .content a.cite {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 6px;
  background: var(--citation-bg);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 12px;
  text-decoration: none;
  border: 1px solid var(--line);
}

.msg.error {
  background: #fdf3f1;
  color: var(--danger);
  border-color: #f0d3cd;
}

/* Shown only when every LLM provider was unavailable and the answer came from
   cache. Deliberately above the answer text, not below it: a warning the
   student reads after acting on the answer is not a warning. */
.stale-note {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--accent-soft);
  border-radius: 10px;
  background: var(--citation-bg);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.citations {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--ink-mute);
}

.citations .cite-pill {
  display: inline-block;
  padding: 3px 8px;
  margin: 2px 4px 0 0;
  background: var(--citation-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}

/* Composer -------------------------------------------------------------- */
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.composer textarea {
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 6px;
  max-height: 200px;
  overflow-y: auto;
}

.composer textarea::placeholder {
  color: var(--ink-mute);
}

.composer button {
  height: 40px;
  width: 40px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.composer button:hover:not(:disabled) {
  background: #b0553a;
}

.composer button:active {
  transform: scale(0.96);
}

.composer button:disabled {
  background: var(--accent-soft);
  color: white;
  cursor: not-allowed;
}

/* Footer / status ------------------------------------------------------- */
.foot {
  padding: 4px 6px 12px;
  min-height: 22px;
}

.status {
  font-size: 12px;
  color: var(--ink-mute);
}

.status.thinking::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  animation: pulse 1.2s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

/* Scrollbar polish ------------------------------------------------------ */
.transcript::-webkit-scrollbar,
.composer textarea::-webkit-scrollbar {
  width: 8px;
}

.transcript::-webkit-scrollbar-thumb,
.composer textarea::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.transcript::-webkit-scrollbar-thumb:hover,
.composer textarea::-webkit-scrollbar-thumb:hover {
  background: var(--ink-mute);
}


/* 2026-10-16: markdown answers and named, numbered sources */
.msg .content p { margin: 0 0 0.6em; }
.msg .content p:last-child { margin-bottom: 0; }
.msg .content ul, .msg .content ol { margin: 0.2em 0 0.6em 1.3em; padding: 0; }
.msg .content li { margin: 0.15em 0; }
.msg .content code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: rgba(0,0,0,0.06); padding: 0.05em 0.3em; border-radius: 4px; }
.msg .content pre { background: rgba(0,0,0,0.06); padding: 0.6em 0.8em; border-radius: 6px; overflow-x: auto; }
.msg .content pre code { background: none; padding: 0; }
.msg .content a.cite { font-size: 0.8em; vertical-align: super; margin: 0 0.1em; }
.citations ol.sources { margin: 0.3em 0 0 1.2em; padding: 0; font-size: 0.9em; }
.citations ol.sources li { margin: 0.1em 0; list-style: none; }
.citations .cite-n { opacity: 0.7; margin-right: 0.3em; }
.citations .cite-parts { opacity: 0.6; font-size: 0.85em; margin-left: 0.4em; }
