/* === DESIGN TOKENS === */
:root {
  --tf-color-primary: #4f46e5;
  --tf-color-primary-soft: rgba(79, 70, 229, 0.12);
  --tf-color-bg: #ffffff;
  --tf-color-bg-elevated: #f9fafb;
  --tf-color-border: #e5e7eb;
  --tf-color-text: #111827;
  --tf-color-text-muted: #6b7280;
  --tf-color-overlay: rgba(15, 23, 42, 0.55);

  --tf-radius-lg: 14px;
  --tf-radius-full: 999px;

  --tf-shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.12);

  --tf-z-overlay: 999999;
}

:root[data-tf-theme="dark"] {
  --tf-color-bg: #020617;
  --tf-color-bg-elevated: #0b1220;
  --tf-color-border: #1f2937;
  --tf-color-text: #e5e7eb;
  --tf-color-text-muted: #9ca3af;
  --tf-color-overlay: rgba(15, 23, 42, 0.78);
}

/* === PLAYER OVERLAY === */

.tf-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--tf-z-overlay) + 2);
  pointer-events: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.tf-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: var(--tf-color-overlay);
  backdrop-filter: blur(0px);
}

/* Подсветка элемента */
.tf-highlight {
  position: absolute;
  border-radius: 10px;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.9),
    0 0 0 6px rgba(79, 70, 229, 0.35),
    0 18px 45px rgba(15, 23, 42, 0.4);
  background: transparent;
  pointer-events: none;
  transition: all 0.18s ease-out;
}

/* Tooltip */
.tf-tooltip {
  position: absolute;
  max-width: 320px;
  background: var(--tf-color-bg);
  color: var(--tf-color-text);
  border-radius: var(--tf-radius-lg);
  padding: 14px 16px 12px;
  box-shadow: var(--tf-shadow-soft);
  border: 1px solid var(--tf-color-border);
  pointer-events: auto;
  font-size: 14px;
  transform-origin: top left;
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  transition: opacity 0.16s ease-out, transform 0.16s ease-out;
}

.tf-tooltip.tf-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tf-tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.tf-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tf-color-bg-elevated);
  color: var(--tf-color-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tf-skip-btn {
  border: none;
  background: transparent;
  color: var(--tf-color-text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 999px;
}

.tf-skip-btn:hover {
  background: var(--tf-color-bg-elevated);
  color: var(--tf-color-text);
}

.tf-tooltip-title {
  margin: 4px 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.tf-tooltip-body {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--tf-color-text-muted);
}

.tf-tooltip-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Buttons */
.tf-primary-btn,
.tf-secondary-btn {
  border-radius: var(--tf-radius-full);
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
}

.tf-primary-btn {
  background: var(--tf-color-primary);
  color: #fff;
}

.tf-primary-btn:hover {
  filter: brightness(1.05);
}

.tf-secondary-btn {
  background: transparent;
  color: var(--tf-color-text-muted);
  border-color: var(--tf-color-border);
}

.tf-secondary-btn:hover {
  background: var(--tf-color-bg-elevated);
  color: var(--tf-color-text);
}

.tf-primary-btn[disabled],
.tf-secondary-btn[disabled] {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.tf-next-icon {
  margin-left: 4px;
  font-size: 14px;
}

/* === AUTHORING TOOLBAR === */

.tf-author-toolbar {
  position: fixed;
  top: 1px;
  right: 36px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.45);
  z-index: calc(var(--tf-z-overlay) + 1);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  cursor: grab;
  user-select: none;
}
.tf-author-toolbar.tf-dragging {
  cursor: grabbing;
}
.tf-author-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.tf-author-label {
  font-weight: 500;
}

.tf-author-spacer {
  flex: 1;
}

.tf-chip-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.8);
  color: #e5e7eb;
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
}

.tf-chip-btn:hover {
  border-color: #e5e7eb;
}

.tf-primary-pill-btn {
  border-radius: 999px;
  border: none;
  background: #4f46e5;
  color: #fff;
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 500;
}

.tf-primary-pill-btn:hover {
  filter: brightness(1.05);
}

.tf-steps-counter {
  font-size: 12px;
  color: #9ca3af;
}

/* === STEP PANEL === */

.tf-step-panel {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 280px;
  max-height: calc(100vh - 80px);
  background: var(--tf-color-bg);
  border-radius: 16px;
  box-shadow: var(--tf-shadow-soft);
  border: 1px solid var(--tf-color-border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  z-index: calc(var(--tf-z-overlay) + 1);
  visibility: hidden;
}

.tf-step-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--tf-color-border);
}

.tf-step-panel-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.tf-step-list {
  margin-top: 8px;
  overflow-y: auto;
  padding-right: 3px;
}

.tf-step-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 4px;
}

.tf-step-item:hover {
  background: var(--tf-color-bg-elevated);
}

.tf-step-item-active {
  background: var(--tf-color-primary-soft);
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.3);
}

.tf-step-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tf-step-index {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--tf-color-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.tf-step-meta {
  display: flex;
  flex-direction: column;
}

.tf-step-title {
  font-size: 13px;
  font-weight: 500;
}

.tf-step-sub {
  font-size: 11px;
  color: var(--tf-color-text-muted);
}

.tf-step-delete {
  border: none;
  background: transparent;
  color: var(--tf-color-text-muted);
  cursor: pointer;
  font-size: 14px;
}

/* === INLINE EDITOR === */

.tf-inline-editor {
  position: absolute;
  max-width: 320px;
  background: var(--tf-color-bg);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--tf-shadow-soft);
  border: 1px solid var(--tf-color-border);
  z-index: calc(var(--tf-z-overlay) + 2);
  font-family: system-ui, sans-serif;
  font-size: 13px;
}

.tf-inline-editor label {
  display: block;
  margin-bottom: 6px;
}

.tf-inline-editor label span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tf-color-text-muted);
  margin-bottom: 2px;
}

.tf-inline-editor input,
.tf-inline-editor textarea,
.tf-inline-editor select {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--tf-color-border);
  background: var(--tf-color-bg-elevated);
  color: var(--tf-color-text);
}

.tf-inline-editor textarea {
  resize: vertical;
}

.tf-inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tf-inline-row > label {
  flex: 1;
}

.tf-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
}

.tf-inline-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.tutor-button {
  width: 2.5em;
  height: 2.5em;
  z-index: 9999;
  border-radius: 20px;
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
  border: none;
  background: #f1f1f1;
  cursor: pointer;
  position: fixed;
  right: 0;
  top: 20%;
}

.tutor-button:hover {
  background: #e5e7eb;
}

/* === EXPORT MODAL === */

.tf-export-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000005;
}

.tf-export-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000006;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tf-export-card {
  width: min(640px, 100% - 32px);
  max-height: calc(100vh - 80px);
  background: var(--tf-color-bg);
  border-radius: 18px;
  box-shadow: var(--tf-shadow-soft);
  border: 1px solid var(--tf-color-border);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
}

.tf-export-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.tf-export-title {
  font-size: 15px;
  font-weight: 600;
}

.tf-export-sub {
  font-size: 12px;
  color: var(--tf-color-text-muted);
  margin-bottom: 8px;
}

.tf-export-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tf-export-row label {
  font-size: 12px;
  color: var(--tf-color-text-muted);
}

.tf-export-row input {
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--tf-color-border);
  background: var(--tf-color-bg-elevated);
  color: var(--tf-color-text);
}

.tf-export-textarea {
  width: 100%;
  min-height: 200px;
  max-height: 320px;
  border-radius: 12px;
  border: 1px solid var(--tf-color-border);
  background: var(--tf-color-bg-elevated);
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 8px;
  box-sizing: border-box;
  color: var(--tf-color-text);
}

.tf-export-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 8px;
  flex-wrap: wrap;
}

.tf-export-actions-right {
  display: flex;
  gap: 8px;
}

.tf-text-badge {
  font-size: 11px;
  color: var(--tf-color-text-muted);
}

/* === Inline editor: selector test === */
.tf-inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

.tf-status-text {
  font-size: 11px;
  color: var(--tf-color-text-muted);
}

.tf-status-text.tf-ok {
  color: #16a34a; /* green */
}

.tf-status-text.tf-bad {
  color: #dc2626; /* red */
}

.tf-input-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}
