/* ── 设计令牌：一次定义，全站继承 ───────────────────────────── */
:root {
  --bg: #f7f8fa;          /* 页面底色：浅灰，让白卡片浮起来 */
  --surface: #ffffff;     /* 卡片 / 弹层 */
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e8eaed;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-2: 0 4px 12px rgba(16, 24, 40, .06);
  --shadow-3: 0 12px 28px rgba(16, 24, 40, .12);
  --page-max: 1040px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 calc(48px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Helvetica Neue",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* 页面容器：最大宽度 + 左右安全区 */
.wrap {
  max-width: var(--page-max);
  margin: 0 auto;
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
}

.spacer { flex: 1; }

/* ── 首页 Hero ── */
.hero { padding: 72px 0 32px; }
.hero h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: 0;
}
.hero p { color: var(--muted); margin: 12px 0 0; font-size: .95rem; }

/* 版本徽标：肉眼确认线上是否已更新（发版三件套之一） */
.app-version {
  font-size: .68rem;
  font-weight: 500;
  margin-left: 10px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
  vertical-align: middle;
}

/* ── 首页入口卡（现在只一个：提示词库）── */
.entries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.entry-card {
  display: block;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: inherit;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.entry-card:hover {
  transform: translateY(-2px);
  border-color: #dcdff0;
  box-shadow: var(--shadow-2);
}
.entry-card .t { font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; }
.entry-card .d { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.entry-card .arrow { color: var(--accent); font-size: .85rem; font-weight: 500; margin-top: 14px; }

/* ── 提示词库顶栏（吸顶）── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 248, 250, .88);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 12px calc(20px + env(safe-area-inset-left)) 12px calc(20px + env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar h1 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}
.count {
  font-size: .72rem;
  color: var(--muted);
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

/* ── 通用小元素 ── */
a.back {
  color: var(--muted);
  font-size: .85rem;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
}
a.back:hover { background: var(--surface); color: var(--fg); }

.section-title {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 32px 0 0;
}

/* ── 提示词库：卡片网格（图优先）+ 标题压在图上 ─────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin: 20px 0 0;
}

.card {
  position: relative;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: #dcdff0;
  box-shadow: var(--shadow-2);
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;   /* 可被内联 style 覆盖（读 params.aspect_ratio） */
  object-fit: cover;
  background: #eef0f3;
}
.card .noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 9 / 16;
  background: #eef0f3;
  color: var(--muted);
  font-size: .8rem;
}

/* 图上渐变遮罩 + 白字标题 */
.card-veil {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 30px 12px 11px;
  background: linear-gradient(to top, rgba(15, 23, 42, .84), rgba(15, 23, 42, 0));
  color: #fff;
  pointer-events: none;
}
.card-title {
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-tool {
  font-size: .66rem;
  opacity: .8;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 骨架屏（加载中）── */
.sk {
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eceef1 25%, #f5f6f8 37%, #eceef1 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.3s ease infinite;
}
.sk-card { aspect-ratio: 9 / 16; }
@keyframes sk-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* 空状态 */
.empty {
  margin: 28px 0 0;
  padding: 44px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}

/* ── 详情弹层（宽屏双栏）── */
.detail {
  width: min(880px, calc(100vw - 32px));
  max-height: 86vh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.detail::backdrop {
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.detail-head strong { font-size: .95rem; letter-spacing: -.01em; }

.detail-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  padding: 16px;
  max-height: calc(86vh - 59px);
  overflow: auto;
}
.detail-body img {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #eef0f3;
}
.detail-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

@media (max-width: 720px) {
  .detail-body { grid-template-columns: 1fr; gap: 14px; }
  .detail-body img { max-width: 200px; margin: 0 auto; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  flex: none;
  font-size: .7rem;
  color: var(--muted);
  background: #f1f3f6;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: .78rem;
}
.meta dt { color: var(--muted); white-space: nowrap; }
.meta dd {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.actions { display: flex; align-items: center; gap: 10px; }

.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
}
.btn:hover { background: #f7f8fa; }
.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--shadow-1);
}
.btn.primary:hover { background: #4338ca; }

pre.prompt {
  margin: 0;
  padding: 14px;
  overflow: auto;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── 复制反馈 toast ── */
.toast {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 60;
  padding: 10px 16px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: .82rem;
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: translateY(0); }

/* ── 信息库：搜索框 + 行列表 ── */
.search {
  width: 100%;
  margin: 20px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: .9rem;
  box-shadow: var(--shadow-1);
}
.search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.search::placeholder { color: #9aa3b2; }

.link-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.link-row:hover { border-color: #dcdff0; box-shadow: var(--shadow-2); }

.link-main { flex: 1 1 220px; min-width: 0; }
.link-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.link-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: .92rem;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-title:hover { color: var(--accent); text-decoration: underline; }
.link-note {
  margin-top: 3px;
  color: var(--muted);
  font-size: .76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-host {
  flex: none;
  margin-left: auto;
  color: var(--muted);
  font-size: .74rem;
  white-space: nowrap;
}

/* 窗口变窄时先缩封面、再把域名换行，避免标题被挤到 0 宽 */
@media (max-width: 620px) {
  .link-cover { width: 84px; height: 112px; }
  .link-host { margin-left: 0; }
}

/* 封面：固定 3:4 竖框 + object-fit:cover —— 图总是裁切填满容器，
   宽高比不一的图（含图床自己补的白边）都被统一裁掉 */
.link-cover {
  flex: none;
  width: 112px;
  height: 150px;
  object-fit: cover;
  border-radius: 12px;
  background: #eef0f3;
  cursor: zoom-in;
  transition: transform .18s ease, box-shadow .18s ease;
}
.link-row:hover .link-cover {
  transform: scale(1.04);
  box-shadow: var(--shadow-2);
}

/* ── 悬停大图浮层（桌面专用）── */
.peek {
  position: fixed;
  z-index: 70;
  width: 340px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
}
.peek.on { opacity: 1; }
.peek > img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  background: #eef0f3;
}
.peek-cap {
  margin-top: 6px;
  font-size: .74rem;
  color: var(--muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 点击看大图 ── */
.lightbox {
  padding: 0;
  border: none;
  background: transparent;
  max-width: none;
  overflow: visible;
}
.lightbox::backdrop { background: rgba(15, 23, 42, .72); }
.lightbox > img {
  display: block;
  max-width: 88vw;
  max-height: 82vh;
  border-radius: 12px;
  box-shadow: var(--shadow-3);
}
.lightbox-cap {
  margin-top: 10px;
  color: #e5e7eb;
  font-size: .82rem;
  text-align: center;
}

/* ── 技能库 ── */
.yt-form {
  margin: 20px 0 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.yt-form .search { margin-top: 0; }
.yt-form .search + .search { margin-top: 8px; }
.yt-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.yt-msg { font-size: .82rem; color: var(--muted); }
.credit { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.credit.low { color: #b45309; font-weight: 600; }
.yt-note {
  margin: 12px 0 0;
  font-size: .76rem;
  line-height: 1.65;
  color: var(--muted);
}

.skill-list { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 0; }
.skill-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.skill-main { display: flex; gap: 14px; align-items: flex-start; }
.skill-thumb {
  flex: none;
  width: 160px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--bg);
}
.skill-info { flex: 1; min-width: 0; }
.skill-title { font-size: .98rem; font-weight: 600; line-height: 1.45; }
.skill-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.skill-sub { margin-top: 8px; font-size: .78rem; color: var(--muted); }
.skill-sub a { color: inherit; text-decoration: none; }
.skill-sub a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 620px) {
  .skill-thumb { width: 112px; height: 63px; }
  .skill-main { gap: 10px; }
}
.skill-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: .84rem;
  line-height: 1.7;
}

.sect { margin-bottom: 12px; }
.sect-t {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 4px;
}
.sect ul, .sect ol { margin: 0; padding-left: 20px; }
.sect li { margin: 2px 0; }
.sect.warn {
  padding: 10px 12px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: var(--radius-sm);
}
.sect.warn .sect-t { color: #b45309; }
.dim { color: var(--muted); }
.sect summary { cursor: pointer; font-size: .8rem; color: var(--muted); }
.sect pre.prompt { margin-top: 8px; max-height: 40vh; }

.sk-row { height: 176px; }
