:root {
  --text: #222;
  --muted: #555;
  --accent: #2b5d8c;
  --rule: #ddd;
  --bg: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Lato", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}

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

/* Header: photo + intro */
header {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  margin-bottom: 48px;
}
header img {
  width: 180px;
  flex-shrink: 0;
  border-radius: 4px;
}
h1 {
  margin: 0 0 16px;
  font-weight: 300;
  font-size: 2.4rem;
  color: var(--accent);
}
header p { margin: 0 0 12px; }

/* Sections */
h2 {
  font-weight: 400;
  font-size: 1.6rem;
  color: var(--accent);
  margin: 48px 0 8px;
}

/* Paper entries */
.paper {
  border-bottom: 1px solid var(--rule);
  padding: 14px 0;
}
.paper summary {
  cursor: pointer;
  list-style: none;
  padding-right: 28px;
  position: relative;
}
.paper summary::-webkit-details-marker { display: none; }
.paper summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 0;
  color: var(--muted);
  font-size: 1.2rem;
}
.paper[open] summary::after { content: "\2212"; }
.paper .title { font-weight: 700; }
.paper .abstract {
  color: var(--muted);
  margin: 10px 0 4px;
}
.paper .extra { margin: 6px 0 0; font-size: 0.95rem; }

/* Non-expandable entries */
.paper.plain { padding: 14px 0; }

footer {
  margin-top: 56px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  main { padding: 28px 16px 48px; }
  header { flex-direction: column; gap: 20px; }
  header img { width: 140px; }
  h1 { font-size: 2rem; }
}

/* "Ask a question about this paper" button and panel (chat.js) */
.chat-open {
  font: inherit;
  font-size: 0.95rem;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
}
.chat-open:hover { background: var(--accent); color: #fff; }
/* Faint speech bubble on the (collapsed) title line */
.chat-open.chat-icon {
  border: 0;
  padding: 2px 4px;
  margin-left: 2px;
  vertical-align: -3px;
  color: var(--muted);
  opacity: 0.5;
  line-height: 0;
}
.chat-open.chat-icon:hover, .chat-open.chat-icon:focus-visible { background: none; color: var(--accent); opacity: 1; }
.chat-open.chat-icon:focus { outline: none; } /* no focus ring; keyboard focus still shows via the colour change */

#chat {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}
#chat[open] { display: flex; flex-direction: column; }
#chat::backdrop { background: rgba(0, 0, 0, 0.35); }
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--rule);
}
.chat-kicker { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
#chat h3 { margin: 2px 0 0; font-weight: 400; font-size: 1.15rem; color: var(--accent); }
.chat-close { font-size: 1.6rem; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  min-height: 220px;
}
.chat-msg { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; max-width: 88%; }
.chat-msg p { margin: 0 0 6px; }
.chat-msg p:last-child { margin: 0; }
.chat-msg.user { margin-left: auto; background: #eef3f8; }
.chat-msg.assistant { background: #f6f6f6; }
.chat-msg.thinking { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--rule); }
.chat-form textarea {
  flex: 1;
  font: inherit;
  font-size: 16px; /* avoids zoom-on-focus on iPhones */
  padding: 8px 10px;
  border: 1px solid #bbb;
  border-radius: 4px;
  resize: none;
}
.chat-form button {
  font: inherit;
  font-weight: 700;
  padding: 0 16px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.chat-form button:disabled { opacity: 0.6; cursor: default; }
.chat-note { margin: 0; padding: 0 18px 12px; font-size: 0.8rem; color: var(--muted); }

.nowrap { white-space: nowrap; } /* keeps the chat bubble on the same line as the word before it */

/* Topic filters (filter.js) */
.topics { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 -24px; font-size: 0.95rem; }
.topics button {
  font: inherit;
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.topics button:hover { color: var(--accent); }
.topics button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.topics button:focus { outline: none; }
.topics button:focus-visible { color: var(--accent); }
.paper[hidden], main h2[hidden] { display: none; }

/* Co-author names: plain text until hovered, then an underlined link */
a.coauthor { color: inherit; text-decoration: none; }
a.coauthor:hover, a.coauthor:focus-visible { color: var(--accent); text-decoration: underline; }

/* Email and profile links under the intro */
.profile-links { font-size: 0.95rem; color: var(--muted); }

/* Instant "Talk to this paper" label when hovering the bubble (replaces the slow browser tooltip) */
.chat-open.chat-icon { position: relative; }
@media (hover: hover) {
  .chat-open.chat-icon::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 8px;
    border-radius: 4px;
    background: #444;
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
  }
  .chat-open.chat-icon:hover::after { opacity: 1; }
}
