.onebox {
  max-width: 720px;
  margin: 1.5rem 0;
  border: 1px solid rgba(108, 117, 125, 0.28);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bs-body-bg, #fff);
  box-shadow: 0 10px 28px rgba(33, 37, 41, 0.08);
}

.onebox .source {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(108, 117, 125, 0.18);
  font-size: 0.85rem;
  color: var(--bs-secondary-color, #6c757d);
}

.onebox .site-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  flex: 0 0 auto;
}

.onebox a {
  color: inherit;
  text-decoration: none;
}

.onebox a:hover {
  text-decoration: underline;
}

.onebox-body {
  display: grid;
  grid-template-columns: minmax(140px, 32%) 1fr;
  grid-template-rows: auto 1fr;
  gap: 0.35rem 1rem;
  padding: 1rem;
}

.onebox .thumbnail {
  grid-row: 1 / 3;
  grid-column: 1;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  background: rgba(108, 117, 125, 0.12);
}

.onebox h3 {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.25;
  border-bottom: 0;
}

.onebox p {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  color: var(--bs-secondary-color, #495057);
  line-height: 1.45;
}

.quarto-dark .onebox {
  border-color: rgba(173, 181, 189, 0.22);
  background: #212529;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

.quarto-dark .onebox .source {
  border-bottom-color: rgba(173, 181, 189, 0.16);
}

.quarto-dark .onebox p {
  color: #ced4da;
}

@media (max-width: 560px) {
  .onebox-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .onebox .thumbnail,
  .onebox h3,
  .onebox p {
    grid-column: 1;
    grid-row: auto;
  }
}


.ai-discussion {
  --ai-chat-border: rgba(108, 117, 125, 0.28);
  --ai-chat-shadow: rgba(33, 37, 41, 0.08);
  --ai-chat-bg: rgba(248, 249, 250, 0.88);
  --ai-query-bg: #e7f1ff;
  --ai-query-border: rgba(13, 110, 253, 0.26);
  --ai-answer-bg: #f1f3f5;
  --ai-answer-border: rgba(73, 80, 87, 0.22);
  --ai-label-color: #6c757d;

  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 760px;
  margin: 2rem auto;
  padding: 1rem;
  border: 1px solid var(--ai-chat-border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0)),
    var(--ai-chat-bg);
  box-shadow: 0 12px 30px var(--ai-chat-shadow);
}

.ai-query,
.ai-answer {
  position: relative;
  max-width: min(88%, 36rem);
  padding: 1.6rem 1rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 8px;
  line-height: 1.45;
}

.ai-query {
  align-self: flex-end;
  border-color: var(--ai-query-border);
  background: var(--ai-query-bg);
}

.ai-answer {
  align-self: flex-start;
  border-color: var(--ai-answer-border);
  background: var(--ai-answer-bg);
}

.ai-query::before,
.ai-answer::before {
  position: absolute;
  top: 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--ai-label-color);
}

.ai-query::before {
  right: 1rem;
  content: "User";
}

.ai-answer::before {
  left: 1rem;
  content: "AI";
}

.ai-query > :last-child,
.ai-answer > :last-child {
  margin-bottom: 0;
}

.ai-query > :first-child,
.ai-answer > :first-child {
  margin-top: 0;
}

.quarto-dark .ai-discussion {
  --ai-chat-border: rgba(173, 181, 189, 0.22);
  --ai-chat-shadow: rgba(0, 0, 0, 0.34);
  --ai-chat-bg: rgba(33, 37, 41, 0.72);
  --ai-query-bg: #12345b;
  --ai-query-border: rgba(110, 168, 254, 0.34);
  --ai-answer-bg: #2b3035;
  --ai-answer-border: rgba(206, 212, 218, 0.18);
  --ai-label-color: #adb5bd;
}

.cr-section .narrative-col .trigger {
  padding-inline: clamp(0.75rem, 3vw, 1.5rem);
}

.cr-section .narrative-col .trigger .narrative {
  max-width: 32rem;
  border: 1px solid rgba(108, 117, 125, 0.24);
  border-left: 4px solid #0d6efd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(33, 37, 41, 0.08);
}

.cr-section .narrative-col .trigger.new-trigger .narrative {
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.cr-section .narrative-col .trigger.new-trigger .narrative:hover {
  border-left-color: #198754;
  box-shadow: 0 14px 34px rgba(33, 37, 41, 0.12);
  transform: translateY(-1px);
}

.cr-section .sticky-col .map-container {
  width: min(100%, 850px);
  margin-inline: auto;
  border: 1px solid rgba(108, 117, 125, 0.28);
  border-radius: 8px;
  background: #f8f9fa;
  box-shadow: 0 14px 36px rgba(33, 37, 41, 0.1);
}

.cr-section .sticky-col .sticky {
  width: 100%;
}

.cr-section .sticky-col .sticky > .cell,
.cr-section .sticky-col .sticky .cell-output-display,
.cr-section .sticky-col .sticky [id^="ojs-cell-"],
.cr-section .sticky-col .sticky .observablehq {
  width: 100%;
}

.konig-map-section {
  --konig-sticky-height: calc(100dvh - 78px);
  grid-template-columns: 1fr !important;
  margin-block: 2rem;
  background: transparent;
}

.konig-map-section .sticky-col {
  grid-column: 1 !important;
  grid-row: 1;
  min-height: var(--konig-sticky-height);
}

.konig-map-section .sticky-col .sticky-col-stack {
  display: flex;
  align-items: center;
  justify-content: center;
  top: 78px;
  height: var(--konig-sticky-height);
  min-height: var(--konig-sticky-height);
  background: transparent;
}

.konig-map-section .sticky-col .sticky {
  width: 100%;
  height: auto;
  margin: 0;
}

.konig-map-section .sticky-col .sticky > .cell,
.konig-map-section .sticky-col .sticky .cell-output-display,
.konig-map-section .sticky-col .sticky .cell-output-display > div,
.konig-map-section .sticky-col .sticky [id^="ojs-cell-"],
.konig-map-section .sticky-col .sticky .observablehq {
  height: auto;
}

.konig-map-section .sticky-col .map-container {
  width: min(100%, calc(var(--konig-sticky-height) * 4096 / 3351));
  max-width: none !important;
  height: auto;
  max-height: var(--konig-sticky-height);
  aspect-ratio: 4096 / 3351 !important;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #212529;
}

.konig-map-section .narrative-col {
  grid-column: 1 !important;
  grid-row: 1;
  z-index: 2;
  width: min(34rem, calc(100% - 2rem));
  max-width: none;
  justify-self: start;
  margin-left: clamp(1rem, 6vw, 5rem);
  pointer-events: none;
}

.konig-map-section .narrative-col .trigger {
  min-height: var(--konig-sticky-height);
  display: flex;
  align-items: center;
  padding-block: 0;
  padding-inline: 0;
}

.konig-map-section .narrative-col .trigger .narrative {
  pointer-events: auto;
  color: #f8f9fa;
  border-color: rgba(248, 249, 250, 0.2);
  border-left-color: rgba(248, 249, 250, 0.42);
  background: rgba(112, 128, 144, 0.62);
  backdrop-filter: blur(6px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.quarto-dark .cr-section .narrative-col .trigger .narrative {
  border-color: rgba(173, 181, 189, 0.22);
  border-left-color: #6ea8fe;
  background: rgba(33, 37, 41, 0.9);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.quarto-dark .cr-section .narrative-col .trigger.new-trigger .narrative:hover {
  border-left-color: #75b798;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

.quarto-dark .cr-section .sticky-col .map-container {
  border-color: rgba(173, 181, 189, 0.22);
  background: #212529;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

.quarto-dark .konig-map-section .narrative-col .trigger .narrative {
  color: #f8f9fa;
  border-color: rgba(248, 249, 250, 0.2);
  border-left-color: rgba(248, 249, 250, 0.42);
  background: rgba(112, 128, 144, 0.62);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.quarto-dark .konig-map-section .sticky-col .map-container,
.konig-map-section .sticky-col .map-container {
  border: 0;
  box-shadow: none;
  background: transparent;
}

.quarto-dark .konig-map-section .sticky-col .map-container {
  color: #f8f9fa;
}

@media (max-width: 520px) {
  .ai-discussion {
    margin-inline: 0;
    padding: 0.75rem;
  }

  .ai-query,
  .ai-answer {
    max-width: 100%;
  }

  .konig-map-section .narrative-col {
    width: calc(100% - 1.5rem);
    margin-inline: auto;
  }
}
