/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #07c160;
  --primary-dark: #06ad56;
  --primary-light: #e8f8ee;
  --accent: #1a73e8;
  --accent-light: #e8f0fe;
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
  --max-width: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --gradient-hero: linear-gradient(135deg, #e8f8ee 0%, #f0fdf4 50%, #f5f7fa 100%);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --surface: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --primary-light: #0a3622;
  --accent-light: #0a2540;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.5);
  --gradient-hero: linear-gradient(135deg, #0a3622 0%, #0f172a 50%, #0f172a 100%);
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-top: var(--nav-height);
  transition: background .3s, color .3s;
  margin: 0;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* ===== Navbar ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--nav-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  transition: background .3s, box-shadow .3s;
  width: 100%;
}
.navbar.scrolled { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.navbar .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}
.navbar .logo {
  font-size: 1.2rem; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}
.navbar .logo:hover { text-decoration: none; }
.navbar .logo .logo-icon {
  width: 32px; height: 32px; background: var(--primary);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 700;
}
.nav-links { display: flex; align-items: center; gap: 4px; list-style: none; }
.nav-links a {
  display: block; padding: 8px 14px;
  font-size: .9rem; font-weight: 500; color: var(--text-secondary);
  border-radius: var(--radius-sm); transition: all .2s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--primary); background: var(--primary-light); text-decoration: none;
}
.nav-right { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 1.1rem; transition: all .2s;
}
.theme-toggle:hover { background: var(--primary-light); color: var(--primary); }
.mobile-toggle {
  display: none; background: none; border: none;
  width: 36px; height: 36px; cursor: pointer;
  flex-direction: column; justify-content: center; gap: 5px;
}
.mobile-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px; transition: all .3s;
}

/* ===== Hero Section ===== */
.hero {
  padding: 0;
  text-align: center;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-hero);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle, rgba(7,193,96,.06) 0%, transparent 70%);
  pointer-events: none;
}
.hero .brand-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 16px; background: var(--primary-light); color: var(--primary);
  border-radius: 50px; font-size: .82rem; font-weight: 600;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: 2.6rem; font-weight: 800;
  margin-bottom: 16px; line-height: 1.25;
}
.hero h1 span { color: var(--primary); }
.hero p {
  font-size: 1.1rem; color: var(--text-secondary);
  max-width: 600px; margin: 0 auto 28px;
}
.hero .cta-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 36px; font-size: 1.05rem; font-weight: 600;
  background: var(--primary); color: #fff; border-radius: 50px;
  border: none; cursor: pointer; transition: all .3s;
  text-decoration: none;
}
.hero .cta-btn:hover { background: var(--primary-dark); transform: translateY(-2px); text-decoration: none; box-shadow: var(--shadow-lg); }
.hero .sub-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 12px; padding: 12px 24px; font-size: .95rem; font-weight: 500;
  background: var(--bg-card); color: var(--text); border-radius: 50px;
  border: 1px solid var(--border); cursor: pointer; transition: all .2s;
  text-decoration: none;
}
.hero .sub-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* ===== Section Headers ===== */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.section-header h2 { font-size: 1.5rem; font-weight: 700; }
.section-header .more-link {
  font-size: .9rem; color: var(--text-secondary);
  display: flex; align-items: center; gap: 4px;
}
.section-header .more-link:hover { color: var(--primary); }

/* ===== Services ===== */
.services-section { padding: 50px 0; }
.services-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.service-card {
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 24px 20px;
  text-align: center; transition: all .3s;
}
.service-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.service-card .icon {
  width: 52px; height: 52px; margin: 0 auto 12px;
  background: var(--primary-light); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.service-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.service-card p { font-size: .85rem; color: var(--text-secondary); line-height: 1.5; }

/* ===== Cards Grid ===== */
.card-grid { display: grid; gap: 20px; }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: all .3s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-img {
  width: 100%; height: 160px; object-fit: cover;
  background: var(--primary-light);
}
.card-body { padding: 16px; }
.card-body h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.card-body p { font-size: .88rem; color: var(--text-secondary); line-height: 1.5; }
.card-meta {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px; font-size: .8rem; color: var(--text-secondary);
}
.tag {
  display: inline-block; padding: 2px 10px; font-size: .75rem;
  background: var(--primary-light); color: var(--primary);
  border-radius: 20px; font-weight: 500;
}

/* ===== News Section ===== */
.news-section, .novels-section, .ads-section { padding: 40px 0; }
.news-list { display: flex; flex-direction: column; gap: 12px; }
.news-item {
  display: flex; gap: 16px; padding: 16px;
  background: var(--bg-card); border-radius: var(--radius-sm);
  border: 1px solid var(--border); transition: all .2s; cursor: pointer;
}
.news-item:hover { border-color: var(--primary); }
.news-item .news-img {
  width: 120px; height: 80px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
  background: var(--primary-light);
}
.news-item .news-content { flex: 1; }
.news-item .news-content h3 { font-size: .95rem; font-weight: 600; margin-bottom: 4px; }
.news-item .news-content p {
  font-size: .85rem; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.news-item .news-meta { font-size: .78rem; color: var(--text-secondary); margin-top: 6px; }

/* ===== CTA Section ===== */
.cta-section {
  padding: 60px 0; text-align: center;
  background: var(--gradient-hero);
}
.cta-section h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 12px; }
.cta-section p { color: var(--text-secondary); margin-bottom: 24px; max-width: 500px; margin-left: auto; margin-right: auto; }

/* ===== Footer ===== */
.footer {
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 40px 0 20px; margin-top: 0;
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px;
  margin-bottom: 24px;
}
.footer h4 { font-size: .95rem; font-weight: 600; margin-bottom: 12px; }
.footer p { font-size: .85rem; color: var(--text-secondary); line-height: 1.6; }
.footer a {
  display: inline-block; font-size: .85rem; color: var(--text-secondary);
  margin-bottom: 6px;
}
.footer a:hover { color: var(--primary); }
.footer-bottom {
  border-top: 1px solid var(--border); padding-top: 16px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.footer-bottom p { font-size: .8rem; color: var(--text-muted); }

.chat-panel {
  display: none; position: fixed;
  width: 60vw; max-width: 780px; min-width: 320px;
  height: 78vh; max-height: 78vh; min-height: 400px;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 9999; flex-direction: column; overflow: hidden;
  animation: fadeIn .3s ease;
}
.chat-panel.open { display: flex; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.chat-panel .chat-header {
  background: var(--primary); color: #fff; padding: 12px 12px;
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.chat-panel .chat-header .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
  transition: transform .2s;
}
/* .chat-panel .chat-header .avatar:hover removed - not clickable */

.chat-panel .chat-header .admin-badge {
  font-size: .55rem; background: #ff4757; color: #fff;
  padding: 1px 6px; border-radius: 8px;
  white-space: nowrap;
}

.chat-panel .chat-header .admin-balance {
  font-size: .55rem; background: #fb923c; color: #fff;
  padding: 1px 6px; border-radius: 8px;
  white-space: nowrap;
  font-weight: 600;
}

.chat-panel .chat-header .login-header-btn {
  background: none; border: none;
  font-size: 1.2rem; cursor: pointer;
  padding: 0 4px; flex-shrink: 0;
  transition: transform .2s;
  line-height: 1;
}
.chat-panel .chat-header .login-header-btn:hover { transform: scale(1.2); }
  font-size: .6rem; background: #ff4757; color: #fff;
  padding: 1px 5px; border-radius: 8px;
  flex-shrink: 0; align-self: flex-start;
  margin-left: -6px; margin-top: 2px;

.chat-panel .chat-header .info { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.chat-panel .chat-header .welcome-msg {
  flex: 1; font-size: 1.1rem; opacity: .92; line-height: 1.5;
  padding: 0 8px; color: #fff; text-align: left;
  font-family: "KaiTi", "STKaiti", "Noto Serif SC", serif;
}
.chat-panel .chat-header .name { font-size: 1.4rem; font-weight: 700; font-family: "KaiTi", "STKaiti", "Noto Serif SC", serif; }
.chat-panel .chat-header .status { font-size: .9rem; opacity: .8; line-height: 1.4; display: flex; align-items: center; }
.chat-panel .chat-header .status-dot {
  display: inline-block; width: 10px; height: 10px;
  background: #4ade80; border-radius: 50%; margin-right: 2px;
  vertical-align: middle;
}
.chat-panel .chat-header .close-btn {
  background: none; border: none; color: #fff; font-size: 20px; cursor: pointer;
  opacity: .7; transition: opacity .2s; line-height: 1;
  margin-left: 4px;
}
.chat-panel .chat-header .close-btn:hover { opacity: 1; }

.chat-panel .chat-header .maximize-btn {
  background: none; border: none; color: #fff; font-size: 18px; cursor: pointer;
  opacity: .6; transition: opacity .2s; line-height: 1;
  margin-left: auto;
}
.chat-panel .chat-header .maximize-btn:hover { opacity: 1; }

.chat-panel.maximized {
  position: fixed !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  min-width: auto !important;
  min-height: auto !important;
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
  transform: none !important;
  animation: none !important;
  margin: 0 !important;
}
.chat-panel.maximized .chat-body {
  max-height: none !important;
  min-height: 0 !important;
  flex: 1 !important;
}

.chat-panel .chat-body {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-panel .chat-body .msg {
  max-width: 85%; padding: 10px 14px; border-radius: 12px;
  font-size: 1.05rem; line-height: 1.5; word-break: break-word;
}
.chat-panel .chat-body .msg.user {
  background: var(--primary); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.chat-panel .chat-body .msg.bot {
  background: var(--bg); color: var(--text);
  align-self: flex-start; border-bottom-left-radius: 4px;
}
.chat-panel .chat-body .msg.bot .name {
  font-size: .9rem; color: var(--primary); font-weight: 600; margin-bottom: 2px;
}
.chat-panel .chat-body .msg.loading {
  background: transparent; align-self: flex-start; color: var(--text-muted); font-size: 1rem;
}

.chat-panel .chat-toolbar {
  display: flex; gap: 4px; padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; flex-wrap: wrap;
}
.chat-panel .chat-toolbar .toolbar-btn {
  background: transparent; border: 1px solid transparent;
  border-radius: 4px; padding: 3px 8px;
  font-size: .8rem; color: var(--text-secondary);
  cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.chat-panel .chat-toolbar .toolbar-btn:hover {
  background: var(--bg); border-color: var(--border);
  color: var(--text);
}

.chat-panel .chat-footer {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}
.chat-panel .chat-footer input {
  flex: 1; border: 1px solid var(--border); border-radius: 20px;
  padding: 12px 16px; font-size: 1.1rem; outline: none; background: var(--bg);
  color: var(--text); min-width: 0;
}
.chat-panel .chat-footer input:focus { border-color: var(--primary); }
.chat-panel .chat-footer button {
  background: var(--primary); color: #fff; border: none;
  border-radius: 20px; padding: 12px 18px; font-size: 1.1rem;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .2s; flex: 0 0 auto; display: inline-flex;
  align-items: center; justify-content: center;
}
.chat-panel .chat-footer button:hover { background: var(--primary-dark); }
.chat-panel .chat-footer button:disabled { background: #a0d8a0; cursor: not-allowed; opacity: .6; }
#chatSendBtn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.chat-panel .chat-footer .chat-tool-btn {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 50%;
  width: 40px; height: 40px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; cursor: pointer; transition: all .2s;
  flex-shrink: 0;
}
.chat-panel .chat-footer .chat-tool-btn:hover {
  background: var(--bg); color: var(--primary); border-color: var(--primary);
}
.chat-panel .chat-footer .chat-tool-btn.recording {
  background: #ff4757; color: #fff; border-color: #ff4757;
  animation: recPulse 1s infinite;
}
@keyframes recPulse {
  0% { box-shadow: 0 0 0 0 rgba(255,71,87,.4); }
  50% { box-shadow: 0 0 0 8px rgba(255,71,87,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,71,87,0); }
}

/* ===== GB Document Preview (所见即所得公文预览) ===== */
.gb-preview {
  background: #fff; color: #000;
  width: 100%; min-height: 200px;
  padding: 56px 42px 42px;
  font-size: 16pt;
  line-height: 28pt;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  box-sizing: border-box;
  font-family: "Times New Roman", "SimSun", serif;
  letter-spacing: 0.05em;
}
[data-theme="dark"] .gb-preview {
  background: #f5f5f0; color: #222;
  border-color: #888;
}
.gb-preview-edit {
  cursor: text;
}
.gb-preview-edit:focus {
  outline: 2px solid #07c160;
  outline-offset: -2px;
}

/* 红头：发文机关标志 — 二号小标宋居中红色 */
.gb-preview .gb-redhead {
  font-size: 22pt;
  font-weight: bold;
  color: #cc0000;
  text-align: center;
  line-height: 40pt;
  margin-bottom: 4px;
  font-family: "SimSun", serif;
}

/* 红色间隔横线（通过JS内联样式处理，此CSS去掉伪元素）*/

/* 发文字号 — 三号仿宋居中 */
.gb-preview .gb-docnum {
  font-size: 16pt;
  text-align: center;
  line-height: 28pt;
  margin-bottom: 8px;
}

/* 发文字号 — 三号仿宋居中（间隔横线已由JS内联处理）*/

/* 标题 — 二号小标宋居中 */
.gb-preview .gb-title {
  font-size: 22pt;
  font-weight: bold;
  text-align: center;
  line-height: 40pt;
  margin-bottom: 12px;
  font-family: "SimSun", serif;
}

/* 主送机关 — 三号黑体顶格加粗 */
.gb-preview .gb-recipient {
  font-size: 16pt;
  font-weight: bold;
  text-align: left;
  line-height: 28pt;
  font-family: "SimHei", "Microsoft YaHei", sans-serif;
}

/* 一级标题 — 三号黑体加粗 */
.gb-preview .gb-body-bold {
  font-size: 16pt;
  font-weight: bold;
  line-height: 28pt;
  font-family: "SimHei", "Microsoft YaHei", sans-serif;
}

/* 二级标题 — 三号楷体 */
.gb-preview .gb-body-kai {
  font-size: 16pt;
  line-height: 28pt;
  font-family: "KaiTi", serif;
}

/* 正文 — 三号仿宋首行缩进2字 */
.gb-preview .gb-body {
  font-size: 16pt;
  line-height: 28pt;
  text-indent: 2em;
}

/* 正文不缩进 */
.gb-preview .gb-body-ni {
  font-size: 16pt;
  line-height: 28pt;
}

/* 发文机关署名 — 三号仿宋右对齐 */
.gb-preview .gb-sign {
  font-size: 16pt;
  text-align: right;
  line-height: 28pt;
  margin-top: 28pt;
}

/* 成文日期 — 三号仿宋右对齐 */
.gb-preview .gb-date {
  font-size: 16pt;
  text-align: right;
  line-height: 28pt;
}

/* 兼容旧格式 */
.gb-preview div[align="center"] { text-align: center; }
.gb-preview div[align="right"] { text-align: right; }
.gb-preview font[color="red"] { color: #cc0000; font-weight: bold; font-size: 22pt; }

/* ===== Preview Edit Toggle ===== */
.preview-edit-toggle {
  text-align: center; padding: 8px; margin-top: 8px;
  font-size: .85rem; color: var(--accent); cursor: pointer;
  border: 1px dashed var(--border); border-radius: 6px;
  transition: all .2s;
}
.preview-edit-toggle:hover {
  background: var(--accent-light); border-color: var(--accent);
}
.preview-edit-area {
  margin-top: 8px;
}

/* ===== Review Feedback ===== */
.feedback-approved {
  background: var(--primary-light); border: 1px solid var(--primary);
  border-radius: 6px; padding: 10px 12px; margin-top: 8px;
  font-size: .9rem; color: var(--text); line-height: 1.5;
}
.feedback-issues {
  background: #fef3c7; border: 1px solid #f59e0b;
  border-radius: 6px; padding: 10px 12px; margin-top: 8px;
  font-size: .9rem; color: #92400e; line-height: 1.6;
}
.feedback-waiting {
  background: var(--bg); border-radius: 6px;
  padding: 10px 12px; margin-top: 8px;
  font-size: .9rem; color: var(--text-muted);
}
[data-theme="dark"] .feedback-issues {
  background: #3b2f00; border-color: #a16207; color: #fbbf24;
}

/* ===== Preview Steps ===== */
/* ===== 格式工具栏（inline in card） ===== */
.fmt-bar {
  display: flex; gap: 6px; padding: 6px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px 6px 0 0; align-items: center;
  flex-wrap: wrap;
}
.fmt-bar select {
  font-size: .8rem; padding: 3px 8px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text);
  cursor: pointer; max-width: 90px;
}
.fmt-bar select:hover { border-color: var(--primary); }
.fmt-bar .fmt-hint {
  font-size: .7rem; color: var(--text-muted);
  margin-left: auto;
}
.fmt-bar .fmt-trans-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 8px;
  font-size: .8rem; cursor: pointer;
  color: var(--text-secondary); flex-shrink: 0;
  transition: all .15s;
}
.fmt-bar .fmt-trans-btn:hover {
  background: var(--surface); border-color: var(--primary);
  color: var(--primary);
}

.preview-step {
  margin-top: 10px;
}
/* ===== 通用弹窗 ===== */
.chat-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  z-index: 100000;
  background: rgba(0,0,0,.4);
  display: none;
  align-items: center; justify-content: center;
}
.chat-modal-overlay.show { 
  display: flex !important; 
  align-items: center !important; 
  justify-content: center !important; 
}

#loginModal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; z-index: 100000; background: rgba(0,0,0,.4); align-items: center; justify-content: center; }
#loginModal.show { display: flex; align-items: center; justify-content: center; }
@media (hover: none) and (pointer: coarse) {
  #loginModal>div { max-width: 90vw !important; }
  #loginModal input { font-size: 16px !important; padding: 14px 12px !important; min-height: 48px; }
  #loginModal button { min-height: 48px; font-size: 1rem !important; }
}

/* ===== 模板/预设/历史列表 ===== */
.tmpl-card {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; transition: all .15s;
  background: var(--bg-card);
}
.tmpl-card:hover { border-color: var(--primary); background: var(--primary-light); }
.tmpl-name { font-size: .95rem; font-weight: 600; color: var(--text); }
.tmpl-desc { font-size: .78rem; color: var(--text-secondary); margin-top: 2px; }
.history-row {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; transition: all .15s;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-card);
}
.history-row:hover { border-color: var(--primary); background: var(--primary-light); }
.history-time { font-size: .78rem; color: var(--text-secondary); }
.confirm-btn {
  display: block; width: 100%; padding: 10px 24px; border: none; border-radius: 8px;
  font-size: .95rem; font-weight: 600; cursor: pointer;
  background: var(--primary); color: #fff; margin-top: 12px;
}
.confirm-btn:hover { background: var(--primary-dark); }
#presetForm label { display: block; font-size: .85rem; font-weight: 600; margin-top: 8px; color: var(--text); }
#presetForm input { display: block; width: 100%; margin: 3px 0 4px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: .9rem; background: var(--bg-card); color: var(--text); box-sizing: border-box; }

/* ===== 登录弹窗 ===== */
.login-tabs {
  display: flex; gap: 0; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.login-tab {
  flex: 1; padding: 8px; text-align: center;
  background: var(--surface); border: none;
  font-size: .9rem; cursor: pointer; color: var(--text-secondary);
  transition: all .15s;
}
.login-tab.active {
  background: var(--primary); color: #fff; font-weight: 600;
}
.login-tab:not(.active):hover { background: var(--bg); }
.login-input {
  display: block; width: 100%; margin: 4px 0 12px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: .9rem;
  background: var(--surface); color: var(--text);
}
.login-input:focus { border-color: var(--primary); outline: none; }
.login-remember {
  display: flex; align-items: center; gap: 6px;
  font-size: .85rem; color: var(--text-secondary);
  margin: 8px 0 14px; cursor: pointer;
}
.login-remember input { width: auto; }

.chat-modal {
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  max-width: 500px; width: 90%; max-height: 80vh;
  display: flex; flex-direction: column;
}
.chat-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-size: 1rem; font-weight: 600;
}
.chat-modal-header .modal-close {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--text-muted); padding: 4px 8px;
  border-radius: 4px;
}
.chat-modal-header .modal-close:hover { background: var(--bg); }
.chat-modal-body {
  padding: 14px 18px; overflow-y: auto; flex: 1;
  max-height: 70vh;
}
.chat-modal-body textarea {
  display: block; width: 100%; margin: 3px 0 4px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; font-size: .9rem;
  background: var(--bg-card); color: var(--text); box-sizing: border-box;
  font-family: inherit; resize: vertical;
}
.chat-modal-body select {
  display: block; width: 100%; margin: 3px 0 4px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; font-size: .9rem;
  background: var(--bg-card); color: var(--text); box-sizing: border-box;
}
.chat-modal-body label {
  display: block; font-size: .85rem; font-weight: 600;
  margin-top: 6px; color: var(--text);
}

/* 模板列表 */
.tmpl-item {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 8px;
  cursor: pointer; transition: background .15s;
}
.tmpl-item:hover { background: var(--bg); }
.tmpl-item .tmpl-icon { font-size: 1.5rem; flex-shrink: 0; }
.tmpl-item .tmpl-info { flex: 1; min-width: 0; }
.tmpl-item .tmpl-name { font-weight: 600; font-size: .95rem; }
.tmpl-item .tmpl-desc { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

/* 预设弹窗表单 */
#presetForm label {
  display: block; margin-bottom: 10px;
  font-size: .85rem; color: var(--text-secondary);
}
#presetForm input {
  display: block; width: 100%; margin-top: 4px;
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: .9rem;
  background: var(--surface); color: var(--text);
}
#presetForm input:focus { border-color: var(--primary); outline: none; }

/* 历史列表 */
.hist-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.hist-item:last-child { border-bottom: none; }
.hist-item .hist-title { flex: 1; font-weight: 500; }
.hist-item .hist-meta { font-size: .75rem; color: var(--text-muted); }
.hist-item .hist-dl {
  padding: 4px 12px; background: var(--primary); color: #fff;
  border-radius: 4px; text-decoration: none; font-size: .8rem;
  flex-shrink: 0;
}
.hist-item .hist-dl:hover { background: var(--primary-dark); }

.preview-step-status {
  padding: 10px 12px; border-radius: 6px;
  font-size: .9rem; color: var(--text-muted);
  background: var(--bg); text-align: center;
}
.preview-step-status.approved {
  background: var(--primary-light); color: var(--primary);
}
.preview-step-status.issues {
  background: #fef3c7; color: #92400e; text-align: left;
  line-height: 1.6;
}
[data-theme="dark"] .preview-step-status.issues {
  background: #3b2f00; color: #fbbf24;
}
.preview-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 24px; border: none; border-radius: 8px;
  font-size: .95rem; font-weight: 600; cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.preview-save {
  width: 100%; background: var(--primary); color: #fff;
  padding: 12px; font-size: 1rem; font-weight: 600;
  border: none; border-radius: 8px; cursor: pointer;
  transition: all .2s;
}
.preview-save:hover { background: var(--primary-dark); }
.preview-dl-btn {
  display: block; text-align: center;
  margin-top: 8px; padding: 12px;
  font-size: 1rem; font-weight: 600;
  background: var(--primary); color: #fff;
  border-radius: 8px; text-decoration: none;
}
.preview-dl-btn:hover { background: var(--primary-dark); text-decoration: none; }

/* ===== Page Header ===== */
.page-header {
  padding: 40px 0 20px;
  background: var(--gradient-hero);
}
.page-header h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; }
.page-header p { color: var(--text-secondary); }

/* ===== Ad Placements ===== */
.ad-banner {
  background: var(--bg-card); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 24px; text-align: center;
  color: var(--text-secondary); font-size: .9rem;
  margin: 20px 0; transition: all .2s;
}
.ad-banner-demo:hover { border-color: var(--primary); background: var(--primary-light); }
.ad-sidebar {
  background: var(--bg-card); border: 1px dashed var(--border);
  border-radius: var(--radius-sm); padding: 16px; text-align: center;
  color: var(--text-secondary); font-size: .82rem; margin-bottom: 16px;
}
.ad-pricing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.ad-plan {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px;
  text-align: center; transition: all .3s;
}
.ad-plan:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.ad-plan.featured {
  border-color: var(--primary); border-width: 2px;
  position: relative;
}
.ad-plan.featured::before {
  content: '推荐'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; padding: 2px 16px; border-radius: 20px;
  font-size: .78rem; font-weight: 600;
}
.ad-plan h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.ad-plan .price { font-size: 2rem; font-weight: 800; color: var(--primary); }
.ad-plan .price-desc { font-size: .8rem; color: var(--text-muted); margin-bottom: 16px; }
.ad-plan ul { list-style: none; text-align: left; margin-bottom: 20px; }
.ad-plan ul li {
  padding: 6px 0; font-size: .85rem; color: var(--text-secondary);
  padding-left: 20px; position: relative;
}
.ad-plan ul li::before { content: '✓'; position: absolute; left: 0; color: var(--primary); font-weight: 700; }
.ad-plan .btn {
  display: inline-block; padding: 10px 28px; border-radius: 50px;
  background: var(--primary); color: #fff; font-weight: 600; font-size: .9rem;
  transition: all .2s;
}
.ad-plan .btn:hover { background: var(--primary-dark); text-decoration: none; }

/* ===== Utility ===== */
.faq-item {
  padding: 16px; border-bottom: 1px solid var(--border);
}
.faq-item:last-child { border-bottom: none; }
.faq-item h4 { font-size: .95rem; font-weight: 600; margin-bottom: 6px; }
.faq-item p { font-size: .85rem; color: var(--text-secondary); }

@media (max-width: 768px) {
  .nav-links a { padding: 12px 14px; width: 100%; }
  .mobile-toggle { display: flex; }
  .hero h1 { font-size: 1.8rem; }
  .services-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid-3, .card-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .chat-panel { width: calc(100vw - 32px); height: 90vh; min-width: auto; max-width: 100vw; top: 50%; left: 50%; transform: translate(-50%, -50%); }
  .ad-pricing { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .page-header h1 { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .card-grid-3, .card-grid-4 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}

/* ===== 移动端适配 (v84) ===== */
@media (max-width: 640px) {
  /* 头部紧凑 */
  .chat-panel .chat-header { padding: 8px 8px; gap: 2px; }
  .chat-panel .chat-header .avatar { width: 32px; height: 32px; font-size: 1rem; }
  .chat-panel .chat-header .welcome-msg { font-size: .9rem; }
  .chat-panel .chat-header .name { font-size: 1.1rem; }
  .chat-panel .chat-header .status { font-size: .75rem; }
  .chat-panel .chat-header .login-header-btn { font-size: 1rem; }
  .chat-panel .chat-header .admin-badge,
  .chat-panel .chat-header .admin-balance { font-size: .5rem; }
  .chat-panel .chat-header .maximize-btn { font-size: 15px; }
  .chat-panel .chat-header .close-btn { font-size: 17px; }

  /* 输入框 */
  .chat-panel .chat-input { padding: 8px; gap: 6px; }
  .chat-panel .chat-input input[type="text"] { font-size: .95rem; padding: 8px 10px; }
  .chat-panel .chat-input .send-btn { width: 40px; height: 40px; font-size: 1.1rem; padding: 0; }

  /* 工具栏按钮 */
  .chat-panel .toolbar { gap: 4px; padding: 4px 6px; }
  .chat-tool-btn { padding: 5px 8px; font-size: .75rem; }
  .chat-tool-btn .tool-icon { font-size: .85rem; }

  /* 消息 */
  .chat-body .msg { max-width: 92%; padding: 8px 12px; font-size: .9rem; }

  /* 弹窗 - 手机全屏铺满 */
  .chat-modal-overlay.show { align-items: flex-end; }
  .chat-modal {
    max-width: 100vw; width: 100%; max-height: 92vh;
    margin: 0; border-radius: 16px 16px 0 0;
  }
  .chat-modal-body { padding: 10px 12px; max-height: 80vh; }

  /* 模板弹窗字段两列变一列 */
  div[style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }

  /* 分类卡片 */
  .cat-card { padding: 10px 12px; }
  .cat-card .cat-name { font-size: .95rem; }
  .cat-card .cat-count { font-size: .7rem; }

  /* 文种列表 */
  .type-item { padding: 8px 10px; }
  .type-item .type-name { font-size: .88rem; }

  /* 表单字段 */
  .tmpl-field label { font-size: .8rem; }
  .tmpl-field input, .tmpl-field textarea, .tmpl-field select {
    padding: 7px 8px; font-size: .85rem;
  }
  .tmpl-submit { padding: 10px 16px; font-size: .9rem; }
  .tmpl-format-bar { font-size: .75rem; padding: 6px 10px; }

  /* 预览卡片 */
  .preview-container { padding: 8px; }
  .preview-bar { padding: 6px 10px; gap: 4px; flex-wrap: wrap; }
  .preview-btn { padding: 6px 14px; font-size: .82rem; }
  .preview-save { padding: 10px; font-size: .88rem; }

  /* 格式工具栏 */
  .fmt-bar { padding: 4px 6px; gap: 4px; flex-wrap: wrap; }
  .fmt-bar select { font-size: .78rem; padding: 3px 4px; max-width: 70px; }
  .fmt-bar button { font-size: .78rem; padding: 3px 6px; }

  /* 首页文本 */
  .hero h1 { font-size: 1.5rem; }
  .brand-tag { font-size: .9rem; }
  .cta-btn { font-size: .95rem; padding: 10px 20px; }

  /* 历史列表 */
  .hist-item { padding: 8px 0; flex-wrap: wrap; }
  .hist-item .hist-title { font-size: .85rem; min-width: 100px; }

  /* 预设弹窗输入框 */
  #presetForm input { padding: 6px 8px; font-size: .85rem; }
}

@media (max-width: 380px) {
  .chat-panel { width: calc(100vw - 16px); height: 92vh; min-width: auto; max-width: 100vw; }
  .chat-panel .chat-header .welcome-msg { display: none; }
  .chat-tool-btn { padding: 4px 6px; font-size: .7rem; }
}

/* ===== 平板/大屏手机 (640-1024px) ===== */
@media (min-width: 641px) and (max-width: 1024px) {
  .chat-panel { width: 80vw; min-width: auto; max-width: 90vw; }
  .chat-modal { max-width: 90vw; }
  .hero h1 { font-size: 2rem; }
}

/* ===== 首页按钮在大屏手机上更好点击 ===== */
@media (hover: none) and (pointer: coarse) {
  .cta-btn { min-height: 52px; padding: 14px 32px; font-size: 1.1rem; }
  .chat-tool-btn { min-height: 36px; }
  .tmpl-submit { min-height: 44px; }
  .preview-save { min-height: 44px; }
  .send-btn { min-height: 44px; min-width: 44px; }
  .cat-card { min-height: 52px; }
  .type-item { min-height: 44px; }
}

/* ===== 手机端输入框优化 ===== */
@media (max-width: 640px) {
  .chat-panel .chat-footer { gap: 4px; padding: 8px 10px; }
  .chat-panel .chat-footer input { 
    font-size: 16px !important; padding: 10px 14px !important; 
    border-radius: 20px; min-height: 42px;
  }
  .chat-panel .chat-footer button {
    font-size: .9rem !important; padding: 10px 16px !important;
    white-space: nowrap; flex-shrink: 0; min-width: 60px;
    touch-action: manipulation; user-select: none;
  }
  .chat-toolbar { 
    display: flex; gap: 4px; padding: 4px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .chat-toolbar .chat-tool-btn {
    width: 36px; height: 36px; font-size: 1rem;
  }
}
