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

:root {
  --bg-0: #0a0a0a;
  --bg-1: #111;
  --bg-2: #1a1a1a;
  --bg-3: #252525;
  --border: #333;
  --border-hover: #444;
  --text-0: #fff;
  --text-1: #bbb;
  --text-2: #777;
  --accent: #00e385;
  --accent-hover: #00c76f;
  --accent-dim: rgba(0, 227, 133, 0.15);
}

html,
body {
  height: 100%;
}
body {
  font:
    14px/1.5 "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg-0);
  color: var(--text-1);
  overflow: hidden;
  font-weight: 400;
}

/* Layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: -0.5px;
}
.logo span {
  color: var(--accent);
}

.header-actions {
  display: flex;
  gap: 10px;
}

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.panel {
  border-bottom: 1px solid var(--border);
}

.panel-header {
  padding: 14px 16px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-2);
}

.panel-body {
  padding: 0 16px 16px;
}

/* Upload */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  border: 2px dashed var(--border-hover);
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}
.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text-1);
}
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.upload-zone span {
  font-size: 13px;
  font-weight: 500;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-dims {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}

/* Buttons */
.btn {
  padding: 10px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-1);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover:not(:disabled) {
  background: var(--bg-3);
  border-color: var(--border-hover);
  color: var(--text-0);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #000;
}

.btn-icon {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  border-radius: 4px;
}
.btn-icon:hover {
  color: var(--text-0);
  background: var(--bg-2);
}

/* Toggle */
.toggle-row {
  display: flex;
  gap: 8px;
}
.toggle {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle:hover {
  color: var(--text-1);
  border-color: var(--border-hover);
}
.toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

/* Controls */
.control {
  display: block;
  margin-bottom: 18px;
}
.control:last-child {
  margin-bottom: 0;
}
.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}
.control output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
}
.hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}
.control .hint {
  margin: 8px 0 0;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--text-0);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: background 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent);
}

/* Stats */
.stats {
  display: flex;
  gap: 16px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.stat span {
  color: var(--text-2);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.stat b {
  color: var(--text-0);
  font-weight: 700;
  font-size: 16px;
}

/* Workspace */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  overflow: hidden;
}

.view-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}
.view-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.view-tab:hover {
  color: var(--text-1);
  background: var(--bg-2);
}
.view-tab.active {
  background: var(--bg-3);
  color: var(--text-0);
}

/* Canvas Area */
.canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-2);
}
.empty-state svg {
  opacity: 0.3;
}
.empty-state p {
  font-size: 15px;
  color: var(--text-1);
}
.empty-state span {
  font-size: 12px;
}

/* Utilities */
[hidden] {
  display: none !important;
}

/* Split View */
.split-view {
  position: absolute;
  inset: 0;
  display: flex;
}

.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 100px;
  overflow: hidden;
}

.pane-label {
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-2);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}

.pane-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  /* Background handled by .pan-container */
}

/* Remove old conflicting canvas constraints */
.pane-content canvas,
.single-view canvas {
  display: block;
  /* No max-width/height - let pan/zoom handle it */
}

/* Single View */
.single-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-0);
  opacity: 0;
  transition: all 0.25s;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success {
  border-color: var(--accent);
  background: rgba(0, 227, 133, 0.1);
}
.toast.error {
  border-color: #e55;
  background: rgba(238, 85, 85, 0.1);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Pan/Zoom Overlay */
.zoom-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  gap: 10px;
  background: rgba(17, 17, 17, 0.9);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  z-index: 100;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.zoom-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-1);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 0;
  transition:
    background 0.15s,
    color 0.15s;
}
.zoom-btn svg {
  width: 18px;
  height: 18px;
}
.zoom-btn:hover {
  color: var(--text-0);
  background: var(--bg-2);
}
.zoom-btn:active {
  transform: scale(0.95);
}

/* Custom Splitter */
.splitter {
  width: 8px;
  background: var(--bg-0);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  z-index: 10;
  position: relative;
  transition: background 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='16' viewBox='0 0 4 16'%3E%3Cpath fill='%23444' d='M0 0h1v16H0zm3 0h1v16H3z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}
.splitter:hover {
  background-color: var(--bg-2);
  border-color: var(--accent);
}

/* Pan Container */
.pan-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  position: relative;
  background-image: linear-gradient(45deg, var(--bg-2) 25%, transparent 25%), linear-gradient(-45deg, var(--bg-2) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg-2) 75%), linear-gradient(-45deg, transparent 75%, var(--bg-2) 75%);
  background-size: 20px 20px;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0px;
  background-color: var(--bg-1);
}
.pan-container:active {
  cursor: grabbing;
}

.pan-content {
  transform-origin: 0 0;
  min-width: 100%;
  min-height: 100%;
}

/* Ensure content fits initially but can be scaled */
.pan-content canvas {
  max-width: none;
  max-height: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  image-rendering: auto;
}
.pan-content svg {
  max-width: none;
  max-height: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  /* Vector rendering */
  shape-rendering: geometricPrecision;
  overflow: visible;
}

/* SVG wrapper - checkerboard for transparency */
.svg-wrap {
  display: inline-block;
  line-height: 0;
  background-image: linear-gradient(45deg, #444 25%, transparent 25%), linear-gradient(-45deg, #444 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #444 75%), linear-gradient(-45deg, transparent 75%, #444 75%);
  background-size: 16px 16px;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0px;
  background-color: #555;
}
