/* ========== 变量 ========== */
:root {
  --bg-page: #f5f0e1;
  --bg-card: #ffffff;
  --bg-soft: #faf8f3;
  --red: #c0392b;
  --yellow: #e6b422;
  --wood: #8b5e3c;
  --green: #27ae60;
  --text: #3e2723;
  --text-sub: #8d6e63;
  --border: #d4c5a9;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 48px;
  --tabbar-h: 50px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background: #ffffff;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  background: #ffffff;
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--wood); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ========== 布局容器 ========== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  max-width: 100%;
  margin: 0 auto;
}

.main-wrap {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-page);
}

.main-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 0 16px;
}

.make-screen {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 0 18px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.make-screen::-webkit-scrollbar { display: none; }

body[data-tab="tutorial"] .make-screen,
body[data-tab="about"] .make-screen {
  flex: 0 0 0;
  overflow: hidden;
  padding: 0;
  min-height: 0;
}
/* ========== 顶部标题栏 ========== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: var(--safe-top) 12px 0;
  min-height: calc(var(--header-h) + var(--safe-top));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid rgba(212, 197, 169, 0.4);
  flex-shrink: 0;
  z-index: 10;
}
.app-title {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
}
.header-actions { display: flex; align-items: center; flex-shrink: 0; }
.brand-mark, .icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); border-radius: 10px; flex-shrink: 0;
}
.icon-btn:active, .brand-mark:active { background: rgba(139, 94, 60, 0.1); }
.ico { width: 22px; height: 22px; display: block; }
.ico-sm { width: 18px; height: 18px; display: block; flex-shrink: 0; }
/* ========== 页面引导标题 ========== */
.page-lead { text-align: center; margin-bottom: 12px; }
.page-lead h1 {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.35;
}
.page-lead-sub {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-sub);
  margin-top: 4px;
}
/* ========== 工具卡片 ========== */
.tool-card {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* ========== 类型快捷按钮 ========== */
.type-tabs {
  display: flex;
  gap: 8px;
}
.type-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 4px;
  font-size: 14px;
  color: var(--text-sub);
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  white-space: nowrap;
  transition: all 0.18s;
}
.type-tab.active {
  color: var(--red);
  background: #fdf3ef;
  border-color: rgba(192, 57, 43, 0.4);
  font-weight: 600;
}
/* ========== 内容输入框 ========== */
.content-input {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.content-input::placeholder { color: #b5a98f; }
.content-input:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(230, 180, 34, 0.18);
  background: #fff;
}
/* ========== 实时预览 ========== */
.preview-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
}
.qr-frame {
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(212, 197, 169, 0.5), var(--shadow-sm);
  overflow: hidden;
}
.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  color: #c2b59b;
}
.qr-placeholder svg { width: 48px; height: 48px; }
.qr-placeholder span { font-size: 14px; }
.qr-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  animation: qrFadeIn 0.4s ease;
}
.qr-image.loading { filter: blur(8px); opacity: 0.5; }
@keyframes qrFadeIn {
  from { filter: blur(10px); opacity: 0; }
  to { filter: blur(0); opacity: 1; }
}
.preview-tip { font-size: 14px; color: var(--green); font-weight: 500; }
/* ========== 美化区 ========== */
.beautify { display: flex; flex-direction: column; gap: 12px; }
.seg-tabs {
  display: flex;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 4px;
  gap: 2px;
}
.seg-tab {
  flex: 1 1 0;
  padding: 9px 4px;
  font-size: 15px;
  color: var(--text-sub);
  border-radius: 9px;
  transition: all 0.18s;
}
.seg-tab.active {
  color: #fff;
  background: var(--wood);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.beautify-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--bg-soft);
  border-radius: 12px;
  animation: panelIn 0.25s ease;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.color-row { display: flex; gap: 10px; }
.color-field {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-sub);
}
.color-field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: none;
  cursor: pointer;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
.grad-dir, .logo-shape { display: flex; gap: 8px; }
.dir-btn, .shape-btn {
  flex: 1 1 0;
  padding: 8px 4px;
  font-size: 14px;
  color: var(--text-sub);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: all 0.18s;
}
.dir-btn.active, .shape-btn.active {
  color: var(--red);
  border-color: var(--red);
  background: #fdf3ef;
  font-weight: 600;
}
.logo-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--wood);
  background: #fff;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.logo-upload:active { background: var(--bg-soft); }
.logo-upload.has-logo { border-style: solid; border-color: rgba(39, 174, 96, 0.5); }
.logo-upload svg { width: 32px; height: 32px; }
.logo-upload span { font-size: 14px; }
.logo-opts { display: flex; flex-direction: column; gap: 10px; }
.logo-remove {
  align-self: center;
  padding: 6px 16px;
  font-size: 14px;
  color: var(--red);
  border: 1px solid rgba(192, 57, 43, 0.4);
  border-radius: 8px;
}
.logo-note {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
  text-align: center;
}

/* ========== 尺寸选择 + 操作按钮 ========== */
.size-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.size-label { font-size: 14px; color: var(--text-sub); flex-shrink: 0; }
.size-tabs { display: flex; gap: 6px; }
.size-tab {
  min-width: 52px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: all 0.18s;
}
.size-tab.active {
  color: #fff;
  background: var(--wood);
  border-color: var(--wood);
  font-weight: 600;
}
.action-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-primary, .btn-secondary {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 48px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  transition: transform 0.1s, opacity 0.2s, box-shadow 0.2s;
}
.btn-primary {
  color: #fff;
  background: var(--red);
  box-shadow: 0 4px 14px rgba(192, 57, 43, 0.28);
}
.btn-secondary {
  color: var(--wood);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }
.btn-primary:disabled, .btn-secondary:disabled {
  opacity: 0.45;
  pointer-events: none;
  box-shadow: none;
}
/* ========== 历史记录 ========== */
.history-block { margin-top: 18px; }
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.history-clear {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-sub);
}
.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-empty {
  font-size: 14px;
  color: var(--text-sub);
  text-align: center;
  padding: 18px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px dashed var(--border);
}
.history-item button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.history-item button:active { background: var(--bg-soft); }
.history-item img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
  background: #fff;
  image-rendering: pixelated;
}
.history-item span {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* ========== 卡片内 SEO 简介 ========== */
.seo-intro {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.seo-intro h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.seo-intro p {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.75;
}
.seo-intro strong { color: var(--wood); font-weight: 600; }
/* ========== 内容面板（教程/关于） ========== */
.article-content {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.article-content::-webkit-scrollbar { display: none; }
body[data-tab="tutorial"] .article-tutorial,
body[data-tab="about"] .article-about { display: block; }
.article-content h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 22px 0 10px;
  padding-left: 10px;
  border-left: 3px solid var(--yellow);
}
.article-content h2:first-child { margin-top: 4px; }
.tutorial-steps { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.tutorial-steps li { font-size: 15px; color: var(--text-sub); line-height: 1.7; }
.tutorial-steps strong, .tip-list strong { color: var(--text); font-weight: 600; }
.tip-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.tip-list li {
  font-size: 15px;
  color: var(--text-sub);
  line-height: 1.7;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.faq-list { display: flex; flex-direction: column; }
.faq-list dt { font-size: 15px; font-weight: 600; color: var(--text); margin-top: 14px; }
.faq-list dd { font-size: 15px; color: var(--text-sub); line-height: 1.7; margin-top: 4px; }
.article-about p { font-size: 15px; color: var(--text-sub); line-height: 1.8; margin-bottom: 4px; }
.about-site { margin-top: 8px; }
/* ========== 广告位 ========== */
.ad-slot{display:none;min-height:60px;max-height:60px;margin:10px 16px;color:#999;font-size:14px;border-radius:8px;border:1px dashed #ccc;background:#fafafa;align-items:center;justify-content:center;overflow:hidden}
.ad-slot:not(:empty){display:flex;flex:0 0 60px}

/* ========== 底部 TabBar ========== */
.tab-bar {
  display: flex;
  order: 999;
  flex-shrink: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff;
  border-top: 1px solid rgba(212, 197, 169, 0.45);
  box-shadow: 0 -2px 12px rgba(62, 39, 35, 0.04);
  z-index: 20;
}
.tab-btn {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  color: var(--text-sub);
  padding: 4px 0 2px;
  transition: color 0.15s;
}
.tab-btn.active { color: var(--red); }
.tab-ico { width: 22px; height: 22px; display: block; }
.tab-btn.active .tab-ico { transform: translateY(-1px); }
/* ========== 页脚 ========== */
.site-footer {
  display: none;
  background: var(--text);
  color: #fff;
  text-align: center;
  padding: 16px 24px;
  font-size: 14px;
  line-height: 1.7;
}
.site-footer p + p { margin-top: 6px; }
.site-footer a { color: #d4c5a9; }
.pc-nav { display: none; }
/* ========== Toast ========== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(62, 39, 35, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 90;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: rgba(39, 174, 96, 0.95); }
.toast.error { background: rgba(192, 57, 43, 0.92); }
/* ========== PC 适配 ========== */
@media (min-width: 768px) {
  body {
    overflow-y: auto;
    min-height: 100dvh;
    background:
      radial-gradient(ellipse 600px 600px at 85% 15%, rgba(212, 197, 169, 0.18), transparent),
      radial-gradient(ellipse 400px 400px at 10% 80%, rgba(141, 110, 99, 0.1), transparent),
      var(--bg-page);
  }
  .app-container {
    max-width: 980px;
    height: 100dvh;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
    background: var(--bg-page);
  }
  .app-header { display: none; }
  .pc-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(212, 197, 169, 0.4);
    flex-shrink: 0;
  }
  .pc-nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-right: auto;
  }
  .pc-nav-brand:hover { text-decoration: none; opacity: 0.9; }
  .pc-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    font-size: 15px;
    color: var(--text-sub);
    border-radius: 9px;
    transition: all 0.18s;
  }
  .pc-nav-link .ico { width: 18px; height: 18px; }
  .pc-nav-link.active { color: var(--red); background: #fdf3ef; font-weight: 600; }
  .tab-bar { display: none; }
  .site-footer { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ========== 隐私政策页 ========== */
.legal-body { background: var(--bg-page); }
.legal-body .app-container { background: var(--bg-page); }
.legal-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 16px;
}
.legal-main::-webkit-scrollbar { display: none; }
.legal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: #fff;
  border-bottom: 1px solid rgba(212, 197, 169, 0.45);
}
.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.legal-brand:hover { opacity: 0.9; text-decoration: none; }
.legal-back { font-size: 16px; color: var(--wood); text-decoration: none; white-space: nowrap; }
.legal-back:hover { text-decoration: underline; }
.legal-main h1 { font-size: 26px; color: var(--text); margin-bottom: 8px; }
.legal-updated { font-size: 16px; color: var(--text-sub); margin-bottom: 20px; }
.legal-lead { font-size: 16px; line-height: 1.8; color: var(--text-sub); margin-bottom: 24px; }
.legal-section { margin-bottom: 28px; }
.legal-section h2 { font-size: 18px; color: var(--text); margin-bottom: 12px; }
.legal-section p,
.legal-section li { font-size: 16px; line-height: 1.8; color: var(--text-sub); margin-bottom: 10px; }
.legal-section ul { padding-left: 1.25em; margin-bottom: 10px; }
.legal-section code { font-size: 16px; background: rgba(212,197,169,.25); padding: 2px 6px; border-radius: 4px; }
.legal-section a { color: var(--wood); }
.legal-icp { margin-top: 16px; font-size: 16px; color: var(--text-sub); }
.legal-footer { padding: 20px 0; border-top: 1px solid rgba(212,197,169,.45); text-align: center; font-size: 16px; color: var(--text-sub); }
.legal-footer a { color: var(--wood); }
