/* ==========================================================================
   Paper "Ask AI" Framed Trigger + Swiss-Editorial Paper Assistant Drawer
   Shared across index.html (Selected Publications) & research/index.html.
   Explicit px units only (Bootstrap 3 sets html { font-size: 10px }).
   ========================================================================== */

/* Framed "Ask AI" Button in Paper Action Rows */
.article-entry .paper-ask-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 0 2px;
  padding: 2px 7px;
  border: 1px solid #cfc6b4;
  border-radius: 0;
  background: #faf6ec;
  color: #463f35;
  cursor: pointer;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.25;
  user-select: none;
  white-space: nowrap;
  vertical-align: middle;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.article-entry .paper-ask-ai-btn::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8C1515;
  flex-shrink: 0;
}

.article-entry .paper-ask-ai-btn:hover,
.article-entry .paper-ask-ai-btn:focus-visible,
.article-entry .paper-ask-ai-btn.is-active {
  color: #8C1515;
  border-color: #8C1515;
  background: #ffffff;
}

.article-entry .paper-ask-ai-btn:focus-visible {
  outline: 2px solid #0645ad;
  outline-offset: 2px;
}

/* Backdrop Overlay */
.paper-ai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1990;
  background: rgba(26, 24, 21, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.paper-ai-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Slide-Over Paper Assistant Drawer */
.paper-ai-drawer,
.paper-ai-drawer * {
  box-sizing: border-box;
}

.paper-ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  width: min(500px, 94vw);
  background: #f5f0e4;
  border-left: 1px solid #cfc6b4;
  box-shadow: -12px 0 36px rgba(26, 24, 21, 0.16);
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  color: #26221d;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

.paper-ai-drawer.is-open {
  transform: translateX(0);
}

/* Header */
.paper-ai-header {
  padding: 15px 20px 13px;
  border-bottom: 1px solid #dcd4c4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: #f5f0e4;
}

.paper-ai-kicker {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b6357;
  line-height: 1.2;
  margin: 0 0 2px;
}

.paper-ai-title {
  margin: 0;
  padding: 0;
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  color: #1a1815;
}

.paper-ai-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.paper-ai-mini-btn,
.paper-ai-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 10px;
  border-radius: 0;
  border: 1px solid #cfc6b4;
  background: transparent;
  color: #26221d;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.paper-ai-close-btn {
  width: 32px;
  padding: 0;
  font-size: 14px;
}

.paper-ai-mini-btn:hover,
.paper-ai-mini-btn:focus-visible,
.paper-ai-close-btn:hover,
.paper-ai-close-btn:focus-visible {
  color: #1a1815;
  border-color: #1a1815;
  background: #faf6ec;
  outline: none;
}

.paper-ai-mini-btn.is-active,
.paper-ai-mini-btn.is-configured {
  color: #8C1515;
  border-color: #8C1515;
  background: #faf6ec;
}

/* Active Paper Context Bar + Model Switcher */
.paper-ai-context-bar {
  padding: 10px 20px;
  border-bottom: 1px solid #dcd4c4;
  background: #faf6ec;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.paper-ai-context-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #6b6357;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paper-ai-context-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8C1515;
  flex-shrink: 0;
}

.paper-ai-context-venue {
  color: #6b6357;
  flex-shrink: 0;
}

.paper-ai-context-title {
  color: #1a1815;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paper-ai-model-switch {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.paper-ai-model-select {
  height: 30px;
  max-width: 158px;
  padding: 2px 8px;
  border-radius: 0;
  border: 1px solid #cfc6b4;
  background: #f5f0e4;
  color: #1a1815;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  text-overflow: ellipsis;
  transition: border-color 0.14s ease, color 0.14s ease;
}

.paper-ai-model-select:hover,
.paper-ai-model-select:focus-visible {
  border-color: #8C1515;
  color: #8C1515;
  outline: none;
}

/* Optional API Key Panel */
.paper-ai-settings-panel {
  padding: 14px 20px;
  border-bottom: 1px solid #dcd4c4;
  background: #faf6ec;
  display: none;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.paper-ai-settings-panel.is-open {
  display: flex;
}

.paper-ai-settings-note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #5c5549;
}

.paper-ai-settings-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.paper-ai-select,
.paper-ai-key-input {
  height: 34px;
  padding: 0 10px;
  border-radius: 0;
  border: 1px solid #cfc6b4;
  background: #f5f0e4;
  color: #1a1815;
  font-size: 12.5px;
  min-width: 0;
}

.paper-ai-select {
  flex: 1 1 180px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.paper-ai-key-input {
  flex: 1 1 190px;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

.paper-ai-settings-status {
  margin: 0;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #8C1515;
  min-height: 16px;
}

/* Scrollable Q&A Stream */
.paper-ai-stream {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Paper Reference Header Card inside Welcome */
.paper-ai-paper-card {
  padding: 12px 14px;
  background: #faf6ec;
  border: 1px solid #dcd4c4;
  border-left: 3px solid #8C1515;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.paper-ai-paper-card-title {
  margin: 0;
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  color: #1a1815;
}

.paper-ai-paper-card-meta {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: #5c5549;
}

.paper-ai-paper-card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 3px;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.paper-ai-paper-card-links a {
  color: #8C1515;
  text-decoration: none;
  font-weight: 500;
}

.paper-ai-paper-card-links a:hover,
.paper-ai-paper-card-links a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.paper-ai-welcome {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.paper-ai-welcome-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #3a352c;
}

.paper-ai-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paper-ai-section-label {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 500;
  color: #6b6357;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.paper-ai-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.paper-ai-chip {
  display: inline-flex;
  align-items: center;
  text-align: left;
  padding: 7px 11px;
  border-radius: 0;
  border: 1px solid #cfc6b4;
  background: transparent;
  color: #1a1815;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.paper-ai-chip:hover,
.paper-ai-chip:focus-visible {
  border-color: #8C1515;
  background: #faf6ec;
  color: #8C1515;
  outline: none;
}

/* Conversation Exchange */
.paper-ai-exchange {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid #dcd4c4;
}

.paper-ai-exchange:last-child {
  border-bottom: none;
  padding-bottom: 4px;
}

.paper-ai-user-q {
  padding: 10px 12px;
  border-left: 3px solid #8C1515;
  background: #faf6ec;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  color: #1a1815;
}

.paper-ai-answer-card {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.paper-ai-answer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #6b6357;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.paper-ai-live-banner {
  padding: 6px 10px;
  border-left: 2px solid #8C1515;
  background: #faf6ec;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #8C1515;
  line-height: 1.4;
}

.paper-ai-live-banner.is-muted {
  border-left-color: #cfc6b4;
  color: #6b6357;
}

.paper-ai-answer-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 14px;
  line-height: 1.58;
  color: #26221d;
}

.paper-ai-answer-body p {
  margin: 0;
}

.paper-ai-answer-body ul {
  margin: 0;
  padding-left: 18px;
  list-style: disc;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paper-ai-answer-body li {
  line-height: 1.5;
}

.paper-ai-answer-body code {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: #faf6ec;
  color: #1a1815;
  padding: 1px 4px;
  border-radius: 0;
}

.paper-ai-wiki-block {
  padding: 10px 12px;
  border-left: 2px solid #cfc6b4;
  background: #faf6ec;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  line-height: 1.5;
  color: #3a352c;
}

.paper-ai-wiki-block p {
  margin: 0;
}

.paper-ai-wiki-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.paper-ai-inline-link {
  color: #8C1515;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

.paper-ai-inline-link:hover,
.paper-ai-inline-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Related Paper Switch Pills */
.paper-ai-related {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.paper-ai-paper-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 0;
  border: 1px solid #cfc6b4;
  background: transparent;
  color: #1a1815;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.25;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}

.paper-ai-paper-pill-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paper-ai-paper-pill:hover,
.paper-ai-paper-pill:focus-visible {
  border-color: #8C1515;
  color: #8C1515;
  background: #faf6ec;
  outline: none;
}

/* 1-Click Default Model + Minimalist Expandable Model Switcher */
.paper-ai-handoff-block {
  padding-top: 9px;
  border-top: 1px solid #dcd4c4;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paper-ai-handoff-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.paper-ai-other-models {
  display: inline-block;
}

.paper-ai-other-models[open] {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paper-ai-other-summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  list-style: none;
  cursor: pointer;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #5c5549;
  user-select: none;
  padding: 4px 2px;
  transition: color 0.14s ease;
}

.paper-ai-other-summary::-webkit-details-marker {
  display: none;
}

.paper-ai-other-summary::before {
  content: "\25B8";
  display: inline-block;
  font-size: 11px;
  color: #8C1515;
  transition: transform 0.14s ease;
}

.paper-ai-other-models[open] > .paper-ai-other-summary::before {
  transform: rotate(90deg);
}

.paper-ai-other-summary:hover,
.paper-ai-other-summary:focus-visible {
  color: #1a1815;
}

.paper-ai-handoff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.paper-ai-handoff-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 30px;
  padding: 0 9px;
  border-radius: 0;
  border: 1px solid #cfc6b4;
  background: transparent;
  color: #26221d;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.paper-ai-handoff-btn:hover,
.paper-ai-handoff-btn:focus-visible {
  color: #1a1815;
  border-color: #1a1815;
  background: #faf6ec;
  text-decoration: none;
  outline: none;
}

.paper-ai-handoff-btn.is-primary {
  border-color: #8C1515;
  color: #8C1515;
  background: #faf6ec;
}

.paper-ai-handoff-btn.is-primary:hover,
.paper-ai-handoff-btn.is-primary:focus-visible {
  background: #8C1515;
  color: #ffffff;
}

/* Further Reading */
.paper-ai-reading-block {
  padding-top: 9px;
  border-top: 1px solid #dcd4c4;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paper-ai-reading-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paper-ai-reading-item {
  font-size: 12.5px;
  line-height: 1.45;
  color: #5c5549;
}

.paper-ai-reading-item a {
  color: #1a1815;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: #cfc6b4;
  text-underline-offset: 2px;
}

.paper-ai-reading-item a:hover,
.paper-ai-reading-item a:focus-visible {
  color: #8C1515;
  text-decoration-color: #8C1515;
}

.paper-ai-reading-tag {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: #6b6357;
  margin-right: 6px;
}

.paper-ai-loading-note {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #6b6357;
}

/* Sticky Composer Footer */
.paper-ai-composer {
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #cfc6b4;
  background: #f5f0e4;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.paper-ai-form {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 0;
}

.paper-ai-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  max-height: 108px;
  padding: 8px 11px;
  border-radius: 0;
  border: 1px solid #cfc6b4;
  background: #faf6ec;
  color: #1a1815;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
}

.paper-ai-input:focus {
  outline: none;
  border-color: #8C1515;
  background: #ffffff;
}

.paper-ai-submit-btn {
  padding: 0 16px;
  min-height: 40px;
  border-radius: 0;
  border: 1px solid #8C1515;
  background: #8C1515;
  color: #ffffff;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.14s ease;
}

.paper-ai-submit-btn:hover {
  opacity: 0.9;
}

.paper-ai-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: #6b6357;
}

.paper-ai-clear-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: #6b6357;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.paper-ai-clear-btn:hover {
  color: #1a1815;
}

@media (max-width: 640px) {
  .paper-ai-drawer {
    width: 100vw;
    max-width: 100vw;
    border-left: 0;
  }

  .paper-ai-header {
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  }

  .paper-ai-context-bar,
  .paper-ai-settings-panel,
  .paper-ai-stream {
    padding-left: 16px;
    padding-right: 16px;
  }

  .paper-ai-composer {
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .paper-ai-model-select {
    max-width: 132px;
    padding: 2px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .paper-ai-drawer,
  .paper-ai-backdrop {
    transition: none;
  }
}
