* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f5f5f5;
  --card-bg: #fff;
  --text: #333;
  --text-secondary: #666;
  --accent: #4A90D9;
  --accent-hover: #357ABD;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* 全局 hidden 语义（与 maker.css L9 对齐）：hidden 属性 = 不渲染，防背板类 fixed 元素载入即挡页 */
[hidden] { display: none !important; }

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 16px 16px 12px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.header h1 {
  font-size: 22px;
  margin-bottom: 12px;
}

.search-bar {
  position: relative;   /* 搜索联想面板的定位锚点 */
  display: flex;
  flex: 1;              /* 与「制作」入口并排时填满剩余宽度 */
  gap: 8px;
  max-width: 480px;
  margin: 0;
}

.search-bar input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-bar button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---- 汉堡菜单（主页） ---- */
.menu-btn { flex-shrink:0; width:44px; height:44px; border:none; border-radius:50%;
  background:transparent; display:flex; flex-direction:column; align-items:center;
  justify-content:center; gap:4px; cursor:pointer; }
.menu-btn:hover { background:var(--card-bg); }
.menu-bar { width:18px; height:2px; background:var(--text); border-radius:1px; }
.menu-drawer { position:fixed; top:0; left:0; bottom:0; width:min(280px,82vw);
  background:var(--card-bg); z-index:900; transform:translateX(-100%);
  transition:transform .22s ease; padding:16px 12px; overflow-y:auto;
  box-shadow:var(--shadow); }
.menu-drawer.open { transform:translateX(0); }
.menu-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:899; }
.menu-section-label { font-size:12px; color:var(--text-secondary); padding:8px 12px; }
.menu-group, .menu-item { display:flex; align-items:center; gap:6px; width:100%;
  min-height:44px; padding:0 12px; border:none; border-radius:8px; background:transparent;
  font-size:15px; color:var(--text); text-decoration:none; cursor:pointer; }
.menu-group:hover, .menu-item:hover { background:var(--bg); }
.menu-arrow { margin-left:auto; transition:transform .15s ease; }
.menu-group[aria-expanded="true"] .menu-arrow { transform:rotate(90deg); }
.menu-sub { display:none; }
.menu-sub.open { display:block; }
.menu-sub .menu-item { padding-left:28px; font-size:14px; }
.menu-note { font-size:12px; color:var(--text-secondary); }

/* ---- 一级导航 ---- */
.primary-nav {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.primary-btn {
  padding: 10px 20px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.primary-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---- 二级导航 ---- */
/* ---- 二级：首字母 A-Z ---- */
.letter-nav {
  display: flex;
  gap: 4px;
  padding: 8px 16px 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--border);
}

.letter-nav::-webkit-scrollbar { height: 6px; }
.letter-nav::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 3px;
}
.letter-nav::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.letter-btn {
  min-width: 30px;
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}

.letter-btn:hover { background: var(--border); }

.letter-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ---- 三级：作品名 ---- */
.secondary-nav {
  display: flex;
  gap: 6px;
  padding: 8px 16px 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  /* 二级标签上百个，滚动条必须常显 —— 藏起来用户就不知道右边还有 */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--border);
}

/* WebKit（Chrome / Safari / Edge）：可见的横向滚动条 */
.secondary-nav::-webkit-scrollbar { height: 6px; }
.secondary-nav::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 3px;
}
.secondary-nav::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}
.secondary-nav::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }

.secondary-btn {
  padding: 4px 14px;
  border: 1px solid var(--accent);
  border-radius: 16px;
  background: var(--card-bg);
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.secondary-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ---- Gallery ---- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 8px 80px;
}

.sticker-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 1;
  cursor: pointer;
  transition: transform 0.15s;
}

.sticker-card:active {
  transform: scale(0.95);
}

.sticker-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sticker-card .tags {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
}

.sticker-card .card-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sticker-card .tag {
  display: inline-block;
  font-size: 10px;
  color: #fff;
  margin-right: 4px;
}

/* ---- Loading ---- */
.loading,
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

/* ---- Preview Modal ---- */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.preview-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.preview-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.preview-close:hover {
  background: rgba(255,255,255,0.3);
}

.preview-overlay img {
  max-width: 90vw;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
}

.preview-info {
  color: #ccc;
  font-size: 13px;
  margin: 12px 0;
  text-align: center;
}

.preview-actions {
  display: flex;
  gap: 12px;
}

.pa-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.2s;
}

.pa-btn:hover {
  background: var(--accent-hover);
}

/* ---- Context Menu ---- */
.context-menu {
  position: fixed;
  z-index: 400;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  min-width: 160px;
  padding: 6px 0;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: opacity 0.15s, transform 0.15s;
}

.context-menu.show {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.cm-item {
  display: block;
  width: 100%;
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.cm-item:hover {
  background: #f0f0f0;
}

/* ---- 搜索联想面板 ---- */
.search-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 150;
}

.search-suggest[hidden] {
  display: none;
}

.ss-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.ss-item:hover {
  background: #f0f0f0;
}

/* ---- 固定分页 ---- */
.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 8px;
}

.pagination:empty {
  display: none;
}

.page-btn {
  min-width: 36px;
  min-height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.page-btn:hover {
  background: var(--border);
}

.page-btn.active {
  background: var(--accent);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.page-ellipsis {
  min-width: 36px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

/* ====== Landing Page ====== */

.landing {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 40px 20px;
  text-align: center;
}

.landing-hero {
  margin-bottom: 40px;
}

.app-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.app-name-cn {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 4px;
}

.app-name-en {
  font-size: 16px;
  opacity: 0.8;
  margin-bottom: 12px;
  font-style: italic;
}

.app-desc {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 24px;
}

.download-btn {
  display: inline-block;
  padding: 14px 40px;
  background: #fff;
  color: #667eea;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* ---- Features ---- */

.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}

.feature-card {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 20px 14px;
  text-align: center;
}

.feature-card .feat-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.feature-card h3 {
  font-size: 15px;
  margin-bottom: 4px;
}

.feature-card p {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.5;
}

/* ---- Download Section ---- */

.download-section {
  background: #fff;
  padding: 48px 20px;
  text-align: center;
}

.download-section h2 {
  font-size: 24px;
  margin-bottom: 8px;
  color: #333;
}

.dl-sub {
  font-size: 14px;
  color: #888;
  margin-bottom: 24px;
}

.dl-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.dl-btn-primary {
  display: inline-block;
  padding: 16px 48px;
  background: #667eea;
  color: #fff;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}

.dl-btn-primary:hover {
  background: #5a6fd6;
}

.dl-hint {
  font-size: 13px;
  color: #999;
}

.qr-box {
  width: 140px;
  height: 140px;
  border: 2px dashed #ddd;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 32px;
}

.qr-box small {
  font-size: 11px;
  margin-top: 4px;
}

.dl-note {
  margin-top: 24px;
  font-size: 12px;
  color: #999;
  line-height: 1.8;
}

/* ---- Sticker Section ---- */

.sticker-section {
  background: #f5f5f5;
  padding: 32px 20px 0;
  text-align: center;
}

.sticker-section h2 {
  font-size: 20px;
  color: #333;
}

/* ---- Footer ---- */

.footer {
  background: #2d2d2d;
  color: #999;
  text-align: center;
  padding: 32px 20px;
  font-size: 14px;
}

.footer-small {
  margin-top: 8px;
  font-size: 12px;
  color: #666;
}

/* ---- Responsive ---- */

@media (max-width: 400px) {
  .features {
    grid-template-columns: 1fr;
  }
  .app-name-cn {
    font-size: 28px;
  }
}

/* ---- 上传入口 ---- */
.upload-entry-btn {
  display: block;
  margin: 10px 16px;
  padding: 10px 18px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.upload-entry-btn:hover {
  background: #eef5fc;
}

/* ---- 上传图的角标 ---- */
.up-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  pointer-events: none;
}

/* ---- 上传弹窗 ---- */
.up-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 1000;
  pointer-events: none;   /* 透明态不拦截点击（修复 AI 页「打不开」bug：无此规则时全屏透明层吞掉所有点击） */
}
.up-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.up-dialog {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 20px 18px 14px;
  transform: translateY(8px);
  transition: transform 0.15s;
}
.up-overlay.show .up-dialog {
  transform: none;
}

.up-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
}

.up-title {
  margin: 0 0 14px;
  font-size: 17px;
  color: var(--text);
}

.up-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
}

.up-field {
  display: block;
  margin-bottom: 14px;
}

.up-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.up-file,
.up-text {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  font-family: inherit;
}
.up-text:focus {
  outline: none;
  border-color: var(--accent);
}

.up-picked:empty {
  display: none;
}
.up-thumb {
  display: block;
  max-width: 100%;
  max-height: 140px;
  margin: 0 auto 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ---- 是否单角色 ---- */
.up-choices {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}
.up-choice {
  flex: 1;
  padding: 14px 0;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.up-choice:hover {
  background: var(--accent);
  color: #fff;
}

/* ---- 角色名多行 ---- */
.up-char-list {
  margin-bottom: 10px;
}
.up-char-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.up-char-row .up-char {
  flex: 1;
}
.up-remove {
  flex: 0 0 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.up-remove:hover {
  border-color: #d9534f;
  color: #d9534f;
}
.up-add {
  width: 100%;
  padding: 8px 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
}
.up-add:hover {
  border-color: var(--accent);
  background: #eef5fc;
}

/* ---- 底部按钮 ---- */
.up-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}
.up-btn {
  padding: 9px 22px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}
.up-btn.hidden {
  display: none;
}
.up-primary {
  background: var(--accent);
  color: #fff;
}
.up-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.up-cancel {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ---- 提示条 ---- */
.up-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 12px);
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 1100;
}
.up-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
