.skill-file-editor {
  display: flex;
  flex-direction: column;
  width: 95vw;
  height: 95vh;
}

/* Inline mode: fill parent container instead of using viewport units */
.skill-file-editor--inline {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.skill-file-editor__body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Left: file tree ── */
.skill-file-editor__tree {
  width: 260px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: hsl(var(--muted) / 0.3);
}

.skill-file-editor__tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  gap: 0.25rem;
}

.skill-file-editor__tree-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-file-editor__tree-actions {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.skill-file-editor__tree-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.625rem;
  color: hsl(var(--muted-foreground));
  transition: all 0.15s;
  background: hsl(var(--background) / 0.7);
  border: 1px solid hsl(var(--border));
  cursor: pointer;
}

.skill-file-editor__tree-btn:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}

.skill-file-editor__tree-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.375rem 0;
}

.skill-file-editor__tree-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  text-align: center;
  gap: 0.5rem;
}

/* ── Tree item ── */
.skill-file-editor__tree-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: hsl(var(--foreground));
  transition: background 0.1s;
  user-select: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.skill-file-editor__tree-item:hover {
  background: hsl(var(--accent) / 0.5);
}

.skill-file-editor__tree-item--active {
  background: hsl(var(--accent));
  font-weight: 500;
}

.skill-file-editor__tree-item--directory {
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.skill-file-editor__tree-item-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
}

.skill-file-editor__tree-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-file-editor__tree-item-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: hsl(var(--primary));
  flex-shrink: 0;
}

.skill-file-editor__tree-item-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.25rem;
  color: hsl(var(--muted-foreground));
  opacity: 0;
  transition: all 0.1s;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

.skill-file-editor__tree-item:hover .skill-file-editor__tree-item-delete {
  opacity: 1;
}

.skill-file-editor__tree-item-delete:hover {
  color: hsl(var(--destructive));
  background: hsl(var(--destructive) / 0.1);
}

/* ── Tree footer ── */
.skill-file-editor__tree-footer {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
}

.skill-file-editor__open-explorer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--accent) / 0.5);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.skill-file-editor__open-explorer-btn:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}

/* ── Right: editor panel ── */
.skill-file-editor__editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.skill-file-editor__editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground));
  gap: 0.5rem;
  font-size: 0.85rem;
}

/* ── Editor header ── */
.skill-file-editor__editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  height: 2.5rem;
  flex-shrink: 0;
  background: hsl(var(--muted) / 0.2);
}

.skill-file-editor__editor-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.skill-file-editor__version-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding-left: 0.25rem;
}

.skill-file-editor__version-toggle-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

.skill-file-editor__editor-tab {
  min-width: 2.25rem;
  height: 2rem;
  padding: 0 0.85rem;
  border-radius: 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  background: hsl(var(--background) / 0.75);
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.skill-file-editor__editor-tab:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}

.skill-file-editor__editor-tab--active {
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.08);
  border-color: hsl(var(--primary) / 0.2);
  box-shadow: none;
}

.skill-file-editor__editor-file-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* ── Editor content ── */
.skill-file-editor__editor-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.skill-file-editor__textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 1rem 1.25rem;
  background: hsl(var(--background));
  border: none;
  outline: none;
  resize: none;
  overflow: auto;
  font-family:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.625;
  color: hsl(var(--foreground));
}

.skill-file-editor__textarea::placeholder {
  color: hsl(var(--muted-foreground));
}

.skill-file-editor__preview {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.skill-file-editor__tree-list,
.skill-file-editor__textarea,
.skill-file-editor__preview {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
}

.skill-file-editor__tree-list::-webkit-scrollbar,
.skill-file-editor__textarea::-webkit-scrollbar,
.skill-file-editor__preview::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.skill-file-editor__tree-list::-webkit-scrollbar-thumb,
.skill-file-editor__textarea::-webkit-scrollbar-thumb,
.skill-file-editor__preview::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* ── Status bar ── */
.skill-file-editor__status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.65rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.2);
  flex-shrink: 0;
  gap: 1rem;
}

.skill-file-editor__status-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

.skill-file-editor__status-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-file-editor__status-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* ── Dialog overlay ── */
.skill-file-editor__dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.skill-file-editor__dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.skill-file-editor__dialog {
  position: relative;
  background: hsl(var(--card));
  border-radius: 0.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 24rem;
  padding: 1.5rem;
}

.skill-file-editor__dialog h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.skill-file-editor__dialog-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--muted) / 0.5);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: hsl(var(--foreground));
  outline: none;
  transition: box-shadow 0.2s;
}

.skill-file-editor__dialog-input:focus {
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.3);
}

.skill-file-editor__dialog-hint {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
}

.skill-file-editor__dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.skill-file-editor__dialog-btn {
  padding: 0.375rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.skill-file-editor__dialog-btn--cancel {
  color: hsl(var(--muted-foreground));
  background: transparent;
}

.skill-file-editor__dialog-btn--cancel:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}

.skill-file-editor__dialog-btn--primary {
  color: hsl(var(--primary-foreground));
  background: hsl(var(--primary));
}

.skill-file-editor__dialog-btn--primary:hover {
  opacity: 0.9;
}

.skill-file-editor__dialog-btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.skill-file-editor__dialog-btn--destructive {
  color: white;
  background: hsl(var(--destructive));
}

.skill-file-editor__dialog-btn--destructive:hover {
  opacity: 0.9;
}

.skill-file-editor__context-menu {
  position: fixed;
  z-index: 110;
  min-width: 180px;
  padding: 0.35rem;
  border-radius: 0.85rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.skill-file-editor__context-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 0.65rem;
  background: transparent;
  color: hsl(var(--foreground));
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.skill-file-editor__context-item:hover {
  background: hsl(var(--accent));
}

.skill-file-editor__context-item--danger {
  color: hsl(var(--destructive));
}

.skill-file-editor__context-item--danger:hover {
  background: hsl(var(--destructive) / 0.08);
}

/* ── Indent levels for tree items ── */
.skill-file-editor__tree-item--depth-0 {
  padding-left: 0.75rem;
}
.skill-file-editor__tree-item--depth-1 {
  padding-left: 1.75rem;
}
.skill-file-editor__tree-item--depth-2 {
  padding-left: 2.75rem;
}
.skill-file-editor__tree-item--depth-3 {
  padding-left: 3.75rem;
}
.skill-file-editor__tree-item--depth-4 {
  padding-left: 4.75rem;
}

/* ── Loading state ── */
.skill-file-editor__loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.85rem;
}

.skill-file-editor__loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
