/* Styled after nielsmede.com (Owlstown "flannel" theme): PT Serif for titles and descriptions, IBM Plex Sans for the
   conversation and the interface, near-black text, brown accent, white surface, light grays.
   Light only: the tool does not follow the browser's dark mode. The page scrolls in the browser window; only the
   question box stays at the bottom of the window during a conversation. The tool is as wide as the main column of
   nielsmede.com (804 px); inside the site's iframe it fills the iframe, standalone it is centered with side padding. */
@import url('https://fonts.googleapis.com/css2?family=PT+Serif:ital,wght@0,400;0,700;1,400&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400&display=swap');

:root {
  color-scheme: light only;
  --pc-bg: #ffffff;
  --pc-fg: #212121;
  --pc-muted: rgba(33, 33, 33, 0.54);
  --pc-accent: #897452;
  --pc-accent-dark: #6f5d41;
  --pc-accent-soft: rgba(137, 116, 82, 0.10);
  --pc-border: #cccccc;
  --pc-border-soft: #e5e5e5;
  --pc-surface-2: rgba(0, 0, 0, 0.04);   /* the site's hover tint */
  --pc-surface-3: #f5f5f5;
  --pc-user: rgba(137, 116, 82, 0.08);
  --pc-badge-data: #2f6b3a;
  --pc-badge-data-bg: rgba(47, 107, 58, 0.10);
  --pc-error: #9a2f2f;
  --pc-shadow: 0 10px 28px rgba(0, 0, 0, 0.09);
  --pc-serif: "PT Serif", Georgia, "Times New Roman", serif;
  --pc-sans: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --pc-width: 804px;         /* all levels: the width of the main column on nielsmede.com */
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; background: var(--pc-bg); color: var(--pc-fg); font-family: var(--pc-serif); font-size: 16px; line-height: 1.5; }
a { color: var(--pc-accent); text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; }
button { font-family: var(--pc-sans); }
img { max-width: 100%; }

.pc-app { max-width: var(--pc-width); margin: 0 auto; padding: 0; }

/* ---------- the page shell: layout of nielsmede.com (Owlstown "flannel" theme), measured on the live site ---------- */
.site-container { display: flex; flex-direction: column; min-height: 100vh; background: var(--pc-bg); box-shadow: 0 0 100px rgba(0, 0, 0, 0.2); }
.site-side { width: 100%; padding: 48px 24px 0; text-align: center; background: var(--pc-bg); font-family: var(--pc-serif); color: var(--pc-fg); }
.site-avatar { width: 200px; margin: 0 auto 24px; }
.site-avatar img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; }
.site-name { font-size: 24px; line-height: 1.2; font-weight: 700; }
.site-name a, .site-name a:hover { color: inherit; text-decoration: none; }
.site-role { font-size: 20px; line-height: 24px; }
.site-space { height: 32px; }
.site-nav-toggle { display: block; margin: 0 auto; padding: 0 0 12px; border: 0; background: none; color: var(--pc-fg); cursor: pointer; }
.site-nav-toggle svg { display: block; margin: 0 auto; }
.site-nav { display: none; flex-direction: column; gap: 2px; margin: 0 -24px; padding: 0; font-size: 16px; }
.site-side.is-open .site-nav { display: flex; }
.site-nav a { display: block; padding: 16px 24px; line-height: 24px; color: var(--pc-fg); text-decoration: none; font-weight: 400; }
.site-nav a:hover { background: rgba(0, 0, 0, 0.05); font-weight: 700; text-decoration: none; }
.site-main { width: 100%; }
.site-article { padding: 32px; }
.site-footer { padding: 0 12px 48px; text-align: center; font-family: var(--pc-serif); font-size: 16px; line-height: 24px; color: var(--pc-fg); }
.site-footer a { font-weight: 400; text-decoration: underline; }
@media (min-width: 769px) {
  .site-container { flex-direction: row; }
  .site-side { width: 33%; padding: 64px 24px 0; }
  .site-avatar { width: 67%; }
  .site-nav-toggle { display: none; }
  .site-nav { display: flex; }
  .site-main { width: 67%; }
  .site-article { padding: 48px; }
}
@media (min-width: 993px) { .site-container { max-width: 992px; margin: 0 auto; } }
@media (min-width: 1201px) { .site-container { max-width: 1200px; } .site-side { width: 25%; } .site-main { width: 75%; } }
/* embedded (?compact=1): only the tool, no shell */
.pc-compact .site-container { box-shadow: none; min-height: 0; max-width: none; }
.pc-compact .site-side, .pc-compact .site-footer { display: none; }
.pc-compact .site-main { width: 100%; }
.pc-compact .site-article { padding: 0; }
/* the header (title, intro, navigation) stays visible while a long conversation scrolls */
.pc-header { position: sticky; top: 0; z-index: 6; background: var(--pc-bg); padding: 10px 0 12px; border-bottom: 1px solid var(--pc-border-soft); }
.pc-compact .pc-header { padding-top: 12px; }
.pc-header h1 { font-size: 48px; line-height: 1.2; margin: 0 0 10px; font-weight: 700; }
.pc-sub { margin: 0; color: var(--pc-muted); font-size: 15px; max-width: none; }
.pc-crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-family: var(--pc-sans); font-size: 14px; color: var(--pc-muted); }
.pc-crumbs button { background: none; border: 0; padding: 0; color: var(--pc-accent); font: inherit; font-weight: 700; cursor: pointer; }
.pc-crumbs button:hover { text-decoration: underline; }
.pc-crumbs .sep { opacity: 0.6; }
.pc-crumbs .current { color: var(--pc-fg); }

.pc-main { padding: 16px 0 8px; }

/* ---------- step 1: themes (two columns, five rows; the "all publications" tile spans both) ---------- */
.pc-themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 4px 2px 10px; }
/* hover: a lift and a shadow only; no scaling, which made the text blurry while the tile was rasterized at the scaled size */
.pc-card { position: relative; display: grid; grid-template-rows: 118px auto 1fr auto; align-items: start; gap: 4px; text-align: left; background: var(--pc-bg); border: 1px solid var(--pc-border); border-radius: 6px; padding: 12px 14px 14px; cursor: pointer; font-family: var(--pc-serif); color: var(--pc-fg); transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
.pc-card:hover, .pc-card:focus-visible { transform: translateY(-3px); box-shadow: var(--pc-shadow); border-color: var(--pc-theme, var(--pc-accent)); outline: none; }
.pc-card .art { display: flex; justify-content: center; align-items: center; height: 118px; margin: 0; }
.pc-card .art svg { display: block; width: 172px; max-width: 100%; height: 112px; }
.pc-card h3 { margin: 0 0 2px; font-size: 16px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--pc-theme, var(--pc-accent)); align-self: start; }
.pc-card p { margin: 0; font-size: 14.5px; line-height: 1.4; color: var(--pc-fg); }
.pc-card .count { display: inline-block; justify-self: start; margin-top: 8px; font-family: var(--pc-sans); font-size: 12px; border-radius: 999px; padding: 2px 9px; color: var(--pc-theme, var(--pc-accent)); background: var(--pc-theme-soft, var(--pc-accent-soft)); }
.pc-card.all { grid-column: 1 / -1; display: grid; grid-template-rows: none; grid-template-columns: 1fr auto; align-items: center; gap: 4px 20px; padding: 14px 18px; }
.pc-card.all h3 { color: var(--pc-accent); }
.pc-card.all .count { color: var(--pc-accent); background: var(--pc-accent-soft); margin-top: 0; justify-self: end; }
/* the line draws itself when a theme card is hovered */
.pc-card:hover .art path, .pc-card:focus-visible .art path { animation: pc-draw 1.9s cubic-bezier(.3, .1, .3, 1) forwards; }
@keyframes pc-draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .pc-card, .pc-card:hover { transition: none; transform: none; } .pc-card:hover .art path { animation: none; } }

/* ---------- step 2: papers ---------- */
.pc-filter { display: flex; gap: 8px; margin: 0 0 12px; }
.pc-filter input { flex: 1; font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--pc-border); border-radius: 4px; background: var(--pc-bg); color: var(--pc-fg); }
.pc-filter input:focus { outline: none; border-color: var(--pc-accent); }
.pc-papers { display: flex; flex-direction: column; gap: 12px; padding-bottom: 10px; }
.pc-paper { position: relative; display: grid; grid-template-columns: 104px 1fr; gap: 14px 18px; text-align: left; border: 1px solid var(--pc-border-soft); border-radius: 6px; padding: 14px 16px; background: var(--pc-bg); cursor: pointer; font-family: var(--pc-serif); color: var(--pc-fg); transition: box-shadow .18s ease, border-color .18s ease; }
.pc-paper:hover, .pc-paper:focus-within { border-color: var(--pc-accent); box-shadow: var(--pc-shadow); }
.pc-paper .pc-os-corner { position: absolute; top: 12px; right: 14px; }
.pc-paper.has-os .title { padding-right: var(--pc-os-width, 96px); }
.pc-paper.ask { grid-template-columns: 1fr; padding: 12px 16px; background: var(--pc-surface-3); border-style: dashed; }
.pc-paper.ask:hover { background: var(--pc-accent-soft); }
.pc-paper .thumb { width: 104px; height: 140px; border: 1px solid var(--pc-border); background: #fff; object-fit: cover; object-position: top; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10); display: block; }
.pc-paper .thumb.placeholder { display: flex; align-items: center; justify-content: center; font-family: var(--pc-sans); font-size: 12px; color: var(--pc-muted); text-align: center; padding: 8px; }
.pc-paper .body { min-width: 0; }
.pc-paper .title { font-size: 18px; font-weight: 700; color: var(--pc-accent); line-height: 1.3; margin: 0 0 4px; }
.pc-paper .meta { font-size: 15px; color: var(--pc-muted); margin: 0 0 6px; }
.pc-paper .summary { font-size: 15px; margin: 0 0 8px; }
.pc-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pc-badge { display: inline-flex; align-items: center; gap: 4px; font-family: var(--pc-sans); font-size: 12px; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--pc-border); color: var(--pc-muted); background: var(--pc-bg); }
.pc-badge.data { color: var(--pc-badge-data); background: var(--pc-badge-data-bg); border-color: transparent; font-weight: 700; }
.pc-badge.theme { color: var(--pc-theme, var(--pc-accent)); background: var(--pc-theme-soft, var(--pc-accent-soft)); border-color: transparent; }
.pc-badge.lang { border-style: dashed; }
.pc-os { display: inline-flex; gap: 4px; align-items: center; margin-left: 2px; }
.pc-os img { width: 24px; height: 24px; display: block; }
.pc-sub.empty { padding: 8px 0; }

/* ---------- step 3: chat ---------- */
.pc-paperhead { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 8px 18px; align-items: center; border: 1px solid var(--pc-border-soft); border-radius: 4px; padding: 10px 14px; margin-bottom: 12px; background: var(--pc-surface-3); }
.pc-paperhead .pc-os-corner { position: absolute; top: 10px; right: 12px; }
.pc-paperhead.has-os .title { padding-right: var(--pc-os-width, 96px); }
.pc-paperhead .art svg { display: block; width: 120px; height: auto; }
.pc-paperhead .title { font-weight: 700; font-size: 17px; margin: 0 0 2px; }
.pc-paperhead .meta { font-size: 14px; color: var(--pc-muted); margin: 0 0 6px; }
.pc-chat { display: flex; flex-direction: column; gap: 12px; min-height: 40vh; padding-bottom: 8px; }
.pc-msg { max-width: 92%; padding: 10px 14px; border-radius: 4px; border: 1px solid var(--pc-border-soft); font-family: var(--pc-sans); font-size: 15.5px; line-height: 1.55; }
.pc-msg.user { align-self: flex-end; background: var(--pc-user); white-space: pre-wrap; border-color: transparent; }
.pc-msg.assistant { align-self: flex-start; background: var(--pc-bg); }
.pc-msg.assistant p { margin: 0 0 0.7em; }
.pc-msg.assistant p:last-child { margin-bottom: 0; }
.pc-msg.assistant ul, .pc-msg.assistant ol { margin: 0.3em 0 0.7em; padding-left: 1.3em; }
.pc-msg.assistant table { border-collapse: collapse; margin: 0.4em 0 0.8em; font-size: 14px; font-family: var(--pc-sans); }
.pc-msg.assistant th, .pc-msg.assistant td { border: 1px solid var(--pc-border-soft); padding: 3px 8px; text-align: left; vertical-align: top; }
.pc-msg.assistant th { background: var(--pc-surface-2); }
.pc-msg.assistant code { font-family: "IBM Plex Mono", Consolas, monospace; font-size: 0.88em; background: var(--pc-surface-2); border-radius: 3px; padding: 0 3px; }
.pc-msg.assistant pre { font-family: "IBM Plex Mono", Consolas, monospace; font-size: 0.85em; background: var(--pc-surface-3); border-radius: 4px; padding: 8px 10px; overflow-x: auto; }
.pc-msg.assistant pre code { background: none; padding: 0; }
.pc-msg.assistant .pc-subhead { margin: 0.9em 0 0.3em; }
.pc-msg.assistant .pc-subhead:first-child { margin-top: 0; }
.pc-msg.assistant strong { font-weight: 600; }
.pc-msg.error { color: var(--pc-error); border-color: var(--pc-error); }
.pc-msg .pc-badge { margin-bottom: 8px; }
.pc-msg.typing { cursor: pointer; }
.pc-msg li.pc-await { list-style: none; }
.pc-msg li.pc-await::marker { content: ""; }
.pc-msg th.pc-await, .pc-msg td.pc-await { border-color: transparent; }
.pc-msg.typing .pc-cursor { display: inline-block; width: 0.55em; height: 1em; margin-left: 1px; vertical-align: -0.15em; background: var(--pc-accent); animation: pc-blink 0.9s steps(2, start) infinite; }
@keyframes pc-blink { to { visibility: hidden; } }
.pc-thinking { color: var(--pc-muted); font-style: italic; display: flex; align-items: center; gap: 8px; }
.pc-dots span { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--pc-accent); opacity: 0.35; animation: pc-pulse 1.2s infinite ease-in-out; }
.pc-dots span:nth-child(2) { animation-delay: 0.2s; }
.pc-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pc-pulse { 0%, 80%, 100% { opacity: 0.35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.pc-figure { margin: 10px 0 4px; border: 1px solid var(--pc-border-soft); border-radius: 4px; padding: 8px; background: #fff; max-width: 100%; }
.pc-figure svg, .pc-figure img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.pc-figure img { max-height: 520px; width: auto; }
.pc-figure figcaption { font-family: var(--pc-sans); font-size: 13px; color: #5b6470; margin-top: 8px; line-height: 1.4; }
.pc-figure .pc-figbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--pc-sans); font-size: 12px; color: #5b6470; margin-top: 6px; }
.pc-figure .pc-figbar a { font-family: var(--pc-sans); font-weight: 400; color: var(--pc-accent); }

/* the example questions and the question box stay at the bottom of the window while the conversation scrolls */
#chat-controls { position: sticky; bottom: 0; z-index: 5; background: var(--pc-bg); border-top: 1px solid var(--pc-border-soft); padding: 4px 0 10px; box-shadow: 0 -8px 16px -12px rgba(0, 0, 0, 0.18); }
.pc-starters { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 4px; }
.pc-starters button { font-family: var(--pc-sans); font-size: 13px; color: var(--pc-fg); background: var(--pc-bg); border: 1px solid var(--pc-border); border-radius: 999px; padding: 5px 11px; cursor: pointer; transition: border-color .15s, color .15s, transform .15s; }
.pc-starters button:hover { border-color: var(--pc-accent); color: var(--pc-accent); transform: translateY(-1px); }
.pc-input { display: flex; gap: 8px; padding: 6px 0 0; }
.pc-input textarea { flex: 1; font: inherit; font-family: var(--pc-sans); font-size: 15.5px; color: var(--pc-fg); background: var(--pc-bg); border: 1px solid var(--pc-border); border-radius: 4px; padding: 9px 11px; resize: none; max-height: 160px; overflow-y: hidden; }
.pc-input textarea:focus { outline: none; border-color: var(--pc-accent); }
.pc-input button { font-family: var(--pc-sans); font-size: 15px; background: var(--pc-accent); color: #fff; border: 0; border-radius: 4px; padding: 0 18px; cursor: pointer; }
.pc-input button:hover { background: var(--pc-accent-dark); }
.pc-input button:disabled { opacity: 0.5; cursor: default; }
.pc-footer { font-family: var(--pc-sans); font-size: 12px; color: var(--pc-muted); padding: 10px 0 14px; }
.pc-footer a { font-weight: 400; text-decoration: underline; color: var(--pc-muted); }
.pc-hidden { display: none !important; }
.pc-compact .pc-title { display: none; }

@media (max-width: 760px) {
  .pc-header h1 { font-size: 34px; }
  .pc-card { grid-template-rows: 100px 48px 1fr auto; }
  .pc-card .art { height: 100px; }
  .pc-card .art svg { width: 146px; height: 95px; }
  .pc-card.all { grid-template-columns: 1fr; }
  .pc-card.all .count { justify-self: start; }
  .pc-msg { max-width: 100%; }
  .pc-paper { grid-template-columns: 1fr; }
  .pc-paper .thumb { width: 84px; height: 112px; }
  .pc-paper .pc-os-corner, .pc-paperhead .pc-os-corner { position: static; margin-top: 2px; }
  .pc-paper.has-os .title, .pc-paperhead.has-os .title { padding-right: 0; }
  .pc-card h3 { white-space: normal; }
  .pc-paperhead { grid-template-columns: 1fr; }
  .pc-paperhead .art { display: none; }
}
@media (max-width: 480px) { .pc-themes { grid-template-columns: 1fr; } .pc-card { grid-template-rows: 100px auto 1fr auto; } .pc-card h3 { align-self: start; } }
