:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #eef4ed;
  --surface-3: #e5edf2;
  --ink: #17221c;
  --muted: #65736b;
  --soft: #8b9990;
  --line: #d7e0d8;
  --line-strong: #b8c8bd;
  --primary: #2156f3;
  --primary-ink: #ffffff;
  --mint: #36c985;
  --lime: #c7f35c;
  --coral: #ff6b4a;
  --amber: #d87900;
  --danger: #d92d20;
  --shadow: 0 18px 45px rgba(31, 54, 42, 0.10);
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(199, 243, 92, 0.28), transparent 32%),
    linear-gradient(315deg, rgba(33, 86, 243, 0.10), transparent 34%),
    var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(33, 86, 243, 0.25);
  outline-offset: 2px;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(184, 200, 189, 0.72);
  background: rgba(244, 246, 242, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  border: 1px solid #121a15;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--lime) 0 50%, var(--mint) 50% 100%);
  box-shadow: 4px 4px 0 #121a15;
  color: #121a15;
  font-weight: 900;
  letter-spacing: 0;
}

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

h1 {
  font-size: 17px;
  line-height: 1.15;
  font-weight: 850;
}

.brand p,
.hero p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.topbar-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-pills span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(23, 34, 28, 0.12);
  border-radius: 999px;
  padding: 5px 11px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.app-layout {
  height: calc(100dvh - 72px);
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid rgba(184, 200, 189, 0.72);
  background: rgba(255, 255, 255, 0.78);
}

.sidebar,
.right-panel {
  scrollbar-gutter: stable;
}

.hero {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 20px 24px 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.hero h2,
section h2,
summary {
  color: #344138;
  font-size: 12px;
  font-weight: 850;
}

section,
details {
  margin: 0;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

details {
  background: rgba(238, 244, 237, 0.38);
}

summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input:hover,
select:hover {
  border-color: #98aaa0;
}

input:focus,
select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(33, 86, 243, 0.10);
}

input[type="range"] {
  min-height: 32px;
  padding: 0;
  accent-color: var(--primary);
}

input[type="checkbox"] {
  width: 19px;
  height: 19px;
  min-height: 19px;
  flex: 0 0 19px;
  accent-color: var(--primary);
}

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

.file-row,
.segmented {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #97a79d;
  box-shadow: 0 10px 24px rgba(31, 54, 42, 0.09);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

button.primary {
  border-color: #173fc0;
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 12px 28px rgba(33, 86, 243, 0.18);
}

button.primary + button.primary {
  border-color: #18231d;
  background: #18231d;
  box-shadow: 0 12px 28px rgba(24, 35, 29, 0.16);
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

.secondary {
  background: var(--surface-2);
}

.full {
  width: 100%;
}

.segmented {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented button {
  flex: 1;
  min-height: 40px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.segmented button:hover {
  box-shadow: none;
}

.segmented .active {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(31, 54, 42, 0.08);
}

.shape-panel {
  display: none;
  margin-top: 14px;
}

.shape-panel.active {
  display: grid;
}

.file-chip {
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  flex: 1;
  border: 1px dashed #a6b9ad;
  border-radius: 8px;
  background: rgba(238, 244, 237, 0.7);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toggle {
  min-height: 44px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--ink);
  font-weight: 760;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.color-card {
  --swatch: var(--primary);
  min-width: 0;
  min-height: 58px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--swatch) 18%, #ffffff), rgba(255, 255, 255, 0.92));
  color: var(--ink);
  padding: 8px;
  cursor: pointer;
}

.color-card:hover {
  border-color: color-mix(in srgb, var(--swatch) 42%, var(--line-strong));
  background: #fff;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--swatch) 24%, #ffffff), rgba(255, 255, 255, 0.96));
}

.color-card input[type="color"] {
  width: 44px;
  height: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  border: 1px solid rgba(23, 34, 28, 0.18);
  border-radius: 8px;
  background: var(--swatch);
  padding: 3px;
  cursor: pointer;
}

.color-card input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-card input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}

.color-card span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.color-card strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.15;
}

.color-card small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.2;
}

.base-text-panel {
  margin-top: 16px;
  border-top: 1px solid rgba(184, 200, 189, 0.64);
  padding-top: 4px;
}

.range-label {
  gap: 9px;
}

.range-label span {
  color: var(--primary);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 850;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
  gap: 18px;
  padding: 18px;
}

.preview-shell {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(102, 123, 112, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.56) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.56) 1px, transparent 1px),
    radial-gradient(circle at 32% 20%, rgba(199, 243, 92, 0.22), transparent 36%),
    radial-gradient(circle at 72% 78%, rgba(33, 86, 243, 0.14), transparent 34%),
    #dbe4dc;
  background-size: 30px 30px, 30px 30px, auto, auto, auto;
  box-shadow: var(--shadow);
}

.preview-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 7px;
}

.preview-view {
  position: absolute;
  inset: 0;
  display: none;
}

.preview-view.active {
  display: block;
}

#preview-canvas {
  width: 100%;
  height: 100%;
}

#preview-3d canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.view-tabs {
  position: absolute;
  z-index: 3;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(23, 34, 28, 0.10);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(31, 54, 42, 0.10);
}

.view-tabs button {
  min-height: 34px;
  padding: 6px 11px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.view-tabs .active {
  background: #18231d;
  border-color: #18231d;
  color: #fff;
}

.empty-preview {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: min(74vw, 360px);
  border: 1px solid rgba(23, 34, 28, 0.10);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(31, 54, 42, 0.10);
  color: var(--muted);
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 720;
  text-align: center;
}

.preview-meta {
  position: absolute;
  z-index: 3;
  left: 16px;
  bottom: 16px;
  max-width: calc(100% - 32px);
  border: 1px solid rgba(23, 34, 28, 0.10);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 24px rgba(31, 54, 42, 0.08);
  color: #405047;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.right-panel {
  min-width: 0;
  overflow-y: auto;
  border: 1px solid rgba(184, 200, 189, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 32px rgba(31, 54, 42, 0.08);
}

.right-panel section {
  padding: 20px;
}

.build-panel {
  display: grid;
  gap: 12px;
}

.build-panel h2,
.right-panel section h2 {
  margin-bottom: 2px;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e9e3;
}

#progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--mint), var(--lime));
  transition: width 0.22s ease;
}

.status {
  min-height: 42px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(184, 200, 189, 0.56);
  border-radius: 8px;
  background: rgba(238, 244, 237, 0.72);
  color: #405047;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 720;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.stats-grid span,
.stats-grid strong {
  display: block;
  min-width: 0;
}

.stats-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.stats-grid strong {
  margin-top: 4px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1;
}

pre {
  min-height: 182px;
  max-height: 280px;
  overflow: auto;
  margin: 14px 0 0;
  border: 1px solid rgba(184, 200, 189, 0.72);
  border-radius: 8px;
  background: #101812;
  color: #d7f2df;
  padding: 13px;
  white-space: pre-wrap;
  font: 12px/1.55 var(--mono);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 1180px) {
  .app-layout {
    grid-template-columns: minmax(300px, 350px) minmax(0, 1fr);
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(520px, 1fr) auto;
  }

  .right-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    overflow: visible;
  }

  .right-panel section {
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }

  .right-panel section:last-child {
    border-right: 0;
  }

  pre {
    max-height: 180px;
  }
}

@media (max-width: 860px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    min-height: 68px;
    align-items: flex-start;
    padding: 12px 14px;
  }

  .topbar-pills {
    display: none;
  }

  .app-layout {
    height: auto;
    min-height: calc(100dvh - 68px);
    display: flex;
    flex-direction: column;
  }

  .workspace {
    order: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 12px;
  }

  .preview-shell {
    height: min(72dvh, 620px);
    min-height: 430px;
  }

  .right-panel {
    display: block;
    overflow: visible;
  }

  .right-panel section {
    border-right: 0;
  }

  .sidebar {
    order: 2;
    overflow: visible;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .hero {
    position: static;
  }

  section,
  details,
  .right-panel section,
  .hero {
    padding-left: 16px;
    padding-right: 16px;
  }

  .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .file-row {
    align-items: stretch;
  }

  .file-row button {
    flex: 0 0 auto;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 14px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    box-shadow: 3px 3px 0 #121a15;
  }

  h1 {
    font-size: 15px;
  }

  .workspace {
    padding: 10px;
    gap: 12px;
  }

  .preview-shell {
    height: 62dvh;
    min-height: 360px;
  }

  .view-tabs {
    top: 10px;
    right: 10px;
  }

  .preview-meta {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }

  .file-row {
    flex-direction: column;
  }

  .segmented {
    gap: 4px;
  }

  .segmented button {
    padding-left: 8px;
    padding-right: 8px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
