:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1f2933;
  --muted: #687583;
  --line: #d9d3c8;
  --accent: #0f8f8c;
  --accent-dark: #096b69;
  --rose: #e15858;
  --blue: #315fbe;
  --shadow: 0 22px 70px rgba(31, 41, 51, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 143, 140, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(225, 88, 88, 0.1), transparent 38%),
    var(--bg);
}

.has-custom-cursor,
.has-custom-cursor * {
  cursor: var(--custom-cursor) !important;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 660px;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
}

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

.mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--accent), var(--blue)),
    var(--accent);
  clip-path: polygon(15% 6%, 82% 52%, 53% 61%, 68% 92%, 52% 99%, 37% 68%, 15% 89%);
}

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

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

h1 {
  font-size: 28px;
  line-height: 1.1;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--accent-dark);
  font-weight: 900;
  cursor: pointer;
}

.help-button {
  width: 28px;
  height: 28px;
  margin-top: 2px;
  font-size: 16px;
}

.icon-button {
  width: 34px;
  height: 34px;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

h2 {
  font-size: 22px;
  line-height: 1.18;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 176px;
  padding: 22px;
  border: 1px dashed #9ba7af;
  border-radius: 8px;
  background:
    linear-gradient(0deg, rgba(15, 143, 140, 0.07), rgba(15, 143, 140, 0.07)),
    var(--surface-strong);
  text-align: center;
  cursor: pointer;
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  font-size: 28px;
  line-height: 1;
}

.upload-title {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.upload-copy {
  display: block;
  max-width: 230px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.text-control {
  display: grid;
  gap: 8px;
}

.text-control span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.text-control input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

.control-head,
.ticks {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.control-head label,
.control-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

output {
  font-weight: 800;
}

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

.ticks {
  color: #8c969f;
  font-size: 12px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.control-grid label {
  display: grid;
  gap: 8px;
}

.control-grid input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eee9df;
}

.segment,
.ghost,
.primary {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.segment {
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segment.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 1px 6px rgba(31, 41, 51, 0.12);
}

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.toggle input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.primary {
  margin-top: auto;
  color: white;
  background: var(--accent);
  font-weight: 900;
}

.primary:disabled {
  cursor: not-allowed;
  background: #aeb8bd;
}

.canvas-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 22px;
  padding: 28px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ghost {
  padding: 0 16px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #ede8de 25%, transparent 25%),
    linear-gradient(-45deg, #ede8de 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ede8de 75%),
    linear-gradient(-45deg, transparent 75%, #ede8de 75%),
    #faf8f2;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
}

.grid-surface {
  position: relative;
  display: grid;
  place-items: center;
  width: min(430px, 78vw);
  aspect-ratio: 1;
}

canvas {
  width: min(256px, 62vw);
  height: min(256px, 62vw);
  image-rendering: pixelated;
}

.hotspot-dot {
  position: absolute;
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 0 2px rgba(31, 41, 51, 0.58);
  transform: translate(-50%, -50%);
}

.empty-state {
  position: absolute;
  left: 50%;
  bottom: 28px;
  width: min(420px, calc(100% - 36px));
  margin: 0;
  transform: translateX(-50%);
  color: var(--muted);
  text-align: center;
  font-weight: 700;
  line-height: 1.5;
}

.help-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid rgba(31, 41, 51, 0.14);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.help-dialog::backdrop {
  background: rgba(31, 41, 51, 0.38);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  font-size: 19px;
}

.help-dialog ol {
  margin: 0;
  padding: 22px 28px 24px 44px;
  color: var(--muted);
  line-height: 1.75;
}

.help-dialog li + li {
  margin-top: 8px;
}

@media (max-width: 880px) {
  .shell {
    width: min(100% - 20px, 680px);
    padding: 10px 0 24px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: 0;
  }

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

  .controls,
  .canvas-area {
    padding: 20px;
  }

  .preview-toolbar {
    align-items: flex-start;
  }

  .preview-stage {
    min-height: 330px;
  }

}

@media (max-width: 480px) {
  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 19px;
  }

  .control-grid,
  .segmented {
    grid-template-columns: 1fr;
  }

  .preview-toolbar {
    display: grid;
  }

  .ghost {
    width: 100%;
  }
}
