:root {
  --bg: #0b1020;
  --panel: #0f1730;
  --panel2: #0c142b;
  --border: #26325a;
  --text: #e7ecff;
  --muted: #9aa7d8;
  --accent: #7aa2ff;
  --danger: #ff6b7a;
  --ok: #4fe39a;
  --shadow: rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 700px at 10% 10%, #121b3b 0%, var(--bg) 60%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

.logo {
  display: inline-block;
  height: 34px;
  width: 34px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.container {
  max-width: 1200px;
  margin: 18px auto;
  padding: 0 16px 28px;
}

.tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--border);
  background: rgba(15, 23, 48, 0.65);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.tab.active {
  border-color: rgba(122, 162, 255, 0.8);
  box-shadow: 0 10px 30px var(--shadow);
}

.logout-link {
  flex: 0 0 auto;
  margin-left: auto;
  border: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.4);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
}

.logout-link:hover {
  border-color: rgba(122, 162, 255, 0.9);
  text-decoration: none;
}

.panel {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(15, 23, 48, 0.75), rgba(12, 20, 43, 0.75));
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 50px var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-title { font-weight: 600; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  border: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.4);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:hover:not(:disabled) {
  border-color: rgba(122, 162, 255, 0.9);
}

.textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  padding: 14px;
  border: 0;
  outline: none;
  color: var(--text);
  background: rgba(10, 15, 32, 0.45);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  scrollbar-color: rgba(122, 162, 255, 0.42) rgba(10, 15, 32, 0.35);
  scrollbar-width: thin;
}

.textarea::-webkit-scrollbar {
  width: 10px;
}

.textarea::-webkit-scrollbar-track {
  background: rgba(10, 15, 32, 0.35);
  border-left: 1px solid rgba(38, 50, 90, 0.45);
}

.textarea::-webkit-scrollbar-thumb {
  background: rgba(122, 162, 255, 0.42);
  border: 2px solid rgba(10, 15, 32, 0.35);
  border-radius: 999px;
}

.textarea::-webkit-scrollbar-thumb:hover {
  background: rgba(122, 162, 255, 0.58);
}

.counters {
  display: flex;
  gap: 16px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.label { color: var(--muted); }

.status {
  font-size: 12px;
  color: var(--muted);
}

.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 170px);
  min-height: 360px;
}

.tree {
  border-right: 1px solid var(--border);
  padding: 10px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-color: rgba(122, 162, 255, 0.42) rgba(10, 15, 32, 0.35);
  scrollbar-width: thin;
}

.tree-search {
  display: block;
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 10px;
  background: transparent;
}

.tree-search input {
  width: 100%;
  border: 1px solid rgba(38, 50, 90, 0.9);
  border-radius: 10px;
  outline: none;
  padding: 9px 11px;
  background: rgba(10, 15, 32, 0.72);
  color: var(--text);
}

.tree-search input::placeholder {
  color: rgba(154, 167, 216, 0.78);
}

.tree-search input:focus {
  border-color: rgba(122, 162, 255, 0.85);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.12);
}

.tree::-webkit-scrollbar {
  width: 10px;
}

.tree::-webkit-scrollbar-track {
  background: rgba(10, 15, 32, 0.35);
  border-left: 1px solid rgba(38, 50, 90, 0.5);
}

.tree::-webkit-scrollbar-thumb {
  background: rgba(122, 162, 255, 0.42);
  border: 2px solid rgba(10, 15, 32, 0.35);
  border-radius: 999px;
}

.tree::-webkit-scrollbar-thumb:hover {
  background: rgba(122, 162, 255, 0.58);
}

.tree-root {
  font-size: 13px;
  min-height: 140px;
  border-radius: 12px;
}

.tree-empty {
  padding: 10px 8px;
  color: var(--muted);
  font-size: 13px;
}

.tree-root.drop-root {
  outline: 1px dashed rgba(122, 162, 255, 0.7);
  background: rgba(122, 162, 255, 0.06);
}

.node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
}

.node.folder .name { color: rgba(231, 236, 255, 0.98); }
.node.file .name { color: rgba(231, 236, 255, 0.92); }

.chevron {
  width: 18px;
  text-align: center;
  opacity: 0.9;
  color: var(--muted);
  flex: 0 0 auto;
}

.lucide {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.node.folder .lucide { color: rgba(122, 162, 255, 0.95); }
.node.file .lucide { color: rgba(154, 167, 216, 0.95); }

.node:hover { background: rgba(122, 162, 255, 0.08); }
.node.selected { background: rgba(122, 162, 255, 0.18); }

.node .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.children { margin-left: 16px; }

.node.dragging {
  opacity: 0.35;
  filter: saturate(0.9);
}

.node.drop-invalid {
  outline: 1px solid rgba(255, 107, 122, 0.7);
  background: rgba(255, 107, 122, 0.08);
}

.node.drop-inside {
  outline: 1px solid rgba(122, 162, 255, 0.8);
  background: rgba(122, 162, 255, 0.12);
}

.node.drop-before::before,
.node.drop-after::after {
  content: "";
  position: absolute;
  left: 30px;
  right: 8px;
  height: 2px;
  background: rgba(122, 162, 255, 0.95);
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(122, 162, 255, 0.12);
}

.node.drop-before::before { top: -1px; }
.node.drop-after::after { bottom: -1px; }

.editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.editor-title {
  flex: 1 1 180px;
  min-width: 90px;
  max-width: 280px;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 360px;
  min-width: 220px;
}

.file-search label {
  flex: 1 1 auto;
  min-width: 0;
}

.file-search input {
  width: 100%;
  border: 1px solid rgba(38, 50, 90, 0.9);
  border-radius: 10px;
  outline: none;
  padding: 8px 10px;
  background: rgba(10, 15, 32, 0.72);
  color: var(--text);
}

.file-search input::placeholder {
  color: rgba(154, 167, 216, 0.78);
}

.file-search input:focus {
  border-color: rgba(122, 162, 255, 0.85);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.12);
}

.file-search input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.file-search-count {
  min-width: 42px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.file-search button {
  width: 34px;
  height: 34px;
  padding: 0;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

#editor-text {
  flex: 1 1 auto;
  min-height: 0;
  resize: none;
}

.page-login .login {
  max-width: 420px;
  margin: 12vh auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: rgba(15, 23, 48, 0.75);
  box-shadow: 0 18px 50px var(--shadow);
}

body.page-login {
  min-height: 100vh;
  background: transparent;
  isolation: isolate;
}

body.page-login::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 600px at 18% 8%, rgba(122, 162, 255, 0.22) 0%, rgba(11, 16, 32, 0) 62%),
    radial-gradient(900px 600px at 85% 30%, rgba(79, 227, 154, 0.10) 0%, rgba(11, 16, 32, 0) 55%),
    linear-gradient(180deg, #0b1020 0%, #070b16 100%);
  pointer-events: none;
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--accent);
}

.page-login .login button {
  display: block;
  margin: 14px auto 0;
  min-width: 140px;
}

.login h1 { margin: 0 0 6px; }
.muted { color: var(--muted); margin-top: 0; }
.muted.small { font-size: 12px; }

.login label {
  display: block;
  margin: 12px 0;
}

.login label span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.login input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(10, 15, 32, 0.45);
  color: var(--text);
  outline: none;
}

.alert {
  border: 1px solid rgba(255, 107, 122, 0.6);
  background: rgba(255, 107, 122, 0.12);
  padding: 10px 12px;
  border-radius: 12px;
}

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 48, 0.92);
  box-shadow: 0 18px 50px var(--shadow);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hide {
  transform: translateX(120%);
  opacity: 0;
}

.toast.success {
  border-color: rgba(79, 227, 154, 0.55);
}

.toast.error {
  border-color: rgba(255, 107, 122, 0.65);
}

.toast-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toast.success .toast-icon { color: var(--ok); }
.toast.error .toast-icon { color: var(--danger); }

.toast-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.2;
}
