* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #0d0d0d;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-container {
  width: 95%;
  max-width: 1200px;
  height: 90vh;
  background-color: #141414;
  border: 1px solid #222;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  background-color: #1a1a1a;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid #282828;
}

.header-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
}

.toolbar-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.toolbar-block {
  background: rgba(31, 31, 31, 0.8);
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 220px;
}

.toolbar-block h3 {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a8a8a8;
  margin-bottom: 6px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-row p {
  font-size: 0.8rem;
  color: #f0f0f0;
  white-space: nowrap;
}

.toolbar-row input[type="color"] {
  width: 34px;
  height: 28px;
  border: 1px solid #3b3b3b;
  background: transparent;
  padding: 0;
  border-radius: 4px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 7px 12px;
  background-color: #2a2a2a;
  border: 1px solid #3c3c3c;
  border-radius: 4px;
  color: #fff;
  font-size: 0.75rem;
  cursor: pointer;
}

.file-button:hover {
  background-color: #333;
  border-color: #555;
}

#imagePreview {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  border: 1px solid #3b3b3b;
  background: #090909;
}

.image-block {
  min-width: 330px;
}

.connection-block {
  min-width: 320px;
}

#cubeEndpoint {
  width: 130px;
  min-height: 28px;
  padding: 7px 8px;
  background: #1b1b1b;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #fff;
  font-size: 0.7rem;
}

.toolbar-row button {
  padding: 7px 12px;
  font-size: 0.75rem;
}

.toolbar-row select {
  background: #1b1b1b;
  color: #fff;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 0.75rem;
  min-width: 120px;
}

.buttons-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modes-block {
  min-width: 280px;
}

.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.offline {
  background-color: rgba(255, 82, 82, 0.15);
  color: #ff5252;
  border: 1px solid rgba(255, 82, 82, 0.3);
}

.workspace {
  display: grid;
  grid-template-columns: 1.45fr 54px 1.2fr;
  flex: 1;
  overflow: hidden;
}

.table-section {
  display: flex;
  flex-direction: column;
  background-color: #0f0f0f;
  padding: 16px 16px 14px;
  gap: 12px;
  overflow: hidden;
}

.search-bar-group input {
  width: 100%;
  padding: 10px 14px;
  background-color: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #fff;
  font-size: 0.95rem;
}

.search-bar-group input:focus {
  outline: none;
  border-color: #00bcd4;
}

.table-container {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #222;
  border-radius: 6px;
  background-color: #141414;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid #222;
}

th {
  background-color: #1a1a1a;
  color: #aaa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:hover {
  background-color: #1a1a1a;
}

.color-preview {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid #444;
  display: inline-block;
}

.control-panel {
  background-color: #181818;
  border-left: 1px solid #282828;
  border-right: 1px solid #282828;
  padding: 10px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slim-strip {
  background: linear-gradient(180deg, rgba(26, 26, 26, 0.8), rgba(20, 20, 20, 0.9));
}

.strip-indicator {
  width: 10px;
  height: 70%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-card {
  background-color: #1f1f1f;
  border: 1px solid #2c2c2c;
  border-radius: 6px;
  padding: 14px 12px;
}

.panel-card h3 {
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#selectedCount {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: #fff;
}

.color-picker-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.color-picker-group label {
  font-size: 0.9rem;
  color: #ccc;
}



input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 1px solid #444;
  border-radius: 4px;
}

button {
  background-color: #2a2a2a;
  color: #fff;
  border: 1px solid #3c3c3c;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
}

button:hover:not(:disabled) {
  background-color: #333;
  border-color: #555;
}

.btn-primary {
  width: 100%;
  background-color: #00bcd4;
  border-color: #00acc1;
  color: #000;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background-color: #26c6da;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.viewport-section {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  position: relative;
  perspective: 1400px;
  overflow: hidden;
}

.matrix-3d-space {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 520px;
  height: 520px;
  transform-style: preserve-3d;
  transform: translate(-50%, -50%) rotateX(60deg) rotateY(-35deg);
  transition: transform 0.12s ease-out;
  pointer-events: none;
}

.matrix-3d-space {
  display: block;
}

.matrix-3d-space::before,
.matrix-3d-space::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  transform-style: preserve-3d;
  pointer-events: none;
}

.matrix-3d-space::before {
  width: 260px;
  height: 260px;
  transform: translate3d(-50%, -50%, 0px) rotateX(90deg) translateZ(-120px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.01);
}

.matrix-3d-space::after {
  width: 260px;
  height: 260px;
  transform: translate3d(-50%, -50%, 0px) rotateY(90deg) translateZ(-120px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.01);
}

.node-3d {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--led-color) 55%, white);
  transform-style: preserve-3d;
  cursor: pointer;
  pointer-events: auto;
  background:
    radial-gradient(circle at 28% 26%, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.78) 13%, color-mix(in srgb, var(--led-color) 92%, white) 28%, var(--led-color) 60%, color-mix(in srgb, var(--led-color) 72%, black) 88%, color-mix(in srgb, var(--led-color) 42%, black) 100%);
  box-shadow:
    inset -2px -2px 3px rgba(0, 0, 0, 0.48),
    inset 2px 2px 3px rgba(255, 255, 255, 0.3),
    0 0 3px color-mix(in srgb, var(--led-color) 60%, transparent);
  opacity: 1;
  transition: transform 0.08s ease, opacity 0.12s ease, filter 0.12s ease;
  will-change: transform;
}

.node-3d::before,
.node-3d::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
}

.node-3d::before {
  width: 17px;
  height: 17px;
  left: -3px;
  top: -3px;
  z-index: -1;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.85) 42%, rgba(0, 0, 0, 0.35) 68%, transparent 72%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateZ(-2px);
}

.node-3d::after {
  width: 3px;
  height: 3px;
  left: 2px;
  top: 2px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.75);
}

.node-3d.is-lit::before {
  opacity: 0.35;
}

.node-3d.is-lit::after {
  width: 4px;
  height: 4px;
  left: 2px;
  top: 2px;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.95);
}

.node-3d.is-lit {
  z-index: 2;
  box-shadow:
    inset -2px -2px 3px rgba(0, 0, 0, 0.42),
    inset 2px 2px 3px rgba(255, 255, 255, 0.36),
    0 0 8px color-mix(in srgb, var(--led-color) 72%, transparent);
}

.node-3d:hover {
  opacity: 1;
  filter: brightness(1.08);
}

.node-3d.is-selected {
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow:
    inset -2px -2px 3px rgba(0, 0, 0, 0.25),
    inset 2px 2px 3px rgba(255, 255, 255, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.14),
    0 0 4px currentColor;
}
