/* Design tokens — matched to website/export-isii-site.html */
:root {
  --cream: #F6F4EF;
  --navy: #0B1A4A;
  --navy-hover: #15235A;
  --navy-dark: #081335;
  --ink: #15203F;
  --ink-soft: #3A4366;
  --muted: #8C95AE;
  --bronze: #9A7B4F;
  --gold: #C6A867;
  --border: #E6E4DD;
  --white: #FFFFFF;
  --serif: 'Spectral', Georgia, serif;
  --sans: Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--cream); }
body { color: var(--ink); font-family: var(--serif); -webkit-font-smoothing: antialiased; }
::selection { background: var(--navy); color: #fff; }
a { color: var(--navy); }
a:hover { color: var(--bronze); }
h1, h2, h3 { text-wrap: balance; font-weight: 500; }
p { text-wrap: pretty; }

/* ---- header ---- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--white); border-bottom: 1px solid var(--border); height: 64px;
}
.header-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 36px; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
}
.wordmark {
  font-family: var(--serif); font-size: 20px; letter-spacing: .14em;
  color: var(--navy); font-weight: 600;
  display: inline-flex; align-items: center;
}
.wordmark-home { display: block; }
.wordmark-home:hover .wordmark-logo { opacity: .75; }
.wordmark-logo { width: 38px; height: auto; display: block; transition: opacity .2s ease; }
.wordmark-sub {
  font-family: var(--sans); font-size: 11px; text-transform: uppercase;
  letter-spacing: .18em; color: var(--bronze); margin-left: 14px; font-weight: 600;
  text-decoration: none;
}
.wordmark-sub:hover { color: var(--navy); }
.header-nav { display: flex; align-items: center; gap: 20px; }
.member-name { font-size: 15px; color: var(--ink-soft); font-style: italic; }
.link-button {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--sans); font-size: 11px; text-transform: uppercase;
  letter-spacing: .13em; font-weight: 600; color: var(--navy);
}
.link-button:hover { color: var(--bronze); }

/* ---- layout ---- */
.shell {
  max-width: 1240px; margin: 0 auto; padding: 40px 36px;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px;
  align-items: start;
}
.content-solo { max-width: 560px; margin: 0 auto; padding: 64px 24px; }

/* when the chat drawer is present, content occupies exactly the visible
   area left of it (margin 0: centering against the full viewport would
   waste a dead margin on the left and hide the right edge under the drawer) */
body.has-chat .shell { display: block; max-width: none; width: calc(100% - 360px); margin: 0; padding: 40px 48px; }
body.has-chat .content { max-width: 880px; margin: 0 auto; }
body.has-chat .site-header { margin-right: 360px; }

/* ---- typography helpers ---- */
.eyebrow {
  font-family: var(--sans); font-size: 11px; text-transform: uppercase;
  letter-spacing: .18em; color: var(--bronze); font-weight: 600; margin: 0 0 10px;
}
.page-title { font-size: clamp(28px, 3.4vw, 40px); margin: 0 0 8px; color: var(--navy); }
.lede { color: var(--ink-soft); font-size: 17px; line-height: 1.6; }

/* ---- forms & buttons ---- */
.field { margin: 18px 0; }
.field label {
  display: block; font-family: var(--sans); font-size: 11px; text-transform: uppercase;
  letter-spacing: .13em; font-weight: 600; color: var(--ink-soft); margin-bottom: 8px;
}
.field input, .field textarea {
  width: 100%; padding: 12px 14px; font-family: var(--serif); font-size: 16px;
  color: var(--ink); background: var(--white); border: 1px solid var(--border);
  border-radius: 0; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--navy); }
.field textarea { min-height: 84px; resize: vertical; line-height: 1.55; }

.btn {
  display: inline-block; cursor: pointer; text-decoration: none; text-align: center;
  font-family: var(--sans); font-size: 11px; text-transform: uppercase;
  letter-spacing: .13em; font-weight: 600; padding: 13px 20px; border-radius: 0;
  color: #fff; background: var(--navy); border: 1px solid var(--navy);
  transition: background .15s ease;
}
.btn:hover { background: var(--navy-hover); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-outline { color: var(--navy); background: transparent; }
.btn-outline:hover { background: var(--navy); color: #fff; }
.btn-block { display: block; width: 100%; }

.form-error { color: #7A2E2F; font-size: 15px; margin-top: 10px; min-height: 1.2em; }
.quiet-note { color: var(--muted); font-size: 14px; margin-top: 14px; line-height: 1.5; }
.text-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--serif); font-size: 15px; color: var(--navy);
  text-decoration: underline; text-underline-offset: 3px;
}
.text-link:hover { color: var(--bronze); }

/* ---- sign-in card ---- */
.signin-card { background: var(--white); border: 1px solid var(--border); padding: 40px 36px; }
.signin-card h1 { font-size: 26px; margin: 0 0 6px; color: var(--navy); }
.hidden { display: none !important; }

/* ---- papers list ---- */
.paper-list { list-style: none; margin: 28px 0 0; padding: 0; }
.paper-item {
  border-top: 1px solid var(--border); padding: 22px 0;
  display: flex; align-items: center; gap: 26px;
}
.paper-item:last-child { border-bottom: 1px solid var(--border); }
.paper-item-body { flex: 1; min-width: 0; }
.paper-thumb { flex: none; display: block; }
.paper-thumb > img, .paper-thumb-fallback {
  display: block; width: 168px; aspect-ratio: 3 / 2; object-fit: cover;
  border: 1px solid var(--border); background: var(--cream);
  transition: opacity .2s ease;
}
.paper-thumb-fallback { display: flex; align-items: center; justify-content: center; }
.paper-thumb-fallback img { width: 40px; height: auto; opacity: .55; }
.paper-thumb:hover > img, .paper-thumb:hover .paper-thumb-fallback { opacity: .85; }
@media (max-width: 640px) {
  .paper-item { gap: 16px; align-items: flex-start; }
  .paper-thumb > img, .paper-thumb-fallback { width: 96px; }
  .paper-thumb-fallback img { width: 28px; }
}
.paper-item h2 { font-size: 21px; margin: 0 0 4px; }
.paper-item h2 a { text-decoration: none; color: var(--navy); }
.paper-item h2 a:hover { color: var(--bronze); }
.paper-meta {
  font-family: var(--sans); font-size: 11px; text-transform: uppercase;
  letter-spacing: .11em; color: var(--muted); margin: 0 0 6px;
}
.paper-summary { color: var(--ink-soft); font-size: 15.5px; line-height: 1.55; margin: 0; }

/* ---- article page ---- */
.article-body { max-width: 720px; font-size: 17px; line-height: 1.75; }
.article-body p { margin: 0 0 1.2em; }
/* pdf2page piv-doc bodies bring their own design system — lift the app caps */
.article-body-rich { max-width: none; }
.content-solo:has(.article-body-rich) { max-width: 1240px; }

/* ---- admin ---- */
a.link-button { text-decoration: none; }
.admin-add { max-width: 420px; margin-bottom: 40px; }
.admin-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.admin-status { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.admin-status.is-active { color: var(--navy); }
.admin-actions { display: flex; gap: 18px; flex: none; }
.admin-section-heading { font-size: clamp(24px, 2.6vw, 32px); color: var(--navy); margin: 56px 0 6px; }
.admin-section-lede { max-width: 560px; font-size: 15.5px; }
.admin-row.is-handled { opacity: .5; }
.admin-row.is-handled strong { text-decoration: line-through; text-decoration-color: var(--border); }
.admin-remove { color: #8a3232; }
.article-actions { margin: 26px 0 34px; }
.article-teaser { position: relative; max-width: 720px; }
.teaser-fade {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(246,244,239,0) 0%, var(--cream) 88%);
}

/* ---- modal ---- */
dialog.modal {
  border: 1px solid var(--border); background: var(--white); color: var(--ink);
  padding: 36px; max-width: 560px; width: calc(100vw - 48px); border-radius: 0;
}
dialog.modal::backdrop { background: rgba(8, 19, 53, .55); }
.modal h2 { margin: 0 0 8px; font-size: 22px; color: var(--navy); }
.modal .modal-close {
  position: absolute; top: 14px; right: 16px; background: none; border: none;
  font-size: 20px; color: var(--muted); cursor: pointer;
}
.segmented { display: flex; border: 1px solid var(--border); }
.segmented label {
  flex: 1; text-align: center; padding: 11px 0; cursor: pointer;
  font-family: var(--sans); font-size: 11px; text-transform: uppercase;
  letter-spacing: .11em; font-weight: 600; color: var(--ink-soft);
}
.segmented input { display: none; }
.segmented input:checked + span { color: #fff; }
.segmented label:has(input:checked) { background: var(--navy); color: #fff; }
.spinner {
  width: 26px; height: 26px; margin: 26px auto; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--navy);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.share-url {
  display: flex; gap: 10px; margin-top: 12px;
}
.share-url input { flex: 1; font-size: 14px; padding: 10px 12px; border: 1px solid var(--border); font-family: var(--sans); color: var(--ink-soft); }

/* ---- chat sidebar: full-height right drawer ---- */
.chat-sidebar {
  background: var(--white); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px;
  z-index: 60; transition: width .3s ease;
  box-shadow: -24px 0 48px -42px rgba(8, 19, 53, .35);
}
.chat-sidebar.expanded { width: 50vw; box-shadow: -32px 0 72px -34px rgba(8, 19, 53, .5); }
.chat-sidebar.expanded .chat-messages { padding: 22px 34px; }
.chat-header { padding: 20px 44px 14px 22px; border-bottom: 1px solid var(--border); position: relative; }
.chat-header h2 { margin: 0 0 4px; font-size: 18px; color: var(--navy); }
.chat-expand {
  position: absolute; top: 16px; right: 14px;
  background: none; border: 1px solid var(--border); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 6px 9px; color: var(--navy);
  transition: color .2s ease, border-color .2s ease;
}
.chat-expand:hover { color: var(--bronze); border-color: var(--bronze); }
.chat-close-mobile {
  display: none; position: absolute; top: 12px; right: 14px;
  background: none; border: 1px solid var(--border); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 2px 10px 5px; color: var(--navy);
}
.chat-disclaimer {
  font-family: var(--sans); font-size: 11.5px; line-height: 1.55;
  color: var(--muted); margin-top: 14px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.chat-sub { font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.45; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; font-size: 15px; line-height: 1.6; }
.chat-msg { margin-bottom: 16px; }
.chat-msg.user { color: var(--navy); font-style: italic; font-weight: 600; }
.chat-msg.assistant { color: var(--ink); }
.chat-msg.assistant:not(:last-child) { border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.chat-msg.assistant p { margin: 0 0 0.9em; }
.chat-msg.assistant p:last-child { margin-bottom: 0; }
.chat-msg.assistant h3, .chat-msg.assistant h4, .chat-msg.assistant h5 {
  font-family: var(--sans); font-size: 12px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--bronze); margin: 1.3em 0 0.5em;
}
.chat-msg.assistant ul, .chat-msg.assistant ol { margin: 0 0 0.9em; padding-left: 20px; }
.chat-msg.assistant li { margin-bottom: 0.35em; }
.chat-msg.assistant code {
  font-family: var(--mono, monospace); font-size: 13px;
  background: var(--cream); padding: 1px 4px;
}
.chat-msg.assistant a.paper-link {
  color: var(--bronze); text-decoration: underline;
  text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.chat-msg.assistant a.paper-link:hover { color: var(--navy); }
.chat-copy {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 9px 16px;
  border: 1px solid var(--border); background: var(--cream); cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--navy);
  transition: color .2s ease, border-color .2s ease;
}
.chat-copy svg { width: 16px; height: 16px; flex: none; }
.chat-copy:hover { border-color: var(--bronze); color: var(--bronze); }
.chat-copy.copied { border-color: var(--bronze); color: var(--bronze); background: var(--white); }
.chat-msg.rejection { color: var(--muted); font-size: 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--border); background: var(--cream); cursor: pointer;
  font-family: var(--serif); font-size: 13.5px; color: var(--navy);
  padding: 7px 12px; text-align: left;
}
.chip:hover { border-color: var(--bronze); color: var(--bronze); }
.chat-form { border-top: 1px solid var(--border); padding: 16px 22px 20px; }
.chat-form textarea, .chat-form input {
  width: 100%; border: 1px solid var(--border); padding: 10px 12px;
  font-family: var(--serif); font-size: 15px; color: var(--ink); margin-bottom: 10px;
}
.chat-thinking { color: var(--muted); font-style: italic; font-size: 14px; }
.sessions-toggle { margin: 0; padding: 12px 22px; border-top: 1px solid var(--border); flex: none; }
.session-list {
  list-style: none; margin: 0; padding: 0 22px 14px;
  overflow-y: auto; max-height: 240px; flex: none;
}
.session-list li { padding: 7px 0; font-size: 14px; border-top: 1px solid var(--cream); }
.session-list a { text-decoration: none; }
.session-date { color: var(--muted); font-size: 12px; margin-left: 8px; }
.cap-block { padding: 18px 22px; border-top: 1px solid var(--border); }
.cap-block h3 { margin: 0 0 6px; font-size: 17px; color: var(--navy); }
.cap-block p { font-size: 14.5px; color: var(--ink-soft); line-height: 1.55; }

/* ---- mobile ---- */
.chat-toggle-mobile { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; padding: 24px 20px; }
  body.has-chat .shell { width: auto; padding: 24px 20px; }
  body.has-chat .site-header { margin-right: 0; }
  .chat-expand { display: none; }
  .chat-close-mobile { display: block; }
  .admin-row { flex-wrap: wrap; }
  .chat-sidebar, .chat-sidebar.expanded {
    position: fixed; inset: auto 0 0 0; top: auto; width: auto; max-height: 82vh;
    border-left: none; border-top: 1px solid var(--border);
    transform: translateY(100%); transition: transform .25s ease; z-index: 50;
  }
  .chat-sidebar.open { transform: translateY(0); }
  .chat-toggle-mobile {
    display: block; position: fixed; right: 18px; bottom: 18px; z-index: 49;
    box-shadow: 0 10px 30px -12px rgba(8,19,53,.5);
  }
  dialog.modal { max-width: none; width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; }
  .header-inner { padding: 0 20px; }
}
