/* REMOVE AUTO HEADING LINES */

:where(.markdown-rendered, .markdown-preview-view, .publish-renderer, .site-body)
  :is(h1, h2, h3, h4, h5, h6) {
  border-bottom: 0 !important;
  box-shadow: none !important;
  background-image: none !important;
  padding-bottom: 0 !important;
}

:where(.markdown-rendered, .markdown-preview-view, .publish-renderer, .site-body)
  :is(h1, h2, h3, h4, h5, h6)::before,
:where(.markdown-rendered, .markdown-preview-view, .publish-renderer, .site-body)
  :is(h1, h2, h3, h4, h5, h6)::after {
  content: none !important;
  border: 0 !important;
  box-shadow: none !important;
  background: none !important;
}

:where(.publish-renderer, .site-body) .page-header,
:where(.publish-renderer, .site-body) .page-header h1 {
  border: 0 !important;
  box-shadow: none !important;
  background-image: none !important;
  padding-bottom: 0 !important;
}

/* WHITE LINE */

.thin-line {
  border: none;
  height: 1.3px;
  background-color: currentColor;
  width: 20ch;
  margin: 1rem 0;
}

/* CANVAS: BASE GRID AND CARD STYLES */

.cm-editor .canvas-grid,
.canvas-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
  gap: 1rem !important;
  margin-top: 1rem !important;
}

.cm-editor .canvas-card,
.canvas-card {
  background-color: var(--background-secondary) !important;
  border-radius: 12px !important;
  padding: 1em !important;
  border: 2px solid var(--background-modifier-border) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

/* LEVEL COLOURS */

.canvas-card.level-1 {
  border-color: #1E90FF !important;
  background-color: rgba(30, 144, 255, 0.1) !important;
}

.canvas-card.level-2 {
  border-color: #9B30FF !important;
  background-color: rgba(155, 48, 255, 0.1) !important;
}

.canvas-card.level-3 {
  border-color: #FF4C4C !important;
  background-color: rgba(255, 76, 76, 0.1) !important;
}

.canvas-card.level-4 {
  border-color: #FF8C42 !important;
  background-color: rgba(255, 140, 66, 0.1) !important;
}

/* Stack level-2 cards under level-1 vertically */

.canvas-card.level-1 > .canvas-grid {
  grid-template-columns: 1fr !important;
}

/* Two-column layout for special panels */

.canvas-card.level-1.two-col > .canvas-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 1rem !important;
}

.canvas-card.level-1.two-col {
  width: 100% !important;
  margin: 1rem 0 !important;
}

/* TEXT ALIGNMENT */

.canvas-card.level-1,
.canvas-card.level-2,
.canvas-card.level-3 {
  text-align: center !important;
}

.canvas-card.level-4 {
  text-align: left !important;
}

/* CANVAS NOTE LINKS */

.callout[data-callout="rat-purple"] {
  background-color: rgba(156, 39, 176, 0.1);
  border: none;
  border-left: 4px solid #9C27B0;
  border-radius: 6px;
  padding: 0.75rem;
  margin: 1rem 0;
}

.callout[data-callout="rat-purple"] > .callout-title {
  display: none;
}

.callout[data-callout="rat-purple"] > .callout-content {
  padding: 0;
}

.callout[data-callout="rat-purple"] .callout-content h3:first-child {
  margin: 0 0 0.5rem 0;
  padding: 0;
  font-size: 1em;
  line-height: inherit;
  font-weight: var(--bold-weight);
}

.callout[data-callout="rat-purple"] .callout-content p {
  margin: 0;
}

/* NESTED CALLOUTS */

/* Purple wrapper */

.markdown-preview-view .my-purple,
.markdown-source-view .my-purple {
  border-left: 4px solid #9B30FF !important;
  background-color: rgba(155, 48, 255, 0.1) !important;
  padding: 12px !important;
  border-radius: 6px !important;
  margin: 16px 0 !important;
}

/* Red children directly inside purple */

.markdown-preview-view .my-purple > .my-red,
.markdown-source-view .my-purple > .my-red {
  border-left: 4px solid #FF4C4C !important;
  background-color: rgba(255, 76, 76, 0.1) !important;
  padding: 12px !important;
  border-radius: 6px !important;
  margin: 12px 0 0 16px !important;
}

/* Red wrapper */

.markdown-preview-view .my-red,
.markdown-source-view .my-red {
  border-left: 4px solid #FF4C4C !important;
  background-color: rgba(255, 76, 76, 0.1) !important;
  padding: 12px !important;
  border-radius: 6px !important;
  margin: 16px 0 !important;
}

/* Orange grandchildren inside red */

.markdown-preview-view .my-red > .my-orange,
.markdown-source-view .my-red > .my-orange,
.markdown-preview-view .my-red .my-orange,
.markdown-source-view .my-red .my-orange {
  border-left: 4px solid #FF8C42 !important;
  background-color: rgba(255, 140, 66, 0.1) !important;
  padding: 12px !important;
  border-radius: 6px !important;
  margin: 12px 0 0 16px !important;
}

/* NAVIGATION */

.nav-buttons {
  display: flex;
  justify-content: space-between;
  margin: 2rem 0;
}

.nav-buttons .internal-link {
  text-decoration: none;
  padding: 0.5em 1em;
  border-radius: 4px;
  border: 1px solid var(--background-modifier-border);
  background-color: var(--background-secondary);
  color: var(--text-normal);
}

.nav-buttons .internal-link:hover {
  background-color: var(--background-modifier-hover);
}

/* HANDWRITING SWAP */

img.theme-aware {
  filter: invert(0) hue-rotate(0deg);
  transition: filter 0.2s ease;
}

html[data-theme="dark"] img.theme-aware,
body.theme-dark img.theme-aware {
  filter: invert(1) hue-rotate(180deg);
}

/* HIDE REFERENCES */

.markdown-preview-view .footnotes,
.markdown-preview-view ol.references,
div.footnotes,
ol.references {
  display: none;
}

/* INDENT ATTRACTION */

.section-block {}

.sb-title {
  font-weight: 500;
  margin-bottom: 4px;
  margin-left: 1rem;
}

.sb-body {
  margin-left: 2rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--text-faint);
}

/* THEME */

:root {
  --font-editor-override: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Ubuntu, sans-serif;
  --font-interface: var(--font-editor-override);
  --font-text: var(--font-editor-override);
}

/* CAUTION TAPE */

:root {
  --caution-height: 8px;
  --caution-stripe: 14px;
  --caution-content-width: min(var(--file-line-width, 860px), 92vw);
  --sidebar-desktop: 300px;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-desktop: 0px;
  }
}

.markdown-preview-view.caution-frame,
.caution-frame .markdown-preview-view {
  position: relative;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* Top tape */

.markdown-preview-view.caution-frame::before,
.caution-frame .markdown-preview-view::before {
  content: "";
  display: block;
  height: var(--caution-height);
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  pointer-events: none;
  margin-bottom: 0.75rem;

  background-repeat: repeat;
  background-image: repeating-linear-gradient(
    45deg,
    #FFD400 0,
    #FFD400 var(--caution-stripe),
    #000 var(--caution-stripe),
    #000 calc(var(--caution-stripe) * 2)
  );
  background-position: 0 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.7);
}

/* Bottom tape */

.markdown-preview-view.caution-frame::after,
.caution-frame .markdown-preview-view::after {
  content: "";
  display: block;
  height: var(--caution-height);
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  pointer-events: none;
  margin-top: 0.75rem;

  background-repeat: repeat;
  background-image: repeating-linear-gradient(
    45deg,
    #FFD400 0,
    #FFD400 var(--caution-stripe),
    #000 var(--caution-stripe),
    #000 calc(var(--caution-stripe) * 2)
  );
  background-position: 0 0;
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}

/* Hide properties in reading view */

.markdown-preview-view .metadata-container {
  display: none !important;
}

/* REMOVE HEADING LINES */

.markdown-preview-view h1,
.markdown-preview-view h2,
.markdown-preview-view h3,
.markdown-preview-view h4,
.markdown-preview-view h5,
.markdown-preview-view h6 {
  margin-bottom: 0.5em;
  padding-bottom: 0;
}

/* WATERMARK REMOVAL */

.site-footer {
  display: none !important;
}

/* SIDEBAR DONATE BUTTON */

#rat-support-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  box-sizing: border-box !important;
  flex: 0 0 auto !important;
  align-self: flex-start !important;

  width: fit-content !important;
  height: auto !important;
  min-height: 0 !important;

  margin: 0 0 12px !important;
  padding: 4px 11px !important;

  border: 1px solid rgba(128, 128, 128, 0.25) !important;
  border-radius: 5px !important;

  background: rgba(128, 128, 128, 0.04) !important;
  color: #a88bfa !important;

  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 1.4 !important;
  text-decoration: none !important;

  box-shadow: none !important;
  cursor: pointer !important;

  transition:
    background-color 0.15s ease,
    border-color 0.15s ease !important;
}

#rat-support-button:hover {
  background: rgba(128, 128, 128, 0.10) !important;
  border-color: rgba(128, 128, 128, 0.45) !important;
  color: #a88bfa !important;
  text-decoration: none !important;
}

#rat-support-button:focus-visible {
  outline: 2px solid #a88bfa !important;
  outline-offset: 3px !important;
}

#rat-support-button:active {
  background: rgba(128, 128, 128, 0.15) !important;
  border-color: rgba(128, 128, 128, 0.55) !important;
}

/* MODAL */

#support-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
}

#support-modal.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* BACKDROP */

.support-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

/* MODAL BOX */

.support-modal-box {
  position: relative;
  z-index: 1;
  width: min(600px, calc(100vw - 30px));
  max-height: 92vh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 36px;
  background: #ffffff;
  color: #30313d;
  border: 1px solid #e6e6e6;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.20);
}

/* CLOSE BUTTON */

.support-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none !important;
  border-radius: 50%;
  outline: none !important;
  background: transparent !important;
  color: #6d6e78 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 27px;
  font-weight: 300;
  line-height: 1;
  box-shadow: none !important;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.support-modal-close:hover {
  background: #f3f3f5 !important;
  color: #30313d !important;
}

.support-modal-close:focus,
.support-modal-close:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  background: #f3f3f5 !important;
}

/* DONATION ENTRY */

.donation-entry {
  width: 100%;
  max-width: 410px;
  margin: 8px auto 0;
}

/* LABELS */

.donation-label {
  display: block;
  margin-bottom: 7px;
  color: #30313d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 500;
}

/* OPTIONAL FIELD SECTIONS */

.donation-field {
  margin-top: 14px;
}

.donation-field .donation-label {
  margin-bottom: 6px;
  color: #555762;
  font-size: 13px;
  font-weight: 500;
}

/* CURRENCY AND AMOUNT ROW */

.donation-input-row {
  display: flex;
  width: 100%;
  gap: 10px;
}

/* SHARED AMOUNT STYLING */

#donation-currency,
.donation-symbol,
#donation-amount {
  color: #30313d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 500;
}

/* CURRENCY DROPDOWN */

.donation-currency-select {
  flex: 0 0 100px;
}

#donation-currency {
  width: 100%;
  height: 48px;
  box-sizing: border-box;
  padding: 0 28px 0 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background-color: #ffffff;
  text-align: center;
  text-align-last: center;
  outline: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  appearance: auto;
  -webkit-appearance: auto;
}

#donation-currency:focus {
  border-color: #635bff;
  outline: none;
  box-shadow: 0 0 0 1px #635bff;
}

/* DONATION AMOUNT */

.donation-amount-wrapper {
  display: flex;
  flex: 1;
  align-items: center;
  height: 48px;
  box-sizing: border-box;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.donation-amount-wrapper:focus-within {
  border-color: #635bff;
  box-shadow: 0 0 0 1px #635bff;
}

.donation-symbol {
  flex-shrink: 0;
  padding-left: 14px;
  pointer-events: none;
}

#donation-amount {
  flex: 1;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0 14px 0 3px;
  border: none !important;
  border-radius: 0 !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  caret-color: #30313d;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

#donation-amount:hover,
#donation-amount:focus,
#donation-amount:focus-visible,
#donation-amount:active {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* NAME FIELD */

#donation-name,
.donation-text-input {
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  margin: 0;
  padding: 0 11px;
  border: 1px solid #e3e3e6 !important;
  border-radius: 6px !important;
  outline: none !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
  color: #30313d !important;
  -webkit-text-fill-color: #30313d !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025) !important;
  appearance: none;
  -webkit-appearance: none;
}

#donation-name:hover,
#donation-name:active {
  background: #ffffff !important;
  background-color: #ffffff !important;
}

#donation-name:focus,
#donation-name:focus-visible {
  border-color: #635bff !important;
  outline: none !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
  color: #30313d !important;
  -webkit-text-fill-color: #30313d !important;
  box-shadow: 0 0 0 1px #635bff !important;
}

/* MESSAGE FIELD */

#donation-message,
.donation-message-input {
  display: block;
  width: 100%;
  height: 76px;
  min-height: 76px;
  box-sizing: border-box;
  margin: 0;
  padding: 9px 11px;
  resize: vertical;
  border: 1px solid #e3e3e6 !important;
  border-radius: 6px !important;
  outline: none !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
  color: #30313d !important;
  -webkit-text-fill-color: #30313d !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025) !important;
  appearance: none;
  -webkit-appearance: none;
}

#donation-message:hover,
#donation-message:active {
  background: #ffffff !important;
  background-color: #ffffff !important;
}

#donation-message:focus,
#donation-message:focus-visible {
  border-color: #635bff !important;
  outline: none !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
  color: #30313d !important;
  -webkit-text-fill-color: #30313d !important;
  box-shadow: 0 0 0 1px #635bff !important;
}

/* ERROR MESSAGE */

.donation-error {
  min-height: 16px;
  margin: 5px 0 3px;
  color: #df1b41;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

/* CONTINUE BUTTON */

#donation-continue {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: #635bff;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(50, 50, 93, 0.10);
}

#donation-continue:hover {
  background: #5851e6;
}

#donation-continue:disabled {
  opacity: 0.65;
  cursor: default;
}

/* STRIPE EMBEDDED CHECKOUT */

#stripe-checkout {
  width: 100%;
  min-height: 300px;
}

/* MOBILE */

@media (max-width: 600px) {
  .support-modal-box {
    width: calc(100vw - 18px);
    max-height: 95vh;
    padding: 32px 18px 20px;
  }

  .donation-entry {
    max-width: none;
  }

  .donation-input-row {
    gap: 8px;
  }

  .donation-currency-select {
    flex-basis: 92px;
  }
}