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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #FAFAFA;
  color: #333;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── Menu Toggle Button ── */
#menu-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  background: #FFF;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s, background 0.2s;
}
#menu-toggle:hover {
  background: #F5F5F5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ── Settings Panel ── */
#settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  height: 100vh;
  background: #FFF;
  border-right: 1px solid #E8E8E8;
  z-index: 999;
  overflow-y: auto;
  padding: 20px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 12px rgba(0,0,0,0.06);
}
#settings-panel.closed {
  transform: translateX(-100%);
  box-shadow: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #EEE;
}
.panel-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  letter-spacing: 0.02em;
}
#panel-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 4px;
}
#panel-close:hover { color: #333; }

.panel-section {
  margin-bottom: 20px;
}
.panel-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  margin-bottom: 10px;
}

/* ── Controls ── */
.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.control-row label {
  font-size: 13px;
  color: #555;
}

select, input[type="text"] {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #DDD;
  border-radius: 6px;
  font-size: 13px;
  background: #FAFAFA;
  color: #333;
  margin-bottom: 8px;
  outline: none;
  transition: border-color 0.2s;
}
select:focus, input[type="text"]:focus {
  border-color: #4A90D9;
}

.control-row select {
  width: auto;
  min-width: 110px;
  margin-bottom: 0;
}

input[type="range"] {
  width: 100px;
  accent-color: #4A90D9;
}

input[type="checkbox"] {
  accent-color: #4A90D9;
  width: 16px;
  height: 16px;
}

input[type="color"] {
  width: 32px;
  height: 28px;
  border: 1px solid #DDD;
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  background: #FAFAFA;
}

/* ── Buttons ── */
.button-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.btn-small {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid #DDD;
  border-radius: 6px;
  background: #FAFAFA;
  color: #555;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-small:hover {
  background: #F0F0F0;
  border-color: #CCC;
}

/* ── Drop Zone ── */
#drop-zone {
  border: 2px dashed #DDD;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  color: #AAA;
  font-size: 13px;
  transition: border-color 0.2s, background 0.2s;
}
#drop-zone.drag-over {
  border-color: #4A90D9;
  background: #F0F7FF;
  color: #4A90D9;
}
.file-label {
  color: #4A90D9;
  cursor: pointer;
  text-decoration: underline;
}

/* ── Type Filters ── */
#type-filters {
  max-height: 200px;
  overflow-y: auto;
}
.type-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  color: #555;
}
.type-filter-row .type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Stats ── */
.stats-text {
  font-size: 12px;
  color: #999;
  line-height: 1.6;
}

/* ── Tooltip ── */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: #FFF;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  color: #444;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2000;
  max-width: 260px;
}
.tooltip.visible { opacity: 1; }
.tooltip .tt-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-bottom: 2px;
}
.tooltip .tt-name {
  font-weight: 600;
  font-size: 13px;
  color: #333;
}
.tooltip .tt-key {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

/* ── Tree Container ── */
#tree-container {
  width: 100vw;
  height: 100vh;
}

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

/* ── Tree Nodes ── */
.node circle {
  stroke-width: 1.5px;
  cursor: pointer;
  transition: r 0.2s;
}
.node circle:hover {
  filter: brightness(0.9);
}

.node text {
  pointer-events: none;
}

.link {
  fill: none;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #DDD; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #BBB; }

/* ── Dark Mode ── */
body.dark-mode {
  background: #111;
  color: #DDD;
}

body.dark-mode #menu-toggle {
  background: #222;
  border-color: #444;
  color: #CCC;
}
body.dark-mode #menu-toggle:hover {
  background: #333;
}

body.dark-mode #settings-panel {
  background: #1A1A1A;
  border-right-color: #333;
  box-shadow: 2px 0 12px rgba(0,0,0,0.3);
}

body.dark-mode .panel-header {
  border-bottom-color: #333;
}
body.dark-mode .panel-header h2 {
  color: #DDD;
}
body.dark-mode #panel-close {
  color: #777;
}
body.dark-mode #panel-close:hover {
  color: #DDD;
}

body.dark-mode .panel-section h3 {
  color: #777;
}

body.dark-mode .control-row label {
  color: #BBB;
}

body.dark-mode select,
body.dark-mode input[type="text"] {
  background: #222;
  border-color: #444;
  color: #DDD;
}

body.dark-mode input[type="color"] {
  background: #222;
  border-color: #444;
}

body.dark-mode .btn-small {
  background: #222;
  border-color: #444;
  color: #BBB;
}
body.dark-mode .btn-small:hover {
  background: #333;
  border-color: #555;
}

body.dark-mode #drop-zone {
  border-color: #444;
  color: #777;
}
body.dark-mode #drop-zone.drag-over {
  border-color: #4A90D9;
  background: #1A2A3A;
  color: #4A90D9;
}

body.dark-mode .type-filter-row {
  color: #BBB;
}

body.dark-mode .stats-text {
  color: #777;
}

body.dark-mode .tooltip {
  background: #222;
  border-color: #444;
  color: #CCC;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
body.dark-mode .tooltip .tt-type {
  color: #777;
}
body.dark-mode .tooltip .tt-name {
  color: #DDD;
}
body.dark-mode .tooltip .tt-key {
  color: #999;
}

body.dark-mode ::-webkit-scrollbar-thumb {
  background: #444;
}
body.dark-mode ::-webkit-scrollbar-thumb:hover {
  background: #555;
}
