/* 芸集 App — 设计系统
   暖纸墨色 · 延续芸集官网视觉 DNA，移动原生化 */

/* ══════════ Tokens ══════════ */
:root {
  --bg: #f6f3ed;
  --bg-blur: rgba(246, 243, 237, 0.86);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #fffdf9;
  --ink: #2a2520;
  --ink-2: #807870;
  --ink-3: #a89e8f;
  --line: rgba(42, 37, 32, 0.08);
  --chip-bg: rgba(42, 37, 32, 0.05);
  --chip-active-bg: #2a2520;
  --chip-active-ink: #f6f3ed;
  --sheet-bg: #fffdf9;
  --toast-bg: #2a2520;
  --toast-ink: #f6f3ed;
  --shadow-card: 0 1px 2px rgba(42, 37, 32, 0.04);
  --shadow-pop: 0 12px 40px rgba(42, 37, 32, 0.14);
  --card-tag-ink: #6f6860;
  --card-host-ink: #a89e8f;
  --icon-tint-pct: 9%;

  --ff-serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'SimSun', serif;
  --ff-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', sans-serif;

  --ease-spring: cubic-bezier(0.2, 0.8, 0.2, 1);
  --r-card: 16px;
  --r-tile: 12px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --max-w: 560px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191611;
    --bg-blur: rgba(25, 22, 17, 0.88);
    --surface: rgba(255, 255, 255, 0.055);
    --surface-solid: #24201a;
    --ink: #ece6da;
    --ink-2: #a89d8c;
    --ink-3: #7d7365;
    --line: rgba(236, 230, 218, 0.1);
    --chip-bg: rgba(236, 230, 218, 0.09);
    --chip-active-bg: #ece6da;
    --chip-active-ink: #191611;
    --sheet-bg: #24201a;
    --toast-bg: #ece6da;
    --toast-ink: #191611;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.45);
    --card-tag-ink: #b3a897;
    --card-host-ink: #6e6455;
    --icon-tint-pct: 15%;
  }
}

/* ══════════ Base ══════════ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--ff-sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(42, 37, 32, 0.15); }

/* ══════════ Hero ══════════ */
.hero { padding: calc(env(safe-area-inset-top, 0px) + 22px) 20px 6px; }
.hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.brand-title {
  font-family: var(--ff-serif);
  font-weight: 600;
  font-size: 34px;
  letter-spacing: 0.14em;
  line-height: 1.1;
}
.brand-sub { color: var(--ink-3); font-size: 12px; letter-spacing: 0.08em; margin-top: 2px; }

.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  transition: transform 0.18s var(--ease-spring), opacity 0.18s;
  animation: pop-in 0.4s var(--ease-spring);
}
.install-btn:active { transform: scale(0.94); }

/* ══════════ Sticky 搜索 + 分类 ══════════ */
.stick {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-blur);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.stick-inner { max-width: var(--max-w); margin: 0 auto; padding: 10px 20px 10px; }

.searchbox {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  height: 44px;
  padding: 0 12px 0 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.searchbox:focus-within { border-color: rgba(42, 37, 32, 0.28); box-shadow: 0 0 0 3px rgba(42, 37, 32, 0.06); }
.search-ico { color: var(--ink-3); flex: none; }
#search {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  padding: 0 8px;
}
#search::placeholder { color: var(--ink-3); }
#search::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 2px;
  padding-right: 28px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.2s, color 0.2s, transform 0.18s var(--ease-spring);
}
.chip .n { font-size: 11px; color: var(--ink-3); font-weight: 400; }
.chip:active { transform: scale(0.94); }
.chip[aria-pressed="true"] { background: var(--chip-active-bg); color: var(--chip-active-ink); }
.chip[aria-pressed="true"] .n { color: var(--chip-active-ink); opacity: 0.6; }
.chips.locked .chip:not([aria-pressed="true"]) { opacity: 0.4; }

/* ══════════ Main ══════════ */
.main { max-width: var(--max-w); margin: 0 auto; padding: 6px 20px 24px; }

.sec { margin-top: 22px; }
.sec-title {
  font-family: var(--ff-serif);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.sec-title .cnt { font-family: var(--ff-sans); font-size: 11.5px; color: var(--ink-3); letter-spacing: 0; font-weight: 400; }

/* ══════════ 卡片网格 ══════════ */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 12px 12px 11px;
  text-decoration: none;
  transition: transform 0.18s var(--ease-spring), border-color 0.2s;
  -webkit-touch-callout: none;
}
.card:active { transform: scale(0.965); }
@media (hover: hover) { .card:hover { border-color: rgba(42, 37, 32, 0.2); } }

.card-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-tile);
  display: grid;
  place-items: center;
  margin-bottom: 9px;
  background: color-mix(in srgb, var(--pc) var(--icon-tint-pct), transparent);
}
.card-icon svg { width: 26px; height: 26px; }

.card-name {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-tag {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 12px;
  color: var(--card-tag-ink);
  margin-top: 3px;
  line-height: 1.45;
  min-height: 2.9em;
}
.card-fav {
  position: absolute;
  top: 10px; right: 10px;
  width: 18px; height: 18px;
  color: var(--pc);
}
.card-fav svg { width: 100%; height: 100%; }
.card-host {
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--card-host-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

/* 入场动效 */
.card { opacity: 0; animation: rise-in 0.5s var(--ease-spring) forwards; animation-delay: calc(var(--i, 0) * 24ms); }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

/* ══════════ 最近（横滑行） ══════════ */
.recents {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.recents::-webkit-scrollbar { display: none; }
.rt {
  flex: none;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  -webkit-touch-callout: none;
}
.rt-icon {
  width: 56px; height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  transition: transform 0.18s var(--ease-spring);
}
.rt:active .rt-icon { transform: scale(0.9); }
.rt-icon svg { width: 30px; height: 30px; }
.rt-name {
  width: 100%;
  font-size: 11px;
  color: var(--ink-2);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════ 空态 / 提示 ══════════ */
.empty { text-align: center; padding: 60px 24px 40px; }
.empty-mark {
  font-family: var(--ff-serif);
  font-size: 44px;
  color: var(--ink-3);
  opacity: 0.35;
  margin-bottom: 12px;
}
.empty-text { font-size: 15px; color: var(--ink-2); }
.empty-text span { color: var(--ink); font-weight: 500; }
.empty-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }

.tip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 26px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--chip-bg);
  color: var(--ink-2);
  font-size: 12.5px;
}
.tip button {
  flex: none;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}

/* ══════════ Footer ══════════ */
.foot {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 8px 20px calc(20px + var(--safe-b));
  border-top: 1px solid var(--line);
  text-align: center;
}
.foot-btn {
  min-height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  transition: color 0.2s, transform 0.18s var(--ease-spring);
}
.foot-btn:active { transform: scale(0.95); color: var(--ink); }
.foot-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.foot-meta a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }

/* ══════════ 面板（动作 / 关于） ══════════ */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(20, 16, 10, 0.4);
  opacity: 0;
  transition: opacity 0.24s;
}
.backdrop.show { opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  margin: 0 auto;
  max-width: var(--max-w);
  background: var(--sheet-bg);
  border-radius: 22px 22px 0 0;
  padding: 8px 20px calc(14px + var(--safe-b));
  box-shadow: var(--shadow-pop);
  transform: translateY(105%);
  transition: transform 0.3s var(--ease-spring);
  will-change: transform;
}
.sheet.show { transform: translateY(0); }
.sheet[hidden] { display: none; }
.sheet-grip {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 4px auto 12px;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.sheet-head .sh-icon {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--pc) 10%, transparent);
  flex: none;
}
.sheet-head .sh-icon svg { width: 28px; height: 28px; }
.sh-name { font-size: 16px; font-weight: 600; }
.sh-tag { font-size: 12px; color: var(--ink-2); margin-top: 1px; }

.sheet-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sheet-act {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px 10px;
  border-radius: 14px;
  background: var(--chip-bg);
  font-size: 12px;
  color: var(--ink-2);
  transition: transform 0.18s var(--ease-spring);
}
.sheet-act:active { transform: scale(0.93); }
.sheet-act svg { color: var(--ink); }

.sheet-cancel {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  border-radius: 14px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.sheet-cancel:active { background: var(--chip-bg); }

/* 关于面板 */
.about-head { text-align: center; padding: 6px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.about-mark {
  font-family: var(--ff-serif);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.2;
}
.about-title { font-family: var(--ff-serif); font-size: 17px; letter-spacing: 0.2em; margin-top: 4px; }
.about-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

.install-guide { display: grid; gap: 10px; }
.ig-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--chip-bg);
  font-size: 13px;
  color: var(--ink-2);
}
.ig-item strong { color: var(--ink); font-weight: 600; margin-right: 6px; }
.ig-item .ig-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-solid); border: 1px solid var(--line); display: grid; place-items: center; font-size: 16px; }
.about-note { font-size: 11.5px; color: var(--ink-3); text-align: center; margin: 14px 0 4px; line-height: 1.6; }

/* ══════════ Toast ══════════ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 120;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s var(--ease-spring);
  pointer-events: none;
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ══════════ 桌面适配 ══════════ */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .brand-title { font-size: 38px; }
}

/* ══════════ 减少动态 ══════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
