.story-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.story-editor-modal[hidden] { display: none !important; }
.story-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
}
.story-editor-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: 94vh;
  overflow-y: auto;
  background: rgba(12, 18, 36, 0.96);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.story-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.story-editor-head h2 {
  margin: 0;
  font-size: 1.05rem;
  color: #e8eefc;
}
.story-editor-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
}
.story-editor-preview {
  position: relative;
  aspect-ratio: 9 / 16;
  max-height: 52vh;
  margin: 0 auto 12px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.story-editor-preview img,
.story-editor-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.story-editor-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #64748b;
  font-size: 0.9rem;
  text-align: center;
  padding: 20px;
}
.story-sticker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.story-sticker-chip {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
  pointer-events: auto;
  cursor: grab;
}
.story-location-tag {
  position: absolute;
  left: 12px;
  bottom: 48px;
  background: rgba(0, 229, 255, 0.18);
  border: 1px solid rgba(0, 229, 255, 0.55);
  color: #e0f7ff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  max-width: 85%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-editor-field label {
  display: block;
  font-size: 0.78rem;
  color: #94a3b8;
  margin: 10px 0 4px;
}
.story-editor-field input,
.story-editor-field textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  color: #f1f5f9;
  font: inherit;
  font-size: 0.88rem;
}
.story-editor-field textarea { min-height: 56px; resize: vertical; }
.story-sticker-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.story-sticker-palette button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 1.2rem;
  cursor: pointer;
}
.story-ambient-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.story-ambient-row button {
  background: rgba(0, 230, 118, 0.1);
  border: 1px solid rgba(0, 230, 118, 0.35);
  color: #bbf7d0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}
.story-ambient-row button.active {
  background: rgba(0, 230, 118, 0.28);
  border-color: #00e676;
}
.story-editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.story-editor-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.story-editor-actions .secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}
.story-editor-actions .primary {
  background: linear-gradient(135deg, #00e5ff, #0284c7);
  color: #041018;
}
.story-editor-note {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 8px;
  line-height: 1.4;
}
.story-ambient-open {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 230, 118, 0.35);
  background: rgba(0, 230, 118, 0.1);
  color: #bbf7d0;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.story-ambient-summary {
  font-size: 0.72rem;
  color: #64748b;
  margin: 6px 0 0;
}
.story-ambient-picker {
  position: fixed;
  inset: 0;
  z-index: 2600;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.story-ambient-picker[hidden] { display: none !important; }
.story-ambient-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}
.story-ambient-picker-panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(10, 14, 28, 0.98);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 18px 18px 0 0;
  padding: 14px;
}
.story-ambient-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.story-ambient-picker-head h3 { margin: 0; font-size: 1rem; color: #e8eefc; }
.story-ambient-picker-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
}
#storyAmbientSearch {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  color: #f1f5f9;
  font: inherit;
  margin-bottom: 8px;
}
.story-ambient-cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 6px;
}
.story-ambient-cats button {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
}
.story-ambient-cats button.active {
  background: rgba(0, 229, 255, 0.18);
  border-color: rgba(0, 229, 255, 0.55);
  color: #e0f7ff;
}
.story-ambient-wave {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 48px;
  margin: 8px 0;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
}
.story-ambient-wave span {
  flex: 1;
  min-width: 2px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  align-self: flex-end;
}
.story-ambient-wave span.on { background: #2dd4bf; }
.story-ambient-segment label {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
  margin: 4px 0 2px;
}
.story-ambient-segment input[type='range'] { width: 100%; }
.story-ambient-segment select {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #f1f5f9;
  padding: 8px;
  margin-bottom: 8px;
}
.story-ambient-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  max-height: 38vh;
}
.story-ambient-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 10px;
  color: #e2e8f0;
  cursor: pointer;
  font-family: inherit;
}
.story-ambient-item.selected {
  border-color: rgba(45, 212, 191, 0.65);
  background: rgba(45, 212, 191, 0.12);
}
.story-ambient-item span:first-child { font-size: 1.2rem; }
.story-ambient-item strong { display: block; font-size: 0.85rem; }
.story-ambient-item small { color: #64748b; font-size: 0.72rem; }
.story-ambient-picker-foot {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.story-ambient-picker-foot button {
  flex: 1;
  padding: 11px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.story-ambient-picker-foot .secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}
.story-ambient-picker-foot .primary {
  background: linear-gradient(135deg, #00e5ff, #0284c7);
  color: #041018;
}
