:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f9fafb 0%, #eef2ff 100%);
  color: var(--text);
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

header {
  margin-bottom: 24px;
}

.hero {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.05;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 70ch;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 20px;
}

.search {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-size: 1rem;
  outline: none;
  background: #fff;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: start;
  margin-top: 24px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.panel-subtle {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}
.panel-grid {
  display: grid;
  gap: 18px;
}

.switch-panel-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
}

.switch-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.switch-panel-title {
  margin: 0;
  font-size: 1rem;
}

.switch-panel-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.paddle-strip {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.paddle {
  width: 52px;
  min-width: 52px;
  height: 96px;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  background: linear-gradient(180deg, #ffffff 0%, #eef2f7 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.paddle::before {
  content: "";
  width: 70%;
  height: 72%;
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fafc 0%, #e5e7eb 100%);
  border: 1px solid #d1d5db;
}

.paddle-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.paddle.active-circuit {
  border-color: var(--accent);
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    0 0 0 3px rgba(37, 99, 235, 0.16);
}

.paddle.active-circuit::before {
  background: linear-gradient(180deg, #ffffff 0%, #dbeafe 100%);
  border-color: #93c5fd;
}

.panel-toggle-list {
  display: grid;
  gap: 12px;
}
.panel-toggle-item {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  border-radius: 10px;
}

.panel-toggle-item:first-child {
  border-top: none;
}

.panel-toggle-item.active-circuit {
  background: rgba(37, 99, 235, 0.08);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.22);
  padding: 10px;
}

.toggle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.toggle-title {
  margin: 0;
  font-size: 0.98rem;
}

.toggle-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.circuit-button,
.link-jump-button {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  border-radius: 999px;
  padding: 5px 9px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.circuit-button:hover,
.circuit-button:focus-visible,
.link-jump-button:hover,
.link-jump-button:focus-visible {
  background: #e5edff;
  color: #1d4ed8;
  outline: none;
}

.circuit-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.linked-toggles {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.linked-toggles-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.linked-toggle-list {
  display: grid;
  gap: 8px;
}

.linked-toggle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.linked-toggle-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-toggle-item h4 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.panel-toggle-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.content {
  padding: 20px;
}

.room-title {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.room-note {
  margin: 0 0 18px;
  color: var(--muted);
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.switch-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
}

.switch-label {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1d4ed8;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.switch-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.switch-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.meta {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--muted);
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}
.floor-toggle {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
}

.floor-toggle-button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.floor-toggle-button:hover,
.floor-toggle-button:focus-visible {
  background: #e5edff;
  color: #1d4ed8;
  outline: none;
}

.floor-toggle-button.active {
  background: var(--accent);
  color: white;
}

.floorplan-wrap {
  padding: 18px;
}

.floorplan-image-wrap {
  position: relative;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
}

.floorplan-image {
  display: block;
  width: 100%;
  height: auto;
}

.floorplan-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.debug-tools {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.debug-button {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.debug-button:hover,
.debug-button:focus-visible {
  background: #e5edff;
  color: #1d4ed8;
  outline: none;
}

.debug-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.debug-panel {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.92rem;
}

.room-hotspot.selected-for-edit {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.hotspot-layer {
  position: absolute;
  inset: 0;
}

.room-hotspot {
  position: absolute;
  border: 2px solid rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.room-hotspot:hover,
.room-hotspot:focus-visible {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.8);
  transform: scale(1.01);
  outline: none;
}

.room-hotspot.active {
  background: rgba(37, 99, 235, 0.28);
  border-color: rgba(37, 99, 235, 1);
}

.room-hotspot.hidden-by-filter {
  opacity: 0.2;
  pointer-events: none;
}

.room-hotspot-label {
  position: absolute;
  left: 4px;
  top: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #1d4ed8;
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.1;
  pointer-events: none;
}

.room-hotspot.small .room-hotspot-label {
  font-size: 0.6rem;
  padding: 1px 4px;
}

.room-hotspot.active-circuit {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.95);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: rgba(37, 99, 235, 0.12);
}

.swatch.active {
  background: rgba(37, 99, 235, 0.28);
}

.circuit-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;

  background: var(--accent-soft);
  color: #1d4ed8;

  border: 1px solid transparent;
  cursor: pointer;
}

.circuit-badge:hover,
.circuit-badge:focus-visible {
  background: #e5edff;
  outline: none;
}

.circuit-badge.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

footer {
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
}