/* ── Panel shell ─────────────────────────────────────────────────────────── */

#panel {
  grid-row: 2 / 3;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  /* children handle their own scroll */
}

/* ── Desktop tab bar ─────────────────────────────────────────────────────── */

.panel-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  padding: 12px 10px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  text-align: center;
}

.panel-tab:hover {
  background: var(--border);
  color: var(--text);
}

.panel-tab.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.panel-tab .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 20px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(238, 109, 11, 0.1);
  color: inherit;
  transition: background 0.12s;
  line-height: 1;
}

.panel-tab.active .tab-count {
  background: rgba(255, 255, 255, 0.20);
}

/* ── Desktop building list ───────────────────────────────────────────────── */

.panel-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 10px;
  overflow-y: auto;
}

/* ── Visibility utility (beats display:flex on .building-btn) ────────────── */

.panel-hidden {
  display: none !important;
}

/* ── Building button ─────────────────────────────────────────────────────── */

.building-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
  cursor: pointer;
}

.building-btn:hover {
  background: var(--bg);
  border-color: var(--border);
}

.building-btn:active {
  transform: scale(0.98);
}

.building-btn .swatch {
  flex-shrink: 0;
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.building-btn .swatch img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.building-btn .info {
  flex: 1;
  min-width: 0;
}

.building-btn .name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.building-btn .meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-hint);
}

.building-btn .add-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border-md);
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.building-btn:hover .add-icon {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {

  #panel {
    flex-shrink: 0;
    flex-direction: column;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
  }

  /* Tab bar: full-width row of equal pill tabs */
  .panel-tabs {
    padding: 8px 8px 6px;
    gap: 5px;
    border-bottom: 1px solid var(--border);
  }

  .panel-tab {
    padding: 6px 4px;
    font-size: 10px;
    gap: 4px;
  }

  .panel-tab .tab-count {
    min-width: 16px;
    height: 22px;
    font-size: 9px;
    padding: 0 4px;
  }

  /* Building list: horizontal scrolling strip */
  .panel-list {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    height: 116px;
    /* thumb + name + meta */
    flex-shrink: 0;
  }

  .panel-list::-webkit-scrollbar {
    display: none;
  }

  /* Cards: compact vertical thumbnail + text */
  .building-btn {
    flex-direction: column;
    flex-shrink: 0;
    flex-grow: 0;
    width: 80px;
    padding: 0;
    gap: 0;
    align-items: center;
    border-radius: var(--radius-sm);
    overflow: hidden;
    justify-content: flex-start;
  }

  .building-btn:hover {
    border-color: var(--accent);
    background: var(--surface);
  }

  .building-btn .swatch {
    width: 72px;
    height: 72px;
    border-radius: 0;
    flex-shrink: 0;
  }

  .building-btn .add-icon {
    display: none;
  }

  .building-btn .info {
    display: block;
    width: 100%;
    padding: 3px 4px 4px;
  }

  .building-btn .name {
    font-size: 9px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .building-btn .meta {
    display: none;
    /* save space on mobile */
  }
}