/* Project Engine — Custom Styles
   Supplements localsite/css/base.css
   Uses CSS variables for dark mode compatibility */

/* =========================================================
   Title row — engine mode menu (Project, Arts, Activities, Design) at far right
   ========================================================= */

/* Page header, just before #engineContent: the same width and side padding as #engineContent
   (.contentpadding, max-width 1600px), and the top padding moves here from it */
#aeHeader {
  max-width: 1600px;
  padding: 25px 30px 0;
  margin-bottom: 24px;
}
#engineContent {
  padding-top: 0;
}
/* Full Screen map (body.map-fullscreen-active, set by toggleMapScreen in team/js/map.js): the header spans
   the full width, with less space above it than the usual 25px */
body.map-fullscreen-active #aeHeader {
  max-width: none;
  padding-top: 20px;
}

/* Image at the start of #ae-subtitle (AE_SUBTITLE_IMAGE in index.html, commented out for now), full width above the text */
.ae-subtitle-image {
  display: block;
  width: 100%;
  margin: 4px 0 8px;
}
.ae-subtitle-image img {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  border-radius: 12px;
}
.dark .ae-subtitle-image img {
  opacity: 0.9;
}

.ae-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 6px;
}

#ae-title .ae-title-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  fill: #4a90e2;
}

/* Title + down arrow (#aeModeTrigger) open #aeModeMenu below the title */
.ae-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

#ae-title {
  cursor: pointer;
  line-height: 1;
}

.ae-mode-trigger.ae-title-arrow {
  padding: 2px;
  border: none;
  border-radius: 8px;
  background: transparent;
}

.ae-mode-trigger.ae-title-arrow .material-icons {
  font-size: 28px;
}

.ae-title-wrap .ae-mode-menu {
  left: 0;
  right: auto;
}

.dark .ae-mode-trigger.ae-title-arrow {
  background: transparent;
}

.dark .ae-mode-trigger.ae-title-arrow:hover {
  background: #363636;
}

.ae-mode-wrap {
  position: relative;
}

.ae-mode-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 6px 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s;
}

.ae-mode-trigger:hover {
  background: #f1f5f9;
}

.ae-mode-trigger .material-icons {
  font-size: 20px;
  color: #64748b;
}

.ae-mode-menu {
  position: absolute;
  /* Above the map's Leaflet layers (400) and controls (1000) and its floating image and location details
     (999 and 998, team/css/widget.css), below modals (10000) */
  z-index: 1100;
  right: 0;
  top: calc(100% + 6px);
  min-width: 170px;
  padding: 6px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.ae-mode-menu[hidden] {
  display: none;
}

.ae-mode-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  border-radius: 10px;
}

.ae-mode-option + .ae-mode-option {
  margin-top: 3px;
}

.ae-mode-option:hover {
  background: #f1f5f9;
}

.ae-mode-option.active {
  background: #e8f1fc;
}

.ae-mode-pick {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  white-space: nowrap;
}

.ae-mode-pick .material-icons {
  font-size: 18px;
  color: #64748b;
}

.ae-mode-option.active .ae-mode-pick {
  font-weight: 600;
}

.ae-mode-option.active .material-icons {
  color: #4a90e2;
}

.ae-mode-check {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #4a90e2;
  cursor: pointer;
}

/* Selected team source links, in the Team Sources panel above Model */
.ae-team-source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: #888;
}

.ae-team-source:not([hidden]) ~ .ae-team-source {
  margin-top: 8px;
}

#teamSourcesPanel[hidden] {
  display: none;
}

.ae-team-source[hidden] {
  display: none;
}

.ae-team-source .material-icons {
  font-size: 18px;
  color: #4a90e2;
}

.dark .ae-team-source .material-icons {
  color: #6aa8ec;
}

.dark .ae-mode-trigger,
.dark .ae-mode-menu {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
}

.dark .ae-mode-menu {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.dark .ae-mode-trigger:hover,
.dark .ae-mode-option:hover {
  background: #363636;
}

.dark .ae-mode-pick {
  color: #e5e7eb;
}

.dark .ae-mode-trigger .material-icons,
.dark .ae-mode-pick .material-icons {
  color: #9ca3af;
}

.dark .ae-mode-option.active {
  background: rgba(74, 144, 226, 0.2);
}

.dark .ae-mode-option.active .material-icons {
  color: #6aa8ec;
}

/* =========================================================
   Model trigger — mirrors chat/prompt sp-model-* pattern
   ========================================================= */

.sp-model-wrap {
  position: relative;
}

.sp-model-trigger {
  min-width: 170px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s;
}

.sp-model-trigger:hover {
  background: #f1f5f9;
}

.sp-model-copy {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.sp-model-name {
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #0f172a;
}

.sp-model-provider {
  font-size: 0.68rem;
  color: #64748b;
  flex: 0 0 auto;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#toggleAgentsEditor.btn-nice:hover,
#toggleAgentsEditor.btn-nice:focus {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff !important;
  box-shadow: 0 2px 10px rgba(29, 78, 216, 0.38);
}

/* Open state — plain button while the key manager is showing */
#toggleAgentsEditor.btn-nice.active {
  background: #fff;
  color: #0f172a !important;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
#toggleAgentsEditor.btn-nice.active:hover {
  background: #f1f5f9;
}
.dark #toggleAgentsEditor.btn-nice.active {
  background: #2a2a2a;
  color: #e5e7eb !important;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.dark #toggleAgentsEditor.btn-nice.active:hover {
  background: #363636;
}

.sp-model-menu {
  position: absolute;
  z-index: 1100; /* over the floating image and location details (team/css/widget.css) */
  left: 0;
  top: calc(100% + 6px);
  width: min(340px, 92vw);
  max-height: 400px;
  overflow: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.sp-model-menu[hidden] {
  display: none;
}

.sp-model-provider-group + .sp-model-provider-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.sp-model-provider-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  color: #64748b;
  font-size: 0.76rem;
  font-weight: 600;
}

.sp-model-option {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: #0f172a;
  font: inherit;
}

.sp-model-option:hover {
  background: #f1f5f9;
}
.sp-model-option.is-disabled {
  opacity: 0.5;
  cursor: default;
}

.sp-model-option-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sp-model-option-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.sp-model-option-meta {
  color: #64748b;
  font-size: 0.71rem;
  line-height: 1.3;
  min-height: 1em;
}

.dark .sp-model-trigger,
.dark .sp-model-menu {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
}

.dark .sp-model-menu {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.dark .sp-model-trigger:hover,
.dark .sp-model-option:hover {
  background: #363636;
}

.dark .sp-model-name,
.dark .sp-model-option {
  color: #e5e7eb;
}

.dark .sp-model-provider,
.dark .sp-model-provider-header,
.dark .sp-model-option-meta {
  color: #9ca3af;
}

.dark .sp-model-provider-group + .sp-model-provider-group {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.issues-header {
  border: none !important;
  padding: 0px !important;
}

.content a:not(.btn):link,
.content a:not(.btn):visited {
  color: #1f5fbf;
  text-decoration: none;
}

.content a:not(.btn):hover,
.content a:not(.btn):focus {
  color: #174a95;
  text-decoration: underline;
}

.dark .content a:not(.btn):link,
.dark .content a:not(.btn):visited {
  color: #8fbaff;
}

.dark .content a:not(.btn):hover,
.dark .content a:not(.btn):focus {
  color: #bfd8ff;
}

/* No underline on map controls (zoom + and -) */
.content .leaflet-control-container a:hover,
.content .leaflet-control-container a:focus {
  text-decoration: none;
}
/* =========================================================
   Layout
   ========================================================= */

.ae-container {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  width: 100%;
}

.ae-left {
  flex: 65;
  min-width: 300px;
}

.ae-right {
  flex: 35;
  min-width: 260px;
  container-type: inline-size;
}

/* One column when .ae-container is under 700px wide, including in Half Screen
   (.ae-one-column is set by setupEngineWidthClasses in js/app.js).
   One-column grid rather than a column flexbox: as a column flex item, .ae-right's
   container-type (inline-size) made Chrome size it taller than its content, leaving blank space below */
.ae-container.ae-one-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.ae-one-column > .ae-right {
  order: -1; /* GitHub token widget first on mobile */
}

/* =========================================================
   Panels
   ========================================================= */

.ae-panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  position: relative;
}

.ae-panel h3 {
  margin: 0 0 14px 0;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
}

.dark .ae-panel {
  background: #2a2a2a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Create Team hidden once team sources are chosen (beats localsite's .local !important on localhost) */
#aeTeamWrap.ae-team-hidden {
  display: none !important;
}

/* Team Sources heading: title left, "Add" menu button at the far right */
.ae-panel h3.ae-team-sources-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ae-team-sources-heading .ae-mode-wrap {
  text-transform: none;
  letter-spacing: normal;
}

.dark .ae-panel h3 {
  color: #aaa;
}

/* =========================================================
   Prompt Input
   ========================================================= */

#promptInput {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s;
  background: #fafafa;
  color: #222;
  overflow: hidden;
}

#promptInput:focus,
#promptInput.expanded {
  outline: none;
  border-color: #4a90e2;
  background: #fff;
  min-height: 110px;
  overflow: auto;
}

.dark #promptInput {
  background: #1e1e1e;
  border-color: #444;
  color: #e0e0e0;
}

.dark #promptInput:focus {
  border-color: #6aacf5;
  background: #222;
}

/* =========================================================
   CSV Upload
   ========================================================= */

.ae-csv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ae-csv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px dashed #bbb;
  border-radius: 8px;
  background: transparent;
  color: #666;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.2s;
}

.ae-csv-btn:hover {
  border-color: #4a90e2;
  color: #4a90e2;
  background: rgba(74, 144, 226, 0.05);
}

.dark .ae-csv-btn {
  border-color: #555;
  color: #aaa;
}

.dark .ae-csv-btn:hover {
  border-color: #6aacf5;
  color: #6aacf5;
}

.ae-csv-name {
  font-size: 0.85rem;
  color: #888;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dark .ae-csv-name {
  color: #777;
}

/* =========================================================
   Loaded Prompts List
   ========================================================= */

#promptList {
  margin-top: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.prompt-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.88rem;
  border: 1px solid transparent;
}

.prompt-item:hover {
  background: rgba(74, 144, 226, 0.08);
  border-color: rgba(74, 144, 226, 0.2);
}

.prompt-item.selected {
  background: rgba(74, 144, 226, 0.12);
  border-color: rgba(74, 144, 226, 0.3);
}

.dark .prompt-item:hover,
.dark .prompt-item.selected {
  background: rgba(106, 172, 245, 0.1);
  border-color: rgba(106, 172, 245, 0.2);
}

.prompt-item-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e8edf5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
}

.dark .prompt-item-num {
  background: #3a3a3a;
  color: #aaa;
}

.prompt-item-text {
  flex: 1;
  line-height: 1.4;
  color: #333;
}

.dark .prompt-item-text {
  color: #ccc;
}

.prompt-item-industry {
  font-size: 0.78rem;
  color: #888;
  margin-top: 2px;
}

/* =========================================================
   Aspect Ratio Selector
   ========================================================= */

.ae-ratio-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ae-ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 64px;
}

.ae-ratio-btn:hover {
  border-color: #4a90e2;
  background: rgba(74, 144, 226, 0.05);
}

.ae-ratio-btn.active {
  border-color: #4a90e2;
  background: rgba(74, 144, 226, 0.1);
}

.dark .ae-ratio-btn {
  background: #1e1e1e;
  border-color: #444;
}

.dark .ae-ratio-btn:hover,
.dark .ae-ratio-btn.active {
  border-color: #6aacf5;
  background: rgba(106, 172, 245, 0.1);
}

/* Example line with compact aspect ratio icons to its right */
.ae-example-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}

.ae-ratio-mini-group {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.ae-ratio-btn.ae-ratio-mini {
  flex-direction: row;
  justify-content: center;
  gap: 0;
  width: 28px;
  height: 26px;
  min-width: 0;
  padding: 0;
  border-width: 1px;
  border-radius: 6px;
}

.ae-ratio-mini-group.expanded .ae-ratio-mini {
  display: none;
}

.ae-ratio-mini .ratio-box {
  display: block;
  border-radius: 2px;
}

.ae-ratio-expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #888;
  cursor: pointer;
}

.ae-ratio-expand:hover {
  background: rgba(74, 144, 226, 0.1);
  color: #4a90e2;
}

.ae-ratio-expand .material-icons {
  font-size: 1.1rem;
}

.dark .ae-ratio-expand {
  color: #aaa;
}

.dark .ae-ratio-expand:hover {
  background: rgba(106, 172, 245, 0.1);
  color: #6aacf5;
}

/* Visual ratio indicator box */
.ratio-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ratio-box {
  background: #ccd9ee;
  border-radius: 3px;
}

.dark .ratio-box {
  background: #3a5a8a;
}

.ae-ratio-btn.active .ratio-box {
  background: #4a90e2;
}

.dark .ae-ratio-btn.active .ratio-box {
  background: #6aacf5;
}

.ratio-label {
  font-size: 0.75rem;
  color: #666;
  font-weight: 500;
  white-space: nowrap;
}

.dark .ratio-label {
  color: #aaa;
}

.ae-ratio-btn.active .ratio-label {
  color: #4a90e2;
}

.dark .ae-ratio-btn.active .ratio-label {
  color: #6aacf5;
}

/* =========================================================
   Output Type + Model Selector
   ========================================================= */

.ae-type-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.ae-type-btn {
  padding: 7px 16px;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  background: transparent;
  color: #555;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.2s;
}

.ae-type-btn:hover:not(.disabled):not(.active) {
  border-color: #4a90e2;
  color: #4a90e2;
}

.ae-type-btn.active {
  border-color: #4a90e2;
  background: #4a90e2;
  color: #fff;
}

.ae-type-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dark .ae-type-btn {
  border-color: #444;
  color: #aaa;
}

.dark .ae-type-btn.active {
  background: #4a7fc2;
  border-color: #4a7fc2;
  color: #fff;
}

.ae-model-select {
  padding: 7px 10px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  color: #333;
  font-size: 0.88rem;
  cursor: pointer;
}

.dark .ae-model-select {
  background: #1e1e1e;
  border-color: #444;
  color: #ddd;
}

/* =========================================================
   Generate Button
   ========================================================= */

#generateBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 28px;
  background: linear-gradient(135deg, #4a90e2 0%, #5ba3f5 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(74, 144, 226, 0.35);
}

#generateBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(74, 144, 226, 0.45);
}

#generateBtn:active {
  transform: translateY(0);
}

#generateBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

#generateBtn .material-icons {
  font-size: 1.1rem;
}

/* Variations input */
.ae-output-controls {
  margin-bottom: 12px;
}

.ae-variations-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  margin-left: auto;
}

.ae-variations-row label {
  font-size: 0.88rem;
  color: #666;
}

.dark .ae-variations-row label {
  color: #aaa;
}

#variationsInput,
#maxTokensInput {
  width: 60px;
  padding: 6px 8px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
  background: #fafafa;
  color: #333;
}

#maxTokensInput {
  width: 80px;
}

.dark #variationsInput,
.dark #maxTokensInput {
  background: #1e1e1e;
  border-color: #444;
  color: #ddd;
}

/* =========================================================
   Status / Progress
   ========================================================= */

#statusBar {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

#statusBar.show {
  display: flex;
}

#statusBar.info {
  background: rgba(74, 144, 226, 0.1);
  color: #2a6fc0;
  border: 1px solid rgba(74, 144, 226, 0.2);
}

#statusBar.success {
  background: rgba(40, 167, 69, 0.1);
  color: #1a7a35;
  border: 1px solid rgba(40, 167, 69, 0.2);
}

#statusBar.error {
  background: rgba(220, 53, 69, 0.1);
  color: #a52030;
  border: 1px solid rgba(220, 53, 69, 0.2);
}

.dark #statusBar.info {
  background: rgba(106, 172, 245, 0.12);
  color: #90c2f8;
}

.dark #statusBar.success {
  background: rgba(80, 200, 100, 0.12);
  color: #5fd880;
}

.dark #statusBar.error {
  background: rgba(240, 80, 90, 0.12);
  color: #f07080;
}

/* Spinner */
.ae-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: ae-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes ae-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Storyboard Flowchart
   ========================================================= */

#storyboardContainer {
  min-height: 160px;
  overflow-x: auto;
  padding: 10px 0;
  position: relative;
}

.ae-flow-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  flex-wrap: wrap;
  position: relative;
}

.ae-scene-node {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  position: relative;
  margin-bottom: 10px;
}

.ae-node-card {
  width: 150px;
  min-height: 120px;
  border: 2px solid #dde4f0;
  border-radius: 10px;
  background: #f7f9fc;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.ae-node-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;

  opacity: 0;
  transform: translateY(-4px);

  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.ae-node-card:hover .ae-node-actions,
.ae-node-card.active .ae-node-actions,
.ae-node-card.editing .ae-node-actions {
  opacity: 1;
  transform: translateY(0);
}

.ae-node-action {
  width: 30px;
  height: 30px;

  border: none;
  border-radius: 8px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(255, 255, 255, 0.92);
  color: #64748b;

  cursor: pointer;

  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);

  transition: all 0.18s ease;
}

.ae-node-action .material-icons {
  font-size: 18px;
}

.ae-node-action:hover {
  transform: translateY(-1px);
}

.ae-edit-btn:hover {
  background: rgba(74, 144, 226, 0.12);
  color: #4a90e2;
}

.ae-delete-btn:hover {
  background: rgba(220, 53, 69, 0.12);
  color: #dc3545;
}

.ae-node-card:hover {
  border-color: #4a90e2;
  box-shadow: 0 2px 10px rgba(74, 144, 226, 0.2);
  transform: translateY(-2px);
}

.ae-node-card.active {
  border-color: #4a90e2;
  background: rgba(74, 144, 226, 0.06);
}

.dark .ae-node-card {
  background: #252525;
  border-color: #3a3a3a;
}

.dark .ae-node-card:hover,
.dark .ae-node-card.active {
  border-color: #6aacf5;
  background: rgba(106, 172, 245, 0.08);
}

.dark .ae-node-action {
  background: rgba(42, 42, 42, 0.95);
  color: #cbd5e1;
}

.dark .ae-edit-btn:hover {
  color: #6aacf5;
}

.dark .ae-delete-btn:hover {
  color: #ff7b88;
}

.ae-node-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: #4a90e2;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dark .ae-node-num {
  color: #6aacf5;
}

.ae-node-thumb {
  width: 100%;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  background: #e0e8f5;
}

.dark .ae-node-thumb {
  background: #333;
}

.ae-node-prompt {
  font-size: 0.75rem;
  color: #555;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.dark .ae-node-prompt {
  color: #aaa;
}

.ae-node-label {
  font-size: 0.7rem;
  color: #888;
  margin-top: 2px;
}

.ae-node-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.ae-node-edit-save,
.ae-node-edit-cancel {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease,
    color 0.18s ease, transform 0.18s ease;
}

.ae-node-edit-save {
  background: #4a90e2;
  color: #fff;
}

.ae-node-edit-save:hover {
  background: #357abd;
}

.ae-node-edit-cancel {
  border-color: #cbd5e1;
  background: #fff;
  color: #64748b;
}

.ae-node-edit-cancel:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
  color: #334155;
}

.ae-node-edit-save:hover,
.ae-node-edit-cancel:hover {
  transform: translateY(-1px);
}

.ae-node-edit-save:focus-visible,
.ae-node-edit-cancel:focus-visible {
  outline: 2px solid #4a90e2;
  outline-offset: 2px;
}

.dark .ae-node-edit-save {
  background: #6aacf5;
  color: #172033;
}

.dark .ae-node-edit-save:hover {
  background: #86bcf7;
}

.dark .ae-node-edit-cancel {
  border-color: #4b5563;
  background: #2a2a2a;
  color: #cbd5e1;
}

.dark .ae-node-edit-cancel:hover {
  border-color: #64748b;
  background: #333;
  color: #fff;
}

/* Arrow connector between nodes */
.ae-node-arrow {
  display: flex;
  align-items: center;
  padding: 0 4px;
  margin-top: 48px; /* vertically center with card thumb area */
  color: #c0cbd8;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.dark .ae-node-arrow {
  color: #444;
}

#scenePromptPreviewText {
  display: none;
  margin: 0 0 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  color: #444;
}
.dark #scenePromptPreviewText {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

/* Add scene button */
.ae-add-scene-btn {
  width: 44px;
  height: 44px;
  border: 2px dashed #ccc;
  border-radius: 10px;
  background: transparent;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-top: 48px;
  margin-left: 8px;
  flex-shrink: 0;
}

.ae-add-scene-btn:hover {
  border-color: #4a90e2;
  color: #4a90e2;
  background: rgba(74, 144, 226, 0.05);
}

.dark .ae-add-scene-btn {
  border-color: #444;
  color: #555;
}

.dark .ae-add-scene-btn:hover {
  border-color: #6aacf5;
  color: #6aacf5;
}

/* Empty state */
.ae-flow-empty {
  text-align: center;
  padding: 30px 20px;
  color: #aaa;
  font-size: 0.88rem;
}

.dark .ae-flow-empty {
  color: #666;
}

/* =========================================================
   Gallery
   ========================================================= */

#galleryPanel {
  display: none;
}

#galleryPanel.show {
  display: block;
}

.ae-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.ae-gallery-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  background: #e8edf5;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.ae-gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.ae-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dark .ae-gallery-item {
  background: #333;
}

.ae-gallery-item .ae-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.ae-gallery-item:hover .ae-item-overlay {
  opacity: 1;
}

.ae-item-btn {
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}

.ae-item-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Text output */
.ae-text-output {
  background: #f7f9fc;
  border: 1px solid #e0e8f5;
  border-radius: 10px;
  padding: 16px;
  font-size: 0.92rem;
  line-height: 1.65;
  white-space: pre-wrap;
  color: #333;
  margin-top: 4px;
}

.dark .ae-text-output {
  background: #1e1e1e;
  border-color: #333;
  color: #ddd;
}

/* =========================================================
   Settings Panel (right column)
   ========================================================= */

.ae-settings-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ae-settings-row label {
  font-size: 0.88rem;
  color: #555;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dark .ae-settings-row label {
  color: #aaa;
}

/* =========================================================
   Save to GitHub
   ========================================================= */

#saveGithubBtn {
  display: none;
  width: 100%;
  padding: 10px;
  background: #2da44e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 10px;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#saveGithubBtn:hover {
  background: #218838;
}

#saveGithubBtn.show {
  display: flex;
}

/* =========================================================
   Backend status indicator
   ========================================================= */

.ae-backend-status {
  display: block;
  font-size: 0.8rem;
  color: #888;
  padding: 4px 0;
  line-height: 1.7;
  white-space: normal;
}

/* "more" revealed: the start instruction replaces "Backend offline on port …" (toggleBackendStartDetail in index.html).
   The label returns once the backend is online, which hides #backendStartInstruction. */
.ae-backend-status:has(#backendStartInstruction:not([hidden]) #backendStartDetail:not([hidden])) #backendLabel {
  display: none;
}

.ae-backend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
  vertical-align: middle;
}

.ae-backend-dot.online {
  background: #28a745;
}
.ae-backend-dot.offline {
  background: #dc3545;
}
.ae-backend-dot.checking {
  background: #ffc107;
  animation: ae-pulse 1s ease-in-out infinite;
}

@keyframes ae-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* =========================================================
   Lightbox / full image overlay
   ========================================================= */

.ae-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ae-lightbox.show {
  display: flex;
}

.ae-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.ae-lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
}

.ae-lightbox-close:hover {
  opacity: 1;
}

/* =========================================================
   Responsive tweaks
   ========================================================= */

@container (max-width: 280px) {
  .ae-ratio-group {
    gap: 6px;
  }
  .ae-ratio-btn {
    min-width: 52px;
    padding: 8px;
  }
}

/* Projects panel — project list moved in from the GitHub widget (app.js moveProjectsToPanel) */
.ae-panel h3.ae-projects-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0; /* No gap below the title while the list is hidden */
}

/* View / Hide Projects button at the far right of the title, with the filters toggle after it */
#projectsPanelActions #toggleProjectsSection,
#projectsPanelActions #toggleProjectFilters {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

#projectsPanelList #projectsSectionsContainer {
  margin-top: 14px;
}

/* No fullscreen toggle for the GitHub widget on the engine page */
#issues-root .header-fullscreen-btn,
#issues-root .fullscreen-btn,
#projectsPanelList .fullscreen-btn {
  display: none;
}

/* Blue action button — "Choose Resource Areas", also the key manager's "Paste Keys" */
.ae-action-btn,
#agentsContainer .key-paste-btn {
  padding: 8px 12px;
  background: #4a90e2;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#agentsContainer .key-paste-btn {
  display: inline-flex;
  width: auto;
}

/* <github-repo-modal> and <resource-area-selector> (engine/js/github-components.js).
   The bundle's Tailwind theme redefines --accent, --color-primary and --color-secondary on :root
   (injected after this stylesheet), which recolored localsite's .btn-primary/.btn-secondary page-wide,
   e.g. white text on light grey for "Edit Issue". Restore localsite's values (localsite/css/base.css)... */
html:root,
body.dark {
  --accent: #235d39;
  --color-primary: var(--accent);
  --color-secondary: #b35488;
}

/* ...and give the components their own values, scoped to them and their popups. */
github-repo-modal,
resource-area-selector,
[data-radix-popper-content-wrapper] {
  --color-primary: hsl(240 5.9% 10%);
  --color-primary-foreground: hsl(0 0% 98%);
  --color-secondary: hsl(240 4.8% 95.9%);
  --color-secondary-foreground: hsl(240 5.9% 10%);
  --color-accent: hsl(240 4.8% 95.9%);
  --color-accent-foreground: hsl(240 5.9% 10%);
}

/* Dark mode for the components, in the page's dark palette. Set directly on the mapped --color-*
   values, since the bundle resolves them on :root while localsite puts .dark on <body>. */
.dark github-repo-modal,
.dark resource-area-selector,
.dark [data-radix-popper-content-wrapper] {
  --color-background: #2a2a2a;
  --color-foreground: #e5e7eb;
  --color-card: #2a2a2a;
  --color-card-foreground: #e5e7eb;
  --color-popover: #2a2a2a;
  --color-popover-foreground: #e5e7eb;
  --color-primary: #e5e7eb;
  --color-primary-foreground: #1f1f1f;
  --color-secondary: #363636;
  --color-secondary-foreground: #e5e7eb;
  --color-muted: #363636;
  --color-muted-foreground: #9ca3af;
  --color-accent: #363636;
  --color-accent-foreground: #e5e7eb;
  --color-border: rgba(255, 255, 255, 0.12);
  --color-input: rgba(255, 255, 255, 0.18);
  --color-ring: #6aa8ec;
}

.dark github-repo-modal {
  color: #e5e7eb;
}

/* The popup's overlay is z-50, below page layers at z-index 1000 (map controls, sticky list controls).
   Raise the popup, and the dropdown layer its menus render into so they stay above it. */
github-repo-modal {
  position: relative;
  z-index: 10000;
}
[data-radix-popper-content-wrapper] {
  z-index: 10001 !important;
}

/* Upper right of the title row: #upperRightIcons (Create Team, map print/download icons, #changeView,
   #introDetailsToggle and #tourPlayButton) */
.ae-upper-right {
  display: flex;
  align-items: center;
  margin-left: auto;
}

#upperRightIcons {
  display: flex;
  align-items: center;
}

/* Create Team, first in #upperRightIcons. Under 750px of header width the icon-only button replaces it.
   Scoped to #upperRightIcons to outrank the shared #changeView/#aeTeamIconTrigger button rule below. */
#upperRightIcons #aeTeamWrap {
  margin: 0 5px;
}
#upperRightIcons #aeTeamIconTrigger {
  display: none;
  margin: 0;
}


/* Tour play/pause: rightmost in #upperRightIcons, after #introDetailsToggle.
   Green play, orange pause while the tour plays (.playing, set by syncTourPlayButtons in localsite.js). */
.ae-upper-right #tourPlayButton {
  background: #2e9e4f;
  border-color: #2e9e4f;
  color: #fff;
}
.ae-upper-right #tourPlayButton:hover {
  background: #25823f;
  border-color: #25823f;
  color: #fff;
}
.ae-upper-right #tourPlayButton.playing {
  background: #f08c00;
  border-color: #f08c00;
}
.ae-upper-right #tourPlayButton.playing:hover {
  background: #d27a00;
  border-color: #d27a00;
}
/* When #aeHeader is under 750px wide (including in Half Screen), the icon-only Create Team button
   replaces the labeled one. .ae-header-compact is set by setupEngineWidthClasses in js/app.js. */
.ae-header-compact #upperRightIcons #aeTeamTrigger {
  display: none;
}
.ae-header-compact #upperRightIcons #aeTeamIconTrigger {
  display: inline-flex;
}

/* When #aeHeader is under 680px wide (including in Half Screen), the icons drop to their own line under
   the title (#aeModeWrap), aligned left. .ae-header-narrow is set by setupEngineWidthClasses in js/app.js. */
.ae-header-narrow .ae-upper-right {
  flex-basis: 100%;
  margin-left: -5px; /* lines the first icon's edge up with the title, past its 5px side margin */
}
.ae-header-narrow #upperRightIcons {
  justify-content: flex-start;
}
/* Icon buttons 30% bigger on the left: 32px to 42px, 18px icons to 23px.
   Prefixed with .ae-upper-right to outrank the #changeView rules later in this file. */
.ae-header-narrow .ae-upper-right .print-download-icon,
.ae-header-narrow .ae-upper-right #changeView,
.ae-header-narrow .ae-upper-right #introDetailsToggle,
.ae-header-narrow #upperRightIcons #aeTeamIconTrigger,
.ae-header-narrow .ae-upper-right #tourPlayButton {
  width: 42px;
  height: 42px;
  padding: 8px;
}
.ae-header-narrow .ae-upper-right .print-download-icon svg {
  width: 23px;
  height: 23px;
}
.ae-header-narrow .ae-upper-right .print-download-icon .material-icons,
.ae-header-narrow .ae-upper-right #changeView .material-icons,
.ae-header-narrow .ae-upper-right #introDetailsToggle .material-icons,
.ae-header-narrow .ae-upper-right #aeTeamIconTrigger .material-icons,
.ae-header-narrow .ae-upper-right #tourPlayButton .material-icons {
  font-size: 23px;
}
/* Popups open rightward from their icons, since right-aligned ones would run off the left edge */
.ae-header-narrow .ae-upper-right .ae-mode-menu,
.ae-header-narrow .ae-upper-right .print-download-popup {
  left: 0;
  right: auto;
}
/* Opens above its button when the button is near the bottom of the window
   (.ae-popup-above, set by setupHeaderPopupFlip in js/app.js) */
#upperRightIcons .ae-popup-above,
#aeModeWrap .ae-popup-above {
  top: auto;
  bottom: calc(100% + 6px);
}

/* #introDetails shown in place of #location-details in the floating location details (#locationFloatLayer)
   while a Full Screen map has a location. Opened by #introDetailsToggle (openIntroFloatPanel in index.html).
   #location-details is hidden while it's open, so the panel's own height sets the box's height,
   up to the window less the header and the box's 60px gap below it. */
.location-float .location-content:has(> #introFloatPanel) > #location-details {
  display: none;
}
.location-float:has(#introFloatPanel) {
  max-height: calc(100vh - var(--headerbar-offset, 0px) - 80px);
}
/* The close X floats over the panel's upper right corner, not in a column of its own */
#introFloatPanel {
  position: relative;
}
.intro-float-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  color: #475569;
  cursor: pointer;
}
.intro-float-close:hover {
  background: #fff;
  color: #0f172a;
}
.intro-float-close .material-icons {
  font-size: 18px;
}
.dark .intro-float-close {
  background: rgba(30, 41, 59, 0.85);
  color: #cbd5e1;
}
.dark .intro-float-close:hover {
  background: #1e293b;
  color: #fff;
}

/* Matches .print-download-icon from team/js/print-download.js */
#changeView, #aeTeamIconTrigger, #introDetailsToggle, #tourPlayButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 32px;
  height: 32px;
  margin: 0 5px;
  padding: 6px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #999;
  cursor: pointer;
  transition: background-color 0.3s;
}
#changeView:hover, #aeTeamIconTrigger:hover, #introDetailsToggle:hover {
  background: #e5e5e5;
  color: #666;
}
#changeView .material-icons, #aeTeamIconTrigger .material-icons, #introDetailsToggle .material-icons, #tourPlayButton .material-icons {
  font-size: 18px;
  line-height: 1;
  user-select: none;
}
.dark #changeView, .dark #aeTeamIconTrigger, .dark #introDetailsToggle {
  background: #3a3a3a;
  border-color: #555;
  color: #888;
}
.dark #changeView:hover, .dark #aeTeamIconTrigger:hover, .dark #introDetailsToggle:hover {
  background: #4a4a4a;
  color: #aaa;
}

/* Local-Only off (#changeViewMenu) — beats localsite's ".local{display:inline-block !important}" on localhost */
body.hideLocalView .local,
body.hideLocalView .localonly {
  display: none !important;
}

/* #changeViewMenu: a row per toggle, its name left of a switch (.switch and .slider from localsite/css/base.css, smaller here) */
.change-view-menu {
  min-width: 220px;
}
.change-view-name {
  white-space: nowrap;
}
.change-view-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.change-view-toggle[hidden] {
  display: none;
}
.change-view-toggle + .change-view-toggle {
  margin-top: 3px;
}
.change-view-toggle:hover {
  background: #f1f5f9;
}
.dark .change-view-toggle:hover {
  background: #363636;
}
.change-view-menu .switch {
  flex-shrink: 0;
  width: 36px;
  height: 20px;
}
.change-view-menu .slider:before {
  width: 14px;
  height: 14px;
  left: 3px;
  bottom: 3px;
}
.change-view-menu input:checked + .slider:before {
  transform: translateX(16px);
}
.change-view-menu input:focus-visible + .slider {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}
/* Tour Speed menu, in place of a switch */
.change-view-select {
  flex-shrink: 0;
  padding: 3px 6px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  cursor: pointer;
}
.change-view-select:focus-visible {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}
.dark .change-view-select {
  border-color: #4b5563;
  background: #2a2a2a;
  color: #e5e7eb;
}

/* Map moved above My Content by team/js/map.js */
#mapCatch #pageMap {
  margin-bottom: 20px;
}

/* Hide the map while a location's detail is shown (class set in index.html) */
body.ae-location-detail #pageMap {
  display: none !important;
}

/* Map's right column is hidden by team/js/map.js after #pageMap moves to #mapCatch — listings fill the panel */
#listwidget #widgetDetailsParent {
  flex: 1 1 auto;
}
