:root {
  --bg: #09090b;
  --panel: #18181b;
  --border: #27272a;
  --accent: #3b82f6;
  --text: #f4f4f5;
  --text-dim: #a1a1aa;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar / Panel */
#sidebar {
  width: 380px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  z-index: 10;
  box-shadow: var(--shadow);
}

h1 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--accent);
}

.section {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
}

/* Control Groups */
.control-row {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
}

input[type="number"],
select,
textarea {
  background: #000;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  width: 100%;
}

input[type="number"]:focus {
  border-color: var(--accent);
  outline: none;
}

button {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: none;
  background: #27272a;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:hover {
  background: #3f3f46;
}

button.primary {
  background: var(--accent);
  color: white;
}

button.primary:hover {
  background: #2563eb;
}

button.export-btn {
  background: var(--success);
  color: white;
  padding: 12px;
  font-size: 1rem;
  margin-bottom: 10px;
}

button.export-btn:hover {
  background: #16a34a;
  transform: scale(1.02);
}

button.danger {
  background: var(--danger);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
}

button.ghost:hover {
  background: var(--border);
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Canvas & Main Area */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  overflow: hidden;
}

#toolbar {
  height: 50px;
  background: rgba(24, 24, 27, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  justify-content: space-between;
}

#canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: crosshair;
}

canvas {
  background-image:
    linear-gradient(45deg, #111 25%, transparent 25%),
    linear-gradient(-45deg, #111 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #111 75%),
    linear-gradient(-45deg, transparent 75%, #111 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px 10px, 10px 0;
  border: 1px solid var(--border);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* Bottom Timeline */
#timeline {
  height: 120px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 10px 20px;
}

.timeline-scroll {
  flex: 1;
  overflow-x: auto;
  display: flex;
  gap: 4px;
  align-items: center;
  padding-bottom: 10px;
}

.frame-cell {
  min-width: 40px;
  height: 60px;
  border: 1px solid var(--border);
  background: #000;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.1s;
}

.frame-cell:hover {
  background: #111;
  border-color: var(--text-dim);
}

.frame-cell.active {
  border-color: var(--accent);
  background: #172554;
}

.frame-indicator {
  display: flex;
  gap: 2px;
  margin-top: 4px;
}

.dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #333;
}

.dot.filled {
  background: var(--accent);
}

/* Modals / Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 30px;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
}

/* Custom File Input */
.file-input-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.file-input-wrapper input[type=file] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#importBox {
  height: 300px;
  margin-top: 20px;
  font-size: 0.75rem;
}

.kbd {
  font-family: monospace;
  background: #333;
  padding: 2px 4px;
  border-radius: 3px;
  color: #fff;
  font-size: 0.7rem;
}