/* ==========================================================================
   PicPic 智图 · 全局样式
   - 移动端优先，桌面端居中显示
   - 6 套主题走 data-theme CSS 变量
   - 大字版：html.large-mode 放大根字号（全站 rem 布局，一次生效）
   ========================================================================== */

/* ---------------- 主题变量 ---------------- */
:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #fafbff;
  --text: #1b1f2a;
  --sub: #6b7280;
  --line: #e8eaf0;
  --brand: #4a6cf7;
  --brand-2: #7a5cff;
  --brand-soft: rgba(74, 108, 247, 0.12);
  --danger: #ef4444;
  --success: #22c55e;
  --topbar: #111318;
  --topbar-text: #ffffff;
  --shadow: 0 2px 10px rgba(20, 25, 45, 0.06);
  --shadow-lg: 0 8px 28px rgba(20, 25, 45, 0.12);
  --radius: 0.875rem;
}

[data-theme="dark"] {
  --bg: #111318;
  --panel: #191c23;
  --panel-2: #1f232b;
  --text: #e8eaf0;
  --sub: #9aa3b2;
  --line: #272b34;
  --brand: #7b93ff;
  --brand-2: #a78bfa;
  --brand-soft: rgba(123, 147, 255, 0.16);
  --topbar: #0c0e13;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.45);
}

[data-theme="blue"] {
  --bg: #eef4ff;
  --panel: #ffffff;
  --panel-2: #f6f9ff;
  --text: #12233f;
  --sub: #5b7191;
  --line: #d9e6ff;
  --brand: #2f6df6;
  --brand-2: #3aa0ff;
  --brand-soft: rgba(47, 109, 246, 0.12);
  --topbar: #16305c;
}

[data-theme="purple"] {
  --bg: #f4efff;
  --panel: #ffffff;
  --panel-2: #faf7ff;
  --text: #241a3d;
  --sub: #6e5f96;
  --line: #e4d9ff;
  --brand: #7c4dff;
  --brand-2: #b06ab3;
  --brand-soft: rgba(124, 77, 255, 0.12);
  --topbar: #2d1b4e;
}

[data-theme="green"] {
  --bg: #eefaf3;
  --panel: #ffffff;
  --panel-2: #f5fdf9;
  --text: #113528;
  --sub: #527d6b;
  --line: #d3f0e2;
  --brand: #18a06a;
  --brand-2: #34c78b;
  --brand-soft: rgba(24, 160, 106, 0.12);
  --topbar: #0f3b2c;
}

[data-theme="warm"] {
  --bg: #fff7ec;
  --panel: #ffffff;
  --panel-2: #fffaf3;
  --text: #3a2a16;
  --sub: #8a7052;
  --line: #f3e2c7;
  --brand: #e2842b;
  --brand-2: #f0a83c;
  --brand-soft: rgba(226, 132, 43, 0.14);
  --topbar: #4a3115;
}

/* ---------------- 基础 ---------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 组件用 display 布局，会覆盖浏览器默认的 [hidden]{display:none}，这里强制兜底 */
[hidden] { display: none !important; }

html { font-size: 16px; }
html.large-mode { font-size: 19px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  background: var(--topbar);
  color: var(--topbar-text);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.brand-logo { width: 1.5rem; height: 1.5rem; border-radius: 50%; object-fit: cover; }
.brand-name { font-size: 1.0625rem; letter-spacing: 0.02em; }
.top-actions { display: flex; gap: 0.5rem; }
.icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--topbar-text);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.8;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
.icon-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------- 布局 ---------------- */
.content {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  min-height: 60vh;
}

.site-footer {
  text-align: center;
  padding: 1.25rem 1rem 2rem;
  color: var(--sub);
  font-size: 0.8125rem;
}
.site-footer .dot { margin: 0 0.375rem; opacity: 0.5; }
.foot-link { color: var(--brand); }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.625rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.section-title .hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--sub);
}

.page-head { margin-bottom: 1rem; }
.page-title { font-size: 1.375rem; font-weight: 800; margin: 0 0 0.25rem; }
.page-desc { color: var(--sub); font-size: 0.875rem; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: var(--shadow); }
.btn-ghost { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 0.875rem 1rem; font-size: 1.0625rem; }
html.large-mode .btn { min-height: 2.875rem; padding: 0.75rem 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--brand); }
.chip.on {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}
html.large-mode .chip { font-size: 1rem; padding: 0.5rem 1rem; }

.field { width: 100%; }
.input, .textarea, .range {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel-2);
  color: var(--text);
  padding: 0.625rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
}
.textarea { min-height: 6rem; resize: vertical; line-height: 1.6; }
.input:focus, .textarea:focus { outline: none; border-color: var(--brand); }
.range { padding: 0.5rem 0; }

.row { display: flex; align-items: center; gap: 0.625rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.625rem; }
.muted { color: var(--sub); font-size: 0.8125rem; }
.mb-8 { margin-bottom: 0.5rem; }
.mb-12 { margin-bottom: 0.75rem; }
.mb-16 { margin-bottom: 1rem; }

/* ---------------- 首页 ---------------- */
.home-hero {
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  margin-bottom: 1rem;
  color: #16213a;
  background-size: cover;
}
.home-hero-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 0.25rem; }
.home-hero-sub { font-size: 0.875rem; margin: 0 0 0.875rem; opacity: 0.85; }
.quota-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.375rem;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 0.25rem 0.875rem;
  font-size: 0.75rem;
}
.quota-num { font-size: 1.125rem; font-weight: 800; color: var(--brand); }

.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.tool-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.875rem;
  box-shadow: var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tool-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  color: #fff;
  margin-bottom: 0.5rem;
}
.tool-name { font-weight: 700; font-size: 1rem; }
.tool-desc { color: var(--sub); font-size: 0.75rem; line-height: 1.5; }
.tool-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--brand);
  color: #fff;
  font-size: 0.625rem;
  border-radius: 999px;
  padding: 0.0625rem 0.375rem;
}
.tool-flag { position: absolute; top: 0.5rem; left: auto; right: 2.75rem; font-size: 1rem; }

.more-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.875rem;
  margin-bottom: 0.625rem;
}
.more-card:hover { border-color: var(--brand); }
.more-name { font-weight: 600; }
.more-desc { color: var(--sub); font-size: 0.75rem; }
.more-arrow { margin-left: auto; color: var(--sub); font-size: 1.25rem; }

.tip-item { color: var(--sub); font-size: 0.8125rem; margin-bottom: 0.375rem; }

/* ---------------- 上传 / 预览 ---------------- */
.uploader {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--sub);
  transition: border-color 0.15s;
}
.uploader:hover { border-color: var(--brand); }
.uploader-icon { font-size: 2rem; margin-bottom: 0.25rem; }
.uploader.has-image { padding: 0.5rem; border-style: solid; }

.preview {
  width: 100%;
  border-radius: 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.preview img { width: 100%; height: auto; display: block; }

.result-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow-lg);
}
.result-actions { display: flex; gap: 0.625rem; margin-top: 0.75rem; }
.result-actions .btn { flex: 1; }

.stat-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.625rem; }
.stat {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}
.stat b { color: var(--brand); }

/* 选项网格（风格 / 场景 / 优化项） */
.opt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 0.75rem;
  padding: 0.5rem 0.625rem;
  text-align: left;
  color: var(--text);
  transition: all 0.15s;
}
.opt:hover { border-color: var(--brand); }
.opt.on { background: var(--brand-soft); border-color: var(--brand); }
.opt-emoji { font-size: 1.125rem; flex: none; }
.opt-label { font-size: 0.875rem; font-weight: 600; }
.opt-desc { font-size: 0.6875rem; color: var(--sub); line-height: 1.4; }

/* 示例词 */
.example-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.example {
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--sub);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}
.example:hover { color: var(--brand); border-color: var(--brand); }

/* 调色板（拼豆） */
.palette { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.625rem; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.1875rem 0.375rem;
  font-size: 0.6875rem;
}
.swatch { width: 0.875rem; height: 0.875rem; border-radius: 0.1875rem; border: 1px solid rgba(0, 0, 0, 0.12); }

/* 九宫格切片 */
.slice-grid { display: grid; gap: 0.375rem; margin-top: 0.75rem; }
.slice-grid img { border-radius: 0.375rem; border: 1px solid var(--line); }

/* ---------------- 遮罩 / 提示 / 弹窗 ---------------- */
.mask {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(10, 14, 25, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.loading-box, .modal-box {
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem;
  width: 100%;
  max-width: 22rem;
  text-align: center;
}
.spinner {
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 auto 0.75rem;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 0.9375rem; }

.modal-title { font-size: 1.0625rem; font-weight: 700; margin-bottom: 0.5rem; }
.modal-content { color: var(--sub); font-size: 0.875rem; margin-bottom: 1rem; white-space: pre-wrap; }
.modal-actions { display: flex; gap: 0.625rem; }
.modal-actions .btn { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  max-width: 80vw;
  background: rgba(18, 22, 33, 0.92);
  color: #fff;
  border-radius: 0.75rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  text-align: center;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
}

/* ---------------- 其它 ---------------- */
.empty-tip { text-align: center; color: var(--sub); padding: 2rem 1rem; font-size: 0.875rem; }
.hidden { display: none !important; }
.canvas-holder { text-align: center; }
.canvas-holder canvas { max-width: 100%; height: auto; border-radius: 0.625rem; border: 1px solid var(--line); }

@media (min-width: 768px) {
  .tool-grid { grid-template-columns: repeat(3, 1fr); }
  .opt-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------------- 左侧功能导航 / 手机抽屉 ---------------- */
/* 手机（默认）：左侧抽屉，默认隐藏，.open 时滑出 */
#btn-menu { display: inline-flex; }
.side-nav {
  position: fixed;
  top: 3.4rem;
  left: 0;
  bottom: 0;
  width: 14rem;
  max-width: 80vw;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 60;
  transform: translateX(-110%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0.25s;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.side-nav.open { transform: translateX(0); visibility: visible; }

.nav-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 55;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}
.nav-scrim.show { opacity: 1; visibility: visible; }

/* 导航项：图标在上、文字在下，文字允许换行，完整显示不截断 */
.sn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0.3rem;
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 0.8125rem;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}
.sn-item:hover { background: var(--brand-soft); color: var(--brand); }
.sn-item.on { background: var(--brand); color: #fff; font-weight: 600; }
.sn-icon { font-size: 1.25rem; line-height: 1; flex: none; }
.sn-label {
  display: block;
  width: 100%;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
}

/* 桌面（≥960px）：常驻左侧固定栏，内容区避让 */
@media (min-width: 960px) {
  #btn-menu { display: none; }
  .nav-scrim { display: none !important; }
  .side-nav {
    top: 3.5rem;
    left: 0.5rem;
    bottom: auto;
    width: 10rem;
    max-width: none;
    transform: none;
    visibility: visible;
    border-right: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.5rem 0.4rem;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 4.5rem);
  }
  .content { padding-left: 11rem; }
}

.crumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.625rem;
  font-size: 0.8125rem;
  color: var(--sub);
}
.crumb-link { color: var(--sub); }
.crumb-link:hover { color: var(--brand); }
.crumb-sep { opacity: 0.5; }
.crumb-cur { color: var(--text); font-weight: 600; }

/* 顶部状态栏额度入口 */
.top-quota {
  font-size: 0.8125rem;
  color: #fff;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 999px;
  padding: 2px 10px;
  margin-right: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.top-quota:hover { background: rgba(255,255,255,0.22); }
.top-quota:active { transform: scale(0.97); }
