:root {
  --base03: #002b36;
  --base02: #073642;
  --base01: #586e75;
  --base00: #657b83;
  --base0: #839496;
  --base1: #93a1a1;

  --yellow: #b58900;
  --orange: #cb4b16;
  --red: #dc322f;
  --magenta: #d33682;
  --violet: #6c71c4;
  --blue: #268bd2;
  --black: #000000;
  --white: #eee;
  --cyan: #2aa198;
  --green: #859900;

  --postit-white-bg: #fdf6e3;
  --postit-white-text: #586e75;
  --postit-transp-bg: #99999922;
  --theme-main-background: var(--base03);
  --theme-editor-background: var(--base02);
  --theme-primary-text: var(--base1);
  --theme-secondary-text: var(--base01);
  --theme-border-color: var(--base01);

  --theme-schema-line-color: var(--orange);
  --theme-schema-text-color: var(--cyan);

  --theme-modal-background: var(--base02);
  --theme-modal-overlay-bg: rgba(0, 0, 0, 0.75);
  --theme-modal-text-primary: var(--base1);
  --theme-modal-text-secondary: var(--base0);
  --theme-modal-button-confirm-bg: var(--red);
  --theme-modal-button-confirm-text: var(--base03);
  --theme-modal-button-cancel-bg: var(--base01);
  --theme-modal-button-cancel-text: var(--base03);
  --theme-modal-button-cancel-hover-bg: var(--base00);

  --theme-postit-yellow-text: var(--base03);
  --theme-postit-red-text: var(--base03);
  --theme-postit-green-text: var(--base03);
  --theme-postit-blue-text: var(--base03);
  --theme-postit-white-text: var(--postit-white-text);
  --theme-postit-transp-text: var(--yellow);

  --theme-postit-yellow-drag-handle: var(--base02);
  --theme-postit-red-drag-handle: var(--base03);
  --theme-postit-green-drag-handle: var(--base02);
  --theme-postit-blue-drag-handle: var(--base03);
  --theme-postit-white-drag-handle: var(--base01);
}

/* CSS-Only Theme Toggle for Static Export === */

#theme-toggle-export {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  top: 0.5em;
}

/* The visible toggle switch label */
.theme-toggle-label {
  cursor: pointer;
  position: fixed;
  top: 3em;
  right: 3em;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: space-between; /* Pushes icons to the edges */
  width: 48px; /* Slightly wider to accommodate icons */
  height: 22px;
  padding: 0 4px; /* Padding for icons */
  background-color: transparent;
  border: 1.5px solid var(--base01);
  border-radius: 24px;
  transition: border-color 0.3s ease-in-out;
}

/* The nub of the switch */
.theme-toggle-label::after {
  content: "";
  position: absolute;
  width: 18px; /* Adjusted nub size */
  height: 18px;
  border-radius: 50%;
  top: 2px;
  left: 3px; /* Initial position */
  background-color: var(--base01);
  transition:
    transform 0.2s ease-in-out,
    background-color 0.3s ease-in-out;
  z-index: 1; /* Ensure nub is above icon area background */
}

/* Base styles for both icons */
.theme-toggle-label .sun-light,
.theme-toggle-label .half-moon {
  font-size: 16px;
  line-height: 24px; /* Center vertically */
  color: var(--base01);
  transition:
    opacity 0.2s ease-in-out,
    color 0.3s ease-in-out;
}

/* For DARK theme export (starts with Sun visible on the right) */
body:not(.light-theme) .sun-light {
  left: 5px;
  opacity: 1;
  transform: translateX(28px);
  color: white;
}
body:not(.light-theme) .half-moon {
  right: 5px;
  opacity: 0;
  transform: translateX(0px);
}

body:not(.light-theme)
  #theme-toggle-export:checked
  ~ .theme-toggle-label
  .sun-light {
  opacity: 0;
  transform: translateX(0px);
}
body:not(.light-theme)
  #theme-toggle-export:checked
  ~ .theme-toggle-label
  .half-moon {
  opacity: 1;
  transform: translateX(-30px);
  color: black;
}

/* For LIGHT theme export (starts with Moon visible on the left) */
body.light-theme .sun-light {
  left: 5px;
  opacity: 0;
  transform: translateX(0px);
}
body.light-theme .half-moon {
  right: 5px;
  opacity: 1;
  transform: translateX(-2px);
  color: black;
}

body.light-theme #theme-toggle-export:checked ~ .theme-toggle-label .sun-light {
  opacity: 1;
  transform: translateX(0);
  color: white;
}
body.light-theme #theme-toggle-export:checked ~ .theme-toggle-label .half-moon {
  opacity: 0;
  transform: translateX(10px);
}

/* --- NUB MOVEMENT --- */
#theme-toggle-export:checked + .theme-toggle-label::after {
  transform: translateX(30px); /* Moves the nub to the right */
}

/* --- THEME OVERRIDE LOGIC (Unchanged from previous correct version) --- */
.pinta-static-container {
  background-color: var(--theme-main-background);
  color: var(--theme-primary-text);
  position: absolute;
  top: 0;
  left: 0;
  min-height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition:
    background-color 0.3s,
    color 0.3s;
}

body.light-theme #theme-toggle-export:checked ~ .pinta-static-container {
  --theme-main-background: var(--base03);
  --theme-editor-background: var(--base02);
  --theme-primary-text: var(--base1);
  --theme-secondary-text: var(--base01);
  --theme-border-color: var(--base01);
  --theme-schema-line-color: var(--orange);
  --theme-schema-text-color: var(--cyan);
}

body:not(.light-theme) #theme-toggle-export:checked ~ .pinta-static-container {
  /* TODO: this is not exactly the same as the light theme below */
  --theme-main-background: #999;
  --theme-editor-background: #aaa;
  --theme-primary-text: #1c1c1c;
  --theme-secondary-text: #4a4a4a;
  --theme-border-color: #c0c0c0;

  --theme-schema-line-color: #333;
  --theme-schema-text-color: #333;

  --theme-modal-background: #ffffff;
  --theme-modal-overlay-bg: rgba(50, 50, 50, 0.6);
  --theme-modal-text-primary: #1c1c1c;
  --theme-modal-text-secondary: #4a4a4a;

  --theme-modal-button-confirm-text: #ffffff;
  --theme-modal-button-cancel-bg: #e0e0e0;
  --theme-modal-button-cancel-text: #1c1c1c;
  --theme-modal-button-cancel-hover-bg: #d0d0d0;

  --theme-postit-yellow-text: #1c1c1c;
  --theme-postit-red-text: #ffffff;
  --theme-postit-green-text: #1c1c1c;
  --theme-postit-blue-text: #ffffff;
  --theme-postit-white-text: #1c1c1c;
  --theme-postit-transp-text: #1c1c1c;

  --theme-postit-yellow-drag-handle: var(--base01);
  --theme-postit-red-drag-handle: var(--postit-white-bg);
  --theme-postit-green-drag-handle: var(--base01);
  --theme-postit-blue-drag-handle: var(--postit-white-bg);
  --theme-postit-white-drag-handle: var(--base01);

  /* Color overrides */
  --yellow: #754900;
  --orange: #a93a16;
}
/* Magic ends */

body.light-theme {
  --theme-main-background: #999;
  --theme-editor-background: #aaa;
  --theme-primary-text: #1c1c1c;
  --theme-secondary-text: #4a4a4a;
  --theme-border-color: #c0c0c0;

  --theme-schema-line-color: #333;
  --theme-schema-text-color: #333;

  --theme-modal-background: #ffffff;
  --theme-modal-overlay-bg: rgba(50, 50, 50, 0.6);
  --theme-modal-text-primary: #1c1c1c;
  --theme-modal-text-secondary: #4a4a4a;

  --theme-modal-button-confirm-text: #ffffff;
  --theme-modal-button-cancel-bg: #e0e0e0;
  --theme-modal-button-cancel-text: #1c1c1c;
  --theme-modal-button-cancel-hover-bg: #d0d0d0;

  --theme-postit-yellow-text: #1c1c1c;
  --theme-postit-red-text: #ffffff;
  --theme-postit-green-text: #1c1c1c;
  --theme-postit-blue-text: #ffffff;
  --theme-postit-white-text: #1c1c1c;
  --theme-postit-transp-text: #1c1c1c;

  --theme-postit-yellow-drag-handle: var(--base01);
  --theme-postit-red-drag-handle: var(--postit-white-bg);
  --theme-postit-green-drag-handle: var(--base01);
  --theme-postit-blue-drag-handle: var(--postit-white-bg);
  --theme-postit-white-drag-handle: var(--base01);

  /* Color overrides */
  --yellow: #754900;
  --orange: #a93a16;
}

body {
  margin: 0;
  font-family: "Inter";
  background-color: var(--theme-main-background);
  color: var(--theme-primary-text);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;

  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

#info {
  position: absolute;
  right: 2em;
  top: 2em;
  opacity: 1;
  transition: opacity 3s ease-in-out;
  line-height: 1.5;
  font-weight: 100;
  min-height: fit-content;
  min-width: fit-content;
  overflow: auto;
  font-family: "monoidregular" !important;
  z-index: -10000;
}

.fades {
  opacity: 0 !important;
  color: var(--theme-primary-text) !important;
  /* I liked the looks of these gradients here: https://codersblock.com/blog/playing-with-infinity-in-css/ */
  background: var(--theme-modal-background)
    linear-gradient(45deg, #0006, transparent);
  border: 1px solid var(--theme-border-color);
  border-radius: 5px;
  padding: 1em;
  z-index: 10000 !important;
}

#editor-container {
  aspect-ratio: 4 / 3;
  width: 98vw;
  max-height: 98vh;
  margin: auto;
  background-color: var(--theme-editor-background);
  border: 1px solid var(--theme-border-color);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  transform-origin: 0 0;
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
#drawingCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  pointer-events: none;
}

#drawingCanvas > * {
  pointer-events: all;
}

.line-element-group {
  position: absolute;
  transform-origin: 0 0;
  z-index: 10;
}
.line-visual {
  width: 100%;
  background-color: var(--theme-schema-line-color);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  cursor: crosshair;
  border-radius: 2px;
  background-clip: padding-box;
  border-top: 0.5em solid transparent;
  border-bottom: 0.5em solid transparent;
  filter: drop-shadow(2px 2px 2px #00000077);
}

.light-theme .line-visual {
  filter: drop-shadow(1px 1px 2px #00000099);
}

.line-text {
  position: absolute;
  white-space: pre-wrap;
  color: var(--theme-schema-text-color);
  font-size: 13px;
  /* TODO add this as a setting */
  padding: 1px 2px;
  background-color: transparent;
  border: none;
  user-select: none;
  white-space: pre-wrap;
  min-width: 10px;
  text-align: center;
}
.line-text[contenteditable="true"] {
  background-color: var(--theme-editor-background);
  border: 1px dashed var(--blue);
  color: var(--theme-primary-text);
  user-select: text;
  cursor: auto;
  outline: none;
}

.shadow {
  filter: drop-shadow(0.15em 0.15em 0.15em #00000077);
}

.light-theme .shadow {
  filter: drop-shadow(0.07em 0.07em 0.02em #00000088);
}

.handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  z-index: 15;
  display: none;
  background-clip: padding-box; /* Ensure background does not leak into transparent border*/
  border: 0.5em solid transparent; /* Increase size of hover area for handle */
}
.resize-handle {
  background-color: var(--blue);
  cursor: ns-resize;
  left: 100%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.root-drag-handle {
  background-color: var(--red);
  cursor: ew-resize;
  left: 0%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.delete-handle {
  color: var(--red);
  background-color: transparent;
  font-size: 14px;
  line-height: 10px;
  text-align: center;
  font-family: monospace;
  font-weight: bold;
  cursor: pointer;
  left: 30%;
  top: 0px;
  width: auto;
  height: auto;
  padding: 0 2px;
  border-radius: 0;
  z-index: 100;
}
.line-element-group:hover .handle {
  display: flex;
  justify-content: center;
  align-items: center;
}
.handle.dragging {
  display: flex !important;
}
.resize-handle.dragging {
  background-color: #1a6a9e;
}
.root-drag-handle.dragging {
  background-color: #a71e1c;
}
.delete-handle:hover {
  color: #a71e1c;
}

.line-selected .line-visual {
  filter: drop-shadow(0 0 3px var(--yellow));
}

.selection-trail {
  position: absolute;
  width: 5px;
  height: 5px;
  background-color: var(--yellow);
  border-radius: 50%;
  pointer-events: none;
  animation: fade-out-trail 1s forwards;
  z-index: 9999;
}

@keyframes fade-out-trail {
  to {
    opacity: 0;
    transform: scale(0);
  }
}

.line-text-wrapper {
  display: inline;
}

span.year {
  vertical-align: super;
  font-size: 70%;
  filter: hue-rotate(-30deg);
  margin-left: 0.2em;
}

span.month {
  vertical-align: super;
  font-size: 70%;
  filter: hue-rotate(-35deg) saturate(0.8);
  margin-left: 0.1em;
}

span.day {
  vertical-align: super;
  font-size: 70%;
  filter: hue-rotate(-40deg) saturate(0.8);
  margin-left: 0.1em;
}

.link-icon-clickable > div {
  font-size: 150%;
  display: inline-block;
  vertical-align: bottom;
  filter: hue-rotate(60deg);
  cursor: pointer;
}

.link-icon-nonclickable > div {
  font-size: 150%;
  display: inline-block;
  vertical-align: bottom;
  filter: hue-rotate(15deg);
}

/* Special for export */

.pinta-static-container .link-icon-nonclickable {
  margin-right: 0.25em;
}

.pinta-static-container .link-icon-clickable {
  margin-right: 0.25em;
}

.line-text em {
  filter: hue-rotate(60deg);
}

.line-text strong {
  filter: hue-rotate(60deg);
}

.line-text code {
  filter: hue-rotate(-90deg);
}

.line-text .highlight {
  filter: hue-rotate(180deg);
}

.post-it {
  position: absolute;
  z-index: 500;
  padding: 20px 8px 8px 8px;
  border-radius: 3px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
  min-width: 100px;
  min-height: 50px;
  font-family: "Inter", sans-serif;
  font-size: 11px;
  color: var(--base1);
  word-wrap: break-word;
  overflow: hidden;
  cursor: default;
  touch-action: none;
  box-sizing: border-box;
  outline: none;
  display: flex;
  flex-direction: column;
}
.postit-drag-handle {
  position: absolute;
  top: 0px;
  left: 0px;
  width: calc(100% - 20px);
  height: 18px;
  cursor: grab;
  display: flex;
  align-items: center;
  padding-left: 5px;
  box-sizing: border-box;
  z-index: 502;
  font-size: 10px;
  color: var(--base00);
}
.postit-drag-handle:active {
  cursor: grabbing;
}
.postit-delete-button {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  font-size: 12px;
  z-index: 503;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0);
  color: var(--red);
  border: none;
  cursor: pointer;
  text-align: center;
  opacity: 0.7;
}
.post-it:hover .postit-delete-button {
  opacity: 1;
}
.postit-delete-button:hover {
  background-color: rgba(220, 50, 50, 0.3);
}
.postit-content-area {
  flex-grow: 1;
  outline: none;
  cursor: text;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: 2px;
  overflow-y: auto;
  color: inherit;
}
.postit-content-area[contenteditable="true"] {
  border: none;
}
.postit-content-area a {
  color: var(--blue);
  text-decoration: underline;
}
.postit-content-area a:hover {
  color: var(--cyan);
}
.postit-color-yellow {
  background-color: var(--yellow);
  color: var(--base03);
}
.postit-color-red {
  background-color: var(--red);
  color: var(--base03);
}
.postit-color-green {
  background-color: var(--green);
  color: var(--base03);
}
.postit-color-blue {
  background-color: var(--blue);
  color: var(--base03);
}
.postit-color-white {
  background-color: var(--postit-white-bg);
  color: #333;
}

.postit-color-transp-0 {
  background-color: var(--postit-transp-bg);
  backdrop-filter: blur(1px);
  color: var(--theme-postit-transp-text);
}

.postit-color-transp-1 {
  background-color: var(--postit-transp-bg);
  backdrop-filter: blur(2px);
  color: var(--theme-postit-transp-text);
}

.postit-color-transp-2 {
  background-color: var(--postit-transp-bg);
  backdrop-filter: blur(4px);
  color: var(--theme-postit-transp-text);
}

.postit-color-yellow .postit-drag-handle {
  color: var(--base02);
}
.postit-color-red .postit-drag-handle {
  color: var(--base03);
}
.postit-color-green .postit-drag-handle {
  color: var(--base02);
}
.postit-color-blue .postit-drag-handle {
  color: var(--base03);
}
.postit-color-white .postit-drag-handle {
  color: var(--base01);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--theme-modal-overlay-bg);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-content {
  background-color: var(--theme-modal-background);
  color: var(--theme-modal-text-secondary);
  padding: 25px;
  border-radius: 8px;
  border: 1px solid var(--theme-border-color);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  width: 90%;
  max-width: 400px;
  text-align: center;
}
.modal-content h3 {
  margin-top: 0;
  font-size: 1.25rem;
  color: var(--theme-modal-text-primary);
}
.modal-content p {
  margin-bottom: 20px;
  color: var(--base0);
  font-size: 0.9rem;
}
.modal-buttons button {
  padding: 10px 15px;
  margin: 0 10px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
}
.modal-confirm-button {
  background-color: var(--theme-modal-button-confirm-bg);
  color: var(--theme-modal-button-confirm-text);
}
.modal-confirm-button:hover {
  background-color: #a71e1c;
}
.modal-cancel-button {
  background-color: var(--theme-modal-button-cancel-bg);
  color: var(--theme-modal-button-cancel-text);
}
.modal-cancel-button:hover {
  background-color: var(--theme-modal-button-cancel-bg);
  color: var(--theme-modal-button-cancel-text);
}

@media print {
  body {
    background-color: white !important;
    color: black !important;
    padding-top: 0 !important;
  }
  #editor-container {
    width: 100% !important;
    height: auto !important;
    min-height: initial !important;
    border: none !important;
    box-shadow: none !important;
    background-color: white !important;
    overflow: visible !important;
  }
  .line-visual {
    background-color: black !important;
    -webkit-print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  .line-text {
    color: black !important;
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
  }
  .handle,
  .delete-handle,
  .resize-handle,
  .root-drag-handle {
    display: none !important;
  }
  .modal-overlay {
    display: none !important;
  }

  #drawingCanvas * {
    stroke: black !important;
    fill-opacity: 0 !important;
    fill: none !important;
  }
  #drawingCanvas line[marker-end] {
    marker-end: url(#arrowhead-print) !important;
  }
  #drawingCanvas rect[fill]:not([fill="none"]) {
    fill: black !important;
    fill-opacity: 0.2 !important;
    -webkit-print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  .post-it {
    background-color: white !important;
    color: black !important;
    border: 1px solid #ccc !important;
    box-shadow: 2px 2px 5px grey !important;
    -webkit-print-color-adjust: exact !important;
    color-adjust: exact !important;
    position: absolute;
    padding: 20px 8px 8px 8px;
    border-radius: 3px;
    min-width: 100px;
    min-height: 50px;
  }
  .postit-drag-handle,
  .postit-delete-button {
    display: none !important;
  }
  .postit-content-area[contenteditable="true"] {
    border: none;
  }
  .postit-content-area a {
    color: #0000ee !important;
    text-decoration: underline !important;
  }
  .theme-toggle-label {
    display: none;
  }
}

#helpModalContent {
  text-align: left;
  max-height: 80vh;
  overflow-y: auto;
  padding-bottom: 60px;
  min-width: 80vw !important;
}

.help-sections-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.help-section {
  flex: 1 1 300px;
}

.help-section h4 {
  margin-top: 0;
  margin-bottom: 0.5em;
}

.help-section ul {
  padding-left: 20px;
  margin-top: 0.25em;
  list-style-type: disc;
}

.help-section ul ul {
  list-style-type: circle;
  margin-top: 0.25em;
}

.help-section li {
  margin-bottom: 0.3em;
}

.help-section code {
  background-color: var(--theme-editor-background);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-family: monospace;
  color: var(--theme-schema-text-color);
}

.help-section a {
  color: var(--yellow);
}

.modal-close-button {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--theme-secondary-text);
  cursor: pointer;
  padding: 5px;
  line-height: 1;
  z-index: 10;
}

.modal-close-button:hover {
  color: var(--theme-primary-text);
}

#helpModal .modal-buttons {
  position: absolute;
  bottom: 15px;
  left: 0;
  right: 0;
  padding-top: 15px;
  background-color: var(--theme-modal-background);
  border-top: 1px solid var(--theme-border-color);
}

.line-label-checkbox {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  width: 1em;
  height: 1em;
  font-size: inherit;

  border: 1.5px solid var(--theme-schema-text-color);
  border-radius: 2px;

  background-color: var(--theme-main-background);

  margin-right: 5px;
  vertical-align: middle;
  cursor: pointer;
  display: inline-block;
  position: relative;
}

.line-label-checkbox:checked {
  background-color: var(--theme-schema-text-color);
  border-color: var(--theme-schema-text-color);
}

.line-label-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 0.25em;
  top: 0.05em;
  width: 0.3em;
  height: 0.6em;
  border: solid var(--theme-main-background);
  border-width: 0 0.15em 0.15em 0;
  transform: rotate(45deg);
}

.line-text.checkbox-checked {
  text-decoration: line-through;
  opacity: 0.9;
  text-decoration-line: line-through;
  text-decoration-thickness: 0.05em !important;
}

.iframe-preview-container {
  position: absolute;
  top: 50px;
  left: 50px;
  width: 30vw;
  height: 40vh;
  background: var(--theme-editor-background);
  border: 1px solid var(--theme-border-color);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  padding: 1.5em;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
  transition: border-color 0.2s;
}

.iframe-preview-container:hover {
  border-color: var(--blue);
}

.iframe-preview-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--red);
  color: white;
  border: 2px solid var(--theme-editor-background);
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  opacity: 0.8;
  transition:
    opacity 0.2s,
    transform 0.2s;

  /* Hidden by default */
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
}

.iframe-preview-container:hover .iframe-preview-close {
  opacity: 1 !important;
  transform: scale(1);
  pointer-events: auto;
}

.iframe-preview-content {
  margin: 0.25em;
  flex-grow: 1;
  border: none;
  background: white;
  border-radius: 2px;
}

.iframe-resize-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 2px dashed var(--theme-border-color);
  background: repeating-linear-gradient(
    45deg,
    var(--theme-editor-background),
    var(--theme-editor-background) 10px,
    var(--theme-main-background) 10px,
    var(--theme-main-background) 20px
  );
  display: none;
  border-radius: 5px;
}

.link-preview-iframe-wrapper {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 30vh;
  height: 15vh;
  border: 1px solid var(--theme-border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  background: var(--theme-main-background);
  z-index: 2000;
  border-radius: 4px;
  overflow: hidden;
  /* display:flex and centering properties removed */
  display: none;
}

.link-preview-iframe {
  background: white;
  border: none;
  /* transform-origin is key for scaling from the top-left corner */
  transform-origin: 0 0;
}

/* --- Info Button & Modal --- */
.info-modal-toggle-checkbox {
  display: none;
}

.info-button {
  font-size: 32px;
  cursor: pointer;
  position: fixed;
  top: 1.4em;
  right: 3.5em; /* Positioned left of the theme-toggle */
  z-index: 10001;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--base01);
  border-radius: 50%;
  transition: all 0.3s ease-in-out;
  color: var(--base01);
  background-color: transparent;
}

.info-button:hover {
  background-color: var(--base02);
  color: var(--base1);
  border-color: var(--base0);
}

.info-button > i {
  font-size: 16px;
}

.info-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(
    0,
    0,
    0,
    0.6
  ); /* Fallback for browsers without var support */
  background-color: var(--theme-modal-overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10002;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

.info-modal-close-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  cursor: default;
}

.info-modal-content {
  background-color: var(--theme-modal-background);
  color: var(--theme-modal-text-secondary);
  padding: 25px;
  border-radius: 8px;
  border: 1px solid var(--theme-border-color);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  width: 90%;
  max-width: 320px;
  text-align: center;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.3s ease-in-out;
  z-index: 10003;
  font-size: 0.9rem;
  line-height: 1.5;
}

#info-modal-text a {
  color: var(--yellow);
  text-decoration: none;
}

#info-modal-text a:hover {
  text-decoration: underline;
}

.info-modal-close-button {
  position: absolute;
  top: 5px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--theme-secondary-text);
  cursor: pointer;
  padding: 5px;
  line-height: 1;
}

.info-modal-close-button:hover {
  color: var(--theme-primary-text);
}

/* Modal visibility logic */
#info-modal-toggle:checked ~ .info-modal-overlay {
  opacity: 1;
  pointer-events: auto;
}

#info-modal-toggle:checked ~ .info-modal-overlay .info-modal-content {
  transform: scale(1);
}

.inlined-image {
  /* This is necessary for the absolute positioning of the pseudo-element */
  position: relative;
  /* Ensures proper positioning context */
  display: inline-block;
  vertical-align: middle;
  border-radius: 8%;
}

/* The wrapper now establishes the positioning context */
.inlined-image-wrapper {
  display: inline-block;
  position: relative;
  /* Match the image's vertical alignment */
  vertical-align: middle;
  line-height: 1; /* Helps contain the image cleanly */
}

.inlined-image-wrapper.pinta-image-downloaded::after,
.inlined-image-wrapper.pinta-image-base64::after {
  content: "";
  display: block;
  position: absolute;
  left: 1px;
  bottom: 1px;
  z-index: 10;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid white;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

/* --- Indicator for MANUAL download (Orange dot) --- */
.inlined-image-wrapper.pinta-image-downloaded::after {
  background-color: #c60;
}

/* --- Indicator for EXTENSION converted (Blue dot) --- */
.inlined-image-wrapper.pinta-image-base64::after {
  background-color: #06c;
}

#info-hover {
  background-color: var(--theme-modal-background);
  color: var(--theme-modal-text-primary);
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--theme-border-color);
  font-family: monospace;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.5s ease-in-out,
    visibility 0s 0.5s;
}

#info-hover code {
  color: var(--yellow);
}

#info-hover.visible {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

/* Styles for the Icon Namer Modal */
#iconNamerModal .modal-content {
  /* You can adjust width as needed */
  max-width: 500px;
}

.icon-namer-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 15px;
  margin-bottom: 20px;
  max-height: 50vh; /* Prevents modal from being too tall on screens with many icons */
  overflow-y: auto;
  padding-right: 10px;
  padding-left: 5px;
}

.icon-entry {
  display: flex;
  align-items: center;
  gap: 15px;
}

.icon-entry input[type="text"] {
  flex-grow: 1;
  padding: 8px;
  border: 1px solid var(--theme-border-color);
  background-color: var(--theme-editor-background);
  color: var(--theme-primary-text);
  border-radius: 4px;
  font-family: "Monoid", monospace;
}

.icon-entry .icon-preview {
  height: 24px;
  width: 24px;
  object-fit: contain;
  background-color: var(--theme-main-background);
  border-radius: 3px;
  border: 1px solid var(--theme-border-color);
  padding: 2px;
}
