.tsa-explorer {
  display: flex;
  flex-direction: row;
  height: 100%;
  background: rgba(15, 23, 42, 0.8);
  color: #e2e8f0;
}

.tsa-explorer__divider {
  width: 6px;
  cursor: col-resize;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  margin: 0 0.4rem;
  position: relative;
  align-self: stretch;
  flex: 0 0 auto;
}

.tsa-explorer__divider::after {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
}

.tsa-explorer--resizing,
.tsa-explorer--resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.tsa-explorer__sidebar {
  width: 260px;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow: auto;
}

.tsa-explorer__sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.tsa-explorer__sidebar-title {
  margin: 0;
  font-size: 1rem;
  color: #f8fafc;
}

.tsa-explorer__refresh {
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(148, 163, 184, 0.15);
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
  color: #f8fafc;
  cursor: pointer;
}

.tsa-explorer__tree {
  flex: 1;
  overflow: auto;
  font-size: 0.9rem;
}

.tsa-explorer__node {
  display: flex;
  flex-direction: column;
}

.tsa-explorer__node-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.2rem;
  cursor: pointer;
}

.tsa-explorer__node-row button {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
}

.tsa-explorer__node-label {
  flex: 1;
  text-align: left;
  padding: 0.1rem 0.25rem;
  border-radius: 6px;
}

.tsa-explorer__node-row:hover,
.tsa-explorer__node-row:focus-visible {
  background: rgba(99, 102, 241, 0.2);
  outline: none;
}

.tsa-explorer__node-toggle {
  width: 1.8rem;
  height: 1.8rem;
  font-size: 1.4rem;
  line-height: 1;
  border-radius: 6px;
  justify-content: center;
}

.tsa-explorer__children {
  display: none;
  margin-left: 1rem;
  border-left: 1px solid rgba(148, 163, 184, 0.3);
  padding-left: 0.4rem;
  margin-top: 0.2rem;
}

.tsa-explorer__node.is-open > .tsa-explorer__children {
  display: block;
}

.tsa-explorer__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.8rem 1rem;
  overflow: hidden;
  gap: 0.6rem;
}

.tsa-explorer__toolbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.tsa-explorer__path {
  font-weight: 600;
  word-break: break-all;
  flex: 1;
}

.tsa-explorer__status {
  font-size: 0.85rem;
  color: #94a3b8;
}

.tsa-explorer__status[data-state="error"] {
  color: #f87171;
}

.tsa-explorer__status[data-state="loading"] {
  color: #fbbf24;
}

.tsa-explorer__toolbar-btn {
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(30, 41, 59, 0.8);
  color: #f8fafc;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.tsa-explorer__toolbar-btn:hover {
  background: rgba(99, 102, 241, 0.35);
}

.tsa-explorer__view-toggle {
  display: inline-flex;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 999px;
  padding: 0.2rem;
}

.tsa-explorer__view-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.tsa-explorer__view-btn.is-active {
  background: rgba(99, 102, 241, 0.35);
  color: #f8fafc;
}

.tsa-explorer__content {
  flex: 1;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.65);
  padding: 0.9rem;
  position: relative;
}

.tsa-explorer__grid-host,
.tsa-explorer__icon-host {
  display: none;
}

.tsa-explorer__content[data-view="grid"] .tsa-explorer__grid-host {
  display: block;
}

.tsa-explorer__content[data-view="icons"] .tsa-explorer__icon-host {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.9rem;
}

.tsa-explorer__empty {
  text-align: center;
  color: #94a3b8;
  margin-top: 2rem;
}

.tsa-explorer__item {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 0.8rem;
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.tsa-explorer__item:hover,
.tsa-explorer__item:focus-visible {
  border-color: rgba(129, 140, 248, 0.7);
  transform: translateY(-1px);
  outline: none;
}

.tsa-explorer__item.is-selected {
  border-color: rgba(129, 140, 248, 0.95);
  background: rgba(99, 102, 241, 0.25);
}

.tsa-explorer__item.is-selected .tsa-explorer__item-icon {
  background: rgba(129, 140, 248, 0.3);
  color: #ede9fe;
}

.tsa-explorer__item-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #c4b5fd;
}

.tsa-explorer__item-icon[data-type="directory"] {
  background: rgba(14, 165, 233, 0.2);
  color: #bae6fd;
}

.tsa-explorer__item-label {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tsa-explorer__grid-fallback {
  color: #f87171;
  margin: 1rem 0;
}

.tsa-explorer__selection-box {
  position: absolute;
  border: 1px solid rgba(59, 130, 246, 0.8);
  background: rgba(59, 130, 246, 0.2);
  pointer-events: none;
  z-index: 5;
  display: none;
}

.tsa-explorer__selection-box.is-active {
  display: block;
}

.tsa-explorer__statusbar {
  margin-top: 0.6rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  font-size: 0.85rem;
  color: #cbd5f5;
}

.tsa-explorer__grid-host tbody tr.is-selected td {
  background: rgba(129, 140, 248, 0.25);
  color: #f8fafc;
}

.datagrid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: #e2e8f0;
  font-size: 0.85rem;
}

.datagrid__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  overflow: hidden;
}

.datagrid__table thead {
  background: rgba(99, 102, 241, 0.2);
}

.datagrid__th,
.datagrid__table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.datagrid__th {
  position: relative;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.datagrid__th-label {
  pointer-events: none;
}

.datagrid__th[data-sort="asc"],
.datagrid__th[data-sort="desc"] {
  color: #f8fafc;
}

.datagrid__th[data-sort="asc"]::after {
  content: '▴';
  font-size: 0.75rem;
  margin-left: 0.35rem;
}

.datagrid__th[data-sort="desc"]::after {
  content: '▾';
  font-size: 0.75rem;
  margin-left: 0.35rem;
}

.datagrid__resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}

.datagrid__table tbody tr:hover td {
  background: rgba(148, 163, 184, 0.12);
}

.datagrid__status {
  display: none;
}

.tsa-explorer__menu {
  position: fixed;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  padding: 0.4rem;
  min-width: 200px;
  display: none;
}

.tsa-explorer__menu.is-visible {
  display: block;
}

.tsa-explorer__menu-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tsa-explorer__menu-item {
  border: none;
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.tsa-explorer__menu-item:hover,
.tsa-explorer__menu-item:focus-visible {
  background: rgba(59, 130, 246, 0.3);
  outline: none;
}

.tsa-explorer__menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}

@media (max-width: 940px) {
  .tsa-explorer__sidebar {
    width: 220px;
  }
}

@media (max-width: 720px) {
  .tsa-explorer {
    flex-direction: column;
  }
  .tsa-explorer__sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  }
}
