:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #657084;
  --line: #d9e0ea;
  --blue: #1059a6;
  --blue-dark: #0d3f7a;
  --yellow: #f6c847;
  --orange: #f07a18;
  --shadow: 0 18px 54px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    system-ui,
    sans-serif;
  background:
    linear-gradient(135deg, rgba(246, 200, 71, 0.22), transparent 34%),
    linear-gradient(315deg, rgba(16, 89, 166, 0.14), transparent 36%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 24px;
  width: min(1320px, calc(100% - 36px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  align-items: center;
}

.editor-panel,
.preview-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 224, 234, 0.9);
  box-shadow: var(--shadow);
}

.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-radius: 8px;
}

.preview-panel {
  padding: 18px;
  border-radius: 8px;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

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

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.16;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: var(--blue);
  background: #edf4fb;
  font-size: 22px;
  transition:
    transform 0.16s ease,
    background 0.16s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: #e2eef9;
}

.field,
.range-field,
.hex-field,
.check-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field input[type="text"],
.field select {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfe;
  font-size: 18px;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--blue) 50%),
    linear-gradient(135deg, var(--blue) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 20px,
    calc(100% - 14px) 20px;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
}

.field input[type="text"]:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(16, 89, 166, 0.12);
}

.emoji-bank {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.emoji-bank button {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #f2f5f9;
  font-size: 22px;
  transition:
    transform 0.16s ease,
    background 0.16s ease;
}

.emoji-bank button:hover {
  transform: translateY(-1px);
  background: #fff0c4;
}

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

.template-button {
  min-height: 42px;
  border-radius: 8px;
  color: var(--blue-dark);
  background: #edf4fb;
  font-weight: 800;
  transition:
    color 0.16s ease,
    background 0.16s ease,
    transform 0.16s ease;
}

.template-button:hover {
  transform: translateY(-1px);
}

.template-button.is-active {
  color: #231a04;
  background: var(--yellow);
}

.range-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 14px;
}

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

.color-row {
  display: flex;
  gap: 14px;
  align-items: end;
  justify-content: flex-end;
}

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

.color-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.color-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.color-preview {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(23, 32, 51, 0.18);
  border-radius: 8px;
  background: var(--current-color, #0f58a8);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.hex-field {
  grid-template-columns: 42px 1fr;
  align-items: center;
}

.hex-field input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font-size: 16px;
  font-weight: 800;
  outline: none;
  font-family:
    "Cascadia Mono",
    Consolas,
    monospace;
}

.hex-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(16, 89, 166, 0.12);
}

.hex-field input.is-invalid {
  border-color: #d81b60;
  box-shadow: 0 0 0 4px rgba(216, 27, 96, 0.1);
}

.rgb-grid {
  display: grid;
  gap: 8px;
}

.rgb-grid label {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.swatch-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.swatch-row button {
  min-height: 34px;
  border: 1px solid rgba(23, 32, 51, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), transparent),
    var(--swatch);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.52);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

.swatch-row button:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.64),
    0 8px 16px rgba(23, 32, 51, 0.12);
}

.check-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  white-space: nowrap;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border-radius: 8px;
  color: white;
  background: var(--blue);
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(16, 89, 166, 0.22);
  transition:
    transform 0.16s ease,
    background 0.16s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: var(--blue-dark);
}

.canvas-frame {
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
  background: #111827;
}

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

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 18px 0;
  }

  .editor-panel {
    order: 2;
  }

  .preview-panel {
    order: 1;
    padding: 10px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 20px, 1320px);
  }

  .editor-panel {
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .emoji-bank {
    grid-template-columns: repeat(4, 1fr);
  }

  .range-grid,
  .template-row {
    grid-template-columns: 1fr;
  }
}
