/* ============================================================
   Base & Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #1f6feb33;
  --green: #3fb950;
  --highlight-bg: #f0e68818;
  --highlight-border: #f0e688;
  --highlight-text: #f0e688;
  --ancestor-bg: #1f6feb18;
  --ancestor-text: #79c0ff;
  --error: #f85149;
  --radius: 8px;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   Header
   ============================================================ */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.2rem 2rem;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 1.5rem; font-weight: 700; }
.subtitle { color: var(--text-muted); margin-top: 0.2rem; font-size: 0.88rem; }

/* ============================================================
   Main
   ============================================================ */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1.2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================================
   Input section
   ============================================================ */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-width: 220px;
}

.input-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 0.6rem 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  width: 100%;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Presets */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.preset-label { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }

.preset-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.25rem 0.7rem;
  transition: background 0.15s, border-color 0.15s;
}

.preset-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   Path display (resolved + breadcrumb)
   ============================================================ */
.path-display {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.resolved-path-box {
  padding: 0.6rem 1rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.resolved-label { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.resolved-path-box code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--green);
  word-break: break-all;
}

.breadcrumb-box {
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.breadcrumb-label { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.breadcrumb-sep { color: var(--text-muted); padding: 0 1px; user-select: none; }

.breadcrumb-name {
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ancestor-text);
}

.breadcrumb-name.is-current {
  color: var(--highlight-text);
  background: var(--highlight-bg);
  border: 1px solid var(--highlight-border);
}

/* ============================================================
   Not-in-tree notice
   ============================================================ */
.not-in-tree-notice {
  background: #f0a50018;
  border: 1px solid #f0a500;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  color: #f0c040;
}

.not-in-tree-notice code {
  font-family: var(--font-mono);
  background: #f0a50020;
  padding: 0 4px;
  border-radius: 3px;
}

/* ============================================================
   Tree section
   ============================================================ */
.tree-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tree-section-header {
  padding: 0.7rem 1.2rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tree-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.legend-ancestor {
  color: var(--ancestor-text);
  background: var(--ancestor-bg);
  border-radius: 3px;
  padding: 0 5px;
}

.legend-current {
  color: var(--highlight-text);
  background: var(--highlight-bg);
  border: 1px solid var(--highlight-border);
  border-radius: 3px;
  padding: 0 5px;
}

/* Tree */
.tree {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.85;
  padding: 1rem 0.5rem 1rem 0;
  overflow-x: auto;
}

.tree-row {
  display: flex;
  align-items: center;
  white-space: nowrap;
  padding: 0 0.8rem;
  border-radius: 5px;
  transition: background 0.1s;
}

.tree-row:hover { background: var(--surface2); }

.tree-indent {
  color: #3d444d;
  user-select: none;
  white-space: pre;
}

.tree-icon { user-select: none; font-size: 0.9em; }

.tree-name { color: var(--text); }
.tree-name.is-dir { color: var(--accent); }
.tree-name.is-file { color: var(--text); }

/* Ancestor: path we're passing through */
.tree-row.is-ancestor {
  background: var(--ancestor-bg);
}

.tree-row.is-ancestor .tree-name.is-ancestor-name {
  color: var(--ancestor-text);
  font-weight: 600;
}

/* Current: destination */
.tree-row.is-current {
  background: var(--highlight-bg);
  border: 1px solid var(--highlight-border);
  margin: 1px 0;
}

.tree-row.is-current .tree-name.is-current-name {
  color: var(--highlight-text);
  font-weight: 700;
}

.current-badge {
  font-size: 0.72rem;
  color: var(--highlight-text);
  margin-left: 0.6rem;
  background: #f0e68820;
  border: 1px solid var(--highlight-border);
  padding: 0 6px;
  border-radius: 10px;
}

.tree-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: -apple-system, sans-serif;
}

.tree-collapsed .tree-collapse-hint {
  color: var(--border);
  font-size: 0.85rem;
}

/* ============================================================
   Utilities
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
  header { padding: 1rem; }
  header h1 { font-size: 1.2rem; }
  main { padding: 1rem 0.6rem 3rem; }
  .tree { font-size: 0.8rem; }
  .legend { gap: 0.5rem; }
}
