:root {
  --bg: #FAF9F7;
  --paper: #FFFFFF;
  --ink: #0A1F44;
  --ink-soft: rgba(10, 31, 68, 0.65);
  --line: rgba(10, 31, 68, 0.12);
  --cherry: #D2042D;
  --graphite: #3B4B63;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;
  --radius: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #06122A;
    --paper: #0A1F44;
    --ink: #EEF2F9;
    --ink-soft: rgba(238, 242, 249, 0.65);
    --line: rgba(238, 242, 249, 0.14);
    --cherry: #FF3043;
    --graphite: #8A99B0;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 1rem; top: 1rem; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.topbar__brand { display: flex; align-items: center; gap: 0.6rem; }

.topbar__mark {
  display: inline-grid;
  place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 0.5rem;
  background: var(--cherry);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
}

.topbar__word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.topbar__tag {
  font-size: 0.75rem;
  color: var(--ink-soft);
  border-left: 1px solid var(--line);
  padding-left: 0.6rem;
}

.lang-switch select {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
}

main { flex: 1; }

.hero {
  max-width: min(96vw, 1600px);
  margin: 0 auto;
  padding: 3.5rem 1.5rem 2rem;
  text-align: center;
}

.hero__headline {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 auto 0.9rem;
  max-width: 48rem;
}

.hero__sub {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0 auto 1.5rem;
  max-width: 42rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  list-style: none;
  margin-bottom: 0.75rem;
}

.chips--knowledge { margin-top: 0.25rem; }

.chip {
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--graphite);
}

.chip--trait {
  background: transparent;
  border-color: var(--cherry);
  color: var(--cherry);
  font-weight: 600;
}

.chat-card__starters {
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.chat-card__starters strong { color: var(--ink); font-weight: 600; }

.chat-card {
  padding: 0 1.5rem;
  margin-bottom: 3rem;
}

.chat-card h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.chat-card__sub {
  color: var(--ink-soft);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
}

.site-footer__meta { margin-top: 0.25rem; opacity: 0.7; }

/* ── Rich content rendering: markdown, mermaid, tables, charts, papers ──
   Ported alongside render.js from the LabourGenie Cleaner-Theme UI. */

.content-md { font-size: 0.95rem; line-height: 1.65; }
.content-md p { margin: 0 0 0.75rem; }
.content-md h1, .content-md h2, .content-md h3 { font-family: var(--font-display); margin: 1rem 0 0.5rem; }
.content-md ul, .content-md ol { margin: 0 0 0.75rem; padding-left: 1.25rem; }
.content-md blockquote { margin: 0 0 0.75rem; padding: 0.5rem 0.9rem; border-left: 3px solid var(--line); color: var(--ink-soft); }
.content-md a { color: var(--cherry); }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--line); border-top-color: var(--ink);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.content-md pre.codeblock {
  background: rgba(0,0,0,0.035); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.8rem 1rem; overflow-x: auto; font-size: 0.82rem; white-space: pre-wrap;
}

.content-md .lgl.lvl-0 { font-weight: 500; color: var(--graphite); margin: 1rem 0 0.4rem; }
.content-md .lgl.lvl-1 { margin-left: 0; }
.content-md .lgl.lvl-2 { margin-left: 1.5rem; }
.content-md .lgl.lvl-3 { margin-left: 3rem; }
.content-md .lgl.lvl-4 { margin-left: 4.5rem; }
.content-md .pgdiv { margin: 1.5rem 0 0.9rem; font-size: 0.65rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.16em; }

.md-tablewrap { overflow-x: auto; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 10px; }
.md-table { border-collapse: collapse; width: 100%; font-size: 0.82rem; background: var(--paper); }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 0.55rem 0.8rem; text-align: left; vertical-align: top; line-height: 1.55; }
.md-table thead th { background: var(--ink); color: var(--bg); font-weight: 500; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; }
.md-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }

.content-md .cellgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr)); gap: 2px 1rem; margin: 0.5rem 0; }
.content-md .cellgrid span { font-size: 0.82rem; padding: 3px 0; border-bottom: 1px solid var(--line); }
.content-md .tcap { font-style: italic; color: var(--ink-soft); font-size: 0.78rem; margin: 0.6rem 0 0.25rem; }
.content-md .gridtbl { border-collapse: collapse; margin: 0.5rem 0; font-size: 0.78rem; display: block; max-width: 100%; overflow-x: auto; }
.content-md .gridtbl td, .content-md .gridtbl th { border: 1px solid var(--line); padding: 4px 9px; vertical-align: top; white-space: nowrap; }
.content-md .gridtbl th { background: rgba(0,0,0,0.03); font-weight: 600; font-size: 0.68rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--graphite); }

.rich-block { position: relative; margin: 1.1rem 0; border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem 1rem 1rem; }
.rb-chip { position: absolute; top: 8px; left: 12px; font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.rb-pending { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); padding: 0.9rem 0.25rem; font-size: 0.82rem; }

.chart-wrap { position: relative; height: 300px; width: 100%; }
@media (max-width: 560px) { .chart-wrap { height: 230px; } }

.mermaid-wrap { position: relative; margin: 1rem 0; padding: 1.1rem; border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.mermaid-wrap svg { max-width: 100%; height: auto; }
.mermaid-wrap .codeblock { text-align: left; margin: 0; }
.mermaid-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; opacity: 0; transition: opacity 0.15s; }
.mermaid-wrap:hover .mermaid-tools, .mermaid-tools:focus-within { opacity: 1; }
.mmpng {
  display: inline-flex; align-items: center; gap: 6px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 0.7rem;
  color: var(--ink-soft); cursor: pointer;
}
.mmpng:hover { border-color: var(--cherry); color: var(--cherry); }
@media (max-width: 480px) { .mermaid-tools { opacity: 1; } }

.tl { margin: 0.5rem 0 0.5rem 0.5rem; }
.tl-item { position: relative; margin: 0 0 0.9rem; padding-left: 1.5rem; }
.tl-dot { position: absolute; left: 0; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--cherry); }
.tl-date { font-size: 0.7rem; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.04em; }
.tl-body { font-size: 0.85rem; }
.tl-detail { color: var(--ink-soft); font-size: 0.78rem; margin-top: 2px; }

.paper { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; }
.paper-title { font-size: 1.05rem; font-weight: 700; text-align: center; margin-bottom: 1.3rem; font-family: var(--font-display); }
.paper-body p { margin: 0 0 0.6rem; }
.paper-body h1, .paper-body h2, .paper-body h3 { font-family: inherit; margin: 1rem 0 0.5rem; }
.paper-tools { display: flex; gap: 8px; justify-content: flex-end; margin-top: 0.6rem; flex-wrap: wrap; }
.ptool {
  font: 600 0.75rem "Plus Jakarta Sans", sans-serif; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); border-radius: 6px; padding: 0.35rem 0.7rem; cursor: pointer;
}
.ptool:hover { border-color: var(--cherry); color: var(--cherry); }

.blank { display: inline-block; min-width: 4rem; border-bottom: 1px solid var(--ink-soft); }

/* ── Chat shell: sidebar + message list + composer ── */
.chat-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  max-width: min(96vw, 1600px);
  margin: 0 auto 3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  min-height: 32rem;
}
@media (max-width: 720px) {
  .chat-shell { grid-template-columns: 1fr; }
}

.chat-sidebar {
  border-right: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(0,0,0,0.015);
}
@media (max-width: 720px) {
  .chat-sidebar { border-right: none; border-bottom: 1px solid var(--line); flex-direction: row; overflow-x: auto; }
}

.chat-sidebar__new {
  font: 600 0.8rem "Plus Jakarta Sans", sans-serif;
  border: 1px solid var(--cherry);
  color: var(--cherry);
  background: transparent;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}
.chat-sidebar__new:hover { background: var(--cherry); color: #fff; }

.chat-sidebar__list { display: flex; flex-direction: column; gap: 0.3rem; overflow-y: auto; }
@media (max-width: 720px) {
  .chat-sidebar__list { flex-direction: row; }
}

.chat-sidebar__item {
  text-align: left;
  font-size: 0.78rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.chat-sidebar__item:hover { background: rgba(0,0,0,0.04); color: var(--ink); }
.chat-sidebar__item.is-active { background: var(--paper); border-color: var(--line); color: var(--ink); font-weight: 600; }

.chat-main { display: flex; flex-direction: column; padding: 1.25rem 1.5rem; min-width: 0; }
.chat-main h2 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 0.15rem; }
.chat-card__sub { color: var(--ink-soft); font-size: 0.8rem; margin-bottom: 0.75rem; }

.chat-messages {
  flex: 1;
  min-height: 18rem;
  max-height: 28rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.25rem 0.1rem 0.75rem;
}

.msg { display: flex; }
.msg--user { justify-content: flex-end; }
.msg--assistant, .msg--system { justify-content: flex-start; }

.msg__body {
  max-width: 85%;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
}
.msg--user .msg__body { background: var(--cherry); color: #fff; border-bottom-right-radius: 3px; }
.msg--assistant .msg__body { background: rgba(0,0,0,0.035); border-bottom-left-radius: 3px; }
.msg--system .msg__body { background: transparent; color: var(--ink-soft); font-size: 0.78rem; padding: 0.2rem 0.4rem; }

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.5rem;
  margin-top: 0.5rem;
}

.chat-composer__upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 8px;
  color: var(--ink-soft);
  cursor: pointer;
  flex-shrink: 0;
}
.chat-composer__upload:hover { background: rgba(0,0,0,0.04); color: var(--cherry); }

#chat-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font: 0.88rem/1.5 "Plus Jakarta Sans", sans-serif;
  background: transparent;
  color: var(--ink);
  max-height: 10rem;
  padding: 0.4rem 0.2rem;
}

.chat-composer__send {
  font: 700 0.8rem "Plus Jakarta Sans", sans-serif;
  background: var(--cherry);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-composer__send:hover { opacity: 0.9; }

.chat-composer__status {
  min-height: 1.1rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-top: 0.4rem;
}
