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

:root {
  --wii-blue: #0AB9E6;
  --wii-blue-dark: #0891b2;
  --wii-light-bg: #f0f4f8;
  --wii-white: #ffffff;
  --wii-gray: #e2e8f0;
  --wii-text: #1e293b;
  --wii-text-secondary: #64748b;
  --wii-accent: #0AB9E6;
  --wii-panel-bg: #ffffff;
  --wii-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --wii-border: #e2e8f0;
  --wii-hover: #f1f5f9;
  --wii-selected: #e0f2fe;
  --hex-bg: #0d1117;
  --hex-text: #00ff41;
  --hex-offset: #58a6ff;
  --hex-ascii: #f0883e;
  --hex-highlight: #ff7b72;
  --font-sans: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

body.homebrew-dark {
  --wii-light-bg: #0a0a1a;
  --wii-white: #12122a;
  --wii-gray: #1e1e3a;
  --wii-text: #e0e0e0;
  --wii-text-secondary: #8888aa;
  --wii-accent: #00ff41;
  --wii-panel-bg: #14142b;
  --wii-shadow: 0 2px 12px rgba(0,0,0,0.4);
  --wii-border: #2a2a4a;
  --wii-hover: #1a1a3a;
  --wii-selected: #1a2a1a;
  --hex-bg: #0a0a0a;
  --hex-text: #00ff41;
}

body {
  font-family: var(--font-sans);
  background: var(--wii-light-bg);
  color: var(--wii-text);
  min-height: 100vh;
  overflow-x: hidden;
}

body.homebrew-dark::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

@keyframes pulse-led {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px 2px rgba(10, 185, 230, 0.6); }
  50% { opacity: 0.5; box-shadow: 0 0 3px 1px rgba(10, 185, 230, 0.3); }
}

.led-pulse {
  animation: pulse-led 2s ease-in-out infinite;
}

body.homebrew-dark .led-pulse {
  animation-name: pulse-led-green;
}

@keyframes pulse-led-green {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px 2px rgba(0, 255, 65, 0.6); }
  50% { opacity: 0.5; box-shadow: 0 0 3px 1px rgba(0, 255, 65, 0.3); }
}

@keyframes spin-disc {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(1080deg); }
}

.disc-spin {
  animation: spin-disc 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fade-in 0.25s ease-out;
}

@keyframes slide-down {
  from { max-height: 0; opacity: 0; }
  to { max-height: 1000px; opacity: 1; }
}

.tree-expand {
  animation: slide-down 0.3s ease-out;
  overflow: hidden;
}

@keyframes disc-read {
  0% { width: 0%; }
  50% { width: 80%; }
  100% { width: 100%; }
}

.disc-read-bar {
  animation: disc-read 0.6s ease-out forwards;
}

@keyframes rotate-cube {
  0% { transform: rotateX(-20deg) rotateY(0deg); }
  100% { transform: rotateX(-20deg) rotateY(360deg); }
}

.rotate-cube {
  animation: rotate-cube 4s linear infinite;
}

.hex-view {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--hex-bg);
  color: var(--hex-text);
}

.hex-row:nth-child(even) {
  background: rgba(255,255,255,0.02);
}

.structure-block {
  transition: all 0.2s ease;
  cursor: pointer;
}

.structure-block:hover {
  transform: scale(1.02);
  filter: brightness(1.2);
  z-index: 10;
}

.tree-node {
  transition: background 0.15s ease;
}

.tree-node:hover {
  background: var(--wii-hover);
}

.tree-node.selected {
  background: var(--wii-selected);
}

.tab-btn {
  transition: all 0.2s ease;
  position: relative;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--wii-accent);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--wii-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--wii-text-secondary);
}

.tooltip-content {
  visibility: hidden;
  opacity: 0;
  transition: all 0.2s ease;
  position: absolute;
  z-index: 100;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  background: #1e293b;
  color: #fff;
  pointer-events: none;
}

.tooltip-parent:hover .tooltip-content {
  visibility: visible;
  opacity: 1;
}

.drop-highlight {
  border-color: var(--wii-accent) !important;
  background: rgba(10, 185, 230, 0.05) !important;
}

body.homebrew-dark .drop-highlight {
  background: rgba(0, 255, 65, 0.05) !important;
}

@media (max-width: 768px) {
  .main-layout {
    flex-direction: column !important;
  }
  .left-panel {
    width: 100% !important;
    max-height: 45vh;
    border-right: none !important;
    border-bottom: 1px solid var(--wii-border) !important;
  }
  .right-panel {
    width: 100% !important;
  }
}