/* ==========================================================================
   common.css — 所有页面共用的框架样式
   设计语言: 浅灰蓝底 + 纯白卡片 + 橙色主色 + 圆角/柔和阴影
   包含: 变量 / 顶部导航 / 广告位 / 页脚 / 弹窗 / 收藏抽屉 / 通用按钮&标签
   ========================================================================== */

:root {
  /* 主色 */
  --brand: #F97C12;
  --brand-dark: #E06B00;
  --brand-2: #FB9D4F;
  --brand-soft: #FFF3E9;

  /* 中性色 */
  --bg: #F4F7FB;
  --surface: #FFFFFF;
  --border: #EAEDF3;
  --border-strong: #DDE3EC;
  --text: #1F2530;
  --text-sub: #4A5464;
  --text-muted: #8A93A5;

  /* 语义色 */
  --green: #1FBF6B;
  --green-soft: #EBFBF2;
  --amber: #E8A100;
  --amber-soft: #FFF8E8;
  --blue: #3B7BFF;
  --blue-soft: #EEF4FF;
  --red: #F0554B;
  --red-soft: #FEECEB;

  /* 分类色 */
  --cat-recent: #FEA79C;
  --cat-image: #FDB771;
  --cat-data: #6799FF;

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --header-h: 64px;
  --content-w: 1240px;
  --shadow-card: 0 6px 20px rgba(31, 41, 55, .06);
  --shadow-pop: 0 18px 50px rgba(31, 41, 55, .18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* 通用内容容器 */
.container {
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 顶部导航 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: .2px;
}
.brand .brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(249, 124, 18, .22);
}
.brand .brand-name { color: var(--text); }

/* 收藏抽屉里的小图标 */
.reco-ico-sm {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.main-nav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  transition: all .15s;
}
.nav-link:hover { color: var(--brand); background: var(--brand-soft); }
.nav-link.active { color: var(--brand); }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 用户信息 */
.user-menu {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.user-menu .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.user-menu .uname { font-size: 14px; color: var(--text); }

/* ---------- 广告位 ---------- */
.ad-banner {
  max-width: var(--content-w);
  margin: 16px auto;
  padding: 0 24px;
}
.ad-inner {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #F8FAFC;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: .3px;
}
/* 当广告位已处于 .container 内部时，去掉自身的宽度与内边距，避免双重留白 */
.container .ad-banner { max-width: none; margin: 18px 0; padding: 0; }

/* ---------- 广告位状态 (由 core/ads.js 控制) ---------- */
/* 0 强制隐藏 / 1 自适应未拉取到广告 -> 整体不显示, 且不留白 */
[data-ad-slot][hidden],
[data-ad-slot].ad-hidden { display: none !important; }

/* ---------- 页脚 ---------- */
.app-footer {
  margin-top: 40px;
  padding: 26px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 6px 16px rgba(249, 124, 18, .25);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn-soft:hover { background: #FFE7D3; color: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-sub); }
.btn-ghost:hover { background: var(--bg); color: var(--brand); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------- 标签 / 徽标 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  white-space: nowrap;
}
.tag-free { background: var(--green-soft); color: var(--green); font-weight: 700; }
.tag-coin { background: var(--amber-soft); color: var(--amber); font-weight: 700; }
.tag-soft { background: var(--blue-soft); color: var(--text-sub); }
.tag-pro  { background: var(--amber-soft); color: var(--amber); font-weight: 700; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
}
.badge.pro { background: var(--amber-soft); color: var(--amber); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 36, .45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-mask.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 400px;
  max-width: 92vw;
  padding: 26px;
  box-shadow: var(--shadow-pop);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 18px; font-size: 18px; }
.modal .field { margin-bottom: 14px; }
.modal label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--text-muted); }
.modal input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.modal input:focus { border-color: var(--brand); }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ==========================================================================
   多语言: 语言切换按钮组 (顶部导航, 位于「收藏本页」左侧)
   ========================================================================== */
.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #F1F4F9;
}
.lang-btn {
  border: 0;
  background: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.lang-btn:hover { color: var(--brand); }
.lang-btn.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .14);
}

/* ==========================================================================
   页脚 (版权 + Cookie 设置 / 政策链接)
   ========================================================================== */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-links { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.footer-links .link-btn { color: var(--text-muted); font-weight: 500; text-decoration: none; }
.footer-links .link-btn:hover { color: var(--brand); }

/* ==========================================================================
   Cookie 同意模块 (顶部置顶条 + 偏好弹窗)
   由 assets/js/core/cookie.js 运行时创建, 页面无需写任何占位/逻辑
   ========================================================================== */
.cookie-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 14px 40px rgba(15, 23, 42, .16);
  animation: cookie-in .26s ease-out;
}
.cookie-bar.show { display: block; }
@keyframes cookie-in {
  from { transform: translateY(-100%); }
  to { transform: none; }
}
.cookie-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 28px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}
.cookie-text { max-width: 760px; }
.cookie-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: .2px;
}
.cookie-desc { font-size: 14px; line-height: 1.7; color: var(--text-sub); }
.cookie-link { color: var(--brand); font-weight: 600; text-decoration: underline; }
.cookie-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.cookie-actions .btn { padding: 11px 20px; font-size: 14px; }

/* 偏好设置弹窗 */
.modal-wide { width: min(640px, 92vw); }
.cookie-prefs-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin: 0 0 18px; }
.cookie-cats { display: flex; flex-direction: column; gap: 12px; }
.cookie-cat {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #FBFCFE;
}
.cookie-cat-name { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 5px; }
.cookie-cat-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; }
.cookie-cat-ctl { flex-shrink: 0; padding-top: 2px; }
.cookie-always { font-size: 12px; font-weight: 600; color: var(--green); }

/* 开关 */
.switch { display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #D5DBE5;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  transition: background .18s;
}
.switch-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .28);
  transition: transform .18s;
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }

@media (max-width: 860px) {
  .cookie-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 22px 20px;
  }
  .cookie-actions { justify-content: flex-end; }
  .cookie-title { font-size: 18px; }
  .cookie-desc { font-size: 13px; }
}

/* ---------- 收藏抽屉 ---------- */
.fav-drawer {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: 330px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(31, 41, 55, .08);
  transform: translateX(100%);
  transition: transform .25s;
  z-index: 900;
  padding: 22px;
  overflow-y: auto;
}
.fav-drawer.open { transform: translateX(0); }
.fav-drawer h3 { margin: 0 0 8px; font-size: 17px; }
.fav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.fav-item a { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.fav-item a:hover { color: var(--brand); }
