* {
  box-sizing: border-box;
}

:root {
  --bg-main: #f8fafd;
  --bg-panel: #ffffff;
  --text-main: #202124;
  --text-label: #202124;
  --text-muted: #5f6368;
  --border-input: #dadce0;
  --border-light: #e8eaed;
  --line-color: #dadce0;
  --input-bg: #ffffff;
  --shadow-color: rgba(60, 64, 67, 0.08);
  --card-bg: #ffffff;
  --target-bg: #f1f3f4;
  --btn-icon-bg: transparent;
  --btn-icon-text: #5f6368;
  --card-radius: 12px;
}

body.dark-mode {
  --bg-main: #131314;
  --bg-panel: #1e1f20;
  --text-main: #e8eaed;
  --text-label: #e8eaed;
  --text-muted: #9aa0a6;
  --border-input: #3c4043;
  --border-light: #3c4043;
  --line-color: #3c4043;
  --input-bg: #28292a;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --card-bg: #1e1f20;
  --target-bg: #3c4043;
  --btn-icon-bg: transparent;
  --btn-icon-text: #9aa0a6;
}

body {
  font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-main);
  margin: 0;
  padding: 20px;
  color: var(--text-main);
  transition: 0.3s;
}

.app-container {
  display: flex;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}

.sidebar {
  background: var(--bg-panel);
  padding: 24px;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 3px var(--shadow-color), 0 4px 8px var(--shadow-color);
  width: 320px;
  flex-shrink: 0;
  transition: 0.3s;
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
}

.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.sidebar h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 500;
}

.btn-theme {
  background: var(--target-bg);
  border: none;
  font-size: 1.1rem;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: 0.2s;
}

.btn-theme:hover {
  filter: brightness(0.95);
}

select.btn-theme {
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
  padding: 6px 10px;
  font-size: 1.1rem;
  outline: none;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-label);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: normal !important;
  cursor: pointer;
  color: var(--text-muted) !important;
}

input[type="text"], textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  font-family: inherit;
  background-color: var(--input-bg);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: 0.2s;
}

input[type="text"]:focus, textarea:focus {
  border-color: #1a73e8;
}

textarea {
  resize: vertical;
}

.color-group {
  display: flex;
  gap: 15px;
  justify-content: space-between;
}

.color-picker-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 48%;
}

input[type="color"] {
  border: none;
  width: 100%;
  height: 35px;
  cursor: pointer;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 24px;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: 0.2s;
}

.btn-primary {
  background-color: #1a73e8;
  color: white;
  margin-bottom: 10px;
}

.btn-primary:hover {
  background-color: #1557b0;
  box-shadow: 0 1px 3px rgba(26,115,232,0.4);
}

.btn-success {
  background-color: #1e8e3e;
  color: white;
}

.btn-success:hover {
  background-color: #188038;
}

.btn-warning {
  background-color: transparent;
  border: 1px solid var(--border-input);
  color: var(--text-main);
}

.btn-warning:hover {
  background-color: var(--target-bg);
}

.btn-reset {
  background-color: #d93025;
  color: white;
  margin-top: 5px;
  font-size: 0.85rem;
  padding: 8px;
}

.btn-reset:hover {
  background-color: #b3261e;
}

.target-indicator {
  padding: 10px 14px;
  background-color: var(--target-bg);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

hr {
  border: 0;
  border-top: 1px solid var(--border-light);
  margin: 24px 0;
}

.tree-container {
  background: transparent;
  padding: 0 10px;
  flex-grow: 1;
  min-height: 500px;
  overflow-x: auto;
}

ul {
  list-style-type: none;
  padding-left: 45px;
  margin: 0;
}

#treeRoot {
  padding-left: 0;
}

li {
  position: relative;
  padding-top: 6px;
  padding-bottom: 6px;
}

#treeRoot ul li::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -22px;
  border-left: 2px solid var(--line-color);
}

#treeRoot ul li::after {
  content: '';
  position: absolute;
  top: 28px;
  left: -22px;
  width: 22px;
  border-bottom: 2px solid var(--line-color);
  border-bottom-left-radius: 16px;
}

#treeRoot ul li:last-child::before {
  bottom: auto;
  height: 28px;
}

details summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: block;
  outline: none;
}

details summary::-webkit-details-marker {
  display: none;
}

.node-wrapper {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.node-card {
  display: flex;
  flex-direction: column;
  background-color: var(--card-bg);
  padding: 14px 18px;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 2px var(--shadow-color);
  border: 1px solid var(--border-light);
  position: relative;
  z-index: 2;
  min-width: 280px;
  transition: 0.2s;
}

.node-card:hover {
  box-shadow: 0 1px 4px var(--shadow-color), 0 4px 8px var(--shadow-color);
}

.node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-grow: 1;
  min-width: 0;
}

.toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--target-bg);
  color: var(--text-muted);
  transition: 0.2s;
  flex-shrink: 0;
}

.toggle-icon:hover {
  background: var(--border-input);
  color: var(--text-main);
}

.toggle-placeholder {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-icon::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-left: -2px;
  transition: transform 0.2s ease;
}

details[open] > summary .toggle-icon::after {
  transform: rotate(45deg);
  margin-left: 0;
  margin-bottom: 2px;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.node-text {
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: normal;
}

.node-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
  align-items: center;
}

.node-card:hover .node-actions {
  opacity: 1;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: 50%;
  border: none;
  background-color: var(--btn-icon-bg);
  color: var(--btn-icon-text);
  cursor: pointer;
  transition: 0.2s;
}

.btn-icon:hover {
  background: var(--target-bg);
  color: var(--text-main);
}

.btn-add-child:hover {
  background-color: #e8f0fe;
  color: #1a73e8;
}

.btn-delete:hover {
  background-color: #fce8e6;
  color: #d93025;
}

.node-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 10px;
  margin-left: 44px;
  padding: 10px 14px;
  background: var(--target-bg);
  border-radius: 8px;
  border-left: 3px solid var(--border-light);
  line-height: 1.5;
}
