:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --accent: #e94560;
  --accent-dim: #c73e54;
  --text: #edf2f4;
  --text-muted: #8d99ae;
  --grid-cell: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

.header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.25rem;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.upload-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent);
  color: white;
}

.btn:hover:not(:disabled) {
  background: var(--accent-dim);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: #2d3a4f;
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #3d4f6a;
}

.btn-icon {
  padding: 0.35rem 0.65rem;
  font-size: 1.25rem;
  line-height: 1;
}

.upload-preview {
  margin-top: 1rem;
  max-width: 100%;
  overflow: hidden;
  border-radius: 8px;
  background: #0f0f1a;
}

.upload-preview img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.digitize-options {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.digitize-options label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.digitize-options input[type="number"] {
  width: 4rem;
  padding: 0.35rem;
  border-radius: 6px;
  border: 1px solid #2d3a4f;
  background: var(--bg);
  color: var(--text);
}

.pattern-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.pattern-name {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

#zoom-level {
  min-width: 3rem;
  text-align: center;
  font-size: 0.9rem;
}

.pattern-container {
  touch-action: none;
  overflow: hidden;
  border-radius: 8px;
  background: #0f0f1a;
  position: relative;
  min-height: 300px;
  user-select: none;
}

#pattern-canvas {
  display: block;
  cursor: crosshair;
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.saved-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #2d3a4f;
  gap: 0.5rem;
}

.saved-list li:last-child {
  border-bottom: none;
}

.saved-list button {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  border: none;
  border-radius: 6px;
  background: #2d3a4f;
  color: var(--text);
  cursor: pointer;
}

.saved-list button:hover {
  background: var(--accent);
  color: white;
}

.saved-list .load-pattern {
  flex: 1;
  text-align: left;
  background: transparent;
}

.saved-list .load-pattern:hover {
  background: #2d3a4f;
}

.empty-saved {
  color: var(--text-muted);
  font-size: 0.9rem;
}
