:root {
  --sidebar-width: 340px;
  --result-height: 60px;
  --results-gap: 6px;
  --results-count: 5;
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, 0.9);
  --accent: #f4a6c6;
  --accent-2: #fde6ef;
  --text: #3b2a36;
  --muted: #7b6a75;
  --shadow: 0 18px 40px rgba(60, 60, 60, 0.08);
  --input-bg: rgba(255,255,255,0.92);
  --input-border: rgba(244,166,198,0.4);
  --separator: rgba(59, 42, 54, 0.18);
}
body.theme-light {
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, 0.9);
  --accent: #f4a6c6;
  --accent-2: #fde6ef;
  --text: #3b2a36;
  --muted: #7b6a75;
  --shadow: 0 18px 40px rgba(60, 60, 60, 0.08);
  --input-bg: rgba(255,255,255,0.92);
  --input-border: rgba(244,166,198,0.4);
  --separator: rgba(59, 42, 54, 0.18);
}
body {
  --bg: #000000;
  --panel: rgba(24, 24, 24, 0.9);
  --accent: #ff9dc9;
  --accent-2: #1e1e1e;
  --text: #f4f4f4;
  --muted: #b0b0b0;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  --input-bg: rgba(36,36,36,0.95);
  --input-border: rgba(255,157,201,0.35);
  --separator: rgba(255,255,255,0.08);
}
* {
  box-sizing: border-box;
}
body {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  margin: 0;
  font-family: "M PLUS Rounded 1c", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: auto;
  overflow-y: hidden;
}
.layout {
  position: relative;
  display: contents;
  width: 100%;
  height: 100vh;
}
#graph {
  width: 100%;
  height: 100vh;
  min-width: 500px;
  border: none;
  background: var(--bg);
  box-shadow: none;
  z-index: 1;
}
.branch {
  position: absolute;
  top: -40px;
  left: calc(100% - 60px);
  z-index: 3;
  max-width: 420px;
  opacity: 1;
  pointer-events: none;
  transform: translateY(var(--branch-offset, 0px)) scale(0.9) rotate(-4deg);
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.08));
}
.sidebar {
  position: relative;
  z-index: 2;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 0;
  background: var(--panel);
  border-right: 1px solid rgba(244,166,198,0.25);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: visible;
}
.sidebar-scroll {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  height: 100%;
  padding: 20px 18px 18px;
  box-sizing: border-box;
  direction: rtl;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.sidebar-scroll > * {
  direction: ltr;
}
.sidebar-top {
  display: grid;
  gap: 12px;
}
.sidebar-bottom {
  display: grid;
  gap: 12px;
}
.sidebar-spacer {
  min-height: 0;
}
header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
h1 {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
  text-align: left;
}
.tagline {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
form {
  position: relative;
  display: grid;
  gap: 8px;
  width: 100%;
  margin: 6px 0 4px;
}
input {
  width: 100%;
  padding: 12px 44px 12px 12px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
}
input:focus {
  outline: none;
  border-color: rgba(244,166,198,0.7);
  box-shadow: 0 0 0 4px rgba(244,166,198,0.18);
}
.search-icon {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 18px;
  height: 18px;
  transform: translateY(-60%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8px;
  pointer-events: none;
}
.results-list {
  min-height: calc(var(--results-count) * var(--result-height) + (var(--results-count) - 1) * var(--results-gap) + 4px);
  overflow: hidden;
}
.results {
  display: flex;
  flex-direction: column;
  gap: var(--results-gap);
  margin: 2px 0 10px;
  padding: 0;
  list-style: none;
  direction: ltr;
}
.result {
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-rows: 1fr;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: var(--result-height);
  min-height: 56px;
  max-height: var(--result-height);
  padding: 6px 8px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  flex: 0 0 var(--result-height);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.result-thumb {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(244,166,198,0.35);
  border-radius: 0;
  background: #f7e9f0;
  object-fit: cover;
}
.result-thumb.artist {
  border-radius: 50%;
}
.result:hover {
  border-color: rgba(244,166,198,0.8);
}
.result.active {
  border-color: rgba(244,166,198,0.9);
  background: rgba(244,166,198,0.12);
}
.result-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
}
.result-sub {
  font-size: 12px;
  color: var(--muted);
}
.status {
  margin: 4px 0 10px;
  min-height: 22px;
  font-size: 14px;
  color: var(--muted);
  white-space: pre-line;
}
.status.error {
  color: #d13a6d;
}
.sidebar-controls {
  display: grid;
  gap: 0;
  margin-top: auto;
  padding-top: 8px;
  border-top: 2px solid rgba(244,166,198,0.55);
}
.control-group {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--separator);
}
.control-group:last-child {
  border-bottom: none;
}
.control-group.credit-tags {
  grid-template-columns: 80px 1fr;
}
.row-label {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}
.row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row-subtext {
  color: var(--muted);
  font-size: 11px;
  opacity: 0.8;
}
.row-label small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.depth-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  width: fit-content;
  padding: 6px;
  border: 1px solid rgba(244,166,198,0.35);
  border-radius: 14px;
  background: rgba(244,166,198,0.12);
}
.depth-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.depth-btn:hover {
  color: var(--text);
}
.depth-value {
  min-width: 20px;
  text-align: center;
  font-weight: 700;
}
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  width: fit-content;
  padding: 6px;
  border: 1px solid rgba(244,166,198,0.35);
  border-radius: 14px;
  background: rgba(244,166,198,0.12);
}
.mode-btn {
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}
.mode-btn.active {
  background: linear-gradient(135deg, #f4a6c6, #ffd7e4);
  color: #3b2a36;
  box-shadow: 0 6px 16px rgba(244,166,198,0.25);
}
.tag-filter {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  justify-self: end;
}
.tag-btn {
  padding: 6px 10px;
  border: 1px solid rgba(244,166,198,0.35);
  border-radius: 12px;
  background: rgba(244,166,198,0.12);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}
.tag-btn.active {
  background: linear-gradient(135deg, #f4a6c6, #ffd7e4);
  color: #3b2a36;
  box-shadow: 0 6px 16px rgba(244,166,198,0.25);
}
