:root {
  --bg: #eceff3;
  --bg-grad: #e3e7ee;
  --panel: #ffffff;
  --card: #f3f5f8;
  --card-hover: #e9edf3;
  --border: #d6dae2;
  --border-strong: #c2c8d2;

  --text: #1a1d24;
  --text-dim: #545b68;
  --text-faint: #868d9b;

  --gold: #e0a82e;
  --gold-deep: #c98a16;
  --gold-tint: #fbf2dc;
  --on-gold: #3a2700;

  --accent: #2b62d9;
  --danger: #d2553f;

  --radius: 12px;
  --shadow: 0 6px 22px rgba(40,50,70,.10);
  --shadow-sm: 0 2px 8px rgba(40,50,70,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-grad) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  font-size: 14px;
}

button,
input,
textarea,
select {
  max-width: 100%;
}

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  display: block;
  width: 132px;
  max-height: 29px;
  object-fit: contain;
}
.brand-text h1 { font-size: 17px; font-weight: 700; letter-spacing: 0; }
.brand-text p { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.topbar-actions {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
  min-width: 0;
}
.hint { font-size: 12.5px; color: var(--text-faint); }
.official-link {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 13px;
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe19a, var(--gold));
  color: var(--on-gold);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(201, 138, 22, .24);
  transition: .12s;
}
.official-link:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

/* ===== Account ===== */
.auth-box {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.cloud-status {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.cloud-status.online {
  border-color: #b8dcc7;
  background: #eef9f2;
  color: #1d7a42;
}
.cloud-status.local {
  border-color: #e0d4b3;
  background: #fff8e7;
  color: #9a6a10;
}
.auth-main,
.auth-small {
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 0 11px;
  cursor: pointer;
  transition: .12s;
  white-space: nowrap;
}
.auth-main:hover,
.auth-small:hover {
  border-color: var(--gold);
  color: var(--gold-deep);
  background: var(--gold-tint);
}
.auth-main.as-user {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 180px;
  overflow: hidden;
  padding-left: 5px;
  padding-right: 10px;
}
.account-avatar {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(184, 127, 10, .24);
  border-radius: 999px;
  background: linear-gradient(180deg, #fffaf0, #f1d98d);
  background-position: center;
  background-size: cover;
  color: var(--gold-deep);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}
.account-avatar.has-image {
  color: transparent;
}
.account-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-small {
  padding: 0 9px;
  font-size: 11.5px;
}
.profile-avatar-btn,
.profile-avatar-preview {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: linear-gradient(180deg, #fffaf0, #f1d98d);
  background-position: center;
  background-size: cover;
  color: var(--gold-deep);
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}
.profile-avatar-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 13px;
}
.profile-avatar-preview {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  font-size: 24px;
}
.profile-avatar-btn.has-image,
.profile-avatar-preview.has-image {
  color: transparent;
}
.profile-panel {
  width: min(500px, calc(100vw - 36px));
}
.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfd;
}
.profile-avatar-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.profile-avatar-row span {
  display: block;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
}
.support-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}
.support-text {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfd;
  padding: 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(17, 24, 39, .42);
  backdrop-filter: blur(6px);
}
.auth-modal.show { display: flex; }
.auth-panel {
  width: min(420px, calc(100vw - 36px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .28);
  overflow: hidden;
}
.auth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.auth-title { font-size: 17px; font-weight: 800; line-height: 1.2; }
.auth-subtitle { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.auth-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text-dim);
  font: 800 18px/1 inherit;
  cursor: pointer;
}
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 14px 16px 0;
}
.auth-tab {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text-dim);
  height: 34px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.auth-tab.active {
  background: var(--gold);
  border-color: var(--gold-deep);
  color: var(--on-gold);
}
.auth-form {
  display: grid;
  gap: 11px;
  padding: 14px 16px 16px;
}
.auth-form label {
  display: grid;
  gap: 5px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 800;
}
.auth-form input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224,168,46,.15);
}
.password-field {
  position: relative;
  display: block;
}
.auth-form .password-field input {
  padding-right: 42px;
}
.password-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.password-eye:hover,
.password-eye.is-visible {
  border-color: var(--border);
  background: var(--panel);
  color: var(--gold-deep);
}
.auth-submit {
  height: 38px;
  border: 1px solid var(--gold-deep);
  border-radius: 8px;
  background: linear-gradient(180deg, #f3cd6b, var(--gold));
  color: var(--on-gold);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.auth-submit:disabled { opacity: .62; cursor: wait; }
.auth-msg {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}
.pay-small {
  border-color: var(--gold-deep);
  background: var(--gold-tint);
  color: var(--gold-deep);
}

/* ===== Payment modal ===== */
.payment-modal {
  position: fixed;
  inset: 0;
  z-index: 105;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(17, 24, 39, .46);
  backdrop-filter: blur(7px);
}
.payment-modal.show { display: flex; }
.payment-panel {
  width: min(820px, calc(100vw - 36px));
  max-height: min(860px, calc(100vh - 36px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .32);
  overflow: hidden;
}
.payment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px 13px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.payment-title { font-size: 18px; font-weight: 900; line-height: 1.2; }
.payment-subtitle { margin-top: 2px; color: var(--text-faint); font-size: 12px; }
.payment-close {
  width: 31px;
  height: 31px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-dim);
  font: 900 18px/1 inherit;
  cursor: pointer;
}
.payment-content {
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 18px;
}
.payment-loading,
.payment-error,
.payment-empty {
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 24px 10px;
}
.payment-error { color: var(--danger); }
.payment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
}
.payment-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfd;
  padding: 12px;
}
.payment-section-title {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}
.payment-plan-list { display: grid; gap: 9px; }
.payment-plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  padding: 10px 11px;
  color: var(--text);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}
.payment-plan:hover,
.payment-plan.active {
  border-color: var(--gold-deep);
  background: var(--gold-tint);
}
.payment-plan strong {
  display: block;
  font-size: 14px;
  font-weight: 900;
}
.payment-plan em {
  display: block;
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}
.payment-plan b {
  color: var(--gold-deep);
  font-size: 18px;
  white-space: nowrap;
}
.payment-method-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.payment-method {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.payment-method.active {
  border-color: #111827;
  background: #111827;
  color: #fff;
}
.payment-qr-wrap {
  height: 246px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.payment-qr {
  width: 218px;
  height: 218px;
  object-fit: contain;
}
.payment-qr-empty {
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.7;
  text-align: center;
}
.payment-amount {
  margin-top: 10px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 800;
}
.payment-amount strong {
  color: var(--gold-deep);
  font-size: 24px;
}
.payment-hint {
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.55;
}
.payment-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  padding: 12px;
}
.payment-form-title {
  font-size: 13px;
  font-weight: 900;
}
.payment-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.payment-form label {
  display: grid;
  gap: 5px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 800;
}
.payment-form input,
.payment-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.payment-form textarea { resize: vertical; min-height: 70px; }
.payment-form input:focus,
.payment-form textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224,168,46,.15);
}
.payment-submit {
  height: 40px;
  border: 1px solid var(--gold-deep);
  border-radius: 9px;
  background: linear-gradient(180deg, #f3cd6b, var(--gold));
  color: var(--on-gold);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.payment-submit:disabled { opacity: .65; cursor: wait; }
.payment-msg {
  min-height: 18px;
  color: var(--gold-deep);
  font-size: 12px;
  font-weight: 800;
}
.payment-orders { margin-top: 14px; }
.payment-order-list { display: grid; gap: 8px; }
.payment-order {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  padding: 9px 10px;
}
.payment-order strong,
.payment-order span {
  display: block;
}
.payment-order strong { font-size: 13px; font-weight: 900; }
.payment-order span { color: var(--text-faint); font-size: 11.5px; }
.payment-order b { margin-right: 8px; color: var(--gold-deep); }
.payment-status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--text-dim);
  font-size: 11.5px;
  font-style: normal;
  font-weight: 900;
}
.payment-status.pending { background: #fff7df; color: #9a6a10; }
.payment-status.approved { background: #e7f7ef; color: #087445; }
.payment-status.rejected { background: #fdecec; color: #a12a22; }

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(430px, .42fr) minmax(720px, 1fr);
  gap: 14px;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 12px 14px 16px;
  align-items: stretch;
}

.builder {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
}

#dimensions {
  display: grid;
  grid-template-columns: repeat(var(--dimension-columns, 2), minmax(0, 1fr));
  grid-template-rows: repeat(var(--dimension-rows, 4), minmax(0, 1fr));
  grid-auto-flow: row;
  gap: 10px;
  min-height: 0;
  align-items: stretch;
}
#dimensions[data-columns="3"] {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
#dimensions[data-columns="3"] > .dimension {
  grid-column: span 2;
}
#dimensions[data-columns="3"][data-remainder="2"] > .dimension:nth-last-child(-n+2) {
  grid-column: span 3;
}
#dimensions[data-columns="3"][data-remainder="1"] > .dimension:last-child {
  grid-column: 3 / span 2;
}
#dimensions[data-columns="2"][data-remainder="1"] > .dimension:last-child {
  grid-column: 1 / -1;
}

/* ===== Basic expansion card ===== */
.expand-card {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  margin-top: 10px;
  box-shadow: var(--shadow-sm);
}
.expand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.expand-card .section-label {
  margin-bottom: 0;
  color: var(--text);
}
.usage-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  height: 19px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--gold-tint);
  color: var(--gold-deep);
  font-size: 10.5px;
  font-weight: 800;
}
.expand-card textarea,
.expand-card input,
.expand-card select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
}
.expand-card textarea {
  min-height: 76px;
  max-height: 150px;
  resize: vertical;
  padding: 8px 9px;
}
.expand-card input,
.expand-card select {
  height: 32px;
  padding: 0 9px;
}
.expand-card textarea::placeholder,
.expand-card input::placeholder {
  color: var(--text-faint);
}
.expand-card textarea:focus,
.expand-card input:focus,
.expand-card select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224,168,46,.15);
}
.expand-settings {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(0, 1.3fr);
  gap: 7px;
}
.expand-actions {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 7px;
}
.api-help {
  display: grid;
  gap: 3px;
  padding: 7px 9px;
  border: 1px dashed #e4d1a4;
  border-radius: 7px;
  background: #fffaf0;
  color: #745319;
  font-size: 11px;
  line-height: 1.45;
}
.api-help strong {
  color: var(--gold-deep);
  font-weight: 900;
}
.btn-secondary,
.btn-expand {
  height: 34px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: .15s;
}
.btn-secondary {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-dim);
}
.btn-secondary:hover {
  border-color: var(--border-strong);
  background: var(--card-hover);
}
.btn-expand {
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, #f3cd6b, var(--gold));
  color: var(--on-gold);
}
.btn-expand:hover { filter: brightness(1.05); }
.btn-expand:disabled {
  opacity: .62;
  cursor: wait;
}
.expand-msg {
  min-height: 17px;
  color: var(--gold-deep);
  font-size: 11.5px;
  font-weight: 700;
}
.section-label {
  font-size: 12.5px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 0; margin-bottom: 10px;
}

/* ===== Presets ===== */
.presets { margin-bottom: 20px; }
.section-label {
  font-size: 12.5px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 0; margin-bottom: 10px;
}
.preset-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.preset-chip {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 8px 14px; cursor: pointer;
  transition: .15s; text-align: left;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.preset-chip:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.preset-chip .pc-name { font-size: 13px; font-weight: 700; }
.preset-chip .pc-name .pc-icon { margin-right: 5px; }
.preset-chip .pc-desc { font-size: 10.5px; color: var(--text-faint); }
.preset-chip.active {
  background: var(--gold-tint);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold) inset, var(--shadow-sm);
}
.preset-chip.active::after {
  content: '✕ 取消';
  position: absolute; top: 6px; right: 9px;
  font-size: 9.5px; font-weight: 700; color: var(--gold-deep);
}

/* ===== Dimensions ===== */
.dimension {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.dim-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; cursor: default; user-select: none;
}
.dim-head:hover { background: #f8fafc; }
.dim-icon { font-size: 16px; }
.dim-titles { flex: 1; min-width: 0; }
.dim-titles .dt-cn { font-size: 13px; font-weight: 700; line-height: 1.25; }
.dim-titles .dim-tag { font-size: 11px; color: var(--gold-deep); font-weight: 700; }
.dim-titles .dt-cn .dt-en { font-size: 10px; color: var(--text-faint); font-weight: 500; margin-left: 6px; letter-spacing: 0; }
.dim-titles .dt-role {
  display: none;
}
.dim-badge {
  min-width: 19px; text-align: center;
  font-size: 10px; font-weight: 700;
  background: var(--gold); color: var(--on-gold);
  border-radius: 20px; padding: 0 6px;
  opacity: 0; transition: .2s;
}
.dim-badge.show { opacity: 1; }
.dim-arrow { color: var(--text-faint); font-size: 12px; transition: transform .2s; }
.dimension:not(.open) .dim-arrow { transform: rotate(-90deg); }

.dim-body { display: none; padding: 0 10px 9px; min-height: 0; overflow: hidden; }
.dimension.open .dim-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: 6px;
  justify-content: space-between;
}

.pill-wrap { display: flex; flex-wrap: wrap; gap: 5px; }
.dimension .pill-wrap {
  flex: 1 1 auto;
  min-height: 0;
  align-content: flex-start;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding-right: 2px;
}
.dimension .pill-wrap::-webkit-scrollbar {
  width: 6px;
}
.dimension .pill-wrap::-webkit-scrollbar-thumb {
  background: #c9ced7;
  border-radius: 999px;
}
.dimension .custom-input {
  flex: 0 0 auto;
}
.pill {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 9px;
  font-size: 12px; color: var(--text);
  cursor: pointer; font-family: inherit;
  transition: .12s; line-height: 1.2;
}
.pill:hover { background: var(--card-hover); border-color: var(--border-strong); }
.pill.selected {
  background: linear-gradient(180deg, #f3cd6b, var(--gold));
  border-color: var(--gold-deep);
  color: var(--on-gold); font-weight: 600;
  box-shadow: 0 1px 4px rgba(201,138,22,.3);
}
.pill .p-cn::before { content: ''; }
.pill.selected .p-cn::before { content: '✓ '; font-weight: 700; }

/* 每个板块的自定义填写框 */
.custom-input {
  width: 100%;
  margin-top: 6px;
  background: #fff;
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
  color: var(--text);
  padding: 6px 9px;
  font-size: 11.5px; font-family: inherit;
}
.custom-input::placeholder { color: var(--text-faint); }
.custom-input:focus {
  outline: none; border-style: solid; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224,168,46,.15);
}

/* ===== 图像比例 ===== */
.ratio-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  margin-top: 0;
  box-shadow: var(--shadow-sm);
}
.ratio-card .section-label { margin-bottom: 7px; }
.pill .r-label { color: var(--text-faint); font-size: 11px; font-weight: 500; }
.pill.selected .r-label { color: var(--on-gold); }

/* ===== 选项悬停浮层 ===== */
.opt-tip {
  position: fixed; z-index: 120;
  width: 280px;
  background: #1d2330;
  color: #eef1f6;
  border: 1px solid #2c3445;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px; line-height: 1.55;
  box-shadow: 0 10px 30px rgba(20,28,45,.28);
  pointer-events: none;
  opacity: 0; transform: translateY(-3px);
  transition: opacity .12s, transform .12s;
}
.opt-tip.show { opacity: 1; transform: translateY(0); }
.opt-tip .tt-img {
  display: block; width: 100%; height: 156px;
  object-fit: cover; border-radius: 7px;
  margin-bottom: 9px; background: #11151f;
}
.opt-tip .tt-en {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11.5px; color: #ffd47a;
  margin-bottom: 7px; padding-bottom: 6px;
  border-bottom: 1px solid #2c3445; word-break: break-word;
}
.opt-tip .tt-row { margin-top: 5px; }
.opt-tip .tt-k {
  display: inline-block; min-width: 56px;
  font-weight: 700; color: #8fa6d6; margin-right: 6px;
}

/* ===== Preview（左侧固定编辑区） ===== */
.preview { min-width: 0; min-height: 0; }
.preview-inner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.lang-toggle {
  display: inline-flex; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 2px;
}
.lang-btn {
  background: transparent; border: none; color: var(--text-dim);
  padding: 4px 12px; font-size: 12px; cursor: pointer; border-radius: 6px;
  transition: .15s; font-family: inherit; font-weight: 600;
}
.lang-btn.active { background: var(--gold); color: var(--on-gold); }
.btn-clear {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 7px; padding: 4px 11px;
  font-size: 12px; cursor: pointer; transition: .15s; font-family: inherit; font-weight: 600;
}
.btn-clear:hover { border-color: var(--danger); color: var(--danger); background: #fdf1ef; }

.prompt-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  flex: 1 1 0;
  height: auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.prompt-box::-webkit-scrollbar {
  width: 8px;
}
.prompt-box::-webkit-scrollbar-thumb {
  background: #c6ccd6;
  border-radius: 999px;
  border: 2px solid #f8fafc;
}
.prompt-box::-webkit-scrollbar-track {
  background: transparent;
}
.prompt-output {
  font-size: 13px; line-height: 1.75; word-break: break-word; color: var(--text);
}
.prompt-output .placeholder { color: var(--text-faint); font-size: 13px; }
.prompt-output .ph { color: var(--gold-deep); font-weight: 700; }   /* 【表头】高亮 */
.prompt-seg { display: inline; }
.prompt-sep,
.prompt-dot { color: var(--text-dim); }
.inline-edit {
  display: inline-block;
  min-width: 58px;
  padding: 1px 4px;
  border-radius: 5px;
  border-bottom: 1px dashed rgba(201, 138, 22, .8);
  background: rgba(251, 242, 220, .55);
  color: var(--text);
  outline: none;
}
.inline-edit:focus {
  background: #fff8e7;
  box-shadow: 0 0 0 2px rgba(224, 168, 46, .18);
}
.inline-edit.empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
}

.preview-actions { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.btn-copy {
  flex: 1;
  background: linear-gradient(180deg, #f3cd6b, var(--gold));
  color: var(--on-gold); border: 1px solid var(--gold-deep); border-radius: 8px;
  padding: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: .15s;
}
.btn-copy:hover { filter: brightness(1.05); }
.btn-copy:active { transform: scale(.98); }
.copy-tip { font-size: 12px; color: var(--gold-deep); font-weight: 600; opacity: 0; transition: .2s; white-space: nowrap; }
.copy-tip.show { opacity: 1; }

.selected-summary {
  margin-top: 10px; border-top: 1px solid var(--border); padding-top: 9px;
  flex-shrink: 0; max-height: 118px; overflow-y: auto;
}
.count {
  background: var(--gold-tint); color: var(--gold-deep);
  border-radius: 20px; padding: 1px 9px; font-size: 11px; margin-left: 4px; font-weight: 700;
}
.selected-list { display: flex; flex-wrap: wrap; gap: 6px; }
.selected-list .empty-note { font-size: 12px; color: var(--text-faint); }
.sel-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 5px 3px 9px; font-size: 11px; color: var(--text);
}
.sel-tag .st-x {
  cursor: pointer; color: var(--text-faint);
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.sel-tag .st-x:hover { background: var(--danger); color: #fff; }

/* ===== Config panel ===== */
.config-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  background: linear-gradient(180deg, #f3cd6b, var(--gold));
  color: var(--on-gold);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(72, 84, 106, .22);
}
.config-fab:hover { filter: brightness(1.04); }
.config-fab:active { transform: translateY(1px); }
.cfg-gear { font-size: 15px; line-height: 1; }

.config-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(17, 24, 39, .42);
  backdrop-filter: blur(6px);
}
.config-modal.show { display: flex; }
.config-panel {
  width: min(1600px, calc(100vw - 28px));
  height: min(940px, calc(100vh - 28px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .28);
  overflow: hidden;
}
.config-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  flex-shrink: 0;
}
.config-title { font-size: 17px; font-weight: 800; line-height: 1.2; }
.config-subtitle { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.config-profile-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.config-profile-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 800;
}
.config-profile-bar select {
  width: 180px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  padding: 0 9px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
}
.config-head-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.cfg-btn,
.cfg-icon-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  border-radius: 7px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: .12s;
}
.cfg-btn:hover,
.cfg-icon-btn:hover { border-color: var(--border-strong); background: var(--card); color: var(--text); }
.cfg-btn.disabled {
  opacity: .48;
  cursor: pointer;
}
.cfg-btn.mini {
  height: 30px;
  padding: 0 8px;
  font-size: 11.5px;
}
.cfg-btn.primary {
  background: var(--gold);
  border-color: var(--gold-deep);
  color: var(--on-gold);
}
.cfg-btn.danger,
.cfg-icon-btn.danger { color: var(--danger); }
.cfg-btn.danger:hover,
.cfg-icon-btn.danger:hover {
  background: #fdf1ef;
  border-color: #efb1a5;
}
.cfg-btn.full { width: 100%; margin-top: 10px; }
.cfg-icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.cfg-btn[data-help],
.cfg-icon-btn[data-help],
.cfg-dim-item[data-help],
.config-fab[data-help] {
  position: relative;
}
.cfg-btn[data-help]::after,
.cfg-icon-btn[data-help]::after,
.cfg-dim-item[data-help]::after,
.config-fab[data-help]::after {
  content: attr(data-help);
  position: absolute;
  z-index: 220;
  width: max-content;
  max-width: 260px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #1d2330;
  color: #f8fafc;
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .24);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s, transform .12s;
  white-space: normal;
}
.cfg-btn[data-help]:hover::after,
.cfg-icon-btn[data-help]:hover::after,
.cfg-dim-item[data-help]:hover::after,
.config-fab[data-help]:hover::after {
  opacity: 1;
}
.config-head-actions [data-help]::after {
  top: calc(100% + 8px);
  right: 0;
  transform: translateY(-3px);
}
.config-head-actions [data-help]:hover::after {
  transform: translateY(0);
}
.config-sidebar [data-help]::after,
.cfg-option-tools [data-help]::after {
  top: 50%;
  right: calc(100% + 8px);
  transform: translate(3px, -50%);
}
.config-sidebar [data-help]:hover::after,
.cfg-option-tools [data-help]:hover::after {
  transform: translate(0, -50%);
}
.config-fab[data-help]::after {
  right: 0;
  bottom: calc(100% + 8px);
  transform: translateY(3px);
}
.config-fab[data-help]:hover::after {
  transform: translateY(0);
}

.config-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}
.config-sidebar {
  min-height: 0;
  padding: 14px;
  background: #f3f5f8;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.config-dim-list { display: flex; flex-direction: column; gap: 7px; }
.cfg-dim-item {
  width: 100%;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 9px;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}
.cfg-dim-item strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12.5px;
}
.cfg-dim-item em {
  min-width: 22px;
  text-align: center;
  color: var(--gold-deep);
  background: var(--gold-tint);
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}
.cfg-dim-item.active {
  border-color: var(--gold);
  background: var(--gold-tint);
  box-shadow: 0 0 0 1px rgba(224, 168, 46, .35) inset;
}
.config-editor {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.config-grid label,
.cfg-option-fields input,
.cfg-option-fields textarea {
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 700;
}
.config-grid label.wide { grid-column: 1 / -1; }
.config-grid input,
.config-grid textarea,
.cfg-option-fields input,
.cfg-option-fields textarea {
  width: 100%;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--text);
  padding: 7px 9px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  resize: vertical;
}
.config-grid input:focus,
.config-grid textarea:focus,
.cfg-option-fields input:focus,
.cfg-option-fields textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224,168,46,.15);
}
.config-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}
.config-section-head > div { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.config-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cfg-option {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  padding: 10px;
  box-shadow: var(--shadow-sm);
}
.cfg-thumb-drop {
  position: relative;
  width: 128px;
  height: 128px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #eef1f5;
  overflow: hidden;
  cursor: pointer;
  transition: .14s;
}
.cfg-thumb-drop:hover,
.cfg-thumb-drop.drag {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224,168,46,.15);
}
.cfg-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cfg-thumb-plus {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  background: repeating-linear-gradient(45deg, #fbfcfd, #fbfcfd 10px, #f0f3f7 10px, #f0f3f7 20px);
  color: var(--text-faint);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}
.cfg-thumb-plus small {
  font-size: 11px;
  font-weight: 800;
}
.cfg-thumb-drop.empty .cfg-thumb {
  opacity: 0;
}
.cfg-thumb-drop.empty .cfg-thumb-plus {
  display: flex;
}
.cfg-option-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  min-width: 0;
}
.cfg-option-fields [data-field="image"],
.cfg-option-fields textarea { grid-column: 1 / -1; }
.cfg-option-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.cfg-option-tools .cfg-btn.upload {
  writing-mode: vertical-rl;
  min-height: 48px;
  padding: 6px 4px;
  text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
  .topbar {
    position: static;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
  }
  .topbar-actions {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    justify-content: flex-end;
    padding-bottom: 2px;
  }
  .auth-box {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .layout {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }
  .builder {
    display: block;
  }
  #dimensions {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .dimension {
    min-height: auto;
  }
  .dimension.open .dim-body {
    min-height: auto;
  }
  .preview { position: static; }
  .preview-inner { height: auto; max-height: none; }
  .prompt-box {
    flex: none;
    min-height: 220px;
    max-height: 380px;
  }
  .ratio-card { margin-top: 10px; }
  .config-modal { align-items: stretch; padding: 10px; }
  .config-panel { height: calc(100vh - 20px); }
  .config-body { grid-template-columns: 1fr; }
  .config-sidebar { max-height: 150px; border-right: none; border-bottom: 1px solid var(--border); }
  .config-dim-list { flex-direction: row; overflow-x: auto; }
  .cfg-dim-item { min-width: 170px; }
  .config-options { grid-template-columns: 1fr; }
}

@media (max-width: 1500px) {
  .config-options { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  body {
    font-size: 13px;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .brand {
    gap: 9px;
  }
  .brand-logo {
    width: 112px;
    max-height: 26px;
  }
  .brand-text h1 { font-size: 15px; }
  .brand-text p { font-size: 11px; }
  .hint { display: none; }
  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 6px;
  }
  .auth-box {
    gap: 6px;
    flex-wrap: wrap;
    overflow-x: visible;
  }
  .auth-main.as-user { max-width: 100%; }
  .official-link {
    min-height: 28px;
    height: auto;
    padding: 0 10px;
    font-size: 11px;
    white-space: normal;
    text-align: center;
  }
  .cloud-status,
  .auth-main,
  .auth-small {
    height: 27px;
    font-size: 11px;
  }
  .payment-modal {
    padding: 0;
  }
  .payment-panel {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }
  .payment-content {
    padding: 12px;
  }
  .payment-grid,
  .payment-form-grid {
    grid-template-columns: 1fr;
  }
  .payment-qr-wrap {
    height: 232px;
  }
  .payment-qr {
    width: 204px;
    height: 204px;
  }
  .payment-order {
    align-items: flex-start;
    flex-direction: column;
  }
  .preview-inner {
    padding: 9px;
  }
  .prompt-box {
    min-height: 230px;
    max-height: none;
  }
  .prompt-output {
    font-size: 12.5px;
    line-height: 1.72;
  }
  .preview-actions {
    gap: 7px;
  }
  .btn-copy {
    padding: 8px 6px;
    font-size: 12px;
  }
  .expand-settings,
  .expand-actions {
    grid-template-columns: 1fr;
  }
  .expand-card textarea {
    min-height: 86px;
  }
  .dim-head {
    padding: 8px 9px;
  }
  .dim-titles .dt-cn {
    font-size: 12.5px;
  }
  .pill {
    font-size: 11.5px;
    padding: 5px 8px;
  }
  .custom-input {
    font-size: 11.5px;
  }
  .ratio-card {
    padding: 9px;
  }
  .config-fab {
    right: 12px;
    bottom: 12px;
    height: 36px;
    padding: 0 12px;
  }
  .config-modal {
    padding: 0;
  }
  .config-panel {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .config-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
    padding: 11px 12px;
  }
  .config-head-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }
  .config-profile-bar {
    width: 100%;
  }
  .config-profile-bar label,
  .config-profile-bar select {
    width: 100%;
  }
  .config-sidebar {
    padding: 9px;
    max-height: 118px;
  }
  .cfg-dim-item {
    min-width: 142px;
    padding: 7px 8px;
  }
  .config-editor {
    padding: 11px;
  }
  .config-section-head {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  .config-section-head > div {
    justify-content: flex-start;
  }
  .config-grid { grid-template-columns: 1fr; }
  .cfg-option {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }
  .cfg-thumb-drop { width: 84px; height: 84px; }
  .cfg-option-fields {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .cfg-option-tools {
    grid-column: 1 / -1;
    flex-direction: row;
  }
  .cfg-option-tools .cfg-btn.upload {
    writing-mode: horizontal-tb;
    min-height: 30px;
  }
  .cfg-btn[data-help]::after,
  .cfg-icon-btn[data-help]::after,
  .cfg-dim-item[data-help]::after,
  .config-fab[data-help]::after {
    display: none;
  }
}

@media (max-width: 420px) {
  .layout {
    padding: 7px;
  }
  .brand-logo {
    width: 104px;
  }
  .brand-text h1 {
    font-size: 14px;
  }
  .brand-text p {
    display: none;
  }
  .topbar-actions,
  .auth-box {
    width: 100%;
  }
  .official-link,
  .cloud-status,
  .auth-main,
  .auth-small {
    flex: 1 1 auto;
    justify-content: center;
  }
  .prompt-box {
    min-height: 210px;
  }
  .preview-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .copy-tip {
    min-height: 16px;
    white-space: normal;
  }
  .pill-wrap {
    gap: 4px;
  }
  .pill {
    padding: 5px 7px;
    font-size: 11px;
  }
  .cfg-option {
    grid-template-columns: 1fr;
  }
  .cfg-thumb-drop {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
  }
  .cfg-option-tools {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== Runtime preset/editing controls ===== */
.box-label {
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 900;
}
.prompt-box {
  position: relative;
  padding-top: 28px;
  flex: 0 0 150px;
  min-height: 120px;
  max-height: 180px;
}
.prompt-box > .box-label {
  position: absolute;
  top: 9px;
  left: 12px;
}
.input-box {
  position: relative;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 11px;
  margin-bottom: 9px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1 1 0;
  min-height: 240px;
}
.input-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.prompt-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.tool-btn {
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text-dim);
  padding: 0 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.tool-btn:hover {
  border-color: var(--gold);
  color: var(--gold-deep);
  background: var(--gold-tint);
}
.tool-btn.active {
  border-color: var(--gold-deep);
  background: var(--gold);
  color: var(--on-gold);
}
.input-note {
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.35;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 7px;
  padding: 6px 8px;
}
.prompt-input {
  font-size: 13px;
  line-height: 2;
  color: var(--text);
  word-break: break-word;
}
.structured-editor {
  display: block;
  white-space: normal;
}
.prompt-clause {
  display: inline;
}
.prompt-lead,
.prompt-separator {
  color: var(--text);
}
.prompt-value {
  display: inline;
  min-height: 22px;
  padding: 0 4px 1px;
  color: var(--text);
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  vertical-align: baseline;
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-color: rgba(201, 138, 22, .95);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}
.prompt-value:focus {
  background: #fff8e7;
  box-shadow: 0 0 0 2px rgba(224, 168, 46, .16);
  border-radius: 5px 5px 0 0;
}
.prompt-value.empty::before {
  content: '点击填写';
  color: var(--text-faint);
  font-size: 12px;
}
.free-editor {
  min-height: 72px;
  outline: none;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.free-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
}
.generated-output {
  white-space: pre-wrap;
  word-break: break-word;
}
.dimension {
  transition: opacity .15s, filter .15s, background .15s;
}
.dimension.dim-disabled {
  opacity: .48;
  filter: grayscale(.2);
  background: #f7f8fa;
}
.dimension.dim-disabled .pill-wrap,
.dimension.dim-disabled .custom-input {
  pointer-events: none;
}
.dim-zoom-btn {
  width: 25px;
  height: 25px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  flex: 0 0 auto;
}
.dim-zoom-btn:hover {
  border-color: var(--gold);
  color: var(--gold-deep);
  background: var(--gold-tint);
}
.dim-switch {
  width: 38px;
  height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px;
  background: #e7ebf1;
  cursor: pointer;
  flex: 0 0 auto;
  transition: .15s;
}
.dim-switch span {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.16);
  transition: transform .15s;
}
.dim-switch.on {
  border-color: var(--gold-deep);
  background: var(--gold);
}
.dim-switch.on span {
  transform: translateX(16px);
}
.mini-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, .38);
  backdrop-filter: blur(5px);
}
.mini-modal.show { display: flex; }
.mini-panel {
  width: min(620px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .28);
  overflow: hidden;
}
.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.mini-title { font-size: 16px; font-weight: 900; line-height: 1.2; }
.mini-subtitle { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.mini-close {
  width: 31px;
  height: 31px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text-dim);
  font: 900 18px/1 inherit;
  cursor: pointer;
}
.order-list,
.dim-zoom-body {
  overflow-y: auto;
  padding: 12px;
}
.order-list {
  display: grid;
  gap: 7px;
}
.order-item {
  display: grid;
  grid-template-columns: 22px 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
  cursor: grab;
}
.order-item.off { opacity: .55; }
.order-item.dragging { opacity: .36; }
.order-item.drag-over {
  border-color: var(--gold);
  background: var(--gold-tint);
}
.drag-handle {
  color: var(--text-faint);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}
.order-item strong {
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-item em {
  color: var(--text-faint);
  font-size: 11px;
  font-style: normal;
}
.dim-zoom-panel {
  width: min(920px, calc(100vw - 32px));
}
.zoom-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.zoom-add-btn {
  height: 32px;
  border: 1px solid var(--gold-deep);
  border-radius: 8px;
  background: linear-gradient(180deg, #f3cd6b, var(--gold));
  color: var(--on-gold);
  padding: 0 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.zoom-pill-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.zoom-param {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}
.zoom-pill {
  font-size: 13px;
  padding: 7px 11px;
}
.zoom-delete-btn {
  width: 25px;
  height: 25px;
  border: 1px solid #e0bbb5;
  border-radius: 999px;
  background: #fff7f5;
  color: var(--danger);
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.zoom-delete-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.zoom-empty {
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--text-faint);
  text-align: center;
  background: #fbfcfd;
}
.config-profile-bar {
  flex-wrap: wrap;
}
.config-profile-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}
.config-profile-bar select {
  min-width: 190px;
}
.config-profile-bar .cfg-btn {
  min-width: 74px;
}
.tool-btn[data-help],
.zoom-delete-btn[data-help] {
  position: relative;
}
.tool-btn[data-help]::after,
.zoom-delete-btn[data-help]::after {
  content: attr(data-help);
  position: absolute;
  z-index: 220;
  width: max-content;
  max-width: 260px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #1d2330;
  color: #f8fafc;
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .24);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s, transform .12s;
  white-space: normal;
}
.tool-btn[data-help]:hover::after,
.zoom-delete-btn[data-help]:hover::after {
  opacity: 1;
}
.prompt-tools [data-help]::after {
  top: calc(100% + 8px);
  right: 0;
  transform: translateY(-3px);
}
.prompt-tools [data-help]:hover::after {
  transform: translateY(0);
}

@media (max-width: 760px) {
  .input-topline {
    align-items: flex-start;
    flex-direction: column;
  }
  .prompt-tools {
    width: 100%;
    justify-content: flex-start;
  }
  .tool-btn {
    flex: 1 1 auto;
  }
  .input-box {
    flex: none;
    min-height: 300px;
  }
  .prompt-box {
    flex: none;
    min-height: 130px;
    max-height: 220px;
  }
  .mini-modal {
    align-items: stretch;
  }
  .mini-panel {
    width: 100%;
    max-height: calc(100vh - 20px);
  }
  .dim-switch {
    width: 34px;
  }
  .dim-switch.on span {
    transform: translateX(12px);
  }
}
