/* style.css */

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

:root {
  --bg: #f8f8f5;
  --surface: #ffffff;
  --border: #e4e4dc;
  --border2: #d0d0c8;
  --text: #1a1a18;
  --muted: #888880;
  --faint: #b8b8b0;

  --green: #2d9e5f;
  --red:   #d94040;
  --blue:  #3b72d4;
  --amber: #c07a10;

  --r0: #2d9e5f;
  --r1: #3b72d4;
  --r2: #9055d4;
  --r3: #c94a9a;
  --r4: #d94040;
  --r5: #c07a10;
  --r6: #1a9e9e;
  --r7: #6a9e1a;

  --radius: 6px;
  --font:  Times, serif;
}

body {
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 15px;
}

/* ── Header ── */
header {
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo {
  font-size: 16px;
  font-weight: 600;
}

header .spacer { flex: 1; }
header .credit {
  font-size: 10px;
  color: var(--faint);
}

/* ── Layout ── */
.app {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 250px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-label {
  font-size: 9px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Form controls ── */
.field-label {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
}
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 6px 9px;
  font-family: var(--font);
  font-size: 12px;
  outline: none;
}
input:focus { border-color: var(--blue); }

.toggle-row {
  display: flex;
  gap: 5px;
  margin-bottom: 2px;
}
.toggle {
  flex: 1;
  padding: 5px 0;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
}
.toggle.active {
  background: #729ae9;
}

.btn-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
button {
  cursor: pointer;
  font-family: var(--font);
  border-radius: var(--radius);
  font-size: 12px;
  letter-spacing: 1px;
  border: 1px solid transparent;
  padding: 6px 10px;
}

.btn-insert {
  flex: 1;
  background: rgb(19, 214, 19);
}

.btn-insert:hover { background: #d8f0e6; }

.btn-delete {
  flex: 1;
  background: rgb(255, 125, 125);
}
.btn-delete:hover { background: #fae0e0; }

.btn-ghost {
  width: 100%;
  background: transparent;
  border-color: var(--border2);
  margin-top: 5px;
}

.btn-danger {
  width: 100%;
  border-color: var(--border2);
  margin-top: 5px;
}

/* ── Stats ── */
.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 11px;
}
.stat-row .key { color: var(--muted); }
.stat-row .val { color: var(--text); font-weight: 500; }


/* ── Canvas area ── */
.canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#tree-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  background: var(--bg);
}
#tree-canvas:active { cursor: grabbing; }

#tree-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  user-select: none;
  gap: 10px;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 2px;
}
.empty-hint svg { opacity: 0.18; }

/* ── Log ── */
.log-panel {
  height: 100px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 18px;
  overflow-y: auto;
  flex-shrink: 0;
  font-size: 10.5px;
}
.log-title {
  font-size: 12px;
  margin-bottom: 5px;
}
.log-entry {
  display: flex;
  gap: 8px;
  margin-bottom: 3px;
  line-height: 1.5;
}
.log-entry .icon { color: var(--faint); flex-shrink: 0; }
.log-insert { color: var(--green); }
.log-delete { color: var(--red); }
.log-error  { color: var(--amber); }
.log-warn   { color: #a07030; }
.log-info   { color: var(--muted); }

/* ── SVG node animations ── */
@keyframes popIn {
  0%   { transform: scale(0); opacity: 0; }
  65%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes fadeOut {
  to { transform: scale(0.1); opacity: 0; }
}
@keyframes glow {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.node-new  { animation: popIn  .42s cubic-bezier(.4,0,.2,1) both; }
.node-del  { animation: fadeOut .36s ease-in both; }
.node-hi   { animation: glow .55s ease-in-out 2; }
