/* ========== 通用 ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  color: #1f2937;
  background: #f3f7fc;
}

/* ========== 生成页：顶栏 ========== */
.site-header {
  background: linear-gradient(180deg, #e9f3ff 0%, #deeeff 100%);
  border-bottom: 1px solid #c7dcf4;
  padding: 1rem 1rem 1.1rem;
  text-align: center;
}

.site-header-inner {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.1rem;
}

.site-header-main {
  text-align: left;
  padding-top: 0.15rem;
}

.site-title {
  margin: 0 0 0.3rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: #0d47a1;
  letter-spacing: 0.02em;
}

.site-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: #4f6475;
}

.auth-box {
  width: min(345px, 100%);
  text-align: left;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #bfd7f1;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(30, 88, 154, 0.1);
  padding: 0.75rem 0.8rem;
}

.auth-box-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.auth-box-icon {
  font-size: 0.95rem;
}

.auth-box-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #2f4a63;
}

.auth-label {
  display: block;
  margin-bottom: 0.22rem;
  font-size: 0.76rem;
  color: #4e6272;
}

.auth-input {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.62rem;
  border: 1px solid #c9d6e4;
  border-radius: 10px;
  font-size: 0.85rem;
  background: #fff;
}

.auth-input:focus {
  outline: none;
  border-color: #4f8fdd;
  box-shadow: 0 0 0 3px rgba(79, 143, 221, 0.15);
}

.auth-actions {
  display: flex;
  gap: 0.45rem;
}

.auth-actions .btn {
  flex: 1;
  padding: 0.48rem 0.7rem;
  font-size: 0.8rem;
}

.auth-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid #b7dfc0;
  border-radius: 10px;
  background: #f1fbf4;
}

.auth-user-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.auth-user-avatar {
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #daf2e0;
}

.auth-user-text {
  margin: 0;
  font-size: 0.83rem;
  color: #1b5e20;
  font-weight: 600;
  word-break: break-all;
}

.auth-status {
  margin: 0.45rem 0 0;
  min-height: 1.2em;
  font-size: 0.78rem;
  color: #5d7385;
}

.auth-status.is-success {
  color: #2e7d32;
}

.auth-status.is-error {
  color: #c62828;
}

.auth-status.is-info {
  color: #1565c0;
}

/* ========== 生成页：主体布局 ========== */
.main-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.4rem;
}

.generator-layout {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.panel {
  background: #fff;
  border: 1px solid #dde7f1;
  border-radius: 12px;
  padding: 1.1rem 1.1rem 1.25rem;
  box-shadow: 0 10px 28px rgba(15, 50, 93, 0.07);
}

.panel-title {
  margin: 0 0 0.95rem;
  font-size: 1.03rem;
  font-weight: 600;
  color: #263a52;
}

/* ========== 表单 ========== */
.gen-form .field {
  margin-bottom: 1rem;
}

.gen-form .field:last-child {
  margin-bottom: 0;
}

.gen-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #3f5568;
  margin-bottom: 0.35rem;
}

.gen-form input[type="date"],
.gen-form input[type="text"],
.gen-form input[type="email"] {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.72rem;
  border: 1px solid #cad6e2;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #f9fbfe;
  color: #243444;
}

.gen-form input:focus {
  outline: none;
  border-color: #4f8fdd;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 143, 221, 0.18);
}

.field-hint {
  display: block;
  min-height: 1.1em;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: #c62828;
}

.form-tip {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: #6f8596;
}

/* ========== 预览区 ========== */
.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #e8eef5;
}

.preview-toolbar .panel-title {
  margin: 0;
}

.preview-box {
  min-height: 280px;
  max-height: min(62vh, 560px);
  overflow: auto;
  padding: 1.15rem 1.2rem;
  border: 1px solid #e3eaf2;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  font-size: 0.9rem;
  line-height: 1.72;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  scrollbar-gutter: stable;
}

.preview-box::-webkit-scrollbar {
  width: 10px;
}

.preview-box::-webkit-scrollbar-thumb {
  background: #d5e2ef;
  border-radius: 8px;
  border: 2px solid #f6faff;
}

.preview-box .policy-doc-title {
  font-size: 1.25rem;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.95rem;
}

.publish-result {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #d9e6f3;
}

.publish-result-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.84rem;
  color: #3f5568;
  font-weight: 600;
}

.publish-result-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.publish-link-icon {
  width: 2.2rem;
  height: 2.2rem;
  flex: 0 0 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccd9e6;
  border-radius: 10px;
  background: #f3f8ff;
}

.publish-result-input {
  flex: 1;
  min-width: 0;
  height: 2.2rem;
  padding: 0 0.65rem;
  border: 1px solid #cad7e4;
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color: #2b3e50;
  background: #f6faff;
}

.publish-time {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: #7b91a3;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  padding: 0.45rem 1rem;
  font-size: 0.84rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.btn-primary {
  background: #1868c2;
  color: #fff;
  border-color: #165dab;
  box-shadow: 0 5px 14px rgba(24, 104, 194, 0.22);
}

.btn-primary:hover {
  background: #155aa8;
  border-color: #124f93;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #fff;
  color: #3f5568;
  border-color: #c9d6e3;
}

.btn-secondary:hover {
  background: #f4f8fc;
  border-color: #b3c6d8;
  transform: translateY(-1px);
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  padding: 0.65rem 1.25rem;
  background: #263238;
  color: #fff;
  font-size: 0.9rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  max-width: calc(100% - 2rem);
  text-align: center;
}

.toast[hidden] {
  display: none !important;
}

/* ========== 正式页 agreement ========== */
.page-agreement {
  background: #fff;
}

.agreement-article {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  min-height: 100vh;
}

.agreement-placeholder {
  padding: 2rem 1rem;
  text-align: center;
  color: #546e7a;
  font-size: 1rem;
}

.agreement-error {
  padding: 2rem 1.25rem;
  background: #fff3e0;
  border: 1px solid #ffcc80;
  border-radius: 8px;
  color: #e65100;
}

.agreement-error h1 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  color: #bf360c;
}

.agreement-error p {
  margin: 0.5rem 0 0;
}

/* 政策正文排版（预览与正式页共用 class） */
.policy-doc-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #2a75c8;
}

.policy-doc-title {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  font-weight: 700;
  color: #134f9f;
  letter-spacing: 0.02em;
}

.policy-doc-meta {
  margin: 0;
  font-size: 0.9rem;
  color: #577187;
}

.policy-doc-body h2 {
  margin: 1.5rem 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #2a4053;
}

.policy-doc-body p {
  margin: 0 0 0.85rem;
  text-align: justify;
  hyphens: auto;
  color: #2d4254;
}

.policy-doc-body a {
  color: #1565c0;
  word-break: break-all;
}

/* ========== 打印 ========== */
@media print {
  .site-header,
  .preview-toolbar .btn,
  .preview-actions,
  .toast {
    display: none !important;
  }

  .preview-box {
    max-height: none;
    border: none;
    padding: 0;
  }

  body.page-generator .panel-preview {
    border: none;
    box-shadow: none;
  }

  body.page-agreement .agreement-article {
    padding: 0;
    max-width: none;
  }
}

/* ========== 移动端 ========== */
@media (max-width: 768px) {
  .site-header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .site-header-main {
    text-align: center;
  }

  .auth-box {
    width: 100%;
  }

  .auth-user {
    flex-direction: column;
    align-items: stretch;
  }

  .generator-layout {
    grid-template-columns: 1fr;
  }

  .preview-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-toolbar .btn-primary {
    width: 100%;
  }

  .publish-result-row {
    flex-direction: column;
    align-items: stretch;
  }

  .publish-link-icon {
    width: 100%;
    height: 2rem;
    flex: none;
  }

  .publish-result-row .btn {
    width: 100%;
  }

  .policy-doc-title {
    font-size: 1.45rem;
  }
}
