/* ============================================================
   Sidebar panel injection
   ============================================================ */

#ms-sidebar-panel {
  display: none;
}

#chat-notifications.ms-chat-hidden {
  display: none !important;
}

#sidebar.ms-panel-active {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  overflow: hidden;
  transition: grid-template-rows 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

#sidebar.ms-panel-active.ms-rows-collapsed {
  grid-template-rows: 0fr 1fr;
}

#sidebar.ms-panel-active > #sidebar-tabs {
  grid-column: 1;
  grid-row: 1 / -1;
}

#ms-sidebar-panel.ms-visible {
  display: flex !important;
  flex-direction: column;
  grid-column: 2;
  grid-row: 1;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, #111214 0%, #0c0c0e 100%) !important;
  border-bottom: 1px solid rgba(212, 168, 75, 0.08);
  align-self: stretch !important;
  height: 100%;
  pointer-events: auto;
}

#sidebar.ms-panel-active > #sidebar-content {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  min-width: 0;
  justify-self: stretch;
  overflow-y: auto;
  transition: opacity 0.25s ease;
}

#sidebar.ms-panel-active > #sidebar-content .directory-header::before,
#sidebar.ms-panel-active > #sidebar-content .combat-tracker-header::before {
  display: none !important;
}


/* ============================================================
   Toggle button in sidebar tabs
   ============================================================ */

.ms-sidebar-toggle.active {
  color: var(--color-warm-2, #d4a84b) !important;
  filter: drop-shadow(0 0 4px rgba(212, 168, 75, 0.3));
}

.ms-sub-btn {
  font-size: 0.55rem !important;
  opacity: 0.45;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.ms-sub-btn:hover {
  opacity: 1;
  color: var(--color-warm-2, #d4a84b) !important;
}
.ms-scene-stop {
  opacity: 0.85 !important;
  color: rgb(200, 70, 70) !important;
}
.ms-scene-stop:hover {
  opacity: 1 !important;
  color: rgb(230, 80, 80) !important;
}
.ms-resize-drag {
  cursor: ew-resize !important;
}

/* Expanded: canvas takes full height, sidebar content hidden */
#sidebar.ms-panel-active.ms-canvas-expanded {
  grid-template-rows: 1fr 0fr;
}
#sidebar.ms-panel-active.ms-canvas-expanded > #sidebar-content {
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}


/* ============================================================
   Panel header
   ============================================================ */

#ms-sidebar-panel .ms-panel-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.55rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  pointer-events: auto;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

#ms-sidebar-panel .ms-panel-header .ms-header-default {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#ms-sidebar-panel .ms-panel-header.ms-editing .ms-header-default {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

#ms-sidebar-panel .ms-panel-header .ms-note-toolbar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 0.55rem;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#ms-sidebar-panel .ms-panel-header.ms-editing .ms-note-toolbar {
  transform: translateY(0);
  opacity: 1;
}

#ms-sidebar-panel .ms-header-default button {
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05) !important;
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.62rem;
  pointer-events: auto;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
#ms-sidebar-panel .ms-header-default button:hover {
  background: rgba(212, 168, 75, 0.12) !important;
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.25);
  box-shadow: 0 0 8px rgba(212, 168, 75, 0.1);
}

.ms-header-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.ms-panel-show.ms-showing {
  background: rgba(200, 60, 60, 0.45) !important;
  border-color: rgba(200, 60, 60, 0.6);
  color: #fff;
}
.ms-panel-show.ms-showing:hover {
  background: rgba(200, 60, 60, 0.65) !important;
}


/* ============================================================
   Location bar
   ============================================================ */

#ms-sidebar-panel .ms-panel-back {
  width: 1.7rem;
  height: 1.7rem;
  flex: 0 0 auto;
  border-radius: 8px;
}
#ms-sidebar-panel .ms-panel-back:disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}
.ms-panel-back.ms-drop-target {
  background: rgba(100, 210, 130, 0.2) !important;
  border-color: rgba(100, 210, 130, 0.6) !important;
  box-shadow: 0 0 10px rgba(100, 210, 130, 0.3);
  opacity: 1 !important;
  pointer-events: auto !important;
}

.ms-panel-location {
  flex: 1 1 0%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.6rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  overflow: hidden;
  max-width: 100%;
}

.ms-panel-location-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  letter-spacing: 0.02em;
}

/* On the actors board the name is the board switcher */
.ms-panel-location-name.ms-ab-board-name {
  cursor: pointer;
  transition: color 0.15s ease;
}
.ms-panel-location-name.ms-ab-board-name:hover {
  color: #d4a84b;
}
.ms-panel-location-name.ms-ab-board-name i.fa-caret-down {
  margin-left: 5px;
  font-size: 0.65rem;
  color: rgba(212, 168, 75, 0.75);
}


/* ============================================================
   Location canvas
   ============================================================ */

#ms-sidebar-panel .ms-panel-canvas {
  flex: 1 1 0%;
  min-width: 0;
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(212, 168, 75, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(100, 140, 200, 0.025) 0%, transparent 50%),
    radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.4) 100%),
    #0c0c0e !important;
  background-size: 100% 100%, 100% 100%, 32px 32px, 100% 100%, 100% 100% !important;
}


/* ============================================================
   Location rectangles
   ============================================================ */

.ms-location {
  position: absolute;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  container-type: inline-size;
  user-select: none;
  pointer-events: auto;
  touch-action: none;
  z-index: 1;
  backdrop-filter: blur(6px);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.ms-location:hover {
  border-color: rgba(212, 168, 75, 0.3);
  transform: translateY(-2px);
  box-shadow:
    0 0 12px rgba(212, 168, 75, 0.1),
    0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.ms-location.dragging {
  cursor: grabbing;
  opacity: 0.92;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transform: scale(1.04);
  z-index: 10;
}
.ms-location.ms-drop-target {
  border-color: rgba(100, 210, 130, 0.7) !important;
  box-shadow:
    0 0 14px rgba(100, 210, 130, 0.3),
    0 0 28px rgba(100, 210, 130, 0.1),
    inset 0 0 10px rgba(100, 210, 130, 0.08) !important;
  transform: scale(1.03);
}

.ms-location-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  border-radius: inherit;
}

.ms-location-label {
  font-size: max(5px, 10cqi);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  text-align: center;
  pointer-events: none;
  padding: 3px 10px;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  border-radius: 6px;
  max-width: 90%;
  word-break: break-word;
  overflow-wrap: break-word;
}

.ms-location-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  min-width: max(12px, 6cqi);
  height: max(12px, 6cqi);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(212, 168, 75, 0.6), rgba(180, 130, 50, 0.5));
  color: #fff;
  border-radius: 999px;
  font-size: max(5px, 3cqi);
  font-weight: 700;
  padding: 0 4px;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Text color picker */
.ms-location-text-color {
  position: absolute;
  top: 4px;
  left: 4px;
  width: max(14px, 8cqi);
  height: max(14px, 8cqi);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  cursor: pointer;
  font-size: max(6px, 3.5cqi);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.ms-location:hover .ms-location-text-color {
  opacity: 1;
}
.ms-location-text-color:hover {
  background: rgba(212, 168, 75, 0.35);
  border-color: rgba(212, 168, 75, 0.5);
  color: #fff;
}
.ms-location-text-color input[type="color"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Eye button */
.ms-location-show {
  position: absolute;
  top: 4px;
  right: 4px;
  width: max(14px, 8cqi);
  height: max(14px, 8cqi);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4) !important;
  backdrop-filter: blur(4px);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  cursor: pointer;
  font-size: max(6px, 3.5cqi);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.ms-location:hover .ms-location-show {
  opacity: 1;
}
.ms-location-show:hover {
  background: rgba(212, 168, 75, 0.35) !important;
  border-color: rgba(212, 168, 75, 0.5);
  color: #fff;
}
.ms-location-show.ms-showing {
  opacity: 1;
  background: rgba(200, 60, 60, 0.45) !important;
  border-color: rgba(200, 60, 60, 0.6);
  color: #fff;
}
.ms-location-show.ms-showing:hover {
  background: rgba(200, 60, 60, 0.65) !important;
}

/* ============================================================
   Actor bar (inside a location view)
   ============================================================ */

.ms-actor-panel {
  position: absolute;
  top: 3%;
  left: 3%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  z-index: 2;
  pointer-events: none;
}

.ms-actor-bar {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 20px 8px;
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  pointer-events: auto;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.ms-actor-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: grab;
  transition: transform 0.15s ease;
}
.ms-actor-bar-item:hover {
  transform: translateY(-3px);
}

.ms-actor-bar-item img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ms-actor-bar-item:hover img {
  border-color: rgba(212, 168, 75, 0.45);
  box-shadow: 0 2px 12px rgba(212, 168, 75, 0.15);
}

.ms-actor-bar-name {
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  letter-spacing: 0.02em;
  transition: color 0.15s ease;
}
.ms-actor-bar-item:hover .ms-actor-bar-name {
  color: rgba(255, 255, 255, 0.7);
}

.ms-actor-bar:empty {
  padding: 14px 28px;
}
.ms-actor-bar:empty::after {
  content: 'Drop actors here';
  font-size: 0.56rem;
  color: rgba(255, 255, 255, 0.18);
  letter-spacing: 0.03em;
}

.ms-actor-bar.ms-drop-target {
  border-color: rgba(100, 210, 130, 0.5);
  box-shadow:
    0 0 14px rgba(100, 210, 130, 0.15),
    inset 0 0 8px rgba(100, 210, 130, 0.06);
}

.ms-actor-pin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translate(-50%, -50%);
  cursor: grab;
  z-index: 8;
  transition: transform 0.15s ease;
  --ms-actor-border: #c9a96e;
}
.ms-actor-pin:hover {
  transform: translate(-50%, -50%) scale(1.1);
}
.ms-actor-pin.dragging {
  cursor: grabbing;
  opacity: 0.7;
  z-index: 50;
}
.ms-actor-pin img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--ms-actor-border);
  object-fit: cover;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.ms-actor-pin:hover img {
  box-shadow: 0 2px 14px rgba(212, 168, 75, 0.25);
}
.ms-actor-pin span {
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.ms-actor-pin-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  transform: translate(-50%, -50%);
  opacity: 0.8;
}
.ms-actor-pin-ghost img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(212, 168, 75, 0.6);
  object-fit: cover;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.ms-bring-party {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(10, 10, 12, 0.65) !important;
  backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.56rem;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.ms-bring-party:hover {
  color: rgba(212, 168, 75, 0.9);
  border-color: rgba(212, 168, 75, 0.25);
  background: rgba(212, 168, 75, 0.08) !important;
}


/* ============================================================
   Clues Kit link button
   ============================================================ */

.ms-clues-kit-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 12, 0.7) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.18s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.ms-clues-kit-btn:hover {
  background: rgba(212, 168, 75, 0.15) !important;
  border-color: rgba(212, 168, 75, 0.35);
  color: #d4a84b;
  transform: scale(1.08);
}
.ms-clues-kit-btn.linked {
  border-color: rgba(212, 168, 75, 0.25);
  color: rgba(212, 168, 75, 0.7);
}

.ms-animator-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 12, 0.7) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.18s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.ms-animator-btn:hover {
  background: rgba(224, 96, 80, 0.15) !important;
  border-color: rgba(224, 96, 80, 0.35);
  color: #e06050;
  transform: scale(1.08);
}

.ms-clues-kit-popup {
  position: fixed;
  z-index: 100001;
  background: rgba(12, 12, 14, 0.92);
  backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 4px;
  min-width: 150px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  animation: ms-popup-in 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ms-clues-kit-popup button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  background: none !important;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.ms-clues-kit-popup button:hover {
  background: rgba(212, 168, 75, 0.1) !important;
  color: #d4a84b;
}
.ms-clues-kit-popup.picker {
  max-height: 240px;
  overflow-y: auto;
}
.ms-clues-kit-popup-empty {
  padding: 8px 12px;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.7rem;
}


/* ============================================================
   Canvas notes (free-form GM text)
   ============================================================ */

.ms-note {
  position: absolute;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0;
  cursor: grab;
  user-select: none;
  overflow: hidden;
  pointer-events: auto;
  touch-action: none;
  z-index: 1;
  box-shadow: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
.ms-note-bordered {
  border-color: rgba(255, 255, 255, 0.12);
}
.ms-note:hover,
.ms-note-bordered:hover {
  border-color: rgba(212, 168, 75, 0.15);
}
.ms-note.dragging {
  cursor: grabbing;
  opacity: 0.92;
  transform: scale(1.02);
}
.ms-note.is-resizing {
  cursor: nwse-resize;
}

.ms-note-drag {
  height: 10px;
  cursor: grab;
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
  position: relative;
}
.ms-note-drag::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.2s ease;
}
.ms-note:hover .ms-note-drag::after { background: rgba(212, 168, 75, 0.3); }
.ms-note.dragging .ms-note-drag { cursor: grabbing; }

.ms-note-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.ms-note-toolbar button {
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.62rem;
  transition: all 0.2s ease;
}
.ms-note-toolbar button:hover {
  background: rgba(212, 168, 75, 0.12);
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.25);
}
.ms-note-toolbar button.active {
  background: rgba(212, 168, 75, 0.18);
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.3);
}
.ms-note-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 2px;
}
.ms-note-toolbar select {
  height: 1.75rem;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  font-size: 0.58rem;
  padding: 0 4px;
  cursor: pointer;
  max-width: 62px;
  transition: all 0.2s ease;
}
.ms-note-toolbar select:hover {
  background: rgba(212, 168, 75, 0.12);
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.25);
}
.ms-note-toolbar input[type="color"] {
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}
.ms-note-toolbar input[type="color"]:hover {
  border-color: rgba(212, 168, 75, 0.25);
}
.ms-note-toolbar input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.ms-note-toolbar input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

.ms-note-body {
  flex: 1;
  padding: 6px 9px;
  outline: none;
  cursor: text;
  user-select: text;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  min-height: 24px;
  transition: opacity 0.15s ease;
}
.ms-note-body:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.2);
  pointer-events: none;
}
.ms-note-body h3 {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  margin: 4px 0 2px;
}
.ms-note-body ul, .ms-note-body ol {
  margin: 3px 0;
  padding-left: 16px;
}
.ms-note-body font[size="1"] { font-size: 10px; }
.ms-note-body font[size="2"] { font-size: 12px; }
.ms-note-body font[size="3"] { font-size: 14px; }
.ms-note-body font[size="4"] { font-size: 16px; }
.ms-note-body font[size="5"] { font-size: 20px; }
.ms-note-body font[size="6"] { font-size: 26px; }
.ms-note-body font[size="7"] { font-size: 34px; }

/* Page navigation */
.ms-note-page-prev,
.ms-note-page-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.6rem;
  cursor: pointer;
  z-index: 3;
  padding: 0;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.15s ease, background 0.15s ease;
}
.ms-note:hover .ms-note-page-prev,
.ms-note:hover .ms-note-page-next {
  opacity: 1;
}
.ms-note-page-prev { left: 0; border-radius: 0 5px 5px 0; }
.ms-note-page-next { right: 0; border-radius: 5px 0 0 5px; }
.ms-note-page-prev:hover,
.ms-note-page-next:hover {
  color: rgba(212, 168, 75, 0.9);
  background: rgba(0, 0, 0, 0.65);
}
.ms-note-page-indicator {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.25);
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ms-note:hover .ms-note-page-indicator {
  opacity: 1;
}

.ms-note .ms-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}


/* ── Journal Pins ── */

.ms-journal-pin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transform: translate(-50%, -50%);
  transition: filter 0.15s;
}
.ms-journal-pin:hover {
  filter: brightness(1.3);
}
.ms-journal-pin.dragging {
  opacity: 0.7;
  z-index: 100;
}
.ms-journal-pin img {
  pointer-events: none;
}
.ms-journal-pin-label {
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 6px rgba(0,0,0,0.5);
  pointer-events: none;
  margin-top: 2px;
}

/* Text anchor positions */
.ms-pin-anchor-top {
  flex-direction: column-reverse;
}
.ms-pin-anchor-top .ms-journal-pin-label {
  margin-top: 0;
  margin-bottom: 2px;
}
.ms-pin-anchor-center .ms-journal-pin-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
.ms-pin-anchor-left {
  flex-direction: row-reverse;
  align-items: center;
}
.ms-pin-anchor-left .ms-journal-pin-label {
  margin-top: 0;
  margin-right: 4px;
}
.ms-pin-anchor-right {
  flex-direction: row;
  align-items: center;
}
.ms-pin-anchor-right .ms-journal-pin-label {
  margin-top: 0;
  margin-left: 4px;
}


/* ============================================================
   Mindscape scene fade overlay
   ============================================================ */

.ms-scene-fade {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 100000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

body.ms-fading .notification.progress {
  display: none !important;
}

/* ============================================================
   Mindscape scene stop button
   ============================================================ */



/* ============================================================
   Right-click context menu
   ============================================================ */

.ms-context-menu,
.ms-flow-ctx {
  position: fixed;
  z-index: 100001;
  background: rgba(12, 12, 14, 0.88);
  backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 4px 0;
  min-width: 140px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  animation: ms-popup-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.ms-context-menu button,
.ms-flow-ctx button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 14px;
  background: none !important;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.ms-context-menu button:hover,
.ms-flow-ctx button:hover {
  background: rgba(212, 168, 75, 0.1) !important;
  color: #d4a84b;
}
.ms-context-menu button.destructive,
.ms-flow-ctx button.destructive {
  color: rgba(220, 100, 100, 0.75);
}
.ms-context-menu button.destructive:hover,
.ms-flow-ctx button.destructive:hover {
  background: rgba(180, 48, 48, 0.12) !important;
  color: #ff8080;
}
.ms-context-menu button.active {
  color: #d4a84b;
}
.ms-context-menu button.active > i {
  color: rgba(212, 168, 75, 0.85);
}
.ms-context-menu button.ms-menu-new {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 4px;
  padding-top: 9px;
}
.ms-ctx-row {
  display: flex;
  align-items: center;
}
.ms-ctx-row > button:first-child {
  flex: 1 1 0%;
  min-width: 0;
}
.ms-context-menu button.ms-ctx-secondary {
  flex: none;
  width: 28px;
  min-width: 28px;
  padding: 7px 0;
  justify-content: center;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.2);
  transition: color 0.15s ease, background 0.15s ease;
}
.ms-context-menu button.ms-ctx-secondary:hover {
  color: #d4a84b;
  background: rgba(212, 168, 75, 0.12) !important;
}
.ms-context-menu button.ms-ctx-delete:hover {
  color: #dc6464;
  background: rgba(180, 48, 48, 0.18) !important;
}

/* Location edit dialog (custom, works in popout window) */
.ms-loc-edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  animation: ms-popup-in 0.15s ease;
}
.ms-loc-edit {
  background: rgba(12, 12, 14, 0.92);
  backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px 20px;
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.ms-loc-edit-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #d4a84b;
  margin-bottom: 12px;
}
.ms-loc-edit-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: center;
}
.ms-loc-edit-fields label {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.78rem;
}
.ms-loc-edit-fields input[type="text"],
.ms-loc-edit-fields textarea {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.9);
  padding: 5px 8px;
  font-size: 0.78rem;
  outline: none;
}
.ms-loc-edit-fields textarea {
  resize: vertical;
  font-family: inherit;
}
.ms-loc-edit-fields input[type="text"]:focus,
.ms-loc-edit-fields textarea:focus,
.ms-loc-edit-fields select:focus {
  border-color: rgba(212, 168, 75, 0.35);
}
.ms-loc-edit-fields select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.9);
  padding: 5px 8px;
  font-size: 0.78rem;
  outline: none;
}
.ms-loc-edit-fields input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: none;
  cursor: pointer;
  padding: 1px;
}
.ms-loc-edit-pick {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.15s;
}
.ms-loc-edit-pick:hover { color: #d4a84b; }
.ms-loc-edit-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.ms-loc-edit-buttons button {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  padding: 5px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ms-loc-edit-buttons button:hover {
  background: rgba(212, 168, 75, 0.1) !important;
  color: #d4a84b;
}

@keyframes ms-popup-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ============================================================
   Portrait image adjustment dialog
   ============================================================ */

.ms-adjust-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ms-adjust-dialog {
  background: rgba(18, 18, 22, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: ms-popup-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.ms-adjust-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.03em;
}

.ms-adjust-preview {
  width: 210px;
  height: 290px;
  border-radius: 6px;
}

.ms-adjust-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ms-adjust-hint {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.3);
}

.ms-adjust-zoom {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

.ms-adjust-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ms-adjust-color {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 1px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.ms-adjust-color:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.ms-adjust-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.ms-adjust-actions button {
  padding: 5px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05) !important;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ms-adjust-actions button:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: rgba(255, 255, 255, 0.9);
}

.ms-adjust-save {
  background: rgba(212, 168, 75, 0.15) !important;
  border-color: rgba(212, 168, 75, 0.3) !important;
  color: #d4a84b !important;
}
.ms-adjust-save:hover {
  background: rgba(212, 168, 75, 0.25) !important;
  color: #e0b85a !important;
}

/* Pill crop dialog variant */
.ms-ab-crop-dialog {
  width: 448px;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.ms-ab-crop-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ms-ab-crop-preview-circle {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  background: #111;
  border: 2px solid rgba(212, 168, 75, 0.8);
  /* hub icon/initial faces size themselves in cqi units */
  container-type: size;
}
.ms-ab-crop-preview-circle canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.ms-ab-crop-preview-name {
  font-size: 0.7rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
}


/* ============================================================
   World wrapper (zoom / pan container)
   ============================================================ */

.ms-canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

/* Actors board: no transform, so browser renders images at native resolution */
.ms-canvas-world[data-location="actors-board"] {
  will-change: auto;
}


/* ============================================================
   SVG connections layer
   ============================================================ */

.ms-connections-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}


/* ============================================================
   Resize handle
   ============================================================ */

.ms-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 5;
  border-radius: 0 0 8px 0;
}
.ms-resize-handle::after {
  content: '';
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-right: 2px solid rgba(255, 255, 255, 0.25);
  border-bottom: 2px solid rgba(255, 255, 255, 0.25);
  transition: border-color 0.15s ease;
}
.ms-location:hover .ms-resize-handle::after {
  border-color: rgba(212, 168, 75, 0.55);
}
.ms-location.is-resizing {
  cursor: nwse-resize;
  opacity: 0.9;
}


/* ============================================================
   Connect mode states
   ============================================================ */

.ms-panel-canvas.ms-connecting {
  cursor: crosshair;
}
.ms-panel-canvas.ms-connecting .ms-location {
  cursor: crosshair;
}
.ms-connect-source {
  border-color: rgba(212, 168, 75, 0.7) !important;
  box-shadow:
    0 0 16px rgba(212, 168, 75, 0.3),
    0 0 32px rgba(212, 168, 75, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}


/* ============================================================
   Panning state
   ============================================================ */

.ms-panel-canvas.ms-panning {
  cursor: grabbing;
}
.ms-panel-canvas.ms-panning .ms-location,
.ms-panel-canvas.ms-panning .ms-note {
  cursor: grabbing;
}


/* ============================================================
   Canvas / content divider
   ============================================================ */

#sidebar.ms-panel-active > #ms-sidebar-panel::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(212, 168, 75, 0.3) 20%,
    rgba(212, 168, 75, 0.5) 50%,
    rgba(212, 168, 75, 0.3) 80%,
    transparent
  );
  z-index: 5;
  pointer-events: none;
}


/* ============================================================
   Navigation animations
   ============================================================ */

.ms-panel-canvas.ms-nav-enter {
  animation: ms-nav-enter 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.ms-panel-canvas.ms-nav-back {
  animation: ms-nav-back 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes ms-nav-enter {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ms-nav-back {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: translateX(0); }
}


/* ============================================================
   Scrollbar
   ============================================================ */

#ms-sidebar-panel ::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
#ms-sidebar-panel ::-webkit-scrollbar-track {
  background: transparent;
}
#ms-sidebar-panel ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}
#ms-sidebar-panel ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}


/* ============================================================
   Session Flow Editor
   ============================================================ */

.ms-flow-editor {
  position: fixed;
  top: 50%;
  right: 360px;
  transform: translateY(-50%);
  width: 420px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  background: rgba(12, 12, 14, 0.96);
  backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 200;
  animation: ms-flow-editor-in 0.22s ease;
  overflow: hidden;
}

@keyframes ms-flow-editor-in {
  from {
    opacity: 0;
    transform: translateY(calc(-50% + 6px)) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

.ms-flow-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  user-select: none;
}
.ms-flow-editor-header:active { cursor: grabbing; }

.ms-flow-editor-header span {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.04em;
}

.ms-flow-editor-actions {
  display: flex;
  gap: 4px;
}

.ms-flow-editor-actions button {
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.7rem;
}
.ms-flow-editor-actions button:hover {
  background: rgba(212, 168, 75, 0.12);
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.25);
}

/* Canvas-based flow chart editor */

.ms-flow-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 20px 20px;
}

.ms-flow-canvas-inner {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  transform-origin: 0 0;
}

.ms-flow-arrows {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.ms-flow-arrow-hit {
  pointer-events: stroke;
}

.ms-flow-node {
  position: absolute;
  width: 140px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 10px 4px;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ms-flow-node:active { cursor: grabbing; }
.ms-flow-node:hover { border-color: rgba(255, 255, 255, 0.2); }
.ms-flow-node.selected {
  border-color: rgba(212, 168, 75, 0.5);
  box-shadow: 0 0 12px rgba(212, 168, 75, 0.12);
}

.ms-flow-canvas-inner.connecting .ms-flow-node:hover {
  border-color: rgba(100, 210, 130, 0.5);
  box-shadow: 0 0 10px rgba(100, 210, 130, 0.12);
}

.ms-flow-node-title {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-flow-node-port {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.18);
  margin: 5px auto 0;
  cursor: crosshair;
  transition: background 0.12s, border-color 0.12s;
}
.ms-flow-node-port:hover {
  background: rgba(212, 168, 75, 0.3);
  border-color: rgba(212, 168, 75, 0.5);
}

/* Edit panel shown when a node is selected */

.ms-flow-node-edit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

.ms-flow-node-edit-footer {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ms-flow-node-edit-footer .ms-flow-beat-connects {
  flex: 1;
}
.ms-flow-node-edit-footer .ms-flow-beat-delete {
  flex-shrink: 0;
}

.ms-flow-beat-title {
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 2px 0 4px;
  outline: none;
  width: 100%;
}
.ms-flow-beat-title::placeholder { color: rgba(255, 255, 255, 0.2); }
.ms-flow-beat-title:focus { border-bottom-color: rgba(212, 168, 75, 0.4); }

.ms-flow-beat-toolbar {
  display: flex;
  gap: 3px;
}
.ms-flow-beat-toolbar button {
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  font-size: 0.6rem;
  transition: all 0.15s;
}
.ms-flow-beat-toolbar button:hover {
  background: rgba(212, 168, 75, 0.1);
  color: #d4a84b;
}

.ms-flow-beat-body {
  min-height: 2.5rem;
  min-width: 0;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  line-height: 1.5;
  outline: none;
  overflow-wrap: break-word;
  word-break: break-word;
  overflow-x: hidden;
}
.ms-flow-beat-body:focus {
  border-color: rgba(212, 168, 75, 0.25);
}
.ms-flow-beat-body:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.18);
  pointer-events: none;
}
.ms-flow-beat-body h3 {
  font-size: 0.85rem;
  color: rgba(212, 168, 75, 0.8);
  margin: 4px 0 2px;
}

.ms-flow-beat-delete {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  font-size: 0.65rem;
  padding: 4px;
  transition: color 0.15s;
}
.ms-flow-beat-delete:hover { color: #e05555; }

.ms-flow-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 8px 10px 10px;
  padding: 8px;
  background: rgba(212, 168, 75, 0.06);
  border: 1px dashed rgba(212, 168, 75, 0.2);
  border-radius: 8px;
  color: rgba(212, 168, 75, 0.5);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.ms-flow-add:hover {
  background: rgba(212, 168, 75, 0.12);
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.35);
}


/* ============================================================
   Plot Line (overlay)
   ============================================================ */

.ms-flow-line {
  position: fixed;
  display: flex;
  align-items: center;
  z-index: 200;
  padding: 4px 0;
  cursor: grab;
  user-select: none;
  animation: ms-popup-in 0.22s ease;
}
.ms-flow-line:active { cursor: grabbing; }

.ms-flow-line.in-canvas {
  position: absolute;
  z-index: 50;
}

.ms-flow-stops {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 0 6px;
  position: relative;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.ms-flow-stops.slide-left  { transform: translateX(-30px); opacity: 0; }
.ms-flow-stops.slide-right { transform: translateX(30px);  opacity: 0; }
.ms-flow-stops.slide-up    { transform: translateY(-30px); opacity: 0; }
.ms-flow-stops.slide-down  { transform: translateY(30px);  opacity: 0; }

.ms-flow-stop {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: auto;
  min-width: 70px;
  position: relative;
  padding: 4px 6px 0;
}
.ms-flow-stop.empty { visibility: hidden; }

.ms-flow-stop-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: all 0.25s ease;
}
.ms-flow-stop:not(.current) .ms-flow-stop-dot {
  cursor: pointer;
}
.ms-flow-stop:not(.current) .ms-flow-stop-dot:hover {
  background: rgba(212, 168, 75, 0.3);
  border-color: rgba(212, 168, 75, 0.5);
}
.ms-flow-stop.current .ms-flow-stop-dot {
  background: #e8bf5a;
  border-color: rgba(232, 191, 90, 0.7);
  box-shadow: 0 0 12px rgba(212, 168, 75, 0.5), 0 0 24px rgba(212, 168, 75, 0.2);
}

/* Connecting line segments (drawn by JS for pixel-perfect alignment) */
.ms-flow-line-seg {
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
  z-index: 0;
  pointer-events: none;
}
.ms-flow-line-seg.from-current {
  background: linear-gradient(to right, rgba(212, 168, 75, 0.4), rgba(255, 255, 255, 0.08));
}
.ms-flow-line.vertical .ms-flow-line-seg.from-current {
  background: linear-gradient(to bottom, rgba(212, 168, 75, 0.4), rgba(255, 255, 255, 0.08));
}

.ms-flow-stop-title {
  margin-top: 6px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  cursor: pointer;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: color 0.15s;
}
.ms-flow-stop-title:hover { color: rgba(255, 255, 255, 0.8); }
.ms-flow-stop.current .ms-flow-stop-title {
  color: #e8bf5a;
  font-weight: 600;
  text-shadow: 0 0 10px rgba(212, 168, 75, 0.4);
}

.ms-flow-stop-detail {
  max-height: 0;
  overflow: hidden;
  width: 0;
  opacity: 0;
  padding: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  margin-top: 6px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.75);
  border-left: 2px solid rgba(212, 168, 75, 0.3);
  border-radius: 4px;
}
.ms-flow-stop.expanded .ms-flow-stop-detail {
  width: 260px;
  opacity: 1;
  padding: 10px;
}


/* ── Vertical orientation ── */

.ms-flow-line.vertical .ms-flow-stops {
  flex-direction: column;
  align-items: stretch;
}

.ms-flow-line.vertical .ms-flow-stop {
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-template-rows: auto auto;
  width: auto;
  min-width: 220px;
  padding: 8px 8px;
  align-items: start;
  gap: 0 10px;
}
.ms-flow-line.vertical .ms-flow-stop.empty {
  visibility: hidden;
  min-height: 0;
  padding: 0;
}

.ms-flow-line.vertical .ms-flow-stop-dot {
  grid-column: 1;
  grid-row: 1;
  margin-top: 2px;
}

.ms-flow-line.vertical .ms-flow-stop-title {
  grid-column: 2;
  grid-row: 1;
  margin-top: 0;
  text-align: left;
  white-space: normal;
}

.ms-flow-line.vertical .ms-flow-stop-detail {
  grid-column: 2;
  grid-row: 2;
  width: 240px;
  margin-top: 4px;
}

/* ── Beat connections (editor) ── */

.ms-flow-beat-connects {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.ms-flow-beat-connects-arrow {
  color: rgba(255, 255, 255, 0.18);
  font-size: 0.6rem;
}

.ms-flow-beat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(212, 168, 75, 0.1);
  border: 1px solid rgba(212, 168, 75, 0.2);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.65rem;
  white-space: nowrap;
}
.ms-flow-beat-chip i {
  font-size: 0.5rem;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 1px;
  transition: color 0.12s;
}
.ms-flow-beat-chip i:hover {
  color: #e05555;
}

.ms-flow-beat-connect-add {
  width: 1.2rem;
  height: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.5rem;
  cursor: pointer;
  transition: all 0.12s;
}
.ms-flow-beat-connect-add:hover {
  background: rgba(212, 168, 75, 0.12) !important;
  border-color: rgba(212, 168, 75, 0.3);
  color: #d4a84b;
}

/* ── Connection picker popup ── */

.ms-flow-connect-picker {
  position: fixed;
  z-index: 300;
  background: rgba(10, 10, 12, 0.94);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px;
  min-width: 120px;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  animation: ms-popup-in 0.15s ease;
}
.ms-flow-connect-picker button {
  padding: 5px 10px;
  background: none !important;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.72rem;
  text-align: left;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.ms-flow-connect-picker button:hover {
  background: rgba(212, 168, 75, 0.12) !important;
  color: #d4a84b;
}
.ms-flow-connect-picker-empty {
  padding: 6px 10px;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.68rem;
}

/* ── Choice tag (overlay) ── */

.ms-flow-choice-tag {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 4px;
  background: rgba(212, 168, 75, 0.15);
  border: 1px solid rgba(212, 168, 75, 0.3);
  border-radius: 4px;
  color: #d4a84b;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}


/* ── GM Note Editor (popup for composing) ── */

.ms-gm-editor {
  position: fixed;
  z-index: 200;
  width: 240px;
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 14, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: ms-popup-in 0.18s ease;
  padding: 8px;
  gap: 6px;
}

.ms-gm-editor-title {
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 2px 0 5px;
  outline: none;
}
.ms-gm-editor-title::placeholder { color: rgba(255, 255, 255, 0.2); }
.ms-gm-editor-title:focus { border-bottom-color: rgba(212, 168, 75, 0.4); }

.ms-gm-editor-toolbar {
  display: flex;
  gap: 3px;
}
.ms-gm-editor-toolbar button {
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  font-size: 0.6rem;
  transition: all 0.15s;
}
.ms-gm-editor-toolbar button:hover {
  background: rgba(212, 168, 75, 0.1);
  color: #d4a84b;
}

.ms-gm-editor-body {
  min-height: 3rem;
  /* grow with the text; only very long notes scroll */
  max-height: min(62vh, 540px);
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  line-height: 1.5;
  outline: none;
  overflow-y: auto;
  overflow-wrap: break-word;
  word-break: break-word;
}
.ms-gm-editor-body:focus {
  border-color: rgba(212, 168, 75, 0.25);
}
.ms-gm-editor-body:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.18);
  pointer-events: none;
}
.ms-gm-editor-body h3 {
  font-size: 0.85rem;
  color: rgba(212, 168, 75, 0.8);
  margin: 4px 0 2px;
}

.ms-gm-editor-footer {
  display: flex;
  justify-content: flex-end;
}
.ms-gm-editor-post {
  background: rgba(212, 168, 75, 0.15);
  border: 1px solid rgba(212, 168, 75, 0.3);
  border-radius: 5px;
  color: #d4a84b;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px 10px;
  transition: all 0.15s;
}
.ms-gm-editor-post:hover {
  background: rgba(212, 168, 75, 0.25);
}

/* Group headers on the module settings page */
.ms-settings-divider {
  margin: 14px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(212, 168, 75, 0.45);
  color: #b58a3e;
  font-size: 0.95em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Posted GM notes (reuses flow-line classes, adds edit/delete) ── */

.ms-gm-posted .ms-gm-posted-header {
  display: flex;
  align-items: center;
  gap: 4px;
  grid-column: 2;
  grid-row: 1;
}

.ms-gm-posted .ms-flow-stop-title {
  margin-top: 0;
}

.ms-gm-posted-font,
.ms-gm-posted-edit,
.ms-gm-posted-delete {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  font-size: 0.55rem;
  padding: 2px;
  transition: color 0.15s;
  opacity: 0;
}
.ms-gm-posted:hover .ms-gm-posted-font,
.ms-gm-posted:hover .ms-gm-posted-edit,
.ms-gm-posted:hover .ms-gm-posted-delete {
  opacity: 1;
}
.ms-gm-posted-font { white-space: nowrap; }
.ms-gm-posted-font:hover,
.ms-gm-posted-edit:hover { color: #d4a84b; }
.ms-gm-posted-delete:hover { color: #e05050; }

/* Posted notes track the note's own width; the flow-line classes they
   borrow pin the detail at 260px otherwise. The base width matches the
   old look and the resize drag's inline width overrides it. */
.ms-gm-posted {
  width: 272px;
}
.ms-gm-posted .ms-flow-stops,
.ms-gm-posted .ms-flow-stop,
.ms-gm-posted .ms-flow-stop-detail {
  width: 100%;
  box-sizing: border-box;
}
/* Width and padding stay constant in both states (max-height: 0 clips a
   border-box fully), so retract animates only height and fade, and the
   expand measurement is never taken mid-padding-animation */
.ms-gm-posted .ms-flow-stop-detail {
  padding: 10px;
  transition: max-height 0.3s ease, opacity 0.25s ease;
}
/* Outranks the stock 260px expanded width (three classes vs three) */
.ms-gm-posted .ms-flow-stop.expanded .ms-flow-stop-detail {
  width: 100%;
}

.ms-gm-posted-resize {
  position: absolute;
  /* the vertical stop carries 8px padding all around; land the grip
     on the note box's actual corner, poking 2px past it */
  right: 6px;
  bottom: 6px;
  width: 13px;
  height: 13px;
  cursor: nwse-resize;
  border-right: 2px solid rgba(212, 168, 75, 0.55);
  border-bottom: 2px solid rgba(212, 168, 75, 0.55);
  border-radius: 0 0 4px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
/* Only an expanded note shows (and accepts) the grip; collapsed notes
   have no box corner for it to sit on */
.ms-gm-posted:hover .ms-flow-stop.expanded .ms-gm-posted-resize {
  opacity: 1;
  pointer-events: all;
}
.ms-gm-posted .ms-flow-stop-detail.ms-scrolly { overflow-y: auto; }


/* ============================================================
   Image Browser
   ============================================================ */

.ms-img-browser {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 520px;
  max-width: 90vw;
  height: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: rgba(12, 12, 14, 0.96);
  backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 300;
  animation: ms-img-browser-in 0.22s ease;
  overflow: hidden;
}

@keyframes ms-img-browser-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px)) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.ms-img-browser-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  user-select: none;
}
.ms-img-browser-header:active { cursor: grabbing; }

.ms-img-browser-path {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-img-browser-header button {
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.7rem;
}
.ms-img-browser-header button:hover {
  background: rgba(212, 168, 75, 0.12);
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.25);
}
.ms-img-browser-header button:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.ms-img-browser-newfolder-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}
.ms-img-browser-newfolder-bar input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 8px;
  color: #eee;
  font-size: 0.72rem;
  outline: none;
}
.ms-img-browser-newfolder-bar input:focus {
  border-color: rgba(212, 168, 75, 0.4);
}
.ms-img-browser-newfolder-bar button {
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 0.65rem;
  transition: all 0.15s ease;
}
.ms-img-browser-newfolder-ok:hover {
  background: rgba(212, 168, 75, 0.12);
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.25);
}
.ms-img-browser-newfolder-cancel:hover {
  background: rgba(255, 80, 80, 0.1);
  color: #ff6b6b;
  border-color: rgba(255, 80, 80, 0.2);
}

.ms-img-browser-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  grid-auto-rows: min-content;
  gap: 14px;
  align-content: start;
}

.ms-img-browser-grid::-webkit-scrollbar { width: 4px; }
.ms-img-browser-grid::-webkit-scrollbar-track { background: transparent; }
.ms-img-browser-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 999px; }

.ms-img-browser-folder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ms-img-browser-folder i {
  font-size: 1.6rem;
  color: rgba(212, 168, 75, 0.6);
}
.ms-img-browser-folder span {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  word-break: break-word;
}
.ms-img-browser-folder:hover {
  background: rgba(212, 168, 75, 0.08);
  border-color: rgba(212, 168, 75, 0.2);
}

.ms-img-browser-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  transition: all 0.15s ease;
  aspect-ratio: 16 / 10;
}
.ms-img-browser-item:hover {
  border-color: rgba(212, 168, 75, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}
.ms-img-browser-item:active { cursor: grabbing; }

.ms-img-browser-item img,
.ms-img-browser-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ms-img-browser-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-img-browser-loading,
.ms-img-browser-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.8rem;
}

/* ============================================================
   ACTORS BOARD (in-canvas view)
   ============================================================ */

.ms-panel-relmap.active,
.ms-panel-draw-area:hover {
  color: #d4a84b !important;
}

.ms-ab-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.ms-ab-svg.ms-ab-handles-active {
  z-index: 6;
}

/* ── Actor pills ── */

.ms-ab-pill {
  position: absolute;
  border-radius: 50%;
  border: var(--ab-ring-w, 2px) solid var(--ab-ring, rgba(212, 168, 75, 0.8));
  background: #0c0c0e;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  container-type: inline-size;
  /* Tight halo in the ring's own color makes the line itself luminous */
  box-shadow: 0 0 7px var(--ab-ring-soft, rgba(212, 168, 75, 0.5)), 0 2px 10px rgba(0, 0, 0, 0.5);
}

.ms-ab-pill-imgwrap {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
}
/* Inner half of the ring glow, painted over the portrait's edge */
.ms-ab-pill-imgwrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: inset 0 0 6px var(--ab-ring-soft, rgba(212, 168, 75, 0.45));
}
.ms-ab-pill-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
/* Hover thickening: a spread shadow reads as a fatter ring without
   moving the portrait inside */
.ms-ab-pill:hover {
  box-shadow: 0 0 0 1.5px var(--ab-ring, rgba(212, 168, 75, 0.8)),
    0 0 14px var(--ab-ring-soft, rgba(212, 168, 75, 0.5)),
    0 2px 10px rgba(0, 0, 0, 0.5);
}
.ms-ab-pill.ms-ab-glowing:hover {
  box-shadow: 0 0 0 1.5px var(--ab-ring, rgba(212, 168, 75, 0.8)),
    0 0 7px var(--ab-ring-soft, rgba(212, 168, 75, 0.5)),
    0 0 var(--ab-glow-size, 22px) 4px var(--ab-glow, rgba(212, 168, 75, 0.6));
}

.ms-ab-pill-name {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: max(7.5px, 13.75cqi);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  text-align: center;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  z-index: 1;
}

.ms-ab-pill-sub {
  position: absolute;
  top: calc(100% + 4px + max(10px, 16.25cqi));
  left: 50%;
  transform: translateX(-50%);
  font-size: max(6.25px, 10cqi);
  color: var(--ab-ring, rgba(212, 168, 75, 0.85));
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  z-index: 1;
}

/* Soft repeating pulse on the ring */
.ms-ab-pill::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid var(--ab-ring, rgba(212, 168, 75, 0.8));
  opacity: 0;
  animation: ms-ab-pulse 5.5s ease-out infinite;
  animation-delay: var(--pulse-delay, 0s);
  pointer-events: none;
}
@keyframes ms-ab-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  18% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ms-ab-pill::before { animation: none; }
}

/* Focus mode */
.ms-ab-pill.ms-ab-dim {
  opacity: 0.25;
  filter: grayscale(0.4) drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
}
.ms-ab-pill.ms-ab-focus {
  box-shadow: 0 0 18px var(--ab-ring, rgba(212, 168, 75, 0.6));
}

/* Custom glow keeps the ring's own line glow underneath */
.ms-ab-pill.ms-ab-glowing {
  box-shadow: 0 0 7px var(--ab-ring-soft, rgba(212, 168, 75, 0.5)),
    0 0 var(--ab-glow-size, 22px) 4px var(--ab-glow, rgba(212, 168, 75, 0.6));
}

/* Ring shapes (thick is folded into --ab-ring-w by the renderer) */
.ms-ab-pill.ms-ring-dashed { border-style: dashed; }
.ms-ab-pill.ms-ring-dotted { border-style: dotted; }

/* Extra rings from the ring builder */
.ms-ab-xring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.ms-ab-xring-spin {
  animation: ms-ab-xring-spin 40s linear infinite;
}
@keyframes ms-ab-xring-spin {
  to { transform: rotate(360deg); }
}

/* Effects: color shift animates the main border only; extra rings
   keep their own opacity and animations */
.ms-fx-flame {
  animation: ms-ab-flame-core var(--ms-flame-dur, 1.7s) ease-in-out infinite alternate;
}
@keyframes ms-ab-flame-core {
  from { border-color: var(--ms-flame-a, #ff7a1f); }
  to { border-color: var(--ms-flame-b, #ffc247); }
}

/* Solid ring + rotation: orbit a pulse of light around the circle */
.ms-ab-xring-orbit {
  animation: ms-ab-xring-spin 6s linear infinite;
}
.ms-ab-xring-orbit::before {
  content: '';
  position: absolute;
  /* abs offsets start at the padding box (inside the border), so the
     border line's center sits half a width ABOVE top: 0 */
  top: calc(var(--xr-w, 2px) / -2);
  left: 50%;
  width: calc(var(--xr-dot, 8px) * 2.6);
  height: var(--xr-dot, 8px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--xr-c, #d4a84b) 0%, rgba(0, 0, 0, 0) 65%);
}
.ms-ab-adj-flame-opts {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.ms-ab-adj-flame-opts input[type="range"] {
  flex: 1;
  accent-color: #d4a84b;
}
@media (prefers-reduced-motion: reduce) {
  .ms-ab-xring-spin,
  .ms-ab-xring-orbit,
  .ms-fx-flame,
  .ms-ab-pill::after {
    animation: none !important;
  }
}

/* Layer-promote the world only while a pan drag is active: a standing
   promotion breaks SMIL repaints (invisible pulses, flickering lines) */
.ms-panning .ms-canvas-world {
  will-change: transform;
}

/* Adjust dialog fx rows */
.ms-ab-adj-fx {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.ms-ab-adj-shape {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 6px;
}

/* Native dropdown lists render white; force dark options everywhere on the board */
.ms-ab-adj-fx select option,
.ms-ab-line-editor select option,
.ms-ctx-select option,
.ms-loc-edit select option {
  background: #1a1a1e;
  color: #fff;
}
.ms-loc-edit-fields select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #fff;
  font-size: 0.75rem;
  padding: 4px 8px;
  outline: none;
}
.ms-ab-adj-glow-str {
  flex: 1;
  accent-color: #d4a84b;
}

/* Ring builder rows */
.ms-ab-adj-sec {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 7px;
  margin-top: 3px;
}
.ms-ab-adj-fx .ms-ab-adj-sec:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.ms-ab-adj-ring-add {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.68rem;
  padding: 3px 9px;
  cursor: pointer;
}
.ms-ab-adj-ring-add:hover { border-color: rgba(212, 168, 75, 0.4); }
.ms-ab-adj-ring-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-ab-adj-ring-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.ms-ab-adj-ring-row select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #fff;
  font-size: 0.68rem;
  padding: 2px 4px;
  width: 82px;
  flex: none;
}
.ms-ab-adj-ring-row input[type="color"] {
  width: 30px;
  height: 25px;
  padding: 1px;
  flex: none;
}
.ms-ab-adj-shape {
  width: 82px;
  flex: none;
}
.ms-ab-adj-ring-row input[type="range"] {
  width: 64px;
  accent-color: #d4a84b;
  flex: none;
}
.ms-ab-adj-ring-spin {
  display: flex;
  align-items: center;
  gap: 2px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.7rem;
  cursor: pointer;
}
.ms-ab-adj-ring-spin input { margin: 0; }
.ms-ab-adj-ring-del {
  background: none;
  border: none;
  color: rgba(255, 120, 120, 0.7);
  cursor: pointer;
  padding: 2px 4px;
}
.ms-ab-adj-ring-del:hover { color: #ff7878; }

/* Frame is sized for the largest possible ring (gap 30 + line) so its
   overflow clipping keeps the dialog's own scrollbars stable */
.ms-ab-crop-ringframe {
  width: 312px;
  height: 312px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
  margin: -22px 0;
}
.ms-ab-crop-ringwrap {
  position: relative;
  width: 240px;
  height: 240px;
  flex: none;
}

/* Dead: grayscale portrait + big red X */
.ms-ab-pill.ms-ab-dead .ms-ab-pill-img { filter: grayscale(1) brightness(0.75); }
.ms-ab-dead-x {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.ms-ab-dead-x span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 86%;
  height: 7cqi;
  min-height: 3px;
  background: #c41e1e;
  border-radius: 999px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
}
.ms-ab-dead-x span:first-child { transform: translate(-50%, -50%) rotate(45deg); }
.ms-ab-dead-x span:last-child { transform: translate(-50%, -50%) rotate(-45deg); }

/* Badge icon on the ring, top-right */
.ms-ab-badge {
  position: absolute;
  top: -4%;
  right: -4%;
  width: 34cqi;
  height: 34cqi;
  min-width: 14px;
  min-height: 14px;
  border-radius: 50%;
  background: #16161a;
  border: 1.5px solid var(--ab-ring, rgba(212, 168, 75, 0.8));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
}
.ms-ab-badge i {
  color: var(--ab-ring, #d4a84b);
  font-size: 17cqi;
}
.ms-ab-badge-mask {
  width: 60%;
  height: 60%;
  background-color: var(--ab-ring, #d4a84b);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

/* Hubs */
.ms-ab-hub-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-ab-hub-icon i { font-size: 42cqi; }
.ms-ab-hub-icon-mask {
  width: 52%;
  height: 52%;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.ms-ab-hub-initial {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44cqi;
  font-weight: 700;
  color: var(--ab-ring, #d4a84b);
}

/* Armed connect-by-type */
.ms-ab-pill.ms-ab-armed-from {
  box-shadow: 0 0 16px var(--ab-ring, rgba(212, 168, 75, 0.8));
  opacity: 1 !important;
}


.ms-ab-pill .ms-resize-handle {
  z-index: 3;
}

.ms-ab-flash {
  animation: ms-ab-flash-anim 0.6s ease;
}
@keyframes ms-ab-flash-anim {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 20px rgba(212, 168, 75, 0.6); }
}

/* ── Connection label ── */

.ms-ab-conn-label {
  fill: rgba(255, 255, 255, 0.92);
  font-family: sans-serif;
}

/* ── Notes panel (expands below pill) ── */

.ms-ab-notes-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 45%;
  min-height: 160px;
  background: rgba(14, 14, 18, 0.97);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 10;
  animation: ms-ab-notes-up 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
  transition: height 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Expanded canvas: notes take 55% */
#sidebar.ms-canvas-expanded .ms-ab-notes-panel {
  height: 55%;
}

/* Side variant: right drawer instead of bottom sheet */
.ms-ab-notes-panel.ms-ab-notes-side {
  left: auto;
  top: 0;
  bottom: 0;
  right: 0;
  width: 33.6%;
  min-width: 208px;
  height: auto !important;
  border-top: none;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  animation: ms-ab-notes-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.ms-ab-notes-panel.ms-ab-notes-side.collapsing {
  animation: ms-ab-notes-out 0.18s ease forwards;
}
@keyframes ms-ab-notes-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@keyframes ms-ab-notes-out {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

/* Optional portrait at the top of the details panel */
.ms-ab-notes-portrait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 16px 0 12px;
}
.ms-ab-np-circle {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 2px solid var(--ab-ring, rgba(212, 168, 75, 0.8));
  background: #0c0c0e;
  container-type: inline-size;
  box-shadow: 0 0 7px var(--ab-ring-soft, rgba(212, 168, 75, 0.5)), 0 4px 16px rgba(0, 0, 0, 0.5);
}
.ms-ab-np-circle img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.ms-ab-np-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}
.ms-ab-np-sub {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
  margin-top: -3px;
}

/* Fullscreen toggle: notes fill the canvas */
.ms-ab-notes-panel.ms-ab-notes-full {
  height: 100%;
}

.ms-ab-notes-panel.collapsing {
  animation: ms-ab-notes-down 0.18s ease forwards;
}

@keyframes ms-ab-notes-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes ms-ab-notes-down {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}


.ms-ab-notes-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.ms-ab-notes-header > span {
  margin-right: auto;
}
.ms-ab-notes-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.ms-ab-notes-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.ms-ab-notes-content {
  flex: 1 1 0%;
  overflow-y: auto;
  padding: 8px 12px;
}

.ms-ab-notes-body {
  min-height: 60px;
  flex: 1 1 0%;
  overflow-y: auto;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.5;
  outline: none;
  padding: 4px;
  border-radius: 4px;
}
.ms-ab-notes-body:focus {
  background: rgba(255, 255, 255, 0.03);
}
.ms-ab-notes-body:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.2);
  pointer-events: none;
}
.ms-ab-notes-body h3 {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.9);
  margin: 6px 0 3px;
}
.ms-ab-notes-body ul, .ms-ab-notes-body ol {
  margin: 4px 0;
  padding-left: 18px;
}

.ms-ab-notes-section + .ms-ab-notes-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.ms-ab-notes-section-header {
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  padding-left: 4px;
}

/* ── Relationships section ── */

.ms-ab-rels {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.ms-ab-rels-title {
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.ms-ab-rel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 0.65rem;
}
.ms-ab-rel-source {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}
.ms-ab-rel-arrow {
  color: rgba(212, 168, 75, 0.7);
  font-size: 1.1rem;
}
.ms-ab-rel-label {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}
.ms-ab-rel-target {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

/* ── Line editor (floating in world) ── */

.ms-ab-line-editor {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(12, 12, 14, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 12px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: ms-popup-in 0.15s ease;
}
.ms-ab-le-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ms-ab-le-row input[type="text"] {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.68rem;
  color: #fff;
  outline: none;
  flex: 1;
  min-width: 0;
}
.ms-ab-le-row input[type="text"]:focus {
  border-color: rgba(212, 168, 75, 0.4);
}
.ms-ab-le-color {
  width: 30px;
  height: 25px;
  padding: 1px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  flex: none;
}

/* Focused dashed/dotted lines march their dashes toward the arrow end.
   Offsets equal one full dash period so the loop is seamless. */
.ms-ab-dash-anim {
  animation: ms-ab-dash-flow 1.04s linear infinite;
}
@keyframes ms-ab-dash-flow {
  to { stroke-dashoffset: -2.5; }
}
.ms-ab-dot-anim {
  animation: ms-ab-dot-flow 0.61s linear infinite;
}
@keyframes ms-ab-dot-flow {
  to { stroke-dashoffset: -1.2; }
}
.ms-ab-le-fontsize {
  width: 42px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 4px;
  font-size: 0.65rem;
  color: #fff;
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}
.ms-ab-le-fontsize::-webkit-inner-spin-button,
.ms-ab-le-fontsize::-webkit-outer-spin-button {
  opacity: 1;
}
.ms-ab-le-fontsize:focus {
  border-color: rgba(212, 168, 75, 0.4);
}
.ms-ab-le-row select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.65rem;
  color: #fff;
  outline: none;
}

/* Connecting state */
.ms-ab-connecting .ms-ab-pill {
  opacity: 0.6;
}
.ms-ab-connecting .ms-ab-pill:hover {
  opacity: 1;
  border-color: rgba(80, 200, 120, 0.6);
}

/* ── Board legend (GM-defined line types) ── */

.ms-ab-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 9;
  min-width: 150px;
  max-width: 220px;
  background: rgba(14, 14, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  font-size: 0.68rem;
  overflow: hidden;
}
.ms-ab-legend-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  color: #d4a84b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.62rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ms-ab-legend-head span { flex: 1; }
.ms-ab-legend-head button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.62rem;
}
.ms-ab-legend-head button:hover { color: #d4a84b; }
.ms-ab-legend.closed .ms-ab-legend-rows { display: none; }
.ms-ab-legend.closed .ms-ab-legend-head { border-bottom: none; }
.ms-ab-legend-rows {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
}
.ms-ab-legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 8px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
}
.ms-ab-legend-row:hover { background: rgba(212, 168, 75, 0.08); }
.ms-ab-legend-row.armed {
  background: rgba(212, 168, 75, 0.16);
  color: #fff;
}
.ms-ab-legend-swatch {
  width: 26px;
  height: 8px;
  flex: 0 0 26px;
}
.ms-ab-legend-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-ab-legend-eye {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 1px 3px;
  font-size: 0.6rem;
}
.ms-ab-legend-eye:hover { color: #d4a84b; }
.ms-ab-legend-empty {
  padding: 6px 10px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.62rem;
  line-height: 1.4;
}

/* ── Hover card ── */

.ms-ab-hovercard {
  position: fixed;
  z-index: 100001;
  background: rgba(14, 14, 18, 0.95);
  border: 1px solid rgba(212, 168, 75, 0.25);
  border-radius: 8px;
  padding: 7px 12px;
  pointer-events: none;
  text-align: center;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.ms-ab-hovercard.visible { opacity: 1; transform: translateY(0); }
.ms-ab-hovercard-text {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.7rem;
  line-height: 1.45;
  max-width: 240px;
  white-space: pre-wrap;
  text-align: left;
}

/* ── Minimap ── */

.ms-ab-minimap {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 9;
  background: rgba(14, 14, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px;
  cursor: crosshair;
}
.ms-ab-minimap canvas { display: block; border-radius: 5px; }

/* ── Ambient embers ── */

.ms-ab-embers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ── Relationship details in the notes panel ── */

.ms-ab-rel-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
/* Seamless prose, styled like the notes body: no box, grows downward */
.ms-ab-rel-detail {
  width: 100%;
  margin: 2px 0 8px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 1.2em;
  outline: none;
  cursor: text;
}
.ms-ab-rel-detail:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.25);
}
.ms-ab-rel-detail-ro {
  margin: 2px 0 8px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.66rem;
  font-style: italic;
  white-space: pre-wrap;
}
.ms-ab-le-type {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 0;
}

/* ── Board search (header) ── */

.ms-panel-ab-find {
  position: relative;
}
.ms-panel-ab-find input {
  width: 130px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: #fff;
  font-size: 0.68rem;
  padding: 3px 8px;
  outline: none;
}
.ms-panel-ab-find input:focus { border-color: rgba(212, 168, 75, 0.4); }
.ms-panel-ab-find-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 3px;
  background: rgba(14, 14, 18, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  z-index: 100001;
  overflow: hidden;
}
.ms-panel-ab-find-list div {
  padding: 4px 9px;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-panel-ab-find-list div:hover {
  background: rgba(212, 168, 75, 0.12);
  color: #fff;
}

/* ── Board Areas ── */

.ms-ab-area {
  pointer-events: all;
}
.ms-ab-area-label {
  font-family: 'Signika', sans-serif;
  font-weight: 600;
  cursor: grab;
  pointer-events: all;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.ms-ab-drawing {
  cursor: crosshair !important;
}
.ms-ab-drawing .ms-ab-pill {
  pointer-events: none;
  opacity: 0.4;
}
.ms-ab-drawing .ms-ab-area {
  pointer-events: none;
}
.ms-ab-drawing .ms-ab-svg {
  pointer-events: all;
  cursor: crosshair;
}
.ms-ab-draw-preview {
  pointer-events: none;
}
.ms-ab-draw-vertex {
  pointer-events: none;
}

.ms-ab-readonly {
  pointer-events: none;
}

.ms-actors-board-presentation {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  background: #0c0c0e;
}
.ms-actors-board-presentation > header {
  height: 44px;
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  color: rgba(255, 255, 255, 0.9);
  background: #111214;
  border-bottom: 1px solid rgba(212, 168, 75, 0.25);
  font-weight: 600;
}
.ms-actors-board-presentation > header > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ms-actors-board-presentation > header small {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.62rem;
  font-weight: 400;
}
.ms-actors-board-presentation > header button {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  cursor: pointer;
}
.ms-actors-board-presentation > header button:hover {
  color: #d4a84b;
  border-color: rgba(212, 168, 75, 0.3);
}
.ms-actors-board-presentation-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.4) 100%),
    #0c0c0e;
  background-size: 32px 32px, 100% 100%, 100% 100%;
}
.ms-actors-board-presentation-canvas.ms-panning {
  cursor: grabbing;
}

/* Context menu extras for areas */
.ms-ctx-header {
  padding: 6px 14px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(212, 168, 75, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ms-ctx-input-row {
  padding: 4px 10px;
}
.ms-ctx-text-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: #ddd;
  padding: 5px 8px;
  font-size: 0.75rem;
  outline: none;
  box-sizing: border-box;
}
.ms-ctx-text-input:focus {
  border-color: rgba(212, 168, 75, 0.4);
}
.ms-ctx-option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75rem;
}
.ms-ctx-option-row i {
  width: 14px;
  text-align: center;
  font-size: 0.7rem;
}
.ms-ctx-option-row span {
  flex: 1;
}
.ms-ctx-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: #ddd;
  padding: 3px 6px;
  font-size: 0.7rem;
  outline: none;
  cursor: pointer;
}
.ms-ctx-select:focus {
  border-color: rgba(212, 168, 75, 0.4);
}
.ms-ctx-range {
  width: 80px;
  accent-color: #d4a84b;
  cursor: pointer;
}

/* ── Settings: Actor Notes Template fields ── */
.ms-template-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-template-field-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ms-template-field-row input {
  flex: 1;
}
.ms-template-remove-btn {
  flex: 0 0 26px;
  height: 26px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  padding: 0;
}
.ms-template-remove-btn:hover {
  color: #e55;
  border-color: rgba(229, 85, 85, 0.3);
}
.ms-template-add-btn {
  align-self: flex-start;
  background: none;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.45);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  margin-top: 2px;
}
.ms-template-add-btn:hover {
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.75);
}

/* ── Journal Pin Dialog ── */
.app.ms-pin-dialog {
  background: #0c0c0e !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
}
.app.ms-pin-dialog .window-header {
  background: #111214 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85) !important;
}
.app.ms-pin-dialog .window-header a,
.app.ms-pin-dialog .window-header .close,
.app.ms-pin-dialog .window-header .header-button {
  color: rgba(255, 255, 255, 0.4) !important;
}
.app.ms-pin-dialog .window-header a:hover,
.app.ms-pin-dialog .window-header .close:hover {
  color: #fff !important;
}
.app.ms-pin-dialog .window-content {
  background: #0c0c0e !important;
  color: rgba(255, 255, 255, 0.85) !important;
}
.app.ms-pin-dialog .dialog-content {
  padding: 8px 12px;
}
.app.ms-pin-dialog fieldset {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  margin: 0 0 8px;
  padding: 6px 10px 10px;
}
.app.ms-pin-dialog legend {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45) !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 6px;
}
.app.ms-pin-dialog .form-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
}
.app.ms-pin-dialog .form-group label {
  flex: 0 0 80px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55) !important;
  text-align: right;
}
.app.ms-pin-dialog .form-group input[type="text"],
.app.ms-pin-dialog .form-group input[type="number"],
.app.ms-pin-dialog .form-group select {
  flex: 1;
  background: #161618 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 4px;
  color: #fff !important;
  padding: 4px 8px;
  font-size: 0.8rem;
  outline: none;
}
.app.ms-pin-dialog .form-group select option {
  background: #111214;
  color: #fff;
}
.app.ms-pin-dialog .form-group input:focus,
.app.ms-pin-dialog .form-group select:focus {
  border-color: rgba(212, 168, 75, 0.4) !important;
}
.app.ms-pin-dialog .form-group input[disabled] {
  opacity: 0.5;
}
.app.ms-pin-dialog .form-group input[type="color"] {
  flex: 1;
  height: 28px;
  background: #161618 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
}
.app.ms-pin-dialog .form-group input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.app.ms-pin-dialog .form-group input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

/* Icon picker */
.ms-pin-icon-picker {
  flex: 1;
  position: relative;
}
.app.ms-pin-dialog .ms-pin-icon-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #161618 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 4px;
  color: #fff !important;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.app.ms-pin-dialog .ms-pin-icon-btn:hover {
  border-color: rgba(212, 168, 75, 0.4) !important;
}
.ms-pin-icon-btn img {
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1);
}
.ms-pin-icon-btn span {
  flex: 1;
  text-align: left;
}
.ms-pin-icon-btn i {
  font-size: 0.65rem;
  opacity: 0.4;
}
.ms-pin-icon-grid {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(auto-fill, 38px);
  gap: 3px;
  padding: 8px;
  margin-top: 4px;
  background: #111214;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  max-height: 200px;
  overflow-y: auto;
}
.ms-pin-icon-item {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.ms-pin-icon-item:hover {
  background: rgba(212, 168, 75, 0.12);
  border-color: rgba(212, 168, 75, 0.3);
}
.ms-pin-icon-item.selected {
  background: rgba(212, 168, 75, 0.2);
  border-color: rgba(212, 168, 75, 0.5);
}
.ms-pin-icon-item img {
  width: 24px;
  height: 24px;
  filter: brightness(0) invert(1);
}

.app.ms-pin-dialog .dialog-buttons {
  padding: 6px 12px 10px;
  background: transparent !important;
}
.app.ms-pin-dialog .dialog-buttons button {
  width: 100%;
  background: rgba(212, 168, 75, 0.15) !important;
  border: 1px solid rgba(212, 168, 75, 0.3) !important;
  border-radius: 6px;
  color: #d4a84b !important;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.app.ms-pin-dialog .dialog-buttons button:hover {
  background: rgba(212, 168, 75, 0.25) !important;
  border-color: rgba(212, 168, 75, 0.5) !important;
}

/* ── Scene Pins ── */
.ms-scene-pin {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  padding: 10px 22px;
  border-radius: 999px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease, border-color 0.15s;
  overflow: hidden;
}
.ms-scene-pin::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  border-radius: inherit;
  transition: background 0.15s;
}
.ms-scene-pin:hover {
  transform: scale(1.06);
  z-index: 10;
  border-color: rgba(212, 168, 75, 0.5);
}
.ms-scene-pin:hover::before {
  background: rgba(0, 0, 0, 0.3);
}
.ms-scene-pin.dragging {
  opacity: 0.7;
  z-index: 50;
}
.ms-scene-pin span {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* ── Sound Pins ── */
.ms-sound-pin {
  --ms-sound-color: #64b4ff;
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 5;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ms-sound-color) 18%, rgba(30, 30, 40, 0.92));
  border: 1px solid color-mix(in srgb, var(--ms-sound-color) 58%, transparent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease, border-color 0.15s, background 0.15s;
}
.ms-sound-pin:hover {
  transform: scale(1.06);
  z-index: 10;
  border-color: var(--ms-sound-color);
  background: color-mix(in srgb, var(--ms-sound-color) 28%, rgba(30, 30, 40, 0.92));
}
.ms-sound-pin.playing {
  border-color: var(--ms-sound-color);
  background: color-mix(in srgb, var(--ms-sound-color) 38%, rgba(25, 30, 40, 0.92));
}
.ms-sound-pin.dragging {
  opacity: 0.7;
  z-index: 50;
}
.ms-sound-pin i {
  font-size: 0.65rem;
  color: var(--ms-sound-color);
  width: 10px;
  text-align: center;
}
.ms-sound-pin.playing i {
  color: var(--ms-sound-color);
  filter: drop-shadow(0 0 4px var(--ms-sound-color));
}
.ms-sound-pin span {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.7rem;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.ms-sound-pin.queue {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr) auto;
  width: 210px;
  padding: 7px;
  border-radius: 10px;
}

.ms-sound-pin.queue > .ms-sound-queue-count {
  color: color-mix(in srgb, var(--ms-sound-color) 45%, white);
  font-size: 0.52rem;
  text-transform: uppercase;
}

.ms-sound-queue-list {
  display: flex;
  grid-column: 1 / -1;
  flex-direction: column;
  gap: 3px;
  margin: 5px 0 0;
  padding: 0;
  list-style: none;
}

.ms-sound-pin.queue.mood {
  width: 320px;
}

.ms-sound-queue-columns {
  display: flex;
  grid-column: 1 / -1;
  gap: 6px;
  margin: 5px 0 0;
}

.ms-sound-queue-columns > .ms-sound-queue-list {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.ms-sound-queue-divider {
  flex: 0 0 1px;
  background: rgba(255, 255, 255, 0.2);
}

.ms-sound-queue-list > li {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid color-mix(in srgb, var(--ms-queue-color) 32%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--ms-queue-color) 10%, rgba(0, 0, 0, 0.35));
  cursor: grab;
  transition: transform 120ms ease, opacity 120ms ease, border-color 120ms ease;
}

.ms-sound-queue-list > li:hover {
  border-color: var(--ms-queue-color);
}

.ms-sound-queue-list > li.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.ms-sound-queue-list > li > i {
  flex: 0 0 10px;
  color: var(--ms-queue-color);
}

.ms-sound-queue-list > li > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-sound-pin.effect {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 65.6px;
  height: 65.6px;
  gap: 4px;
  margin: 0;
  padding: 6.4px;
  border-radius: 50%;
  color: inherit;
  font-family: inherit;
  line-height: normal;
  appearance: none;
}

.ms-sound-pin.effect i {
  width: auto;
  font-size: 1.16rem;
}

.ms-sound-pin.effect span {
  display: -webkit-box;
  max-width: 52.8px;
  overflow: hidden;
  font-size: 0.5rem;
  font-weight: 600;
  line-height: 1.05;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ── Pop-out window (V14) ── */

/* Popout window container: sidebar left, canvas right */
.ms-popout-body {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  background: #0c0c0e;
  overflow: hidden;
}

/* Sidebar in the popout: default Foundry width, full height, no fixed positioning */
.ms-popout-body > #sidebar {
  position: static !important;
  height: 100% !important;
  max-height: 100% !important;
  right: auto !important;
  top: auto !important;
  flex: 0 0 auto;
}

/* Mindscape panel fills remaining space next to the sidebar */
.ms-popout-body > #ms-sidebar-panel {
  flex: 1 1 0%;
  min-width: 0;
  height: 100%;
  display: flex !important;
  flex-direction: column;
  background: #0c0c0e;
}
.ms-popout-body > #ms-sidebar-panel .ms-panel-canvas {
  flex: 1 1 0%;
  min-height: 0;
}

/* Popout app frame */
#mindscape-popout {
  background: #0c0c0e !important;
  border: none;
}
#mindscape-popout .window-header { display: none !important; }
#mindscape-popout .window-content {
  padding: 0;
  height: 100%;
  background: #0c0c0e !important;
  overflow: hidden;
}


/* ============================================================
   Scene Markers (canvas map pins)
   ============================================================ */

.ms-scene-markers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}

.ms-scene-marker {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  transition: filter 0.12s ease;
  user-select: none;
}
.ms-scene-marker:hover {
  filter: drop-shadow(0 2px 8px var(--marker-color, #d4a84b));
}

.ms-scene-marker i {
  font-size: var(--marker-size, 32px);
  color: #d4a84b;
  transition: transform 0.12s ease;
}
.ms-scene-marker:hover i,
.ms-scene-marker:hover .ms-marker-icon {
  transform: scale(1.15);
}

.ms-marker-icon {
  width: var(--marker-size, 32px);
  height: var(--marker-size, 32px);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  transition: transform 0.12s ease;
}

.ms-scene-marker span {
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  margin-top: 4px;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.ms-scene-marker:hover span {
  opacity: 1;
}


.ms-marker-hidden {
  opacity: 0.75;
}

.ms-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.7rem;
}
.ms-marker-slider {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.ms-marker-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d4a84b;
  cursor: pointer;
}
.ms-marker-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d4a84b;
  border: none;
  cursor: pointer;
}

/* Icon picker */
.ms-icon-picker {
  position: fixed;
  width: 360px;
  max-height: 480px;
  background: rgba(12, 12, 14, 0.88);
  backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  z-index: 100005;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  animation: ms-popup-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.ms-icon-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.ms-icon-tab {
  flex: 1;
  padding: 8px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.ms-icon-tab:hover {
  color: rgba(255, 255, 255, 0.6);
}
.ms-icon-tab.active {
  color: #d4a84b;
  border-bottom-color: #d4a84b;
}
.ms-icon-search {
  margin: 8px 10px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.8rem;
  outline: none;
  box-sizing: border-box;
}
.ms-icon-search:focus {
  border-color: rgba(212, 168, 75, 0.4);
}
.ms-icon-fa {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.6);
}
.ms-icon-cell:hover .ms-icon-fa {
  color: #fff;
}
.ms-marker-fa-icon {
  font-size: var(--marker-size, 32px);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.ms-icon-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 0 10px 10px;
  overflow-y: auto;
  max-height: 380px;
}
.ms-icon-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  cursor: pointer;
  padding: 6px;
  transition: background 0.12s ease;
}
.ms-icon-cell:hover {
  background: rgba(212, 168, 75, 0.1);
}
.ms-icon-cell.active {
  background: rgba(212, 168, 75, 0.2);
  outline: 1px solid #d4a84b;
}
.ms-icon-swatch {
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.6);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  transition: background-color 0.12s ease;
}
.ms-icon-cell:hover .ms-icon-swatch {
  background-color: #fff;
}
.ms-icon-clear {
  margin: 4px 10px 10px;
  padding: 7px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  font-size: 0.75rem;
  text-align: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.ms-icon-clear:hover {
  background: rgba(212, 168, 75, 0.1);
  color: #d4a84b;
}

/* ── Dramatic Entrance Zone ── */

.ms-dramatic-zone {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-top: 4px;
  border-radius: 8px;
  background: rgba(14, 14, 18, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  pointer-events: auto;
}

.ms-dramatic-drop {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.65rem;
  cursor: default;
  flex: 1;
  transition: border-color 0.15s, background 0.15s;
}
.ms-dramatic-drop::before {
  content: 'Dramatic Entrance';
  font-style: italic;
}
.ms-dramatic-drop.ms-dramatic-has-actor::before {
  display: none;
}
.ms-dramatic-drop.ms-drop-target {
  border-color: rgba(212, 168, 75, 0.5);
  background: rgba(212, 168, 75, 0.08);
}
.ms-dramatic-drop img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}
.ms-dramatic-drop span {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-dramatic-sound-drop {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 28px;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px dashed rgba(100, 180, 255, 0.25);
  color: rgba(100, 180, 255, 0.4);
  font-size: 0.6rem;
  cursor: default;
  transition: border-color 0.15s, background 0.15s;
  pointer-events: auto;
}
.ms-dramatic-sound-drop::before {
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  content: '\f001';
  font-size: 0.6rem;
}
.ms-dramatic-sound-drop.ms-dramatic-sound-has::before {
  display: none;
}
.ms-dramatic-sound-drop.ms-drop-target {
  border-color: rgba(100, 180, 255, 0.6);
  background: rgba(100, 180, 255, 0.08);
}
.ms-dramatic-sound-drop i {
  color: rgba(100, 180, 255, 0.6);
  font-size: 0.6rem;
  flex-shrink: 0;
}
.ms-dramatic-sound-drop span {
  color: rgba(100, 180, 255, 0.7);
  font-size: 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60px;
}

.ms-dramatic-controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.ms-dramatic-controls button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.ms-dramatic-controls button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.ms-dramatic-play.ms-dramatic-active {
  background: rgba(200, 60, 60, 0.2);
  border-color: rgba(200, 60, 60, 0.4);
  color: #e55;
}
.ms-dramatic-play.ms-dramatic-active:hover {
  background: rgba(200, 60, 60, 0.3);
}

/* ── Dramatic Config Popup ── */

.ms-dramatic-config {
  z-index: 999;
  background: rgba(18, 18, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 160px;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}
.ms-dramatic-config label {
  display: block;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ms-dramatic-config select {
  width: 100%;
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.72rem;
  margin-bottom: 8px;
  outline: none;
}
.ms-de-dur {
  width: 100%;
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.72rem;
  outline: none;
}

/* ── Dramatic Entrance Overlay (fullscreen, all clients) ── */

.ms-dramatic-overlay {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
.ms-dramatic-overlay img {
  max-height: 85vh;
  max-width: 70vw;
  object-fit: contain;
  filter: drop-shadow(0 0 60px rgba(0, 0, 0, 0.8));
}
.ms-dramatic-overlay[data-animation="fade"] img {
  animation-name: ms-de-fade;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
.ms-dramatic-overlay[data-animation="slideUp"] img {
  animation-name: ms-de-slide-up;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
.ms-dramatic-overlay[data-animation="blurIn"] img {
  animation-name: ms-de-blur-in;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
.ms-dramatic-overlay[data-animation="flicker"] img {
  animation-name: ms-de-flicker;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
.ms-dramatic-overlay[data-animation="jumpscare"] img {
  animation-name: ms-de-jumpscare;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  animation-duration: 0.15s !important;
}

.ms-dramatic-exit {
  animation: ms-de-exit 0.4s ease forwards !important;
}

@keyframes ms-de-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes ms-de-slide-up {
  from { transform: translateY(100vh); }
  to { transform: translateY(0); }
}
@keyframes ms-de-blur-in {
  0% { opacity: 0; filter: blur(40px) brightness(1.5); }
  30% { opacity: 1; filter: blur(40px) brightness(1.5); }
  100% { opacity: 1; filter: blur(0) brightness(1); }
}
@keyframes ms-de-flicker {
  0% { opacity: 0; }
  5% { opacity: 0.8; }
  10% { opacity: 0; }
  20% { opacity: 0.6; }
  25% { opacity: 0; }
  40% { opacity: 0.9; }
  45% { opacity: 0.2; }
  55% { opacity: 0; }
  65% { opacity: 0.7; }
  70% { opacity: 0; }
  80% { opacity: 1; }
  85% { opacity: 0.3; }
  95% { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes ms-de-jumpscare {
  from { opacity: 0; transform: scale(3); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes ms-de-exit {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Portrait States Popup */
.ms-portrait-states {
  position: fixed;
  z-index: 10000;
  padding: 8px 10px;
  background: #111214;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  transform: translateX(-50%);
}
.ms-pstate-grid {
  display: flex;
  gap: 6px;
}
.ms-pstate {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.ms-pstate:hover {
  border-color: rgba(212, 168, 75, 0.5);
  transform: scale(1.1);
}
.ms-pstate.active {
  border-color: #d4a84b;
  box-shadow: 0 0 8px rgba(212, 168, 75, 0.4);
}
.ms-pstate img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ms-pstate-add {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-style: dashed;
}
.ms-pstate-add:hover {
  background: rgba(212, 168, 75, 0.1);
}
.ms-pstate-add i {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.9rem;
}

/* Items on mindscape location scenes */
.ms-scene-items {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}
.ms-scene-item {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.55));
  transition: transform 0.15s ease, filter 0.12s ease;
}
.ms-scene-item:hover {
  filter: drop-shadow(0 3px 12px rgba(212, 168, 75, 0.45));
}
.ms-scene-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.ms-scene-item span {
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  background: rgba(0, 0, 0, 0.45);
  padding: 1px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

/* Item examine popup */
.ms-item-examine {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.ms-item-examine.visible { opacity: 1; }
.ms-item-examine-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: #111214;
  border: 1px solid rgba(212, 168, 75, 0.3);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.ms-item-examine-card img {
  max-width: 320px;
  max-height: 320px;
  border-radius: 8px;
}
.ms-item-examine-card span {
  color: #d4a84b;
  font-weight: 600;
}

/* GM note display on the main screen */
.ms-note-display {
  position: fixed;
  z-index: 95;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  min-height: 140px;
  background: rgba(17, 18, 20, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(212, 168, 75, 0.3);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ms-note-display.visible {
  opacity: 1;
  transform: translateY(0);
}
.ms-note-display-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
  color: rgba(212, 168, 75, 0.8);
  font-size: 0.75rem;
  user-select: none;
}
.ms-note-display-header:active { cursor: grabbing; }
.ms-note-display-pager {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.7rem;
}
.ms-note-display-header button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 2px 5px;
  font-size: 0.7rem;
}
.ms-note-display-header button:hover:not(:disabled) { color: #d4a84b; }
.ms-note-display-pager button:disabled { opacity: 0.25; cursor: default; }
.ms-note-display-close { margin-left: 4px; }
.ms-note-display-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.ms-note-display-resize {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  border-right: 2px solid rgba(212, 168, 75, 0.4);
  border-bottom: 2px solid rgba(212, 168, 75, 0.4);
  border-radius: 0 0 6px 0;
}

/* Scene marker hover preview (GM) */
.ms-marker-preview {
  position: fixed;
  width: 220px;
  z-index: 10;
  background: #111214;
  border: 1px solid rgba(212, 168, 75, 0.25);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ms-marker-preview.visible {
  opacity: 1;
  transform: translateY(0);
}
.ms-marker-preview img,
.ms-marker-preview video {
  width: 100%;
  display: block;
  border-radius: 5px;
}

/* Rubber-band selection */
.ms-marquee {
  position: absolute;
  border: 1px dashed rgba(212, 168, 75, 0.8);
  background: rgba(212, 168, 75, 0.08);
  pointer-events: none;
  z-index: 60;
}
.ms-canvas-world .ms-selected {
  outline: 2px solid rgba(212, 168, 75, 0.85);
  outline-offset: 2px;
}
