/* 蓝标Pro 表单页样式：只依赖系统字体与内联图形 */
:root {
  --green: #0f6b4f;
  --blue: #1a56db;
  --blue-dark: #1749c0;
  --bg: #eef2f7;
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --card: #ffffff;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-line: #fecaca;
  --ok: #15803d;
  --ok-bg: #ecfdf5;
  --radius: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: var(--blue);
}

/* ---------- 可访问性 ---------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff;
  color: var(--blue);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.2);
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

main:focus {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 顶部品牌条 ---------- */
.topbar {
  background: var(--green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 10px rgba(15, 107, 79, 0.18);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.brand-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.4;
}

.secure {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
}

/* ---------- 页面骨架 ---------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 20px 56px;
}

.layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 28px;
}

.col-form {
  flex: 1 1 720px;
  min-width: 0;
  max-width: 720px;
}

.col-preview {
  flex: 0 0 375px;
  width: 375px;
  max-width: 100%;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04),
    0 10px 28px -18px rgba(15, 23, 42, 0.18);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.step-dot {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(26, 86, 219, 0.28);
}

.card-sub {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- 表单控件 ---------- */
.field {
  margin-top: 16px;
}

.field > label,
.field > .field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

input[type="text"],
input[type="tel"],
input[type="url"],
input[type="password"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input[type="text"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

input.input-invalid,
textarea.input-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
}

input[readonly],
textarea[readonly] {
  background: #f8fafc;
  color: var(--text);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.field-error {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.5;
}

/* 验证码：单输入框、等宽数字、居中 */
.code-input {
  letter-spacing: 0.42em;
  text-align: center;
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding-left: calc(12px + 0.42em);
}

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  padding: 12px 18px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease, transform 0.06s ease;
}

.btn-primary {
  width: 100%;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  padding: 13px 16px;
  box-shadow: 0 8px 18px -10px rgba(26, 86, 219, 0.75);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-secondary {
  background: #f8fafc;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover:not(:disabled) {
  background: #f1f5f9;
}

.btn-link {
  background: none;
  color: var(--blue);
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
}

.btn-link:hover:not(:disabled) {
  text-decoration: underline;
}

.btn:disabled {
  background: #e2e8f0;
  color: #64748b;
  border-color: #e2e8f0;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.btn-primary:focus-visible {
  outline-color: #93c5fd;
}

.row-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.row-actions .btn {
  flex: 1 1 0;
}

#resetPhoneBtn {
  margin-top: 10px;
}

/* ---------- 状态块 ---------- */
.state-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.state-box.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--muted);
}

.state-box.warn {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
}

.state-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.state-text {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.6;
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.state-actions .btn {
  width: auto;
  flex: 0 0 auto;
}

.spinner {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}

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

.inline-note {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------- 号码回显 ---------- */
.phone-locked {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.phone-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 2px;
}

.phone-value {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

/* ---------- 已验证条 ---------- */
.verified-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--ok-bg);
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 13px;
  font-weight: 500;
}

.verified-phone {
  font-variant-numeric: tabular-nums;
  color: #047857;
  font-weight: 600;
}

/* ---------- 模板动态表单 ---------- */
.template-form {
  margin-top: 4px;
}

.form-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #f1f5f9;
}

.form-block:first-child {
  margin-top: 12px;
  padding-top: 0;
  border-top: 0;
}

.block-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.readonly-block {
  margin-top: 8px;
  padding: 11px 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.readonly-key {
  color: var(--muted);
  font-size: 12.5px;
}

.template-source {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.template-source > summary {
  cursor: pointer;
  color: var(--blue);
  width: fit-content;
  padding: 2px 0;
}

.template-source .readonly-block {
  margin-top: 6px;
}

.button-row {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfdff;
}

.button-row:first-of-type {
  margin-top: 10px;
}

.button-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.button-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.tag-dynamic {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.tag-ab {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.button-row .field {
  margin-top: 10px;
}

.url-prefix {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.static-url {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-size: 12.5px;
  color: var(--text);
}

.static-url-link {
  color: var(--blue);
  word-break: break-all;
}

/* 上传 */
.upload-status {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 1px;
}

.upload-status.ok {
  color: var(--ok);
  font-weight: 500;
}

.upload-status.error {
  color: var(--danger);
}

.upload-status.loading {
  color: var(--blue);
}

input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text);
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: #f1f5f9;
}

input[type="file"]:disabled {
  opacity: 0.6;
}

.upload-thumb {
  display: block;
  margin-top: 10px;
  width: 100%;
  max-width: 280px;
  max-height: 160px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f1f5f9;
}

/* ---------- 收件人 ---------- */
.meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
  color: #475569;
}

.warn-text {
  color: #b45309;
  font-weight: 600;
}

.error-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
}

.error-list:empty {
  display: none;
}

.error-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.45;
}

.line-badge {
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: 6px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#recipients {
  min-height: 164px;
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
}

.submit-area {
  margin-top: 18px;
}

.submit-area .field-error {
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
}

.submit-area .btn-primary {
  margin-top: 2px;
}

#submitHint {
  text-align: center;
}

.result-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--ok-bg);
  border: 1px solid #6ee7b7;
}

.result-title {
  font-size: 14px;
  font-weight: 600;
  color: #065f46;
  margin-bottom: 4px;
}

.result-text {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #065f46;
  line-height: 1.6;
}

/* ---------- 右侧预览 ---------- */
.preview-shell {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-label {
  padding-left: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.phone {
  width: 375px;
  max-width: 100%;
  height: 812px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid #d8dee7;
  background: #efeae2;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08),
    0 28px 60px -32px rgba(15, 23, 42, 0.45);
}

.wa-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--green);
  color: #fff;
}

.wa-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e8f0ec;
  color: var(--green);
  font-size: 15px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.wa-meta {
  min-width: 0;
}

.wa-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
}

.wa-check {
  display: inline-flex;
  flex: 0 0 auto;
}

.wa-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.74);
  line-height: 1.4;
}

.wa-chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px 18px;
  background-color: #efeae2;
  background-image: radial-gradient(rgba(90, 70, 45, 0.06) 1px, transparent 1px);
  background-size: 18px 18px;
  scrollbar-width: thin;
}

.wa-bubble {
  width: fit-content;
  max-width: 90%;
  background: #fff;
  border-radius: 10px;
  border-top-left-radius: 3px;
  overflow: hidden;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.14);
}

.wa-bubble.has-media {
  width: 90%;
}

.wa-media {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  background: #e2e8f0;
}

.wa-media-placeholder {
  height: 132px;
  display: grid;
  place-items: center;
  background: #e6ebf0;
  color: #7b8794;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.wa-content {
  padding: 9px 11px 3px;
}

.wa-title {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  color: #111b21;
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-body {
  font-size: 14px;
  line-height: 1.5;
  color: #111b21;
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-footer {
  margin-top: 6px;
  font-size: 12px;
  color: #667781;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-time {
  margin-top: 2px;
  font-size: 10.5px;
  color: #8696a0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.wa-buttons {
  display: flex;
  flex-direction: column;
  border-top: 1px solid #e9edef;
}

.wa-btn {
  padding: 10px 12px;
  border-top: 1px solid #e9edef;
  color: var(--blue);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  line-height: 1.4;
  word-break: break-word;
}

.wa-btn:first-child {
  border-top: 0;
}

.wa-empty {
  width: fit-content;
  max-width: 82%;
  margin: 26px auto 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  text-align: center;
}

.preview-count {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.preview-count strong {
  margin: 0 4px;
  color: var(--blue);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 页脚与提示 ---------- */
.page-foot {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: #94a3b8;
}

.page-foot a {
  color: var(--blue);
  text-decoration: none;
}

.page-foot a:hover {
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 12px 30px -10px rgba(15, 23, 42, 0.65);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: #991b1b;
}

/* ---------- 响应式 ---------- */
@media (max-width: 999px) {
  .layout {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .col-form {
    flex: 0 0 auto;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
  }

  .col-preview {
    flex: 0 0 auto;
    width: 100%;
    max-width: 720px;
    margin: 14px auto 0;
  }

  .phone {
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 10px 14px;
    gap: 10px;
  }

  .brand-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-sub {
    font-size: 11px;
  }

  .secure {
    padding: 6px 8px;
  }

  .page {
    padding: 16px 12px 44px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 14px;
  }

  .row-actions {
    flex-direction: column;
  }

  .row-actions .btn {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .phone {
    border-radius: 16px;
  }

  .wa-top {
    padding: 10px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
