:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101114;
  color: #f2f5f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 22% 18%, rgba(54, 142, 184, 0.22), transparent 28rem),
    linear-gradient(135deg, #101114 0%, #171a20 50%, #121716 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 440px) minmax(0, 1fr);
  min-height: 100vh;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: 100vh;
  overflow: auto;
  padding: 28px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(16, 17, 20, 0.84);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 8px;
  background: #42b883;
  color: #06130d;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

p {
  margin: 6px 0 0;
  color: #aeb8c2;
  line-height: 1.45;
}

.project-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.project-card {
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 12px;
  text-align: left;
  align-content: start;
}

.project-card strong {
  color: #f8fbfd;
}

.project-card span {
  color: #aeb8c2;
  font-size: 0.82rem;
  line-height: 1.35;
}

.project-card.active {
  border-color: #42b883;
  background: rgba(66, 184, 131, 0.16);
}

.controls,
.panel {
  display: grid;
  gap: 16px;
}

.panel {
  display: none;
}

.panel.active {
  display: grid;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: #d9e0e6;
  font-size: 0.92rem;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 10px 11px;
  background: #1b2028;
  color: #f7fafc;
  outline: none;
}

input:focus {
  border-color: #42b883;
  box-shadow: 0 0 0 3px rgba(66, 184, 131, 0.18);
}

input[type="range"] {
  padding: 0;
  accent-color: #42b883;
}

input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #151a21;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 6px;
  color: #cbd5df;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented label:has(input:checked) {
  background: #42b883;
  color: #06130d;
  font-weight: 800;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #222934;
  color: #f8fbfd;
  cursor: pointer;
}

button:hover {
  background: #2a3341;
}

button.primary {
  border-color: #42b883;
  background: #42b883;
  color: #06130d;
  font-weight: 800;
}

button.primary:hover {
  background: #55c793;
}

.status {
  min-height: 22px;
  margin-top: auto;
  color: #c8d2dc;
}

.viewport {
  position: relative;
  min-height: 100vh;
}

#preview {
  display: block;
  width: 100%;
  height: 100%;
}

.viewport-meta {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(16, 17, 20, 0.76);
  color: #dce5ed;
  font-size: 0.9rem;
}

body[data-box-shape="round"] .rect-only,
body[data-box-shape="rect"] .round-only {
  display: none;
}

body:not([data-fastener-mode="screw"]) .screw-only,
body:not([data-fastener-mode="grip"]) .grip-only {
  display: none;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .toolbar {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .viewport {
    min-height: 58vh;
  }
}

@media (max-width: 520px) {
  .toolbar {
    padding: 20px;
  }

  .grid-2,
  .actions,
  .project-picker,
  .viewport-meta {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
