/* Palette taken from the RNIT logo only: its black, its amber, white, and greys mixed from the black. */
:root {
  --black: #000000;
  --amber: #F8A820;
  --amber-tint: #FEF3DC;
  --amber-deep: #B87400;     /* amber darkened for text-on-white contrast */
  --white: #FFFFFF;
  --mist: #F5F5F5;
  --line: #E3E3E3;
  --grey: #6A6A6A;
  --text: #1C1C1C;
  --radius-bubble: 18px;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--mist);
  color: var(--text);
  font: 400 16px/1.55 var(--font);
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- header */
.top {
  background: var(--white);
  border-bottom: 4px solid var(--amber);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 48px);
}
.brand h1 {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--black);
  line-height: 1.1;
}
.brand p { margin: 4px 0 0; color: var(--grey); font-size: 14px; max-width: 60ch; }
.logo { height: clamp(56px, 8vw, 88px); width: auto; display: block; }

/* ---------------------------------------------------------------- chat panel */
.shell {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  padding: clamp(12px, 2.5vw, 28px) clamp(12px, 3vw, 32px);
}
.chat {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px clamp(16px, 3vw, 36px) 12px;
  scroll-behavior: smooth;
}

.msg { margin: 0 0 22px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--black);
  color: var(--white);
  border-radius: var(--radius-bubble) var(--radius-bubble) 4px var(--radius-bubble);
  padding: 10px 16px;
  max-width: 72%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.bot { flex-direction: column; max-width: 100%; }
.msg.bot .who {
  font-size: 13px;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg.bot .who::before {
  content: "";
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--amber);
}
.answer {
  border-left: 3px solid var(--amber);
  padding: 2px 0 2px 16px;
  max-width: 90ch;
  overflow-wrap: anywhere;
}
.answer.card {
  background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--amber);
  border-radius: 12px; padding: 16px 20px; box-shadow: 0 2px 10px rgba(0,0,0,.06);
  animation: grow .25s ease-out;
}
.answer.card.streaming > div > :last-child::after {
  content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 2px;
  background: var(--amber); vertical-align: text-bottom; animation: blink 0.9s steps(2) infinite;
}
.answer p { margin: 0 0 10px; }
.answer p:last-child { margin-bottom: 0; }
.answer ul { margin: 4px 0 10px; padding-left: 20px; }
.answer li { margin: 0 0 6px; }
.answer li::marker { color: var(--amber-deep); }
.answer strong { font-weight: 700; color: var(--black); }
.answer .streaming::after {
  content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 2px;
  background: var(--amber); vertical-align: text-bottom; animation: blink 0.9s steps(2) infinite;
}
.answer.refused { border-left-color: var(--line); color: var(--grey); }
.sources { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sources span.lbl { font-size: 13px; color: var(--grey); margin-right: 2px; }
.chip-src {
  font-size: 13px; font-weight: 600;
  background: var(--amber-tint); color: var(--black);
  border: 1px solid #F6D697; border-radius: 999px; padding: 2px 10px;
}
.chip-src[hidden] { display: none; }
.more-src {
  font: 600 13px/1.4 var(--font); color: var(--black);
  background: var(--white); border: 1px dashed var(--amber-deep); border-radius: 999px;
  padding: 2px 10px; cursor: pointer;
}
.more-src:hover { background: var(--amber-tint); }
a.chip-src { text-decoration: none; cursor: pointer; }
a.chip-src:hover { background: var(--amber); border-color: var(--amber); }

/* ---------------------------------------------------------------- PDF viewer (in-page, not full screen) */
.viewer {
  width: min(900px, 92vw); height: 86vh;
  padding: 0; border: 0; border-radius: 14px;
  background: var(--white); color: var(--text);
  overflow: hidden;
}
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgba(0, 0, 0, .45); }
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 10px 20px;
  border-bottom: 3px solid var(--amber);
}
.viewer-bar h3 { margin: 0; font-size: 18px; font-weight: 800; color: var(--black); }
.viewer-close {
  width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: var(--mist); color: var(--black);
  font: 400 26px/1 var(--font); cursor: pointer;
}
.viewer-close:hover { background: var(--black); color: var(--amber); }
.viewer iframe { flex: 1; width: 100%; border: 0; background: var(--mist); }

.note {
  margin-top: 12px; font-size: 14px; color: var(--text);
  background: var(--mist); border-radius: 8px; padding: 8px 12px;
}
.note-title { font-weight: 600; }
.note-quote {
  margin: 8px 0 0; padding-left: 10px; border-left: 3px solid var(--amber);
  font-style: italic;
}
.meta { margin-top: 8px; font-size: 12.5px; color: var(--grey); }

/* ---------------------------------------------------------------- greeting (centred until the first question) */
.log:has(.hero) { display: flex; }
.hero { margin: auto; text-align: center; max-width: 780px; padding: 24px 0; }
.hero h2 {
  margin: 0 0 12px;
  font-size: clamp(34px, 5vw, 56px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05;
  color: var(--black);
}
.hero p { margin: 0 auto; max-width: 64ch; font-size: 17px; color: var(--grey); }

/* suggested questions: a compact grid under the greeting; after the first question, behind one button */
.examples {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  margin: 22px auto 0; max-width: 760px; text-align: left;
}
.ex-card {
  display: flex; flex-direction: column; gap: 3px;
  font: 500 13.5px/1.35 var(--font); color: var(--text); text-align: left;
  background: var(--white); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.ex-card:hover { border-color: var(--amber); background: var(--amber-tint); transform: translateY(-1px); }
.ex-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--amber-deep);
}
.ex-q {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chat { position: relative; }
.composer .suggest-btn {
  align-self: stretch; display: flex; align-items: center; gap: 6px;
  font: 600 13.5px var(--font); color: var(--text);
  background: var(--white); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 0 12px; cursor: pointer;
}
.composer .suggest-btn[hidden] { display: none; }
.composer .suggest-btn:hover, .composer .suggest-btn[aria-expanded="true"] { border-color: var(--amber); background: var(--amber-tint); }
.suggest-btn svg { color: var(--amber-deep); }
.suggest-pop {
  position: absolute; left: clamp(12px, 2.5vw, 24px); bottom: 78px; z-index: 5;
  width: min(620px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
  animation: grow .15s ease-out;
}
.suggest-pop[hidden] { display: none; }

/* ---------------------------------------------------------------- progress track (the signature piece) */
.progress { margin: 2px 0 4px; max-width: 86ch; }
.track {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(6, 1fr);
  counter-reset: step;
}
.track li {
  position: relative;
  counter-increment: step;
  font-size: 12.5px; color: var(--grey);
  padding-top: 34px; padding-right: 6px;
  line-height: 1.3;
}
.track li::before {                       /* the step dot, numbered */
  content: counter(step);
  position: absolute; top: 0; left: 0;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: var(--white); color: var(--grey);
  border: 2px solid var(--line);
  z-index: 1;
  transition: background .25s, border-color .25s, color .25s;
}
.track li::after {                        /* the connector to the next step */
  content: ""; position: absolute; top: 12px; left: 26px; right: 0; height: 2px;
  background: var(--line);
}
.track li:last-child::after { display: none; }
.track li.done { color: var(--text); }
.track li.done::before { content: "✓"; background: var(--black); border-color: var(--black); color: var(--amber); }
.track li.done::after { background: var(--black); }
.track li.active { color: var(--black); font-weight: 700; }
.track li.active::before { background: var(--amber); border-color: var(--amber); color: var(--black); animation: pulse 1.3s ease-in-out infinite; }
.track li.skipped { color: #A8A8A8; }
.track li.skipped::before { content: "–"; border-style: dashed; }
.track li.skipped::after { background: var(--black); }
.progress-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; color: var(--grey); }
.progress-foot .clock { font-variant-numeric: tabular-nums; }
.progress.finished .progress-foot .now { color: var(--text); }

/* ---------------------------------------------------------------- composer */
.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px clamp(12px, 2.5vw, 24px);
  background: var(--white);
}
.composer { border-top: 1px solid var(--line); }
.composer textarea {
  flex: 1; resize: none; max-height: 160px;
  font: 400 16px/1.45 var(--font); color: var(--text);
  padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--white);
}
.composer textarea:focus { outline: none; border-color: var(--black); }
.composer button {
  font: 700 15px var(--font);
  background: var(--amber); color: var(--black);
  border: 0; border-radius: 12px; padding: 12px 22px; cursor: pointer;
}
.composer button:hover { background: #F09A00; }
.composer button#stop {
  display: flex; align-items: center; gap: 6px;
  background: var(--black); color: var(--white); padding: 12px 16px;
}
.composer button#stop[hidden] { display: none; }
.composer button#stop:hover { background: #3A3A3A; }
.composer button:disabled { background: var(--line); color: var(--grey); cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.composer textarea:focus-visible { outline: none; }

@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(248,168,32,.55); } 50% { box-shadow: 0 0 0 7px rgba(248,168,32,0); } }
@keyframes grow { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes blink { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .track li.active::before, .answer .streaming::after { animation: none; }
  .log { scroll-behavior: auto; }
}
@media (max-width: 640px) {
  .examples, .suggest-pop { grid-template-columns: 1fr; }
  .suggest-btn span { display: none; }
  .brand p { display: none; }
  .msg.user .bubble { max-width: 88%; }
  .track li { font-size: 11px; padding-top: 30px; }
  .track li::before { width: 22px; height: 22px; }
  .track li::after { top: 10px; left: 22px; }
}


/* ---------------------------------------------------------------- editing the latest question */
.msg.user { align-items: flex-start; gap: 6px; }
.edit-q {
  order: -1; align-self: center;
  border: 0; background: transparent; color: var(--grey); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 6px; border-radius: 8px; opacity: 0;
  transition: opacity .15s, background .15s;
}
.msg.user:hover .edit-q, .edit-q:focus-visible { opacity: 1; }
.edit-q:hover { background: var(--mist); color: var(--black); }
.msg.user.editing { justify-content: flex-end; }
.edit-box { display: flex; gap: 6px; align-items: flex-start; width: min(560px, 90%); }
.edit-input {
  flex: 1; resize: vertical; min-height: 44px; max-height: 160px;
  font: 400 16px/1.45 var(--font); color: var(--text);
  padding: 9px 12px; border: 1.5px solid var(--black); border-radius: 12px; background: var(--white);
}
.edit-ok, .edit-no {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  font: 700 17px/1 var(--font); flex: none;
}
.edit-ok { background: var(--amber); color: var(--black); }
.edit-ok:hover { background: #F09A00; }
.edit-no { background: var(--mist); color: var(--grey); }
.edit-no:hover { background: var(--line); color: var(--black); }
@media (hover: none) { .edit-q { opacity: 1; } }
