/*
 * dsh-magical-girl-catalog — 样式
 *
 * 改这里不需要重启 dsh：服务端每次请求都现读磁盘（Cache-Control: no-store）。
 * 存盘后刷新浏览器即可。
 *
 * 板块 2 的卡图按 2:3 处理（--card-ratio），改比例只改这一个变量。
 */

:root {
  color-scheme: light dark;
  --bg: #f6f4fb;
  --panel: #ffffff;
  --panel-2: #faf9fe;
  --border: #e5e0f2;
  --text: #1e1b2b;
  --muted: #6d6885;
  --accent: #7c4dff;
  --accent-2: #ff7ac6;
  --accent-weak: #f1ecff;
  --danger: #cf222e;
  --ok: #1a7f37;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(64, 40, 140, 0.10);
  --shadow-lg: 0 18px 50px rgba(64, 40, 140, 0.18);
  --card-ratio: 2 / 3;
  --max: 1120px;
  --bar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131120;
    --panel: #1c1929;
    --panel-2: #221e33;
    --border: #322c48;
    --text: #eae7f6;
    --muted: #a29dbf;
    --accent: #a98bff;
    --accent-2: #ff8fd0;
    --accent-weak: #262038;
    --danger: #ff7b72;
    --ok: #3fb950;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.42);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.7 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* 屏幕阅读器 / aria-live 用 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

a { color: var(--accent); }

/* ==========================================================================
   顶栏
   ========================================================================== */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--bar-h);
  padding: 0 18px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.bar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.bar-spark { font-size: 17px; }
.bar-title { white-space: nowrap; }

.bar-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.bar-nav::-webkit-scrollbar { display: none; }

.bar-nav a {
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.bar-nav a:hover { background: var(--accent-weak); color: var(--text); }
.bar-nav a[aria-current="page"] { background: var(--accent-weak); color: var(--accent); font-weight: 600; }

.bar-right { display: flex; align-items: center; gap: 8px; flex: none; }

.lock {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

/* ==========================================================================
   按钮
   ========================================================================== */

.btn {
  font: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:not(:disabled):hover { filter: brightness(1.08); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:not(:disabled):hover { background: var(--accent-weak); }

.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:not(:disabled):hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 4px 8px; font-size: 13px; line-height: 1.2; }

/* ==========================================================================
   视图容器
   ========================================================================== */

.view { display: block; }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 26px 20px 64px;
}

/* ==========================================================================
   首页
   ========================================================================== */

.hero {
  position: relative;
  min-height: calc(100vh - var(--bar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(160deg, #241a44, #3c2a63 45%, #6a3f86);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
/* 背景图读不到时，这一层保证文字仍然可读 —— 不会出现「一片白什么都没有」 */
.hero-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.55) 70%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45));
}

.hero-inner {
  position: relative;
  width: 100%;
  max-width: var(--max);
  padding: 48px 20px 64px;
  text-align: center;
  color: #fff;
}

.hero-title {
  margin: 0;
  font-size: clamp(30px, 5.4vw, 58px);
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 4px 26px rgba(0, 0, 0, 0.55);
}

.hero-sub {
  margin: 12px 0 0;
  font-size: clamp(13px, 1.6vw, 16px);
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 3px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

.hero-img-error {
  margin: 14px auto 0;
  max-width: 640px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(207, 34, 46, 0.92);
  color: #fff;
  font-size: 12px;
  word-break: break-all;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 42px;
  text-align: left;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 132px;
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  color: #fff;
  text-decoration: none;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.tile:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-lg);
}

.tile-icon { font-size: 24px; line-height: 1; min-height: 24px; }
.tile-name { font-size: 16px; font-weight: 700; letter-spacing: 0.6px; }
.tile-desc { font-size: 12px; color: rgba(255, 255, 255, 0.82); line-height: 1.6; }
.tile-count {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.72);
  font-variant-numeric: tabular-nums;
}

.hero-foot {
  margin-top: 34px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
}

/* ==========================================================================
   板块通用头部
   ========================================================================== */

.board-head {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.board-head h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.board-head .count { font-size: 13px; color: var(--muted); font-weight: 400; }
.board-head .grow { flex: 1; }
.board-desc { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

.empty {
  padding: 40px 22px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}
.empty .big { font-size: 30px; margin-bottom: 10px; }
.empty .hint { font-size: 12px; margin-top: 8px; color: var(--muted); }

/* ==========================================================================
   板块 2：角色卡（2:3）
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}

.char-card {
  position: relative;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.char-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.char-card.is-hidden { opacity: 0.55; }

.char-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* 2:3 卡图容器。没有图时这里是一块渐变占位 + 提示，不会塌成 0 高 */
.char-figure {
  position: relative;
  aspect-ratio: var(--card-ratio);
  background:
    linear-gradient(135deg, var(--accent-weak), color-mix(in srgb, var(--accent-2) 22%, var(--accent-weak)));
  overflow: hidden;
}

.char-figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.char-figure .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 12px;
  line-height: 1.6;
}
.char-figure .placeholder .glyph { font-size: 34px; }

/* 卡图加载失败时的提示条：绝不静默变成一块空白 */
.char-figure .img-error {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 6px 8px;
  background: rgba(207, 34, 46, 0.9);
  color: #fff;
  font-size: 10px;
  line-height: 1.45;
  word-break: break-all;
}

.char-meta {
  padding: 11px 12px 13px;
  border-top: 1px solid var(--border);
}
.char-real { font-size: 14px; font-weight: 700; }
.char-codename { font-size: 12px; color: var(--accent); margin-top: 2px; }
.char-codename.none { color: var(--muted); font-style: italic; }

.char-icon {
  position: absolute;
  top: 9px;
  left: 9px;
  z-index: 2;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  font-size: 15px;
  backdrop-filter: blur(4px);
}

.char-badge {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 10px;
  backdrop-filter: blur(4px);
}

.char-tools {
  position: absolute;
  z-index: 3;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.char-card:hover .char-tools,
.char-card:focus-within .char-tools { opacity: 1; }
.char-tools .btn {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1e1b2b;
}
.char-tools .btn:hover { background: #fff; }

/* ==========================================================================
   角色详情
   ========================================================================== */

.detail-top {
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  gap: 26px;
  align-items: start;
}
@media (max-width: 760px) {
  .detail-top { grid-template-columns: 1fr; }
}

/* ---- 图库：主图 + 缩略图条（一个角色可以有多张图） ---------------------- */

.gallery { display: grid; gap: 10px; }

.gallery-main {
  position: relative;
  aspect-ratio: var(--card-ratio);
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent-weak), color-mix(in srgb, var(--accent-2) 22%, var(--accent-weak)));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.gallery-main img,
.detail-figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-thumbs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: thin;
}
.gallery-thumb {
  flex: none;
  width: 52px;
  height: 78px; /* 2:3 */
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--accent-weak);
  cursor: pointer;
  padding: 0;
  position: relative;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-thumb[aria-current="true"] { border-color: var(--accent); }
.gallery-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 保留旧类名，卡图与立绘仍可能用到 */
.detail-figure {
  position: relative;
  aspect-ratio: var(--card-ratio);
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent-weak), color-mix(in srgb, var(--accent-2) 22%, var(--accent-weak)));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.detail-names h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: 1px; }
.detail-codename { font-size: 16px; color: var(--accent); font-weight: 600; }
.detail-names .none { color: var(--muted); font-style: italic; font-weight: 400; }
.detail-tagline { margin: 10px 0 0; color: var(--muted); }

/* ---- 基本信息总览 ------------------------------------------------------- */

.info-grid {
  display: grid;
  gap: 0;
  margin: 16px 0 0;
  border-top: 1px solid var(--border);
}
.info-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.info-row dt { color: var(--muted); font-size: 13px; }
.info-row dd { margin: 0; word-break: break-word; }
.info-row dd.is-unknown { color: var(--muted); font-style: italic; }
.info-row dd .field-note {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
  margin-top: 2px;
}

/* 别名一行（本名／代号之外的其它称呼） */
.alias-row { margin-top: 10px; font-size: 12px; color: var(--muted); }
.alias-row .tag {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
}

/* 「简介」栏已暂时移除（详情页只保留八项信息 + 别名）。
   .detail-summary 相关样式一并删掉，避免留下没人用的死样式；
   要恢复时连着 page.js 里那段注释一起加回来。 */

/* ---- 关系网 ------------------------------------------------------------- */

.rel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 22px 18px;
}

.rel-center { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.rel-avatar {
  width: 84px;
  height: 112px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--accent);
  box-shadow: var(--shadow);
  background: var(--accent-weak);
  position: relative;
  flex: none;
}
.rel-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rel-avatar .glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.rel-center .rel-name { font-weight: 700; font-size: 14px; }
.rel-center .rel-sub { font-size: 11px; color: var(--muted); }

/* 连线的示意：中心到四周的一圈虚线 */
.rel-connector {
  width: 2px;
  height: 26px;
  background: repeating-linear-gradient(to bottom, var(--border) 0 4px, transparent 4px 8px);
}

.rel-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  width: 100%;
}

.rel-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 96px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  text-align: center;
}

a.rel-node {
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
a.rel-node:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.rel-node .rel-avatar { width: 60px; height: 80px; border-width: 1px; border-color: var(--border); }
.rel-node .rel-name { font-size: 12px; font-weight: 600; line-height: 1.35; }
.rel-node .rel-label { font-size: 10px; color: var(--muted); line-height: 1.4; }

.detail-body { margin-top: 22px; }
.detail-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.detail-section h2 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 1px;
  font-weight: 600;
}
.detail-prose { white-space: pre-wrap; word-break: break-word; }
.detail-prose.empty-prose { color: var(--muted); font-style: italic; }

/* 描述区：占位块与已录入块 */
.placeholder-block {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.placeholder-block:last-child { margin-bottom: 0; }
.placeholder-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.placeholder-block h3 .ph-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
}
.placeholder-block p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.7; }

/* 已录入：实线边框 + 正常文字色，跟「待填充」的虚线灰块一眼区分 */
.placeholder-block.filled { border-style: solid; background: var(--panel); }
.placeholder-block.filled h3 .ph-tag.done {
  background: color-mix(in srgb, var(--ok) 15%, transparent);
  color: var(--ok);
}
/* pre-wrap：作者在编辑框里按回车换的行必须保留（例如把「王冠：…」单独起一行）。
   默认的 white-space:normal 会把换行折叠成空格，排版就散了。 */
.placeholder-block.filled p {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 武装的多条列表（每件一行，末尾可带一条总注） */
.desc-list { margin: 0; padding-left: 1.15em; display: grid; gap: 6px; }
.desc-list li {
  line-height: 1.8;
  color: var(--text);
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }

/* ==========================================================================
   板块 1 / 3 的条目
   ========================================================================== */

.entry-list { display: grid; gap: 12px; }

.entry {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.entry.is-hidden { opacity: 0.55; }

/* 条目边上的图标位（表情包后填） */
.entry-icon {
  flex: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--accent-weak);
  font-size: 20px;
  line-height: 1;
}
.entry-icon.empty { color: var(--muted); font-size: 15px; }

.entry-main { flex: 1; min-width: 0; }
.entry-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.entry-cat {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
}
.entry-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry-body { margin-top: 5px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.entry-tools { flex: none; display: flex; gap: 6px; align-items: flex-start; }

/* 板块 4：链接 */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.link-card {
  display: flex;
  gap: 13px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.link-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.link-card.is-hidden { opacity: 0.55; }
/* 有配图时卡片改成上下两段：图在上、文字行在下。
   不能只是往 flex 行里塞一张图 —— 分享卡是竖长海报，会把整行撑成一根柱子。 */
.link-card.has-figure { display: grid; grid-template-columns: 1fr; gap: 12px; }
.link-figure {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px;
  border-radius: 12px;
  background: var(--accent-weak);
  overflow: hidden;
}
.link-figure img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 8px;
}
.link-body { display: flex; gap: 13px; min-width: 0; }
.link-card .entry-icon { width: 40px; height: 40px; font-size: 20px; }
.link-main { min-width: 0; flex: 1; }
.link-title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.link-url { font-size: 11px; color: var(--muted); word-break: break-all; margin-top: 2px; }
.link-desc { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ==========================================================================
   弹窗
   ========================================================================== */

.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  max-width: min(560px, calc(100vw - 32px));
  width: 100%;
}
.dialog::backdrop { background: rgba(20, 14, 40, 0.55); backdrop-filter: blur(2px); }

.dialog-form { padding: 20px 22px 18px; }
.dialog-title { margin: 0 0 14px; font-size: 17px; }
.dialog-body { max-height: min(62vh, 560px); overflow: auto; }
.dialog-error {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 12px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* 表单 */
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--muted); }
.field .note { font-size: 11px; color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.65; }

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

/* ==========================================================================
   toast
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(640px, calc(100vw - 32px));
  padding: 9px 18px;
  border-radius: 999px;
  background: #1e1b2b;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

.muted { color: var(--muted); }

/* ==========================================================================
   图标位 = 表情包（emoji 或图片）
   --------------------------------------------------------------------------
   一个字段两种填法，所以每条尺寸规则都要同时照顾「画文字」和「画图片」。
   图片一律 object-fit: contain —— 用 cover 会把表情包裁掉半张脸。
   ========================================================================== */

.icon-text { line-height: 1; }

/* 图片读不到时的记号：必须看得见，否则又变成「这个位置不支持插图」的错觉 */
.icon-text.icon-broken {
  color: var(--warn, #d98a00);
  font-size: 0.85em;
  cursor: help;
}

.icon-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

/* 各图标位的容器尺寸（图片按容器撑满） */
.tile-icon .icon-img { max-width: 44px; max-height: 44px; margin: 0 auto; }
.board-icon .icon-img { width: 30px; height: 30px; display: inline-block; vertical-align: -7px; }
.char-icon { overflow: hidden; }
.char-icon .icon-img { width: 20px; height: 20px; }
.entry-icon { overflow: hidden; }
.entry-icon .icon-img { width: 32px; height: 32px; }
.detail-icon { display: inline-flex; width: 30px; height: 30px; vertical-align: -5px; margin-right: 6px; }
.detail-icon .icon-img { width: 100%; height: 100%; }
.char-figure .placeholder .glyph .icon-img,
.gallery .placeholder .glyph .icon-img { width: 44px; height: 44px; margin: 0 auto; }
.rel-avatar .glyph .icon-img { width: 60%; height: 60%; margin: 0 auto; }

/* 编辑器里的图标位：输入框 + 预览 + 选图按钮 */
.icon-row { display: flex; gap: 8px; align-items: center; }
.icon-row input { flex: 1; min-width: 0; }
.icon-preview {
  flex: none;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--accent-weak);
  font-size: 18px;
  overflow: hidden;
}
.icon-preview[data-kind="图片"] { border-style: solid; }

/* 选图对话框 */
.dialog-wide { max-width: min(760px, calc(100vw - 32px)); }
.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  max-height: min(46vh, 420px);
  overflow: auto;
  padding: 2px;
}
.icon-pick {
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  text-align: center;
  font: inherit;
  color: inherit;
}
.icon-pick:hover { border-color: var(--accent); background: var(--accent-weak); }
.icon-pick img {
  width: 100%;
  height: 84px;
  object-fit: contain;
  background: var(--accent-weak);
  border-radius: 7px;
}
.icon-pick-name { font-size: 11px; word-break: break-all; line-height: 1.25; }
.icon-pick-dir { font-size: 10px; color: var(--muted); }

/* ==========================================================================
   工具类
   --------------------------------------------------------------------------
   ⚠️ 为什么要有这些看起来多余的类：页面的 CSP 是 `style-src 'self'`，**没有**
   `unsafe-inline`。于是 `el('div', { style: '...' })`（即 setAttribute('style')）
   会被浏览器**静默丢掉** —— 不报错、不生效，只是看起来「设计成这样」。
   曾经首页封面就是用这种方式设的 background-image，结果是**封面从来没显示过**。
   要动态设样式，用 CSSOM（`node.style.backgroundImage = ...`，CSP 不管它）；
   静态样式一律走这里的类。
   ========================================================================== */

.w-full { width: 100%; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mt-22 { margin-top: 22px; }
.wrap-flush { padding-bottom: 0; }
.field-inline { display: flex; align-items: center; gap: 9px; }
.btn-inline { display: inline-block; margin-top: 14px; }
