:root {
  --bg: #ffffff;
  --surface: #f5f5f6;
  --border: #d1d5db;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.status {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.status-plotter.ready {
  color: var(--success);
}

.status-plotter.not-ready {
  color: var(--danger);
}

.main {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  flex: 1;
}

@media (max-width: 700px) {
  .main {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.upload-section {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.upload-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.file-input {
  display: block;
  width: 100%;
  padding: 0.5rem;
  font-size: 0.875rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.file-input::file-selector-button {
  margin-right: 0.5rem;
  padding: 0.25rem 0.5rem;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.transform-section h2,
.print-section h2,
.scale-section h2 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

.scale-section {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
}

.scale-section .dims {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.scale-section .unit {
  color: var(--muted);
  font-size: 0.8em;
}

.transform-section {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--border);
  border-color: var(--accent);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-print {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  border: none;
  color: #fff;
}

.plotter-info {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text);
}

.plotter-info-row {
  margin: 0.25rem 0;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.plotter-info-row strong {
  color: var(--muted);
  font-weight: 500;
}

.btn-print:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-check-plotter {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.btn-check-plotter:hover {
  background: var(--border);
  border-color: var(--accent);
}

.print-section {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.message {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  min-height: 1.25rem;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.preview-section {
  min-height: 400px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: none;
}

.preview.loaded {
  display: block;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.preview-placeholder.hidden {
  display: none;
}
