/* ===== Script Editor ===== */

.se-root {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ─── Layout ──────────────────────────────────────────── */
.se-layout {
  display: flex;
  gap: 1rem;
  height: 100%;
  min-height: 0;
}

.se-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.se-speaker-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  overflow-y: auto;
}

/* ─── Toolbar ─────────────────────────────────────────── */
.se-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.se-toolbar-info {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ─── Lines list ──────────────────────────────────────── */
.se-lines {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}

.se-lines::-webkit-scrollbar { width: 5px; }
.se-lines::-webkit-scrollbar-track { background: transparent; }
.se-lines::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* ─── Line item ───────────────────────────────────────── */
.se-line {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 6px;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
  position: relative;
}

.se-line:hover {
  border-color: var(--border);
  background: #1e1e22;
}

.se-line.se-line-has-speaker {
  border-left-width: 3px;
}

/* ─── Drag handle ─────────────────────────────────────── */
.se-line-gutter {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.3rem;
  flex-shrink: 0;
}

.se-drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 1rem;
  opacity: 0.3;
  transition: opacity 0.15s;
  user-select: none;
  line-height: 1;
}

.se-line:hover .se-drag-handle {
  opacity: 0.7;
}

.se-drag-handle:active {
  cursor: grabbing;
}

/* ─── Line body ───────────────────────────────────────── */
.se-line-body {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.5rem;
}

.se-line-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.se-speaker-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 1px 8px;
  border-radius: 10px;
  color: #000;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.se-speaker-badge.se-speaker-unassigned {
  background: #444;
  color: var(--text-dim);
  font-weight: 400;
  font-style: italic;
}

.se-line-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  outline: none;
  border-radius: 4px;
  padding: 1px 2px;
  transition: background 0.15s;
}

.se-line-text.se-editing {
  background: var(--bg);
  border: 1px solid var(--accent);
  padding: 4px 6px;
}

/* ─── Line actions ────────────────────────────────────── */
.se-line-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0.3rem 0.4rem;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.se-line:hover .se-line-actions {
  opacity: 1;
}

.se-btn-action {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 3px 5px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.se-btn-action:hover {
  background: var(--border);
  color: var(--text);
}

.se-btn-delete:hover {
  background: #5c2020;
  color: #e57373;
}

/* ─── Section lines ───────────────────────────────────── */
.se-line-section {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
  margin-top: 0.8rem;
  margin-bottom: 0.3rem;
}

.se-line-section:hover {
  background: transparent;
}

.se-line-section .se-line-content {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
}

.se-section-icon {
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  opacity: 0.7;
}

.se-section-text {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.8;
}

/* ─── Drag state ──────────────────────────────────────── */
.se-line.se-dragging {
  opacity: 0.3;
}

.se-line-placeholder {
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  margin: 2px 0;
}

/* ─── Speaker picker (dropdown) ───────────────────────── */
.se-speaker-picker {
  position: absolute;
  top: 100%;
  left: 2rem;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.4rem 0;
}

.se-picker-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  font-family: var(--font-sans);
}

.se-picker-option:hover {
  background: var(--highlight);
}

.se-picker-option.se-picker-active {
  background: var(--highlight);
  font-weight: 600;
}

.se-picker-option.se-picker-unassign {
  color: var(--text-dim);
  font-style: italic;
}

.se-picker-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.se-picker-divider {
  height: 1px;
  background: var(--border);
  margin: 0.3rem 0;
}

.se-picker-new {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
}

.se-picker-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  font-family: var(--font-sans);
}

.se-picker-input:focus {
  border-color: var(--accent);
}

/* ─── Speaker panel ───────────────────────────────────── */
.se-panel-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  color: var(--text);
}

.se-panel-empty {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.se-speaker-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.se-speaker-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
}

.se-speaker-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.se-speaker-color {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  padding: 1px;
  flex-shrink: 0;
}

.se-speaker-name-edit {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
  font-family: var(--font-sans);
}

.se-speaker-name-edit:hover {
  border-color: var(--border);
}

.se-speaker-name-edit:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.se-speaker-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.se-speaker-card-actions {
  display: flex;
  gap: 0.4rem;
}

.se-speaker-card-actions .btn {
  flex: 1;
  font-size: 0.75rem;
  padding: 0.25em 0.5em;
}

.se-btn-delete-speaker:hover {
  background: #5c2020 !important;
  color: #e57373 !important;
  border-color: #5c2020 !important;
}

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 700px) {
  .se-layout {
    flex-direction: column;
  }

  .se-speaker-panel {
    width: 100%;
    max-height: 200px;
    order: -1;
  }

  .se-line-actions {
    opacity: 1;
  }

  .se-speaker-picker {
    left: 0;
    right: 0;
    min-width: auto;
  }
}
