/* =========================================================
   菟乖乖资源小站 · 视觉精简版
   目标：白底 + 灰底、去边框、收窄层级；手机端首屏少占 100px
   结构（HTML 类名 / JS 逻辑）保持不变，只做视觉层
   ========================================================= */

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-2: #f2f2f5;
  --text: #16181d;
  --text-2: #5c6170;
  --text-3: #9ca1ad;
  --line: #e8e8ec;
  --brand: #4f5bd5;
  --brand-soft: #eceefc;
  --shadow: 0 1px 2px rgba(17, 19, 28, .04), 0 8px 22px rgba(17, 19, 28, .05);
  --radius: 12px;
  --tap: 36px;
}

[data-theme="dark"] {
  --bg: #0b0c10;
  --card: #15171d;
  --card-2: #1c1f27;
  --text: #eceef4;
  --text-2: #a3a9b8;
  --text-3: #868d9e;
  --line: #23262e;
  --brand: #808aff;
  --brand-soft: #1b1f2e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 26px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* 关键：作者样式的 display 会盖过浏览器默认的 [hidden]，必须显式兜底 */
[hidden] { display: none !important; }

.modal[hidden], .login[hidden], .more[hidden], .empty[hidden], .view[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background .25s, color .25s;
}

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }

a { color: inherit; text-decoration: none; }

/* 统一的下拉箭头，去掉系统自带那种粗黑三角 */
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 4.6 6 8l3.4-3.4' fill='none' stroke='%239ca1ad' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 10px 10px;
  padding-right: 22px;
  font-family: inherit;
  cursor: pointer;
}

/* ---------- 顶栏 ---------- */
.hdr {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.hdr-in {
  display: flex; align-items: center; gap: 16px;
  height: 62px;
  min-width: 0;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 0 1 auto; }

.logo {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  font-size: 18px;
  background: var(--brand-soft);
  border-radius: 10px;
}

.brand-txt { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-txt b {
  font-size: 16px; font-weight: 650; letter-spacing: .1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-txt i {
  font-style: normal; font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.hdr-actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* 搜索框：无边框浅底，聚焦才描边，视觉噪音更低 */
.search {
  display: flex; align-items: center; gap: 7px;
  background: var(--card-2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 11px;
  height: 36px;
  width: 260px;
  margin-left: auto;
  transition: background .2s, border-color .2s, box-shadow .2s;
}

.search:focus-within {
  background: var(--card);
  border-color: color-mix(in srgb, var(--brand) 55%, transparent);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.search svg { width: 15px; height: 15px; flex: none; stroke: var(--text-3); fill: none; stroke-width: 2; stroke-linecap: round; }

.search input {
  border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 14px; width: 100%; min-width: 0;
}

.search input::placeholder { color: var(--text-3); }

.search input::-webkit-search-cancel-button { display: none; }

.q-clear {
  border: 0; background: var(--card-2); color: var(--text-2);
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1;
  display: none; place-items: center; flex: none; padding: 0;
}
.search:focus-within .q-clear { background: #e9e9ee; }

.q-clear.show { display: grid; }

/* 图标按钮：去掉圆圈描边，只留 emoji 本体 */
.icon-btn {
  border: 0; background: transparent;
  width: var(--tap); height: var(--tap); border-radius: 9px; cursor: pointer;
  font-size: 16px; flex: none; padding: 0;
  display: grid; place-items: center;
  transition: background .18s, transform .18s;
}

.icon-btn:hover { background: var(--card-2); }
.icon-btn:active { transform: scale(.94); }

/* ---------- 主体容器 ---------- */
.main-wrap { padding-top: 14px; padding-bottom: 8px; }

/* 公告：白底细条 + 一个品牌色小点，替代原来整块紫色 */
.notice {
  position: relative;
  display: inline-block;
  max-width: 100%;
  background: var(--card);
  color: var(--text-2);
  border-radius: 10px;
  padding: 9px 12px 9px 25px;
  font-size: 12.5px;
  line-height: 1.55;
  margin-bottom: 12px;
  cursor: pointer;
  transition: background .18s;
}

.notice::before {
  content: ''; position: absolute; left: 12px; top: 50%;
  width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%;
  background: var(--brand);
}

.notice:hover { background: var(--card); }

/* ---------- 筛选胶囊（桌面） ---------- */
.chips {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none; cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13.5px;
  line-height: 1.4;
  white-space: nowrap;
  font-family: inherit;
  transition: background .18s, color .18s;
}

.chip:hover { background: var(--card); color: var(--text); }

.chip.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.chip em { font-style: normal; opacity: .55; font-size: 11.5px; margin-left: 4px; font-weight: 400; }

/* 深色下小号数字/次要文字对比度本来就低，单独提亮一档 */
[data-theme="dark"] .chip em { opacity: .75; }

/* 网盘筛选行：与分类行平行，视觉上更轻 */
.chips-pf { padding: 0 0 8px; }
.chips-pf .chip { padding: 4px 10px; font-size: 12.5px; color: var(--text-3); }
.chips-pf .chip:hover { color: var(--text); }
.chips-pf .chip.on { color: var(--brand); background: var(--brand-soft); font-weight: 600; }

/* ---------- 工具条（数量 + 排序） ---------- */
.toolbar { display: block; }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 2px 12px;
  min-height: 24px;
}

.count { font-size: 12.5px; color: var(--text-3); }

.sortsel { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }

.sortsel select {
  border: 0; background-color: transparent; color: var(--text-2);
  border-radius: 8px; padding: 4px 20px 4px 4px; font-size: 12.5px; outline: 0;
  transition: background-color .18s;
}
.sortsel select:hover { background-color: var(--card); }

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 20px 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column;
  box-shadow: 0 1px 2px rgba(17, 19, 28, .035);
  transition: transform .2s ease, box-shadow .2s ease;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.cover {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--c1, #6a7bff), var(--c2, #8f6bff));
}

.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cover .folder { font-size: 38px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .18)); }

/* 线路数在 meta 里已经有一条，封面角标是重复信息，收起 */
.cover .badge-n { display: none; }

.cover .pin {
  position: absolute; top: 7px; left: 7px;
  background: rgba(255, 255, 255, .94); color: #1b1d23;
  font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px;
  backdrop-filter: blur(4px);
}

.card-b { padding: 9px 12px 11px; display: flex; flex-direction: column; gap: 7px; flex: 1; }

.card-t {
  font-size: 14px; font-weight: 600; line-height: 1.42; letter-spacing: .1px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 40px;
  margin: 0;
}

.card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-m { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.dot-row { display: flex; gap: 3px; }

.dot { width: 15px; height: 15px; border-radius: 4px; color: #fff; font-size: 9px; display: grid; place-items: center; font-weight: 700; }

.meta { font-size: 11.5px; color: var(--text-3); }

/* ---------- 空态 / 加载更多 ---------- */
.empty { text-align: center; padding: 60px 16px; color: var(--text-3); }
.empty-ico { font-size: 40px; margin-bottom: 8px; opacity: .8; }
.empty p { margin: 0 0 14px; font-size: 14px; }

.btn {
  border: 1px solid transparent; background: var(--brand); color: #fff;
  border-radius: 9px; padding: 8px 16px; font-size: 13.5px; cursor: pointer;
  font-family: inherit;
  transition: filter .2s;
}

.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }

.more {
  display: block; margin: 24px auto 36px;
  border: 0; background: var(--card); color: var(--text-2);
  border-radius: 999px; padding: 9px 24px; cursor: pointer; font-size: 13.5px;
  font-family: inherit;
  transition: color .2s, box-shadow .2s;
}

.more:hover { color: var(--text); box-shadow: var(--shadow); }

/* ---------- 详情弹层 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; }

.mask { position: absolute; inset: 0; background: rgba(10, 12, 18, .5); backdrop-filter: blur(3px); }

.sheet {
  position: relative;
  width: min(560px, calc(100% - 28px));
  max-height: 86vh; overflow: auto;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  animation: pop .22s ease;
  -webkit-overflow-scrolling: touch;
}

@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.sheet-x {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 0; background: rgba(0, 0, 0, .35); color: #fff; font-size: 18px; line-height: 1;
  backdrop-filter: blur(6px);
}

.sheet-banner {
  height: 150px; display: grid; place-items: center; font-size: 50px;
  background: linear-gradient(135deg, var(--c1, #6a7bff), var(--c2, #8f6bff));
}

.sheet-banner img { width: 100%; height: 150px; object-fit: cover; display: block; }

.sheet-body { padding: 16px 20px 22px; }

.sheet-cat { font-size: 11.5px; color: var(--brand); font-weight: 600; margin-bottom: 4px; letter-spacing: .3px; }

.sheet-body h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.4; }

.sheet-desc { margin: 0 0 12px; color: var(--text-2); font-size: 13.5px; white-space: pre-wrap; }

.tagrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.tag { background: var(--card-2); color: var(--text-2); font-size: 11.5px; padding: 3px 9px; border-radius: 999px; }

.links { display: flex; flex-direction: column; gap: 8px; }

.link-item {
  display: flex; align-items: center; gap: 10px;
  border-radius: 11px;
  padding: 9px 10px; background: var(--card-2);
}

.link-pf {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700;
}

.link-name { font-size: 13.5px; font-weight: 500; }

.link-note { font-size: 11px; color: var(--text-3); }

.link-code {
  font: 11.5px/1 ui-monospace, Menlo, Consolas, monospace;
  background: var(--card); border: 1px dashed var(--line);
  padding: 3px 6px; border-radius: 5px; color: var(--text-2);
}

.link-acts { margin-left: auto; display: flex; gap: 6px; flex: none; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg);
  padding: 9px 18px; border-radius: 999px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 99;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 页脚 ---------- */
.ft { margin-top: 26px; padding: 22px 0 34px; color: var(--text-3); font-size: 12.5px; }
.ft p { margin: 0; }
.ft-sub { margin-top: 4px; opacity: .8; }

.ft-contact {
  margin-top: 12px;
  border: 0;
  background: var(--card);
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: color .2s, box-shadow .2s;
}

.ft-contact:hover { color: var(--brand); box-shadow: var(--shadow); }

/* ---------- 内置浏览器（微信 / QQ）提示条 ---------- */
.inapp {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff8e8; color: #8a5a00;
  border-bottom: 1px solid #ffedc7;
  padding: 8px 20px; font-size: 12.5px;
}
[data-theme="dark"] .inapp {
  background: #322812; color: #ffd591; border-bottom-color: #4a3a18;
}
.inapp b { font-weight: 700; }
.inapp button {
  margin-left: auto; flex: none;
  border: 1px solid currentColor; background: transparent; color: inherit;
  border-radius: 7px; padding: 4px 11px; font-size: 12px; cursor: pointer;
  font-family: inherit;
}

/* ---------- 联系站长 ---------- */
.qr-wrap { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.qr-card {
  border-radius: 12px;
  padding: 10px;
  width: 148px;
  text-align: center;
  background: var(--card-2);
  position: relative;
}

/* 二维码必须完整露出：cover 会把非正方形的码裁掉一角，直接扫不出来 */
.qr-card img {
  width: 122px; height: 122px; object-fit: contain;
  border-radius: 8px; display: block; margin: 6px auto 8px; background: #fff;
}

.qr-tag {
  position: absolute; top: 6px; right: 6px;
  font-size: 10px; line-height: 1; font-weight: 600;
  padding: 4px 6px; border-radius: 5px;
  background: #1aad19; color: #fff;
}
.qr-tag.is-qq { background: #12b7f5; }

.qr-card .qr-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.qr-card .qr-tip { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.contact-rows { display: flex; flex-direction: column; gap: 8px; }

.contact-row {
  display: flex; align-items: center; gap: 10px;
  border-radius: 11px;
  padding: 9px 10px; background: var(--card-2);
}

.contact-row .c-ico { font-size: 17px; flex: none; }
.contact-row .c-name { font-size: 13px; font-weight: 500; }
.contact-row .c-val {
  font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--text-3);
}
.contact-row .c-act { margin-left: auto; flex: none; }

.ct-empty { color: var(--text-3); font-size: 13px; margin: 0; }
.ct-note { font-size: 12px; color: var(--text-3); margin: 14px 0 0; }

/* ---------- 手机端 ================================================
   目标：把一个屏幕 27% 的头部压到 16% 左右
   1) 品牌 + 搜索 + 两个图标挤在同一行（52px）
   2) 公告收成单行，点一下展开
   3) 分类 / 网盘 / 排序 收成一行下拉
   ================================================================ */

.m-sel { display: none; }

@media (max-width: 720px) {
  .wrap { padding: 0 14px; }

  /* --- 顶栏：单行 --- */
  .hdr-in {
    flex-wrap: nowrap;
    gap: 8px;
    height: 52px;
    padding-top: 0; padding-bottom: 0;
  }

  .logo { width: 28px; height: 28px; border-radius: 8px; font-size: 15px; }

  .brand { flex: 0 1 auto; gap: 7px; min-width: 0; }
  .brand-txt { min-width: 0; }
  .brand-txt b { font-size: 14.5px; max-width: 34vw; }
  .brand-txt i { display: none; }

  .search {
    margin-left: auto;
    width: 0;
    flex: 1 1 0;
    min-width: 0;
    height: 34px;
    padding: 0 10px;
    border-radius: 9px;
  }
  .search input { font-size: 13.5px; }

  .hdr-actions { gap: 0; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; }

  .inapp { padding: 7px 14px; font-size: 12px; gap: 8px; }
  .inapp button { padding: 4px 10px; font-size: 11.5px; margin-left: 0; }

  /* --- 公告：单行 + 可展开 --- */
  .main-wrap { padding-top: 10px; }
  .notice {
    display: block;
    max-width: none;
    padding: 7px 11px 7px 24px;
    font-size: 12px;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .notice::before { left: 11px; }
  .notice.open { white-space: normal; overflow: visible; }

  /* --- 两排胶囊换成一行下拉 --- */
  .chips, .chips-pf { display: none; }

  .toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
    min-height: 34px;
    min-width: 0;
  }

  .m-sel {
    display: flex;
    gap: 6px;
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    margin: 0;
  }

  .m-sel select {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    height: 34px;
    border: 0;
    background-color: var(--card);
    color: var(--text-2);
    border-radius: 9px;
    padding: 0 22px 0 10px;
    font-size: 12.5px;
    outline: 0;
    text-overflow: ellipsis;
  }

  .bar { padding: 0; margin: 0; flex: 0 0 auto; min-height: 0; }
  .bar .count { display: none; }
  .sortsel { gap: 0; }
  .sortsel-t { display: none; }
  .sortsel select {
    height: 34px;
    background-color: var(--card);
    color: var(--text-2);
    border-radius: 9px;
    padding: 0 22px 0 10px;
    font-size: 12.5px;
    max-width: 92px;
  }

  /* --- 卡片：横向条状，更紧 --- */
  .grid { grid-template-columns: 1fr; gap: 9px; }
  .card {
    flex-direction: row; align-items: center;
    gap: 12px; padding: 10px;
    border-radius: 11px;
  }
  .card:hover { transform: none; }
  .cover { width: 64px; height: 64px; aspect-ratio: 1 / 1; border-radius: 9px; flex: none; }
  .cover .folder { font-size: 22px; }
  .cover .pin {
    width: 100%; height: 100%; top: 0; left: 0; border-radius: 0;
    display: grid; place-items: center; padding: 0;
    background: rgba(0, 0, 0, .42); color: #fff; font-size: 10px;
  }
  .card-b { padding: 0; gap: 3px; min-width: 0; }
  .card-t { min-height: 0; font-size: 13.5px; line-height: 1.35; -webkit-line-clamp: 2; }
  .card-foot { gap: 5px; }
  .card-m { gap: 4px; }
  .dot { width: 13px; height: 13px; font-size: 8px; border-radius: 3px; }
  .meta { font-size: 11.5px; }

  .more { margin: 16px auto 28px; }

  /* --- 弹层 --- */
  .sheet { max-height: 90vh; border-radius: 16px; }
  .sheet-banner { height: 116px; }
  .sheet-banner img { height: 116px; }
  .sheet-body { padding: 14px 16px 18px; }
  .link-item { flex-wrap: wrap; }
  .link-acts { margin-left: 0; width: 100%; }
  .link-acts .btn { flex: 1; text-align: center; }
  .qr-wrap { gap: 8px; }
  .qr-card { width: calc(50% - 4px); }
  .qr-card img { width: 100%; height: auto; aspect-ratio: 1 / 1; }

  .ft { margin-top: 18px; padding: 16px 0 26px; }
}

@media (max-width: 380px) {
  .brand-txt b { max-width: 26vw; font-size: 14px; }
  .m-sel select, .sortsel select { font-size: 12px; padding-left: 8px; padding-right: 20px; }
  .sortsel select { max-width: 84px; }
}
