@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg:           #0a0a0a;
  --bg-surface:   #141414;
  --bg-raised:    #1e1e1e;
  --bg-input:     #080808;
  --border:       #222222;
  --border-focus: #333333;
  --text:         #f0f0f0;
  --text-muted:   #666666;
  --text-mid:     #aaaaaa;
  --accent:       #ffffff;
  
  --action-add:    #10b981;
  --action-del:    #f43f5e;
  --action-move:   #38bdf8;
  --action-focus:  #a855f7;

  --panel-width:  340px;
  --header-height: 60px;
  --footer-height: 28px;
  
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition: 0.15s var(--ease);
  
  --radius-md: 8px;
  --radius-lg: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }

body {
  font-family: 'Outfit', 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', monospace; }

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  height: var(--header-height);
  padding: 0 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.brand-icon {
  width: 30px; height: 30px; background: var(--accent); color: var(--bg);
  border-radius: 4px; display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 0.8rem;
}
.brand-name { font-weight: 600; font-size: 0.95rem; letter-spacing: 0.05em; text-transform: uppercase; }

.header-toolbar { display: flex; align-items: center; gap: 0.4rem; }

main {
  flex: 1;
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  overflow: hidden; /* Crucial for internal scrolling */
}

aside#sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-box {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0.6rem 1rem; font-size: 0.85rem;
  color: var(--text); outline: none; transition: border-color var(--transition);
}
.search-box:focus { border-color: var(--border-focus); }

.node-list-container { 
  flex: 1; 
  overflow-y: auto; 
  overflow-x: hidden;
  padding: 0.5rem; 
}
.node-list-container::-webkit-scrollbar { width: 4px; }
.node-list-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

section#canvas { 
  background-color: #0d0d0d;
  background-image: radial-gradient(#1a1a1a 1px, transparent 1px);
  background-size: 30px 30px;
  display: flex; 
  flex-direction: column; 
  position: relative; 
  overflow: hidden; 
}

.canvas-toolbar {
  height: 36px; padding: 0 1.25rem; background: rgba(20,20,20,0.8);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.65rem; color: var(--text-muted); font-weight: 700; letter-spacing: 0.1em;
  flex-shrink: 0;
}

.viewport {
  flex: 1; overflow: auto; padding: 4rem; display: flex; justify-content: center;
  align-items: flex-start; scroll-behavior: smooth;
  position: relative;
}

#ascii-render {
  background: #111111; padding: 4rem; border-radius: 4px;
  border: 1px solid var(--border); white-space: pre; line-height: 1.6;
  font-size: 0.95rem; color: #999; box-shadow: 0 40px 100px rgba(0,0,0,0.8);
  min-width: min-content; position: relative;
}

/* Floating Preview Controls - Fixed Layout */
.preview-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.btn {
  padding: 0.5rem 0.8rem; border-radius: 6px; font-size: 0.75rem;
  font-weight: 600; cursor: pointer; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  transition: all var(--transition); color: var(--text-muted); background: transparent;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-raised); color: var(--text); border-color: var(--border); }
.btn.primary { background: var(--accent); color: var(--bg); }
.btn.btn-icon { width: 32px; height: 32px; padding: 0; }

.node-row {
  display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.node-row:hover { background: var(--bg-raised); }
.node-row.active { background: var(--bg-raised); border-color: var(--border); }

.node-expander {
  width: 18px; height: 18px; display: flex; align-items: center;
  justify-content: center; color: var(--text-muted); flex-shrink: 0;
}

.node-label { flex: 1; font-size: 0.85rem; color: var(--text-mid); outline: none; padding: 2px 4px; }
.node-row.active .node-label { color: var(--text); font-weight: 500; }

.node-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.node-row:hover .node-actions, .node-row.active .node-actions { opacity: 1; }

.btn-add { color: var(--action-add); }
.btn-del { color: var(--action-del); }
.btn-move { color: var(--action-move); }
.btn-focus { color: var(--action-focus); }

.node-children { margin-left: 1.2rem; border-left: 1px solid var(--border); display: none; }
.node-children.visible { display: block; }

/* 12-Level Depth Analysis Colors */
.depth-0  { color: #ffffff !important; font-weight: 700; }
.depth-1  { color: #fbbf24 !important; }
.depth-2  { color: #10b981 !important; }
.depth-3  { color: #3b82f6 !important; }
.depth-4  { color: #8b5cf6 !important; }
.depth-5  { color: #f43f5e !important; }
.depth-6  { color: #06b6d4 !important; }
.depth-7  { color: #f97316 !important; }
.depth-8  { color: #ec4899 !important; }
.depth-9  { color: #84cc16 !important; }
.depth-10 { color: #6366f1 !important; }
.depth-11 { color: #14b8a6 !important; }

#ascii-render .node-text { 
  cursor: grab; 
  border-radius: 3px; 
  transition: 0.1s; 
  padding: 0 4px; 
  display: inline-block; 
  pointer-events: auto !important;
  user-select: none; /* Prevent text selection during drag */
  -webkit-user-drag: element; /* Safari support */
}
#ascii-render .node-text:active { cursor: grabbing; }
#ascii-render .node-text:hover { background: rgba(255,255,255,0.08); color: #fff !important; }
#ascii-render .node-text.dragging { opacity: 0.2; pointer-events: none !important; }
#ascii-render .highlight { background: #fff; color: #000 !important; font-weight: 700; }
#ascii-render .branch { color: #444; transition: color 0.2s; user-select: none; }
#ascii-render .root-node { color: #fff; font-weight: 800; }

/* Radial Export Overlay (Hidden) */
#radial-export-container {
  position: absolute; 
  top: 0; 
  left: -5000px; /* Better than fixed -10000 for some browsers */
  width: 1600px; 
  height: 1600px; 
  background: #0a0a0a;
  overflow: hidden;
  visibility: hidden;
}


.dropdown { position: relative; }
.dropdown-content {
  position: absolute; top: 100%; right: 0; margin-top: 0.5rem;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; width: 220px; display: none;
  flex-direction: column; padding: 0.4rem; box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  z-index: 2000;
}
.dropdown.active .dropdown-content { display: flex; }
.dropdown-item {
  padding: 0.6rem 0.8rem; font-size: 0.75rem; cursor: pointer; border-radius: 4px;
  display: flex; align-items: center; gap: 0.6rem; color: var(--text-mid);
}
.dropdown-item:hover { background: var(--bg-raised); color: #fff; }

footer { height: var(--footer-height); padding: 0 1.5rem; background: var(--bg-surface); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-size: 0.55rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.2em; flex-shrink: 0; }

#toast { position: fixed; bottom: 2rem; left: 50%; transform: translate(-50%, 100px); background: #fff; color: #000; padding: 0.6rem 1.5rem; border-radius: 4px; font-weight: 700; font-size: 0.8rem; transition: 0.3s var(--ease); z-index: 5000; }
#toast.show { transform: translate(-50%, 0); }

.flex { display: flex; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }
.pr-2 { padding-right: 0.5rem; }
.mr-1 { margin-right: 0.25rem; }
.border-r { border-right: 1px solid rgba(255,255,255,0.1); }
