* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

@font-face {
  font-family: "Perfect DOS VGA 437";
  src: url("PerfectDOSVGA437.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "Symbols Nerd Font Mono";
  src: url("SymbolsNerdFontMono-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

:root {
  --fzt-bg: #181825;
  --fzt-fg: #cdd6f4;
  --fzt-font: "Perfect DOS VGA 437", "Cascadia Code", "Fira Code", "JetBrains Mono", "Consolas", "Symbols Nerd Font Mono", monospace;
}

body {
  background: #050505;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #cdd6f4;
  font-family: var(--fzt-font);
  font-size: 16px;
  margin: 0;
  padding: 0;
  line-height: 1.4;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  font-smooth: never;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 12px 16px;
}

#toolbar {
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

#main-panel {
  flex: 1;
  min-height: 0;
}

#fzh-terminal {
  position: absolute;
  inset: 0;
  padding: 8px;
}

#fzh-terminal.hidden {
  display: none;
}

#tree {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.5;
}

#tree.hidden {
  display: none;
}

#toolbar button {
  background: transparent;
  color: #4a9a4a;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  transition: color 0.15s, text-shadow 0.15s;
}

#toolbar button:hover {
  color: #33ff33;
  text-shadow: 0 0 6px #33ff33;
}

/* ── Each node row ─────────────────────────────── */

.node {
  display: flex;
  align-items: baseline;
  position: relative;
}

.node.clickable {
  cursor: pointer;
  isolation: isolate;
}

.node.clickable:hover {
  background: rgb(0, 0, 102);
}

.node-prefix {
  white-space: pre;
  color: #585b70;
  user-select: none;
}

.node-icon {
  display: inline-block;
  width: calc(2 * var(--char-w, 9.6px));
  text-align: center;
  font-family: "Symbols Nerd Font Mono", monospace;
  vertical-align: bottom;
  line-height: 1.2;
  user-select: none;
  color: #585b70;
  margin-right: 6px;
}

.node-icon.folder-icon {
  color: #f9e2af;
  font-weight: bold;
}

.node-icon.file-icon {
  color: #585b70;
}

/* Ref nodes — shared bookmark folders (resolved from blob storage refs).
   Green icon distinguishes from regular folders (yellow). */
.ref-node .node-icon.folder-icon {
  color: #a6e3a1;
  opacity: 0.85;
}

.node-label a {
  color: #89b4fa;
  text-decoration: none;
  transition: color 0.15s;
}

.node-label a:hover {
  color: #b4befe;
  text-decoration: underline;
}

.node-label.folder {
  color: #94e2d5;
  font-weight: bold;
}

.node-label.folder a {
  color: #94e2d5;
}

.node-label.folder a:hover {
  color: #b4befe;
}

/* ── Prompt hint (visual mode) ────────────────── */

.tree-prompt {
  color: #585b70;
  font-size: inherit;
  margin-bottom: 4px;
  user-select: none;
}

.tree-prompt .prompt-char {
  color: #f9e2af;
  font-weight: bold;
}

/* ── Hover URL hint ───────────────────────────── */

.node-url {
  display: none;
  position: absolute;
  left: var(--url-left);
  color: #585b70;
  pointer-events: none;
  white-space: nowrap;
}

.node:hover > .node-url {
  display: inline;
}

/* ── Children container ────────────────────────── */

.children {
  display: none;
}

.children.open {
  display: block;
}

/* ── Empty state ─────────────────────────────── */

.empty-state {
  color: #a6adc8;
  padding: 12px 0;
}

/* ── API error banner ────────────────────────── */

#api-error {
  margin-bottom: 12px;
  padding: 6px 12px;
  background: #2a2030;
  color: #f38ba8;
  border: 1px solid #45475a;
  border-radius: 4px;
  font-size: 0.8em;
}

/* ── Hidden utility ──────────────────────────── */

.hidden {
  display: none !important;
}

/* ── Loading state ───────────────────────────── */

#loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 80vh;
  color: #585b70;
  font-size: 1.2em;
}

/* ── Edit mode ───────────────────────────────── */

#save-btn {
  background: #a6e3a1;
  color: #1e1e2e;
  border: 1px solid #a6e3a1;
  font-weight: bold;
}

#save-btn:hover {
  background: #94e2d5;
}

#cancel-btn {
  background: #f38ba8;
  color: #1e1e2e;
  border: 1px solid #f38ba8;
  font-weight: bold;
}

#cancel-btn:hover {
  background: #eba0ac;
}

.edit-actions {
  display: inline-flex;
  gap: 2px;
  margin-left: 1ch;
}

.edit-actions button {
  background: none;
  border: none;
  color: #585b70;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85em;
  padding: 0 3px;
  transition: color 0.15s;
}

.edit-actions button:hover {
  color: #cdd6f4;
}

.edit-actions button.action-delete:hover {
  color: #f38ba8;
}

.edit-actions button.action-add:hover {
  color: #a6e3a1;
}

.node-edit-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.node-edit-form input {
  background: #313244;
  color: #cdd6f4;
  border: 1px solid #45475a;
  border-radius: 3px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: inherit;
}

.node-edit-form input:focus {
  outline: none;
  border-color: #89b4fa;
}

.node-edit-form input.edit-name {
  width: 20ch;
}

.node-edit-form input.edit-url {
  width: 30ch;
}

.node-edit-form button {
  background: none;
  border: none;
  color: #585b70;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0 3px;
  transition: color 0.15s;
}

.node-edit-form button.edit-confirm:hover {
  color: #a6e3a1;
}

.node-edit-form button.edit-cancel:hover {
  color: #f38ba8;
}

.add-root-btn {
  background: none;
  border: 1px dashed #45475a;
  border-radius: 4px;
  color: #585b70;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 4px 12px;
  margin-top: 8px;
  transition: color 0.15s, border-color 0.15s;
}

.add-root-btn:hover {
  color: #a6e3a1;
  border-color: #a6e3a1;
}

/* ── Drag handle ─────────────────────────────── */

.drag-handle {
  cursor: grab;
  color: #45475a;
  user-select: none;
  padding: 0 6px 0 0;
  font-size: 0.75em;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s;
}

.drag-handle:hover {
  color: #cdd6f4;
}

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

.node.dragging {
  opacity: 0.3;
}

.node.drag-over-top {
  box-shadow: inset 0 2px 0 #89b4fa;
}

.node.drag-over-bottom {
  box-shadow: inset 0 -2px 0 #89b4fa;
}

.edit-mode .node.clickable {
  cursor: default;
}

.edit-mode .node-url {
  display: none !important;
}

.edit-mode .node-label a {
  pointer-events: none;
  color: #89b4fa;
  text-decoration: none;
}

/* ── Local dev badge ─────────────────────────── */

#local-badge {
  position: fixed;
  bottom: 6px;
  left: 6px;
  font-size: 0.55em;
  color: #585b70;
  letter-spacing: 0.1em;
  user-select: none;
  pointer-events: none;
}

/* Sync indicator — appears when background fetch detects newer bookmarks
   than what's cached. Click applies pending data without page reload. */
#sync-indicator {
  position: fixed;
  bottom: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #a6e3a1;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 100;
}

#sync-indicator:hover {
  opacity: 1;
}

#sync-indicator.hidden {
  display: none;
}

/* ── Mobile responsive ───────────────────────── */

@media (max-width: 600px) {
  #app {
    padding: 8px;
  }

  #toolbar {
    flex-wrap: wrap;
  }

  .node-url {
    display: none !important;
  }
}
