:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171b1f;
  --panel-2: #21262c;
  --line: #343b44;
  --text: #eef2f4;
  --muted: #a8b2bc;
  --accent: #34c6a3;
  --accent-2: #f2b84b;
  --danger: #ff6b6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(52, 198, 163, 0.12), transparent 30%),
    radial-gradient(circle at 78% 14%, rgba(242, 184, 75, 0.10), transparent 22%),
    var(--bg);
}

.release-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(52, 198, 163, 0.12), transparent 34%),
    radial-gradient(circle at 76% 20%, rgba(242, 184, 75, 0.12), transparent 24%),
    var(--bg);
}

.release-panel {
  width: min(620px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 31, 0.94);
  box-shadow: var(--shadow);
}

.release-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.release-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.release-actions a {
  text-decoration: none;
}

.release-actions code {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-2);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1760px;
  margin: 0 auto 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

h2 {
  font-size: 16px;
}

.signin-form,
.auth-stack,
.viewer-toolbar,
.toolbar-actions,
.editor-actions,
.section-heading,
.save-bar,
.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.signin-form {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.auth-stack {
  display: grid;
  gap: 8px;
  justify-items: end;
  min-width: min(760px, 100%);
}

.signin-form input {
  width: min(220px, 100%);
}

.signin-form select {
  width: 120px;
}

.active-user {
  color: var(--muted);
  font-size: 13px;
}

.studio-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 430px;
  gap: 16px;
  max-width: 1760px;
  margin: 0 auto;
  align-items: stretch;
}

.library-panel,
.controls {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 31, 0.92);
}

.library-panel {
  padding: 14px;
  height: calc(100vh - 120px);
  overflow: auto;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.project-list {
  display: grid;
  gap: 10px;
}

.project-card {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.project-card.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.project-card strong,
#currentProjectTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card span,
.project-card small,
#projectState {
  color: var(--muted);
  font-size: 12px;
}

.viewer-panel {
  min-width: 0;
}

.viewer-toolbar {
  justify-content: space-between;
  min-height: 54px;
  margin-bottom: 10px;
}

.viewer-toolbar > div:first-child {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.drop-zone {
  position: relative;
  height: calc(100vh - 190px);
  min-height: 500px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e1012;
  box-shadow: var(--shadow);
}

.drop-zone.dragging {
  border-color: var(--accent);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
  font-size: 22px;
}

.hidden {
  display: none;
}

.status-badge {
  position: absolute;
  left: 14px;
  top: 14px;
  max-width: calc(100% - 28px);
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(17, 19, 21, 0.78);
  color: var(--muted);
  font-size: 13px;
  backdrop-filter: blur(12px);
}

.model-stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 12px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.model-stats span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100vh - 120px);
  overflow: hidden;
}

.tabs {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 20, 0.38);
}

.tab {
  flex: 1;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.tab.active {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.tab-panel {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.tab-panel.active {
  display: grid;
  align-content: start;
  gap: 14px;
}

.control-group {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.checkbox-list {
  display: grid;
  gap: 8px;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  color: var(--text);
  text-transform: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
}

input,
select {
  height: 40px;
  padding: 0 10px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

textarea {
  min-height: 420px;
  resize: vertical;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.short-textarea {
  min-height: 110px;
  font-family: inherit;
  font-size: 14px;
}

.scad-group {
  min-height: 100%;
}

.button,
.icon-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  color: #07100d;
  background: var(--accent);
}

.button.secondary {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.button.compact {
  min-height: 34px;
  padding: 0 12px;
  background: var(--accent-2);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 20px;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.save-bar {
  justify-content: stretch;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.save-bar .button {
  flex: 1;
}

@media (max-width: 1220px) {
  .studio-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .controls {
    grid-column: 1 / -1;
    height: auto;
    min-height: 520px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .studio-layout,
  .model-stats,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .studio-layout {
    display: grid;
  }

  .signin-form,
  .viewer-toolbar {
    align-items: stretch;
  }

  .auth-stack {
    justify-items: stretch;
  }

  .signin-form input,
  .signin-form select {
    width: 100%;
  }

  .library-panel,
  .controls {
    height: auto;
  }

  .drop-zone {
    height: 56vh;
    min-height: 340px;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    min-width: 92px;
  }
}
