body {
  background-color: #f5f6f8;
  color: #212529;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

h1 {
  font-size: 1.3rem;
  font-weight: bold;
}

h2 {
  font-size: 1.2rem;
  font-weight: bold;
}

h3 {
  font-size: 1.1rem;
  font-weight: bold;
}

.navbar-brand {
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.navbar a.btn {
  font-weight: 600;
}

.main-content {
  padding-bottom: 4rem;
}

.main-content section + section {
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.icon-tile,
.step-card,
.security-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.icon-tile:hover,
.icon-tile:focus-within,
.step-card:hover,
.step-card:focus-within,
.security-card:hover,
.security-card:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 1.25rem 2.5rem rgba(15, 60, 130, 0.12);
  background-color: #f8faff;
}

.security-card {
  background-color: #f8f9fb;
}

.badge.text-bg-light {
  background-color: rgba(13, 110, 253, 0.08) !important;
  color: #0d3d8f;
  letter-spacing: 0.04em;
}

footer .nav-link {
  color: rgba(33, 37, 41, 0.65);
}

footer .nav-link:hover,
footer .nav-link:focus {
  color: #0d6efd;
}

.border-dashed {
  border-style: dashed !important;
}

.file-dropzone {
  border-color: rgba(13, 110, 253, 0.35);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.file-dropzone.is-dragover {
  background-color: #e9f3ff;
  border-color: #0d6efd;
  color: #0d6efd;
}

#narrative-attachments {
  position: sticky;
  top: 1rem;
  align-self: flex-start;
  max-height: calc(100vh - 1.5rem);
  overflow-y: auto;
  padding-bottom: 0.5rem;
}

#narrative-attachments.is-dragover {
  outline: 2px dashed rgba(13, 110, 253, 0.5);
  border-radius: 0.75rem;
  background-color: rgba(13, 110, 253, 0.06);
  transition: background-color 120ms ease, outline-color 120ms ease;
}

#narrative-attachments .narrative-drop-overlay {
  position: absolute;
  inset: 0;
  border-radius: 0.75rem;
  background-color: rgba(13, 110, 253, 0.85);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

#narrative-attachments .narrative-drop-overlay i,
#narrative-attachments .narrative-drop-overlay p,
#narrative-attachments .narrative-drop-overlay small {
  color: #fff;
}

#narrative-attachments.is-dragover .narrative-drop-overlay {
  opacity: 1;
}

.attachments-sortable [data-attachment-item] {
  cursor: grab;
}

.attachments-sortable [data-attachment-item].is-dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.fact-content {
  white-space: pre-wrap;
  display: block;
  width: 100%;
  height: auto;
}

.fact-attachment,
.attachment {
  margin: 0 0.2rem;
  font-weight: 600;
  display: inline-block;
}

.mention-suggestions {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 0.25rem;
  display: none;
}

.mention-suggestions.is-visible {
  display: block;
}

.attachment[data-attachment-chip='true'] {
  background-color: rgba(13, 110, 253, 0.08);
  border-radius: 0.35rem;
  padding: 0.1rem 0.35rem;
  cursor: default;
}

.attachment[data-attachment-chip='true'].is-selected {
  background-color: rgba(255, 159, 67, 0.25);
  outline: 2px solid rgba(255, 159, 67, 0.6);
}

.upload-progress .progress {
  height: 0.75rem;
}

.rich-editor-wrapper {
  display: flex;
  padding: 0;
  min-height: 220px;
}

.rich-editor-wrapper.form-control {
  padding: 0;
}

.rich-editor-wrapper:focus-within {
  box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.25);
  border-color: #0d6efd;
}

.rich-editor[contenteditable="true"] {
  position: relative;
  flex: 1;
  min-height: 220px;
  outline: none;
  overflow-y: auto;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border: 0;
  background-color: transparent;
  font-size: 0.9375rem;
  line-height: 1.5;
  white-space: normal;
}

.rich-editor[contenteditable="true"]:focus {
  box-shadow: none;
  border-color: transparent;
}

.rich-editor.is-empty::before {
  content: attr(data-placeholder);
  color: rgba(33, 37, 41, 0.55);
  pointer-events: none;
}

#narrative-format-buttons {
  position: sticky;
  top: 4rem;
  z-index: 1040; /* above editor content */
  background-color: #fff;
  padding: 0.5rem 0;
  margin-bottom: 0.25rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.1rem;
  box-shadow: 0 0.35rem 1rem rgba(15, 60, 130, 0.06);
  padding: 10px;
}

.rich-editor-form {
  position: relative;
}

.rich-editor p {
  margin-top: 0;
  margin-bottom: 0;
}

.rich-editor li > p {
  margin-top: 0;
  margin-bottom: 0;
}

.attachment-mention {
  background-color: #f1f3f5;
  border: 1px solid #e1e3e5;
  color: #212529;
  font-weight: 600;
  cursor: pointer;
  user-select: text;
  font-size: inherit;
  line-height: inherit;
  font-weight: 600;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.45rem;
  border-radius: 0.3rem;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.attachment-mention:hover {
  background-color: #ffcf9e;
  border-color: #ffb566;
  color: #1f1f1f;
}

.attachment-title {
  display: inline-block;
  max-width: 24rem;
  vertical-align: middle;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.narrative-toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.narrative-toc li {
  margin: 0.15rem 0;
}
.narrative-toc .toc-h1 {
  margin-left: 0;
}
.narrative-toc .toc-h2 {
  margin-left: 1rem;
}
.narrative-toc .toc-h3 {
  margin-left: 1.5rem;
}
.narrative-toc a {
  color: inherit;
  text-decoration: none;
}
.narrative-toc a:hover {
  text-decoration: underline;
}
.narrative-toc-panel a {
  color: inherit;
  text-decoration: none;
}
.narrative-toc-panel a:hover {
  text-decoration: underline;
}
.highlight-yellow {
  background-color: #fff3cd;
  padding: 0 0.05em;
}

#narrative-format-buttons [data-rich-action="highlight"] .bi-highlighter {
  color: #f5c400;
}

.story-done .fw-semibold,
.story-done .story-desc {
  color: rgba(181, 181, 181, 1) !important;
  text-decoration: line-through;
}

.narrative-assertion {
  transition: background-color 120ms ease;
  position: relative;
}

.narrative-assertion:hover {
  background-color: #e7f3ff;
}

.narrative-assertion-btn {
  margin-left: 0.35rem;
  padding: 0.125rem 0.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  border-width: 1px;
  font-size: 0.85em;
  position: absolute;
  top:0;
  right: 0;
  background-color: white;  
}

.narrative-assertion-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  min-width: 14rem;
  z-index: 5;
}
.narrative-toc-toggle {
  position: fixed;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: left top;
  z-index: 2000;
  box-shadow: 0 0.35rem 1rem rgba(15, 60, 130, 0.1);
}
.narrative-toc-panel {
  position: fixed;
  left: 3.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 0.5rem;
  padding: 0.75rem 0.75rem 0.5rem 0.75rem;
  box-shadow: 0 0.75rem 2rem rgba(0,0,0,0.12);
  z-index: 2001;
}
.narrative-toc-panel .close-btn {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
}

@media print {
  /* Force colors and backgrounds to be kept by the browser print engine */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body {
    background: #f5f6f8 !important;
    color: #212529 !important;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif !important;
    font-size: 1rem !important;
    line-height: 1.6 !important;
  }
  h1 {
    font-size: 1.3rem !important;
    font-weight: bold !important;
  }
  h2 {
    font-size: 1.2rem !important;
    font-weight: bold !important;
  }
  h3 {
    font-size: 1.1rem !important;
    font-weight: bold !important;
  }
  .attachment-mention {
    background-color: #f1f3f5 !important;
    border: 1px solid #cdd0d4 !important;
    color: #212529 !important;
    border-radius: 0.3rem;
    padding: 0.1rem 0.45rem;
  }
  .rich-editor,
  .narrative-assertion {
    background: #fff !important;
    color: #212529 !important;
  }
  .narrative-assertion {
    page-break-inside: avoid;
  }
  /* Hide purely interactives in print */
  #narrative-format-buttons,
  .narrative-assertion-btn,
  .narrative-assertion-menu,
  .btn,
  .dropdown-menu {
    display: none !important;
  }
}
