:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #555;
  --border: #111;
  --hair: #00000022;

  --artist: #ff1f7a;
  --genre: #0066ff;
  --label: #ffb000;
  --city: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.brandTitle {
  font-family: "Archivo Black", system-ui;
  font-size: 24px;
  letter-spacing: .2px;
}

.brandSub {
  font-size: 16px;
  color: var(--muted);
  margin-top: 3px;
}

.brandSub a {
  color: #000;
  text-decoration: underline;
}

.topActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.searchWrap {
  position: relative;
}

.searchInput {
  height: 34px;
  min-width: 300px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-size: 14px;
  outline: none;
}

.searchInput:focus {
  box-shadow: 0 0 0 2px rgba(0,0,0,.08);
}

.searchDropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  max-height: 320px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
  z-index: 100;
}

.searchItem {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(0,0,0,.08);
  background: #fff;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.searchItem:last-child {
  border-bottom: 0;
}

.searchItem:hover,
.searchItem.active {
  background: #f5f5f5;
}

.searchItemTitle {
  font-size: 14px;
  font-weight: 700;
  color: #111;
}

.searchItemMeta {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.btn {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.btn:hover {
  background: #f4f4f4;
}

.btn:active {
  transform: translateY(1px);
}

.popover {
  position: absolute;
  right: 18px;
  top: 54px;
  width: 240px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  display: none;
  z-index: 20;
}

.popoverTitle {
  font-weight: 800;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: .2px;
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  padding: 6px 0;
}

.popoverHint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: calc(100vh - 63px);
}

.stage {
  position: relative;
  border-right: 1px solid var(--border);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #fff;
}

.side {
  padding: 14px;
  overflow: auto;
  background: #fff;
}

.sideBlock {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.sideTitle {
  font-size: 12px;
  letter-spacing: .6px;
  font-weight: 800;
  margin-bottom: 10px;
  color: #222;
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.legendItem {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid #000;
  display: inline-block;
}

.dot.artist { background: var(--artist); }
.dot.genre { background: var(--genre); }
.dot.label { background: var(--label); }
.dot.city { background: var(--city); }

.connectionLegend {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,.1);
}

.connectionLegendTitle {
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: .4px;
}

.connectionItem {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 7px;
}

.lineSample {
  display: inline-block;
  width: 28px;
  height: 0;
  border-top: 2px solid rgba(0,0,0,.55);
}

.lineSample.dashed {
  border-top-style: dashed;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  background: #fff;
}

.panelTitle {
  font-weight: 900;
  font-size: 14px;
  margin-bottom: 10px;
}

.panelBody {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.cardTitle {
  font-weight: 900;
  margin-bottom: 6px;
}

.kv {
  font-size: 12px;
  margin: 3px 0;
  line-height: 1.35;
}

.kv b {
  font-weight: 900;
}

.btnRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pillBtn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  color: #000;
}

.pillBtn:hover {
  background: #f4f4f4;
}

.pillBtn.disabled {
  opacity: .35;
  pointer-events: none;
}

.sideTools {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.sideTools .btn {
  flex: 1;
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .topActions {
    width: 100%;
  }

  .searchWrap {
    width: 100%;
  }

  .searchInput {
    min-width: 100%;
    width: 100%;
  }

  .searchDropdown {
    width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 58vh 42vh;
    height: calc(100vh - 90px);
  }

  .stage {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .side {
    padding: 10px;
  }

  .popover {
    right: 10px;
    left: 10px;
    width: auto;
    top: 120px;
  }

  .brandTitle {
    font-size: 18px;
  }

  .brandSub {
    font-size: 13px;
  }

  .btn {
    height: 30px;
  }
}

/* migliorie mobile: search + bottom sheet */
@media (max-width: 900px) {
  .searchDropdown {
    max-height: 220px;
  }

  .searchItem {
    padding: 12px 12px;
  }

  body.is-mobile .sheetHandle {
    padding: 14px 0 10px;
    min-height: 34px;
  }

  body.is-mobile .sheetHandleBar {
    width: 54px;
    height: 6px;
  }
}