@keyframes neon-ping {
  0%   { transform: scale(0.98); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

@font-face {
  font-family: "AstroSpace";
  src: url("AstroSpace-0Wl3o.otf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

.dpa {
  background-color: rgb(10, 10, 10);
  color: #0ff;
  flex: 1;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  border-left: 2px solid #333;
}

/* EXACT PIXEL HEIGHTS — No more flex growth */
.dpa-notes {
  height: 517px;
  display: flex;
  flex-direction: column;
  padding: 8px;
  box-sizing: border-box;
}

.dpa-chat {
  height: 518px;
  display: flex;
  flex-direction: column;
  padding: 8px;
  box-sizing: border-box;
}

/* Section headers */
.dpa-section-header {
  font-family: "AstroSpace", sans-serif;
  font-size: 13.45px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  margin-bottom: 4px;
  color: #0ff;
  border-bottom: 1px solid #333;
  padding-bottom: 2px;

  display: flex;
  align-items: center;

  /* NEW — keep everything on the left */
  justify-content: flex-start;
  gap: 8px;  /* spacing between “D.P.A.” and the icons */
}

.dpa-title {
  flex: 0 0 auto;
}

.dpa-mode-buttons {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

/* Icon buttons */
/* Prevent stretching for DPA header icons */
.dpa-mode-button {
  width: 22px;          /* fixed icon box (adjust if desired) */
  height: 22px;
  background: transparent;
  border: 1px solid transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 4px;

  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;      /* prevents overflow distortion */
}

.dpa-mode-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;    /* ⭐ KEY: preserve aspect ratio */
  object-position: center;
  pointer-events: none;   /* click should hit button, not image */
  display: block;
}

.dpa-mode-button:hover,
.dpa-mode-button.active {
  border-color: #0ff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
  background: rgba(0, 255, 255, 0.06);
}

/* DPA screens (only one visible at a time) */
.dpa-screen {
  display: none;
  height: 100%;
}

.dpa-screen.active {
  display: flex;
  flex-direction: column;
}

/* The journal textarea inside the journal screen */
.dpa-screen-journal .dpa-notes-textarea {
  flex: 1;
}

/* TEMP placeholders for the Settings and Private Messages screens */
.dpa-settings-placeholder,
.dpa-private-placeholder,
.dpa-gw-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #888;
  border: 1px dashed #333;
  background: rgba(255, 255, 255, 0.02);
}

/* Notes textarea */
.dpa-notes-textarea {
  flex: 1;
  width: 100%;
  resize: none;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #333;
  color: #0ff;
  font-family: inherit;
  font-size: 13px;
  padding: 6px;
  box-sizing: border-box;
  outline: none;
}

.dpa-notes-textarea:focus {
  border-color: #0ff;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

/* ==========================
   JOURNAL SUB-HEADER
   ========================== */

.journal-subheader {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;

  border-bottom: 1px solid #333;
  padding-bottom: 4px;
  margin-bottom: 6px;

  color: #0ff;
  font-family: "AstroSpace";
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.journal-subheader-title {
  flex: 0 0 auto;
  font-weight: bold;
}

.journal-subheader-buttons {
  display: flex;
  gap: 6px;
}

/* FIX: Prevent icon stretching by giving buttons a fixed box
   and letting the image size itself proportionally */
.journal-subheader-buttons button {
  width: 22px;          /* box size (adjust if needed) */
  height: 22px;
  background: transparent;
  border: 1px solid transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 4px;

  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;     /* ensures image doesn't spill outside */
}

.journal-subheader-buttons button img {
  width: 100%;
  height: 100%;
  object-fit: contain;   /* ⭐ KEEP aspect ratio — never stretch */
  object-position: center;
  display: block;
  pointer-events: none;  /* click goes to button, not image */
}

.journal-subheader-buttons button:hover {
  border-color: #0ff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.9);
  background: rgba(0, 255, 255, 0.06);
}

/* Roll history / chat log */
.dpa-roll-history {
  flex: 1;
  overflow-y: auto;
  max-height: 100%;
  border: 1px solid #333;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  box-sizing: border-box;
  font-size: 12px;
}

.roll-history-entry,
.chat-message-entry {
  margin-bottom: 4px;
  padding: 4px 6px;
  border-left: 3px solid #0ff;
  background: rgba(0, 0, 0, 0.45);
  box-shadow:
    0 0 4px rgba(0, 255, 255, 0.4),
    inset 0 0 4px rgba(0, 255, 255, 0.2);
  animation: neon-ping 0.2s ease-out;
}

.chat-message-entry {
  border-left-color: #0077cc;
  box-shadow:
    0 0 4px rgba(0, 119, 204, 0.4),
    inset 0 0 4px rgba(0, 119, 204, 0.2);
}

/* Chat input row */
.dpa-chat-input-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  position: relative;
}

.dpa-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #333;
  color: #0ff;
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  box-sizing: border-box;
  outline: none;
}

.dpa-chat-input-row::before {
  content: "";
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #0ff, transparent);
  position: absolute;
  top: -6px;
  left: 0;
  opacity: 0.7;
}

.dpa-chat-input:focus {
  border-color: #0ff;
  box-shadow: 0 0 8px #0ff9, inset 0 0 6px #0ff7;
}

.dpa-chat-send {
  background: linear-gradient(180deg, #0cc, #099);
  border: 1px solid #0ff;
  color: #000;
  text-shadow: 0 0 3px #0007;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
  border-radius: 3px;
}

.dpa-chat-send:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.8);
}

/* ==========================
   JOURNAL: LIST + ENTRY VIEW
   ========================== */

.journal-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* allow inner scroll */
}

/* We’ll toggle visibility between these two via JS */
.journal-list-view,
.journal-entry-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.journal-entry-view {
  display: none; /* start hidden until an entry is opened */
}

/* Breadcrumb / folder path ("Journal / Some Folder") */
.journal-folder-path {
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
}

/* Scrollable list of folders + entries */
.journal-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #333;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  box-sizing: border-box;
}

/* Single row in the list */
.journal-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 3px;
  cursor: pointer;
}

.journal-item:hover {
  background: rgba(0, 255, 255, 0.08);
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
}

/* Icon column (folder or document) */
.journal-item-icon {
  width: 16px;
  flex: 0 0 auto;
  text-align: center;
}

/* Use custom image for folder icons */
.journal-item-folder .journal-item-icon {
  /* hard fallback first */
  background-image: url("folder.webp");

  /* prefer AVIF when supported */
  background-image: image-set(
    url("folder.avif") type("image/avif"),
    url("folder.webp") type("image/webp")
  );

  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;

  font-size: 0;        /* hides the 📁 emoji text */
  line-height: 16px;   /* keeps the box nicely sized */
}

/* Use custom image for entry (document) icons */
.journal-item-entry .journal-item-icon {
  /* hard fallback first */
  background-image: url("document.webp");

  /* prefer AVIF when supported */
  background-image: image-set(
    url("document.avif") type("image/avif"),
    url("document.webp") type("image/webp")
  );

  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;

  font-size: 0;        /* hides the 📄 emoji text */
  line-height: 16px;   /* keeps the box nicely sized */
}

/* Name text (normal display mode) */
.journal-item-name {
  flex: 1;
  font-size: 12px;
  color: #0ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline name editor (when creating or renaming) */
.journal-item-edit-input {
  flex: 1;
  font-size: 12px;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid #0ff;
  color: #0ff;
  outline: none;
  border-radius: 3px;
}

/* ENTRY VIEW (when in an entry) */
.journal-entry-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.journal-back-btn {
  background: transparent;
  border: 1px solid #0ff;
  color: #0ff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.journal-back-btn:hover {
  background: rgba(0, 255, 255, 0.1);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.7);
}

.journal-entry-title {
  font-size: 12px;
  font-weight: bold;
  color: #0ff;
}

.journal-entry-textarea:focus {
  border-color: #0ff;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

/* Placeholder text for empty contenteditable entry area */
.journal-entry-textarea:empty::before {
  content: attr(data-placeholder);
  color: rgba(0, 255, 255, 0.4);
  pointer-events: none;
}

/* Journal images: max 150x150, no stretching, text wraps around */
.journal-entry-textarea img.journal-entry-image {
  max-width: 150px;
  max-height: 150px;
  height: auto;
  width: auto;
  object-fit: contain;  /* avoid distortion */

  float: left;          /* text wraps around the image */
  margin: 4px 8px 4px 0;

  cursor: move;         /* hint that the image can be dragged */
}


/* ==========================
   JOURNAL LAYOUT + LIST
   ========================== */

.journal-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* List view under the sub-header */
.journal-list-view {
  flex: 1;
  overflow-y: auto;
  max-height: 442px;
  border: 1px solid #333;
  background: rgba(255, 255, 255, 0.02);
  padding: 4px;
  box-sizing: border-box;
}

.journal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
}

.journal-item {
  display: flex;
  align-items: center;
  padding: 3px 4px;
  cursor: pointer;
  color: #0ff;
  border-bottom: 1px solid #222;
}

.journal-item:last-child {
  border-bottom: none;
}

.journal-item:hover {
  background: rgba(0, 255, 255, 0.06);
}

.journal-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journal-item.entry > .journal-item-label::before {
  content: "📝 ";
}

/* Children (nested) */
.journal-item-children {
  margin-left: 10px;
  border-left: 1px dashed #333;
  padding-left: 6px;
}

/* Highlight currently selected folder (parent context) */
.journal-item.folder.selected-folder {
  background: rgba(0, 255, 255, 0.12);
}

/* Entry view (full-screen within the Journal) */
.journal-entry-view {
  flex: 1;
  display: none; /* hidden until an entry is opened */
  flex-direction: column;
  min-height: 0;
  border: 1px solid #333;
  background: rgba(0, 0, 0, 0.9);
  padding: 4px;
  box-sizing: border-box;
}

.journal-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.journal-back-btn {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 3px;
  border: 1px solid #0ff;
  background: transparent;
  color: #0ff;
  cursor: pointer;
}

.journal-back-btn:hover {
  background: rgba(0, 255, 255, 0.1);
}

.journal-entry-title {
  font-family: "AstroSpace", sans-serif;
  font-size: 12px;
}

/* Text area for the entry content */
.journal-entry-textarea {
  flex: 1;
  width: 100%;
  max-height: 410px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #333;
  color: #0ff;
  font-family: inherit;
  font-size: 13px;
  padding: 6px;
  box-sizing: border-box;
  outline: none;

  overflow-y: auto;      /* scroll if content is tall */
  white-space: pre-wrap; /* treat line breaks like a textarea */
}

.journal-entry-textarea:focus {
  border-color: #0ff;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

/* Simple helper class */
.hidden {
  display: none !important;
}

/* ==========================
   JOURNAL TREE EXTRAS
   ========================== */

/* Little caret area before the folder icon */
.journal-item-toggle {
  width: 14px;
  flex: 0 0 auto;
  text-align: center;
  font-size: 10px;
  cursor: pointer;
}

/* Just a spacer for non-folder rows */
.journal-item-toggle-spacer {
  cursor: default;
}

/* Highlight row when it's a drop target */
.journal-item-drop-target {
  outline: 1px solid #0ff;
  background: rgba(0, 255, 255, 0.12);
}

/* Highlight a glowing line ABOVE or BELOW a row when dropping between items */
.journal-item-drop-before,
.journal-item-drop-after {
  position: relative;
}

.journal-item-drop-before::before,
.journal-item-drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #0ff, transparent);
  pointer-events: none;
}

.journal-item-drop-before::before {
  top: 0;
}

.journal-item-drop-after::after {
  bottom: 0;
}

/* Delete button aligned to the right of the row */
.journal-item-delete-btn {
  margin-left: 0px;
  padding: 2px 2px;
  font-size: 11px;
  border-radius: 3px;
  border: 1px solid #600;
  background: rgba(0, 0, 0, 0.6);
  color: #f88;
  cursor: pointer;
}

.journal-item-delete-btn:hover {
  background: rgba(255, 0, 0, 0.2);
  box-shadow: 0 0 6px rgba(255, 80, 80, 0.8);
}

/* Edit button (left of Delete) */
.journal-item-edit-btn {
  margin-left: 8px;
  padding: 2px 2px;
  font-size: 11px;
  border-radius: 3px;
  border: 1px solid #0ff;
  background: rgba(0, 0, 0, 0.6);
  color: #0ff;
  cursor: pointer;
}

.journal-item-edit-btn:hover {
  background: rgba(0, 255, 255, 0.2);
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.8);
}


/* ==========================
   JOURNAL DELETE CONFIRM POPUP
   ========================== */

.journal-confirm-overlay {
  position: fixed;
  inset: 0; /* top:0; right:0; bottom:0; left:0 */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2200; /* above most stuff */
}

.journal-confirm-dialog {
  background: #000;
  border: 1px solid #0ff;
  padding: 8px 12px;
  color: #0ff;
  font-size: 12px;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
  min-width: 200px;
  text-align: center;
}

.journal-confirm-message {
  margin-bottom: 8px;
}

.journal-confirm-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.journal-confirm-buttons button {
  padding: 2px 10px;
  border: 1px solid #0ff;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.9);
  color: #0ff;
  cursor: pointer;
}

.journal-confirm-buttons button:hover {
  background: rgba(0, 255, 255, 0.2);
  box-shadow: 0 0 6px #0ff;
}

/* Galactic Web Icon */
.gw-mode-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none; /* ensures clicks hit the button, not the image */
}

/* Brighten Skill Tree icon only */
.dpa-mode-tree img{
  filter: brightness(2);
}






