/* ===== 字帖生成器 移动端全局样式 ===== */
:root {
  --bg: #f7f4ee;
  --panel: #ffffff;
  --ink: #2b2620;
  --ink-2: #6b6255;
  --ink-3: #a89f8f;
  --line: #ece6da;
  --accent: #8b5a2b;
  --accent-soft: #f4ede2;
  --green: #3d7a4f;
  --red: #b0413e;
  --blue: #2e5d8a;
  --gold: #b8902a;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}

/* 顶部导航 */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--line);
  height: 50px;
  display: flex; align-items: center;
  padding: 0 14px;
}
.topbar .back { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--ink); text-decoration: none; margin-left: -8px; }
.topbar .title { flex: 1; text-align: center; font-size: 17px; font-weight: 600; }
.topbar .right { width: 40px; }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; height: 56px;
  padding-bottom: var(--safe-bottom);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--ink-3); font-size: 11px; gap: 2px; }
.tabbar a .ico { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--accent); font-weight: 600; }

/* 页面容器 */
.page { max-width: 640px; margin: 0 auto; padding: 16px 14px 80px; }

/* 功能网格 */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.feature-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 8px; text-align: center; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform .1s;
}
.feature-card:active { transform: scale(.96); }
.feature-card .f-ico { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 24px; background: var(--accent-soft); }
.feature-card .f-name { font-size: 13px; font-weight: 500; }

/* 分组标题 */
.group-title { font-size: 15px; font-weight: 700; margin: 24px 0 12px; padding-left: 10px; border-left: 4px solid var(--accent); }

/* 热门模板区 */
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.template-card .f-ico { background: #fdf3e3; }
.template-card .f-desc { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.template-card { border-color: #f0e0c8; }

/* 表单 */
.form-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.form-panel .fp-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--ink); }
.form-row { margin-bottom: 14px; }
.form-row:last-child { margin-bottom: 0; }
.form-label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.form-input, .form-select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 16px; background: #faf9f5; color: var(--ink); outline: none;
  -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); background: #fff; }
textarea.form-input { min-height: 90px; resize: vertical; font-size: 16px; }
.form-hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* 分段选择器 */
.seg { display: flex; background: #f1ede3; border-radius: 8px; padding: 3px; }
.seg button { flex: 1; padding: 8px 0; border: none; background: transparent; font-size: 14px; color: var(--ink-2); border-radius: 6px; }
.seg button.on { background: #fff; color: var(--accent); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* 复选框行 */
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* 按钮 */
.btn {
  display: block; width: 100%; padding: 13px; border: none; border-radius: 10px;
  font-size: 16px; font-weight: 600; text-align: center; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: #774a20; }
.btn-primary:disabled { background: #cbb89a; }
.btn-outline { background: #fff; color: var(--accent); border: 1px solid var(--accent); }

/* 底部固定操作栏 */
.action-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 99;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 14px; padding-bottom: calc(10px + var(--safe-bottom));
}

/* 提示 */
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 12px 20px; border-radius: 8px;
  font-size: 14px; z-index: 999; max-width: 80%; text-align: center; display: none;
}
.toast.show { display: block; }

/* 激活页 */
.activate-hero { text-align: center; padding: 40px 0 20px; }
.activate-hero .logo { width: 80px; height: 80px; border-radius: 20px; background: var(--accent-soft); margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; font-size: 44px; }
.activate-hero h1 { font-size: 22px; margin: 0 0 6px; }
.activate-hero p { color: var(--ink-3); font-size: 14px; margin: 0; }

/* 管理后台 */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.admin-table th { color: var(--ink-2); font-weight: 600; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge.unused { background: #e7f2eb; color: var(--green); }
.badge.used { background: #eeece6; color: var(--ink-2); }
.badge.disabled { background: #f7e9e8; color: var(--red); }

/* 卡片列表（历史记录） */
.list-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.list-item .li-title { font-size: 15px; font-weight: 600; }
.list-item .li-meta { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

@media (min-width: 768px) {
  .feature-grid { grid-template-columns: repeat(4, 1fr); }

  /* 内容区给左侧导航留白 */
  body { padding-left: 200px; }

  /* 底部导航 → 左侧固定 sidebar */
  .tabbar {
    top: 0; bottom: 0; left: 0; right: auto;
    width: 200px; height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    padding: 24px 0;
    border-top: none;
    border-right: 1px solid var(--line);
    padding-bottom: 0;
  }
  .tabbar a {
    flex-direction: row; gap: 12px;
    padding: 14px 24px;
    justify-content: flex-start;
    font-size: 14px;
  }
  .tabbar a .ico { font-size: 18px; width: 22px; text-align: center; }

  /* action-bar（tool 页下载按钮）从 sidebar 右侧开始 */
  .action-bar { left: 200px; }
}
