:root {
  color-scheme: light;
  --ink: #222b3d;
  --muted: #697386;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --mint: #5ed6b4;
  --sun: #ffd46b;
  --berry: #ee6f95;
  --sky: #67b9ff;
  --violet: #8d7bff;
  --line: #eadfce;
  --shadow: 0 22px 70px rgba(52, 58, 76, 0.18);
  --soft-shadow: 0 14px 34px rgba(52, 58, 76, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 16%, rgba(255, 212, 107, 0.42), transparent 25%),
    radial-gradient(circle at 88% 10%, rgba(103, 185, 255, 0.33), transparent 26%),
    radial-gradient(circle at 80% 86%, rgba(238, 111, 149, 0.22), transparent 26%),
    linear-gradient(135deg, #fff7e6 0%, #f6fbff 48%, #fff2f6 100%);
  color: var(--ink);
  font-family:
    ui-rounded, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui,
    sans-serif;
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  font-size: 22px;
  letter-spacing: 16px;
  color: rgba(34, 43, 61, 0.08);
  pointer-events: none;
}

body::before {
  content: "✦ ✿ ● ✦ ✿";
  top: 9vh;
  left: 5vw;
  transform: rotate(-12deg);
}

body::after {
  content: "★ ◌ ✦ ★ ◌";
  right: 3vw;
  bottom: 10vh;
  transform: rotate(10deg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 32px);
}

.workspace {
  display: grid;
  width: min(430px, 100%);
  align-items: center;
  justify-items: center;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.controls {
  position: relative;
  width: 100%;
  max-height: calc(100dvh - 32px);
  padding: clamp(18px, 4vw, 26px);
  display: flex;
  flex-direction: column;
  gap: clamp(13px, 2.4vh, 18px);
  overflow: hidden;
}

.controls::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(238, 111, 149, 0.25);
  border-radius: 8px;
  pointer-events: none;
}

.brand-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brand-mark {
  width: 54px;
  aspect-ratio: 1;
  border-radius: 18px;
  background: linear-gradient(140deg, var(--sun), var(--berry));
  display: grid;
  place-items: center;
  transform: rotate(-5deg);
  box-shadow: 0 12px 26px rgba(238, 111, 149, 0.24);
}

.brand-mark span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 38%, #fff 0 18%, transparent 19%),
    radial-gradient(circle at 64% 38%, #fff 0 18%, transparent 19%),
    linear-gradient(#fff, #fff);
  background-size: 100% 100%, 100% 100%, 54% 16%;
  background-position: center, center, center 70%;
  background-repeat: no-repeat;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 6vw, 31px);
  line-height: 1.18;
  letter-spacing: 0;
}

.brand-row p,
.dialog-head p {
  margin-top: 6px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.field span,
legend {
  color: #4e586b;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  padding: 0 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

input:focus,
select:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(103, 185, 255, 0.18);
}

input[type="range"] {
  accent-color: var(--berry);
  padding: 0;
}

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

.style-grid label {
  cursor: pointer;
}

.style-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.style-grid span {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: #4e586b;
  font-weight: 800;
}

.style-grid input:checked + span {
  border-color: #32b389;
  background: #e8fff7;
  color: #146b53;
  box-shadow: 0 8px 18px rgba(94, 214, 180, 0.18);
}

.actions,
.dialog-actions {
  display: grid;
  gap: 10px;
}

.button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: #eef3ff;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(52, 58, 76, 0.08);
}

.button.primary {
  background: linear-gradient(135deg, var(--mint), var(--sky));
  color: #123043;
}

.button.ghost {
  background: #fff0f6;
}

.button:hover {
  filter: brightness(1.02);
}

.button:active {
  transform: translateY(1px);
}

.render-canvas {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.result-dialog {
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.result-dialog::backdrop {
  background: rgba(31, 38, 54, 0.52);
  backdrop-filter: blur(8px);
}

.dialog-card {
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 212, 107, 0.34), transparent 28%),
    var(--panel-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.dialog-head h2 {
  margin-top: 4px;
  font-size: clamp(20px, 5vw, 24px);
  letter-spacing: 0;
}

.icon-button {
  width: 40px;
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: #f3f5fb;
  color: var(--ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.result-image-wrap {
  min-height: 0;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(238, 111, 149, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(103, 185, 255, 0.1) 1px, transparent 1px),
    #fff8ec;
  background-size: 22px 22px;
}

#resultImage {
  display: block;
  width: min(100%, 320px);
  max-height: min(52dvh, 520px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.save-tip {
  padding: 11px 12px;
  border-radius: 8px;
  background: #f7fbff;
  color: var(--muted);
  line-height: 1.65;
}

.dialog-actions {
  flex-shrink: 0;
}

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

  .workspace {
    width: min(100%, 390px);
  }

  .controls {
    padding: 18px;
    gap: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .result-dialog {
    width: min(100vw - 28px, 360px);
  }

  #resultImage {
    width: min(100%, 292px);
    max-height: 44dvh;
  }

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

@media (max-height: 760px) {
  .controls {
    gap: 8px;
    padding: 14px;
  }

  .brand-mark {
    width: 44px;
  }

  .brand-row p {
    display: none;
  }

  input,
  select,
  .button {
    min-height: 38px;
  }

  .style-grid span {
    min-height: 36px;
  }

  .field {
    gap: 5px;
  }
}
