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

:root {
  --bg: #0d0f14;
  --surface: #161a23;
  --surface2: #1e2330;
  --border: #252b38;
  --accent: #69c9ff;
  --text: #e2e8f0;
  --muted: #8b93a5;
  --radius: 8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

button, select, input[type="number"], input[type="text"], input[type="range"], input[type="color"], input[type="checkbox"] {
  font: inherit;
}

button {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-title {
  font-weight: 650;
  margin-right: 0.4rem;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.back-link:hover { color: var(--accent); border-color: var(--accent); }

.status {
  color: var(--muted);
  font-size: 0.82rem;
  margin-left: auto;
}

.status.error { color: #f87171; }

.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.rail {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0.85rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rail-h {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 0.4rem;
}

.units-note {
  font-size: 0.78rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.85rem;
}

.field span {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text);
}

.field em {
  font-style: normal;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.field select,
.field input[type="number"],
.field input[type="text"] {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.field input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  border-radius: 8px;
  accent-color: #69c9ff;
  cursor: pointer;
  align-self: flex-start;
}

.field input[type="color"] {
  height: 36px;
  padding: 0.15rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.leather-swatches {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.leather-swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0;
}

.leather-swatch[aria-pressed="true"] {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.preview-3d {
  flex: 1 1 42%;
  min-width: 220px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  background: #0d0f14;
  border-right: 1px solid var(--border);
  user-select: none;
}

.preview-3d canvas,
#editor-3d {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  background: #0d0f14;
  touch-action: none;
}

.preview-3d-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.explode-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.explode-field input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.sheet {
  flex: 1 1 42%;
  min-width: 0;
  overflow: auto;
  padding: 1rem;
  background:
    linear-gradient(var(--bg), var(--bg)),
    repeating-linear-gradient(0deg, transparent, transparent 19px, #1a1f2a 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, #1a1f2a 20px);
}

#pattern-svg {
  display: block;
  max-width: 100%;
  height: auto;
  background: #11141c;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.auth-signin {
  background: var(--accent);
  color: #0d0f14;
  border: none;
  border-radius: 8px;
  font-weight: 650;
}

@media (max-width: 720px) {
  .workspace { flex-direction: column; }
  .rail { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .preview-3d {
    min-height: 280px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
