:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #627086;
  --line: #dce3ee;
  --blue: #2f7df6;
  --green: #18a999;
  --orange: #ec6b35;
  --yellow: #f5b700;
  --shadow: 0 12px 32px rgba(24, 33, 47, 0.08);
  --radius: 16px;
  --radius-sm: 12px;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

a {
  color: inherit;
}

.shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.15;
  font-weight: 800;
}

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

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.mode {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  text-transform: lowercase;
}

.create-stack {
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section {
  padding: 18px;
}

.section-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
}

.upload {
  display: grid;
  gap: 10px;
}

.upload-box {
  position: relative;
  min-height: 168px;
  display: grid;
  place-items: center;
  border: 1.5px dashed #b8c4d4;
  border-radius: var(--radius-sm);
  background: #f9fbfe;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}

.upload-box:hover {
  border-color: var(--blue);
  background: #f3f8ff;
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-copy {
  text-align: center;
  padding: 20px;
  pointer-events: none;
}

.upload-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: rgba(47, 125, 246, 0.1);
  color: var(--blue);
  display: grid;
  place-items: center;
}

.upload-copy strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}

.upload-copy span {
  color: var(--muted);
  font-size: 13px;
}

.preview {
  width: 100%;
  height: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #fff;
}

.avatar-options {
  display: grid;
  gap: 14px;
}

.avatar-option-row {
  display: grid;
  gap: 8px;
}

.avatar-option-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.option-segment-item {
  position: relative;
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.option-segment-item.active {
  border-color: var(--blue);
  background: rgba(47, 125, 246, 0.08);
  color: var(--blue);
}

.option-segment-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.avatar-option-toggle {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.avatar-option-toggle strong {
  font-size: 14px;
}

.toggle-switch {
  position: relative;
  width: 46px;
  height: 28px;
  display: inline-flex;
  align-items: center;
}

.toggle-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d6dfeb;
  transition: background 0.15s;
}

.toggle-switch span::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
  transition: transform 0.15s;
}

.toggle-switch input:checked + span {
  background: var(--blue);
}

.toggle-switch input:checked + span::after {
  transform: translateX(18px);
}

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

.template-category {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.template-category:first-child {
  margin-top: 0;
}

.template-category h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.template-card {
  position: relative;
  padding: 0;
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.template-card-body {
  padding: 10px 12px 12px;
}

.template-card-media {
  position: relative;
  aspect-ratio: 1;
  background: #eef2f7;
  overflow: hidden;
}

.template-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.template-card .preview-hint {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(24, 33, 47, 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  backdrop-filter: blur(6px);
}

.template-card:hover {
  border-color: #b8ccf7;
}

.template-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 125, 246, 0.14);
}

.template-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.template-card strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.template-card .tag {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-group {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.option-group:last-child {
  margin-bottom: 0;
}

.option-group > label {
  color: var(--muted);
  font-size: 13px;
}

.type-chip {
  min-height: 40px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}

.type-chip:hover {
  border-color: #b8ccf7;
}

.type-chip.active {
  border-color: var(--blue);
  background: rgba(47, 125, 246, 0.08);
  color: var(--blue);
  font-weight: 600;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.field input,
.field select {
  height: 46px;
}

.field textarea {
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: rgba(246, 248, 251, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 20;
}

.actionbar-inner {
  width: min(100%, 720px);
  margin: 0 auto;
}

.actionbar-secondary {
  width: 100%;
  min-height: 48px;
  margin-bottom: 12px;
  color: var(--blue);
  font-size: 16px;
  font-weight: 700;
}

.primary {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.secondary {
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
}

.secondary:hover {
  border-color: #b8ccf7;
}

.danger {
  color: #b42318;
}

.result-shell {
  padding-bottom: 108px;
  max-width: 480px;
}

.result-topbar {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-top: 4px;
}

.result-back {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(24, 33, 47, 0.06);
}

.result-topbar-center {
  text-align: center;
}

.result-topbar-center h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}

.result-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
}

.result-topbar-spacer {
  width: 40px;
}

.result-page {
  display: grid;
  gap: 12px;
}

.wait-experience {
  gap: 16px;
}

.wait-summary {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.wait-summary h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.wait-summary p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.wait-spinner {
  width: 28px;
  height: 28px;
  border-width: 3px;
  justify-self: center;
}

.wait-progress {
  display: grid;
  gap: 8px;
}

.wait-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.wait-progress-bar {
  display: block;
  height: 100%;
  min-width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 0.35s ease;
}

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

.wait-grid-cell {
  position: relative;
  min-height: 76px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #dbe5f3;
  border-radius: var(--radius-sm);
  background: #f8fbff;
}

.wait-grid-cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.72) 45%, transparent 72%);
  transform: translateX(-100%);
  animation: waitShimmer 1.8s infinite;
}

.wait-grid-cell > span {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dce8f7, #f2f6fb);
}

.wait-grid-cell small {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #516179;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.wait-quote-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #f1d899;
  border-radius: var(--radius-sm);
  background: #fff9e8;
}

.wait-quote-card span {
  color: #8a5b00;
  font-size: 12px;
  font-weight: 700;
}

.wait-quote-card strong {
  color: #332512;
  font-size: 16px;
  line-height: 1.55;
}

.wait-long-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #f8fbff;
  color: #334155;
  font-size: 13px;
  line-height: 1.5;
}

@keyframes waitShimmer {
  100% {
    transform: translateX(100%);
  }
}

.result-media {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: #fff;
}

.result-hero {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #fff;
}

.result-fail {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  text-align: center;
}

.result-code-card {
  display: grid;
  gap: 2px;
  padding: 14px 16px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(24, 33, 47, 0.05);
  text-align: center;
}

.result-code-label {
  color: var(--muted);
  font-size: 12px;
}

.result-code-value {
  color: var(--blue);
  font-size: clamp(36px, 9vw, 44px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.04em;
  margin: 2px 0;
}

.result-code-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.result-tag {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(47, 125, 246, 0.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 500;
}

.result-quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.result-quick-actions.single {
  grid-template-columns: 1fr;
}

.quick-action {
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(24, 33, 47, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.quick-action:active {
  transform: scale(0.98);
}

.quick-action svg {
  color: var(--muted);
}

.quick-action.primary-outline {
  border-color: var(--blue);
  color: var(--blue);
  background: rgba(47, 125, 246, 0.05);
  box-shadow: 0 0 0 1px rgba(47, 125, 246, 0.12);
}

.quick-action.primary-outline svg {
  color: var(--blue);
}

.result-actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 50;
  box-shadow: 0 -4px 20px rgba(24, 33, 47, 0.06);
}

.result-actionbar-inner {
  width: min(100%, 480px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-btn {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.result-btn.outline {
  border: 1.5px solid var(--blue);
  background: var(--panel);
  color: var(--blue);
}

.result-btn.solid {
  border: 1.5px solid var(--blue);
  background: var(--blue);
  color: #fff;
}

.result-btn.solid:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 33, 47, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  z-index: 200;
}

.sheet {
  width: min(100%, 480px);
  max-height: min(85vh, 640px);
  overflow: auto;
  background: var(--panel);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 40px rgba(24, 33, 47, 0.15);
  animation: slideUp 0.22s ease;
  padding: 8px 18px max(18px, env(safe-area-inset-bottom));
}

.sheet-handle {
  width: 36px;
  height: 4px;
  margin: 4px auto 12px;
  border-radius: 999px;
  background: #d0d8e4;
}

.sheet-head {
  margin-bottom: 16px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.sheet-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sheet-options {
  display: grid;
  gap: 10px;
}

.result-media.process-view {
  display: grid;
  gap: 10px;
  padding: 16px;
  place-items: center;
  background: #f9fbfe;
}

.process-caption {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.5;
}

.avatar-result-hint {
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.avatar-result-list {
  display: grid;
  gap: 18px;
}

.avatar-result-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(24, 33, 47, 0.08);
}

.avatar-result-image {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  background: #f2f5f9;
}

.avatar-result-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.process-back-link {
  justify-self: center;
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.badge-view .badge-frame {
  position: relative;
  width: min(72vw, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 5px solid #fff;
  box-shadow: 0 10px 28px rgba(24, 33, 47, 0.16), inset 0 0 0 1px rgba(24, 33, 47, 0.06);
}

.badge-crop {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pixel-view {
  overflow: hidden;
}

.pixel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.pixel-size-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.pixel-label-toggle {
  min-height: 36px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.pixel-label-toggle.active {
  border-color: var(--green);
  background: rgba(24, 169, 153, 0.1);
  color: #08745f;
}

.pixel-size-chip {
  min-height: 36px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.pixel-size-chip.active {
  border-color: var(--green);
  background: rgba(24, 169, 153, 0.1);
  color: #08745f;
}

.pixel-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.process-controls {
  display: flex;
  justify-content: center;
  width: 100%;
}

.watermark-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.watermark-checkbox {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: border-color 0.15s, background 0.15s;
}

.watermark-checkbox.checked {
  border-color: var(--blue);
  background: rgba(47, 125, 246, 0.12);
}

.watermark-checkbox-icon {
  width: 10px;
  height: 6px;
  border-left: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transform: rotate(-45deg) translateY(-1px);
  transition: border-color 0.15s;
}

.watermark-checkbox.checked .watermark-checkbox-icon {
  border-left-color: var(--blue);
  border-bottom-color: var(--blue);
}

.watermark-option-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.pixel-canvas-wrap {
  position: relative;
  width: 100%;
  overflow: visible;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
}

.pixel-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  background: #fff;
}

.brand-watermark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(24, 33, 47, 0.14);
  backdrop-filter: blur(6px);
}

.brand-watermark.corner {
  position: absolute;
  right: 10px;
  bottom: 10px;
}

.brand-watermark.center {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
}

.brand-watermark.top-left,
.brand-watermark.top-right,
.brand-watermark.bottom-left,
.brand-watermark.bottom-right,
.brand-watermark.bottom-center,
.brand-watermark.top-center,
.brand-watermark.left-center,
.brand-watermark.right-center {
  position: absolute;
  max-width: calc(100% - 24px);
}

.brand-watermark.top-left {
  top: 12px;
  left: 12px;
}

.brand-watermark.top-right {
  top: 12px;
  right: 12px;
}

.brand-watermark.bottom-left {
  bottom: 12px;
  left: 12px;
}

.brand-watermark.bottom-right {
  right: 12px;
  bottom: 12px;
}

.brand-watermark.bottom-center {
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
}

.brand-watermark.top-center {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
}

.brand-watermark.left-center {
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
}

.brand-watermark.right-center {
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
}

.brand-watermark-rainbow {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-watermark-text {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.logo-view {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.logo-view .result-hero {
  border-radius: 0;
}

.sheet-option-icon.logo-preview {
  background: #fff;
  padding: 4px;
}

.sheet-option-icon.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sheet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px 12px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
  overflow: hidden;
  transition: border-color 0.15s;
}

.sheet-option:hover {
  border-color: #b8ccf7;
}

.sheet-option.accent-orange {
  border-left: 4px solid var(--orange);
}

.sheet-option.accent-green {
  border-left: 4px solid var(--green);
}

.sheet-option.accent-blue {
  border-left: 4px solid var(--blue);
}

.sheet-option-icon {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  margin-left: 12px;
  border-radius: 50%;
  overflow: hidden;
  background: #eef2f7;
  display: grid;
  place-items: center;
}

.sheet-option-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sheet-option-icon.pixel-preview img {
  image-rendering: pixelated;
  transform: scale(1.6);
}

.sheet-option-icon.logo-preview {
  background: rgba(47, 125, 246, 0.12);
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.sheet-option-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.sheet-option-body strong {
  font-size: 15px;
  line-height: 1.3;
}

.sheet-option-body span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sheet-chevron {
  flex: 0 0 auto;
  color: var(--muted);
  margin-right: 4px;
}

.sheet-cancel {
  width: 100%;
  min-height: 46px;
  margin-top: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  background: #18212f;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

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

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #fff8e5;
  color: #694b00;
  border: 1px solid #ffe08a;
  font-size: 14px;
}

.notice.danger {
  background: #fef3f2;
  color: #b42318;
  border-color: #fecdca;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 33, 47, 0.45);
  display: grid;
  place-items: end center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop.centered {
  place-items: center;
}

.modal {
  width: min(100%, 480px);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(24, 33, 47, 0.2);
  animation: slideUp 0.22s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.modal-body {
  padding: 14px 18px 18px;
  display: grid;
  gap: 14px;
}

.preview-art {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #eef2f7;
}

.preview-art-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-art-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(24, 33, 47, 0.62);
  color: #fff;
  font-size: 12px;
  backdrop-filter: blur(6px);
}

.preview-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.prompt-preview,
.keyword-controls {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.prompt-preview {
  border-color: rgba(47, 125, 246, 0.24);
  background: #f8fbff;
}

.prompt-preview-head,
.keyword-controls-head {
  display: grid;
  gap: 2px;
}

.prompt-preview-head strong,
.keyword-controls-head strong {
  color: var(--ink);
  font-size: 15px;
}

.prompt-preview-head span,
.keyword-controls-head span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.prompt-lines {
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
}

.prompt-lines p {
  margin: 0;
}

.prompt-keyword {
  padding: 1px 5px;
  border-radius: 6px;
  color: #111827;
  font-weight: 700;
}

.prompt-keyword.kw-0,
.keyword-dot.kw-0 {
  background: #ffe3e3;
}

.prompt-keyword.kw-1,
.keyword-dot.kw-1 {
  background: #dcfce7;
}

.prompt-keyword.kw-2,
.keyword-dot.kw-2 {
  background: #dbeafe;
}

.prompt-keyword.kw-3,
.keyword-dot.kw-3 {
  background: #fef3c7;
}

.prompt-keyword.kw-4,
.keyword-dot.kw-4 {
  background: #ede9fe;
}

.prompt-keyword.kw-5,
.keyword-dot.kw-5 {
  background: #cffafe;
}

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

.keyword-control > span {
  display: grid;
  gap: 2px;
}

.keyword-control strong {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
}

.keyword-control em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.keyword-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.keyword-control-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 8px;
}

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

.modal-actions .primary,
.modal-actions .secondary {
  width: 100%;
}

.custom-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(47, 125, 246, 0.08);
  color: var(--blue);
  font-size: 12px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef2f7;
}

.status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #e7f8f3;
  color: #08745f;
  font-size: 12px;
}

.status.failed {
  background: #fee4e2;
  color: #b42318;
}

.admin-scroll {
  overflow-x: auto;
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.admin-pagination .row {
  gap: 8px;
}

.admin-avatar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 24px;
  overflow: auto;
  background: rgba(15, 23, 42, 0.38);
}

.admin-avatar-panel {
  width: min(100%, 920px);
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
}

.admin-avatar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.admin-avatar-head h3,
.admin-avatar-head p {
  margin: 0;
}

.admin-avatar-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.admin-avatar-controls {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(180px, 240px);
  gap: 14px;
  align-items: end;
}

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

.admin-avatar-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.admin-avatar-card img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border-radius: 6px;
  object-fit: cover;
  background: #eef2f7;
}

.admin-avatar-card strong {
  font-size: 13px;
}

.admin-avatar-card .row {
  gap: 8px;
}

.admin-avatar-card .secondary {
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.admin-tab {
  flex: 0 0 auto;
  padding: 10px 12px;
  background: transparent;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
}

.admin-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 700;
}

.cms-form {
  display: grid;
  gap: 18px;
}

.cms-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
}

.cms-section h3,
.cms-section h4 {
  margin: 0;
}

.cms-section h3 {
  font-size: 16px;
}

.cms-section h4 {
  font-size: 14px;
}

.cms-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cms-help {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(47, 125, 246, 0.18);
  border-radius: var(--radius-sm);
  background: #f8fbff;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
}

.cms-help strong,
.cms-help p {
  margin: 0;
}

.cms-help code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #eef4ff;
  color: #1f5fbf;
}

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

.cms-grid .field,
.cms-subcard .field {
  margin: 0;
}

.span-2 {
  grid-column: 1 / -1;
}

.checkbox-field {
  min-height: 42px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.checkbox-field input {
  width: auto;
}

.cms-list {
  display: grid;
  gap: 12px;
}

.cms-card,
.cms-subcard {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.cms-template-card {
  display: block;
}

.cms-template-summary {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.cms-template-summary::-webkit-details-marker {
  display: none;
}

.template-summary-preview {
  width: 56px;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f7;
  border: 1px solid var(--line);
}

.template-summary-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.template-summary-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.template-summary-main strong,
.template-summary-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-summary-main small {
  color: var(--muted);
  font-size: 12px;
}

.cms-template-status {
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(47, 125, 246, 0.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.cms-template-detail {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.cms-subcard {
  align-content: start;
}

.danger-soft {
  color: #b42318;
  background: #fff2f0;
}

.asset-upload {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 140px auto;
  gap: 10px;
  align-items: center;
}

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

.asset-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.asset-item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8fb;
}

.asset-item strong,
.asset-item span,
.asset-item code {
  display: block;
}

.asset-item span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.asset-item code {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.cms-savebar {
  position: sticky;
  bottom: 0;
  padding: 10px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 35%);
}

.debug-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.debug-list {
  display: grid;
  gap: 8px;
  max-height: 720px;
  overflow: auto;
}

.debug-list-item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.debug-list-item.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 125, 246, 0.12);
}

.debug-list-item strong,
.debug-list-item small {
  display: block;
}

.debug-list-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.debug-detail {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.debug-empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.debug-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.debug-head h3,
.debug-head p {
  margin: 0;
}

.debug-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.debug-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}

.debug-block summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

.debug-block pre {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  color: #243044;
  background: #f8fafc;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.wide {
  grid-column: 1 / -1;
}

@media (max-width: 720px) {
  .cms-grid,
  .asset-upload,
  .asset-item,
  .debug-layout,
  .admin-avatar-controls,
  .keyword-control-row {
    grid-template-columns: 1fr;
  }

  .admin-avatar-backdrop {
    padding: 12px;
  }

  .admin-avatar-grid {
    grid-template-columns: 1fr;
  }

  .asset-item img {
    width: 72px;
    height: 72px;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 640px) {
  .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .shell {
    width: min(100%, 960px);
    padding-top: 28px;
  }

  .create-stack {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .create-stack.single-flow {
    grid-template-columns: minmax(0, 640px);
    justify-content: center;
  }

  .create-stack .span-full {
    grid-column: 1 / -1;
  }

  .actionbar-inner {
    width: min(100%, 960px);
  }

  .result-actionbar-inner {
    width: min(100%, 960px);
  }

  .sheet-backdrop {
    place-items: center;
  }

  .sheet {
    border-radius: var(--radius);
    max-width: 480px;
  }

  .modal-backdrop {
    place-items: center;
  }
}
