/* =============================================================================
   统一 UI 组件库（Component Library）v2.0
   布局骨架 / 导航 / 表单 / 数据展示 / 反馈 / 页面区块
   ========================================================================== */

/* =============================== 1. 应用外壳 =============================== */
.app-shell {
  display: grid;
  /* 用 minmax(0, 1fr) 而不是 1fr：1fr 的最小值默认是 auto，即「内容最小宽度」，
     窄屏时图表/表格会把主区域列撑破（实测 504px 视口下主区域被撑到 630px，
     内容右侧被 overflow:hidden 裁掉）。minmax(0,1fr) 允许收缩到 0，
     溢出交给内部元素自己处理。 */
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) minmax(0, 1fr) var(--footer-h);
  grid-template-areas: "header header" "sidebar main" "footer footer";
  height: 100vh; height: 100dvh;
  overflow: hidden;
}
.app-shell[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* ------------------------------- 顶栏 ------------------------------------ */
.app-header {
  grid-area: header;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 var(--sp-5);
  background: var(--bg-header);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
  z-index: var(--z-header);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(6px);
}
.brand-mark svg { width: 20px; height: 20px; color: var(--gold-300); }
.brand-text { min-width: 0; }
.brand-title {
  font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: .4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub {
  font-size: 10px; color: var(--text-on-brand); letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; flex: none; }
.header-btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 34px; padding: 0 var(--sp-3);
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, .88);
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  transition: background var(--dur-base) var(--ease-std), color var(--dur-base);
  white-space: nowrap;
}
.header-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.header-btn.icon-only { width: 34px; padding: 0; justify-content: center; }
.header-btn svg { width: 17px; height: 17px; }
.header-btn.is-accent { background: rgba(200, 164, 92, .22); border-color: rgba(226, 188, 104, .45); color: var(--gold-200); }
.header-btn.is-accent:hover { background: rgba(200, 164, 92, .34); color: #fff; }

/* 顶栏全局搜索 */
.global-search { position: relative; flex: 1; min-width: 0; max-width: 420px; }
.global-search input {
  width: 100%; height: 34px;
  padding: 0 var(--sp-8) 0 var(--sp-8);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, .20);
  background: rgba(255, 255, 255, .12);
  color: #fff; font-size: var(--fs-sm);
  transition: background var(--dur-base), border-color var(--dur-base);
}
.global-search input::placeholder { color: var(--header-placeholder); opacity: 1; }
.global-search input:focus { background: rgba(255, 255, 255, .12); border-color: rgba(226, 188, 104, .6); }
.global-search .gs-icon { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: rgba(226, 238, 248, .7); }
.kbd-group { position: absolute; right: 8px; top: 8px; display: flex; gap: 3px; }
.kbd {
  font-family: var(--font-mono); font-size: 10px; line-height: 1;
  padding: 3px 5px; border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, .16); color: var(--text-inverse);
  border: 1px solid rgba(255, 255, 255, .2);
}
.kbd-dark { background: var(--bg-inset); color: var(--text-muted); border: 1px solid var(--border); }

/* 用户菜单 */
.user-menu { position: relative; }
.user-trigger {
  display: flex; align-items: center; gap: var(--sp-2);
  height: 34px; padding: 0 var(--sp-2) 0 var(--sp-1);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .08);
  color: #fff; font-size: var(--fs-sm);
  transition: background var(--dur-base);
}
.user-trigger:hover { background: rgba(255, 255, 255, .18); }
.avatar {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  color: var(--text-on-gold); font-size: 11px; font-weight: var(--fw-bold);
}
.avatar.lg { width: 40px; height: 40px; font-size: var(--fs-base); }
.role-badge {
  flex: none; padding: 1px 7px; border-radius: var(--radius-pill);
  font-size: 10px; line-height: 1.6; font-weight: var(--fw-semibold);
  letter-spacing: .2px; white-space: nowrap;
  color: var(--text-on-gold); background: linear-gradient(135deg, var(--gold-300), var(--gold-500));
}
/* 窄屏隐藏角色徽章，避免顶栏挤压搜索框 */
@media (max-width: 1180px) { .role-badge { display: none; } }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 250px; z-index: var(--z-tooltip);
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop-in var(--dur-base) var(--ease-out);
}
.popover-header { padding: var(--sp-4); border-bottom: 1px solid var(--border); display: flex; gap: var(--sp-3); align-items: center; }
.popover-body { padding: var(--sp-2); }
.popover-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-md);
  font-size: var(--fs-sm); color: var(--text-secondary); text-align: left;
}
.popover-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.popover-item svg { width: 16px; height: 16px; flex: none; }

/* ------------------------------- 侧边导航 -------------------------------- */
.app-sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; z-index: var(--z-sticky);
}
.sidebar-scroll { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-3) var(--sp-4); }
.nav-section { margin-bottom: var(--sp-5); }
.nav-label {
  font-size: 10px; font-weight: var(--fw-bold); letter-spacing: 1px;
  color: var(--text-muted); text-transform: uppercase;
  padding: 0 var(--sp-3); margin-bottom: var(--sp-2);
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  color: var(--text-secondary); text-align: left;
  transition: background var(--dur-fast) var(--ease-std), color var(--dur-fast);
  min-height: 36px;
}
.nav-item + .nav-item { margin-top: 2px; }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.is-active { background: var(--bg-active); color: var(--brand-600); font-weight: var(--fw-semibold); }
.nav-item.is-active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--brand-600);
}
[data-theme="dark"] .nav-item.is-active { color: var(--brand-300); }
[data-theme="dark"] .nav-item.is-active::before { background: var(--brand-400); }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: var(--fw-bold);
  padding: 1px 6px; border-radius: var(--radius-pill);
  background: var(--danger-bg); color: var(--danger-fg);
}
.nav-badge.neutral { background: var(--bg-inset); color: var(--text-muted); }
.nav-item .nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 折叠态 */
[data-sidebar="collapsed"] .nav-text,
[data-sidebar="collapsed"] .nav-label,
[data-sidebar="collapsed"] .nav-badge,
[data-sidebar="collapsed"] .sidebar-footer-text { display: none; }
[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: var(--sp-2) 0; }
[data-sidebar="collapsed"] .nav-item + .nav-item { margin-top: var(--sp-1); }

.sidebar-footer { border-top: 1px solid var(--border); padding: var(--sp-3); }
.storage-meter { font-size: 10px; color: var(--text-muted); }
.storage-bar { height: 4px; border-radius: var(--radius-pill); background: var(--bg-inset); overflow: hidden; margin-top: 4px; }
.storage-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-500), var(--grass-500)); }

/* ------------------------------- 主区域 ---------------------------------- */
.app-main {
  grid-area: main;
  overflow-y: auto; overflow-x: hidden;
  /* min-width:0 与上面 .app-shell 的 minmax(0,1fr) 是一对：
     只改列定义不够，grid item 自身的 min-width 默认仍是 auto，
     宽内容依旧会把它顶开（实测 504px 视口下被撑到 630px）。 */
  min-width: 0;
  padding: var(--sp-6);
  background: var(--bg-app);
  scroll-behavior: smooth;
}
.page { max-width: var(--content-max); margin: 0 auto; animation: page-in var(--dur-slow) var(--ease-out); }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5);
}
.page-title { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-2xl); font-weight: var(--fw-bold); }
.page-title svg { width: 22px; height: 22px; color: var(--brand-600); }
.page-desc { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 4px; max-width: 720px; }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* ============ 竖排蒙汉对照：歌名（详情页页头） ============ */
/* 左：汉语曲名；右：竖排蒙古文歌名 + 竖排蒙文别名（传统竖排自左向右书写，
   故蒙文列置于汉语之后，与书卷式唱词区「蒙文在左」的句内顺序不冲突）。
   蒙文列用 order 排到末尾，并用 margin-left:auto 顶到行右端；
   若空间不足则整体换行，但仍保持「汉语在前、蒙文在后」的顺序。 */
.page-head-mn {
  display: flex; align-items: center; gap: var(--sp-4);
  min-width: 0; flex-wrap: wrap;
}
.song-title-mn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  flex: 0 0 auto; padding-left: var(--sp-4);
  border-left: 1px solid var(--border);
  order: 2;                     /* 置于汉语曲名之后 → 视觉上位于右侧 */
  margin-left: auto;            /* 顶到行右端（仅第一个蒙文列吃满剩余空间） */
  /* 歌名较短，列长压到 4.5em，避免汉语曲名一侧留出大片空白 */
  --mn-col-h: 4.5em;
}
.song-title-mn .mn-cn-label { margin-bottom: 0; }
.song-title-mn .mn-v {
  font-size: var(--fs-xl);
  color: var(--text-primary);
}
/* 蒙文别名：与歌名同构的竖排列，列长略短以示从属 */
.song-alias-mn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  flex: 0 0 auto; padding-left: var(--sp-4);
  border-left: 1px solid var(--border);
  order: 3;
  --mn-col-h: 4.5em;
}
.song-alias-mn .mn-cn-label { margin-bottom: 0; }
.song-alias-mn .mn-v {
  font-size: var(--fs-lg);
  color: var(--text-secondary);
}
/* 汉语曲名不吃剩余空间，宽度按内容收缩 */
.song-title-cn { min-width: 0; flex: 0 1 auto; order: 1; }

/* ============ 竖排蒙汉对照：歌名（列表卡片） ============ */
/* 曲目卡容器：整卡可双击直达详情（见 views.js），故给出指针与轻微按压反馈，
   让「可点」这件事在视觉上被声明，而不是靠用户猜。 */
.song-card {
  display: flex; flex-direction: column;
  cursor: pointer;
}
.song-card .card-body { display: flex; flex-direction: column; }
.song-card:active { transform: translateY(1px); }
/* 卡内元信息行（流传地区 / 历史时期 / 音频时长）：等距横排，窄屏自动换行 */
.song-card-meta {
  display: flex; flex-wrap: wrap;
  gap: var(--sp-4);
}
.song-card-meta > span { display: inline-flex; align-items: center; gap: var(--sp-1); }

.song-card-head {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  margin-bottom: var(--sp-3); min-width: 0;
}
.song-card-mn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  flex: 0 0 auto; padding-right: var(--sp-3);
  border-right: 1px solid var(--border);
}
.song-card-mn .mn-cn-label { margin-bottom: 0; }
.song-card-mn .mn-v {
  --mn-col-h: 4.5em;              /* 卡内歌名较短，单独压低列长 */
  font-size: var(--fs-md);
  color: var(--text-primary);
}
.song-card-title { min-width: 0; flex: 1 1 auto; }
.song-card-cn {
  display: block; padding: 0; text-align: left;
  font-size: var(--fs-lg); font-weight: 600; color: var(--text-primary);
}
.song-card-cn:hover { color: var(--brand-600); }
.song-card-alias {
  font-size: var(--fs-xs); color: var(--text-muted);
  font-family: var(--font-mn);
  margin-bottom: 6px;
  word-break: keep-all;
}
.song-card-lyric {
  --mn-col-h: 8.5em;             /* 卡片首句预览：列长低于详情页 */
  padding: var(--sp-3);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  /* 预览区横向滚动查看后续句，不撑破卡片 */
  overflow-x: auto;
  overflow-y: hidden;
}
.song-card-lyric > .mn-v {
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
/* 卡内汉译同样竖排，与蒙文成对 */
.song-card-lyric > .mn-cn {
  flex: 0 0 auto;
  writing-mode: vertical-lr;
  -webkit-writing-mode: vertical-lr;
  text-orientation: mixed;
  -webkit-text-orientation: mixed;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  line-height: 1.7;
  letter-spacing: .1em;
  color: var(--text-muted);
  inline-size: var(--mn-col-h);
  max-inline-size: var(--mn-col-h);
  overflow: hidden;
  padding-left: var(--sp-2);
  border-left: 1px dashed var(--border-strong);
}

/* 列表项中的蒙文曲名（首页最近更新等紧凑场景） */
.li-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.li-title .mn-v {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.li-title-cn { font-family: var(--font-sans); }

/* 要素词条的竖排蒙文（卡片内，与汉语词条名对照） */
.term-mn-v {
  --mn-col-h: 7em;
  font-size: var(--fs-md);
  color: var(--text-secondary);
}
.breadcrumb {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--sp-2);
}
.breadcrumb svg { width: 12px; height: 12px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-600); }

/* ------------------------------- 页脚 ------------------------------------ */
.app-footer {
  grid-area: footer;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding: 0 var(--sp-5);
  background: var(--brand-800); color: rgba(226, 232, 240, .78);
  font-size: var(--fs-2xs); border-top: 1px solid rgba(255, 255, 255, .08);
}
.app-footer .f-links { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: center; }
.app-footer .dot { opacity: .4; }
/* 备案号链接：低调但可点，hover 时提亮以表明可交互 */
.app-footer .beian-link {
  color: inherit; text-decoration: none;
  border-bottom: 1px dotted rgba(226, 232, 240, .35);
  transition: color var(--dur-fast) var(--ease-std),
              border-color var(--dur-fast) var(--ease-std);
}
.app-footer .beian-link:hover { color: #fff; border-bottom-color: rgba(255, 255, 255, .8); }
.app-footer .beian-link:focus-visible {
  outline: 2px solid var(--focus-ring, #c8a45c); outline-offset: 2px;
  border-radius: 2px;
}
/* 公安联网备案：官方强制「图标在左、编号在右」，故图标是 a 的第一个子元素。
   a 本身是 inline，img 走基线对齐会让图标明显下沉，所以这枚链接改成
   inline-flex + align-items:center，让图标与文字垂直居中；
   其余（颜色、点线下划线、hover 提亮）沿用 .beian-link，保持两个备案号观感一致。 */
.app-footer .beian-police {
  display: inline-flex; align-items: center; gap: 5px;
  /* 去掉整盒下划线：inline-flex 的 border-bottom 会横穿图标底部，
     在警徽下方留一道虚线，看起来像没对齐。改由内层 span 承担下划线，
     视觉上就和左边那条 ICP 号一致了（只在文字下面）。 */
  border-bottom: none;
}
.app-footer .beian-police > span {
  border-bottom: 1px dotted rgba(226, 232, 240, .35);
  transition: border-color var(--dur-fast) var(--ease-std);
}
.app-footer .beian-police:hover { border-bottom: none; }
.app-footer .beian-police:hover > span { border-bottom-color: rgba(255, 255, 255, .8); }
.app-footer .beian-icon {
  flex: none;
  /* 官方图标是 36×40 的 png（RGBA，本身就是透明底），在页脚按一半尺寸显示
     即可看清警徽轮廓；再大就会压过文字，也破坏页脚的行高节奏。
     不要对它做 de-saturate / blend 之类的处理——备案图标属于官方标识，
     改灰度或改色在合规上说不清。 */
  width: 16px; height: 18px;
  border-radius: 2px;
}

/* =============================== 2. 按钮 ================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 36px; padding: 0 var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-std), color var(--dur-fast),
              border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 42px; padding: 0 var(--sp-5); font-size: var(--fs-md); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--button-primary-bg); color: var(--button-primary-fg); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--button-primary-hover); box-shadow: var(--shadow-brand); }
.btn-secondary { background: var(--bg-surface); color: var(--text-secondary); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); border-color: var(--brand-300); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-gold { background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); color: var(--text-on-gold); }
.btn-gold:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 6px 16px rgba(168, 132, 60, .32); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-soft-brand { background: var(--brand-soft-bg); color: var(--brand-soft-fg); border-color: var(--brand-100); }
[data-theme="dark"] .btn-soft-brand { border-color: rgba(59, 124, 184, .3); }
.btn-soft-brand:hover:not(:disabled) { background: var(--brand-100); color: var(--brand-700); }

.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--bg-surface); }
.btn-group .btn { border-radius: 0; border: none; border-right: 1px solid var(--border); background: transparent; color: var(--text-muted); }
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn.is-active { background: var(--bg-active); color: var(--brand-700); font-weight: var(--fw-semibold); }
[data-theme="dark"] .btn-group .btn.is-active { color: var(--brand-200); }

/* =============================== 3. 卡片 ================================= */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card-hover { transition: box-shadow var(--dur-base) var(--ease-std), transform var(--dur-base) var(--ease-std), border-color var(--dur-base); }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--brand-200); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card-head h3 { font-size: var(--fs-md); font-weight: var(--fw-semibold); display: flex; align-items: center; gap: var(--sp-2); }
.card-head h3 svg { width: 16px; height: 16px; color: var(--brand-600); }
.card-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; font-weight: var(--fw-normal); }
.card-body { padding: var(--sp-5); }
.card-body.tight { padding: var(--sp-4); }
.card-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--bg-surface-2); display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.card-toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

.grid-cards { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-2 { display: grid; gap: var(--sp-5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--sp-5); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* KPI 指标卡 */
.stat-card {
  position: relative; overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--sp-5); box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-base), transform var(--dur-base);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent, var(--brand-600));
}
.stat-card .sc-label { font-size: var(--fs-xs); color: var(--text-muted); display: flex; align-items: center; gap: var(--sp-2); }
.stat-card .sc-label svg { width: 14px; height: 14px; color: var(--accent, var(--brand-600)); }
.stat-card .sc-value { font-size: var(--fs-4xl); font-weight: var(--fw-bold); letter-spacing: -.5px; margin: var(--sp-2) 0 2px; font-variant-numeric: tabular-nums; }
.stat-card .sc-value small { font-size: var(--fs-xs); font-weight: var(--fw-normal); color: var(--text-muted); margin-left: 4px; }
.stat-card .sc-meta { font-size: var(--fs-2xs); color: var(--text-muted); display: flex; align-items: center; gap: var(--sp-2); }
.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: var(--fw-semibold); font-size: var(--fs-2xs); }
.trend.up { color: var(--success); } .trend.down { color: var(--danger); }

/* =============================== 4. 表单 ================================= */
.field { display: flex; flex-direction: column; gap: 6px; }
/* 双列表单：账号/密码等成对字段并排，窄屏自动降为单列 */
.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3) var(--sp-4);
}
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field-label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.field-label .req { color: var(--danger); }
.field-hint { font-size: var(--fs-2xs); color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; min-height: 36px;
  padding: 0 var(--sp-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary); font-size: var(--fs-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.textarea { padding: var(--sp-2) var(--sp-3); min-height: 84px; resize: vertical; line-height: var(--lh-base); }
.input::placeholder, .textarea::placeholder { color: var(--text-placeholder); opacity: 1; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-500); box-shadow: var(--ring); outline: none;
}
.input:disabled, .select:disabled { background: var(--bg-inset); color: var(--text-muted); cursor: not-allowed; }
.select {
  appearance: none; padding-right: var(--sp-7); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input-group { position: relative; }
.input-group .ig-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--n-400); pointer-events: none; }
.input-group .input { padding-left: var(--sp-8); }
.input-group .ig-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--n-400); }
.input-group .ig-clear:hover { color: var(--danger); }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px; height: 22px; border-radius: var(--radius-pill);
  background: var(--border-strong); position: relative; transition: background var(--dur-base);
  flex: none;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs);
  transition: transform var(--dur-base) var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--brand-600); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus + .switch-track { box-shadow: var(--ring); }
.switch-text { font-size: var(--fs-sm); color: var(--text-secondary); }

/* 复选框 */
.checkbox { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-sm); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand-600); cursor: pointer; }

/* 过滤条 */
.filter-bar { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.filter-bar .filter-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; grid-column: 1 / -1; }
.chips-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

/* =============================== 5. 标签 / 徽章 ========================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); line-height: 1.6;
  background: var(--bg-inset); color: var(--text-secondary);
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge-brand { background: var(--brand-soft-bg); color: var(--brand-soft-fg); }
.badge-gold { background: var(--gold-soft-bg); color: var(--gold-soft-fg); }
.badge-success { background: var(--success-bg); color: var(--success-fg); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge-danger { background: var(--danger-bg); color: var(--danger-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }

/* 要素类型标签（与图表色板一致） */
.type-tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); }
.type-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.type-vocab    { background: var(--type-vocab-bg);    color: var(--type-vocab-fg); }
.type-custom   { background: var(--type-custom-bg);   color: var(--type-custom-fg); }
.type-name     { background: var(--type-name-bg);     color: var(--type-name-fg); }
.type-religion { background: var(--type-religion-bg); color: var(--type-religion-fg); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 var(--sp-3); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--dur-fast) var(--ease-std);
}
.chip:hover { border-color: var(--brand-400); color: var(--brand-700); }
[data-theme="dark"] .chip:hover { color: var(--brand-200); }
.chip.is-on { background: var(--button-primary-bg); border-color: var(--button-primary-bg); color: var(--button-primary-fg); }
.chip svg { width: 13px; height: 13px; }
.role-chip { font-size: var(--fs-2xs); padding: 1px 8px; border-radius: var(--radius-sm); font-weight: var(--fw-semibold); }
.role-admin { background: var(--type-name-bg); color: var(--type-name-fg); }
.role-annotator { background: var(--type-custom-bg); color: var(--type-custom-fg); }
.role-researcher { background: var(--success-bg); color: var(--success-fg); }
.role-guest { background: var(--bg-inset); color: var(--text-muted); }

/* =============================== 6. 表格 ================================= */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; font-size: var(--fs-sm); min-width: 640px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-surface-2);
  text-align: left; font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--text-muted); letter-spacing: .3px;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { transition: background var(--dur-fast); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .col-num { font-variant-numeric: tabular-nums; text-align: right; }
.data-table .cell-title { font-weight: var(--fw-medium); color: var(--text-primary); }
.data-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.table-empty { padding: var(--sp-9) var(--sp-4); text-align: center; color: var(--text-muted); }

/* 分页 */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding-top: var(--sp-4); }
.pagination-info { font-size: var(--fs-xs); color: var(--text-muted); }
.pager { display: flex; gap: 4px; align-items: center; }
.pager-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-secondary);
  font-size: var(--fs-xs); display: grid; place-items: center;
  transition: all var(--dur-fast);
}
.pager-btn:hover:not(:disabled) { border-color: var(--brand-400); color: var(--brand-700); }
.pager-btn.is-active { background: var(--button-primary-bg); border-color: var(--button-primary-bg); color: var(--button-primary-fg); font-weight: var(--fw-semibold); }
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }

/* =============================== 7. 歌词与标释 =========================== */
/* 唱词区版式（传统竖排书卷式，参照万丽 docx 版式）：
   每句唱词 = 序号/时间码 + 蒙文竖列 + 汉译竖列，句与句自左向右排列成"卷"；
   蒙汉两列同为纵向书写（writing-mode: vertical-lr），列长由 --mn-col-h 统一约束；
   整卷按内容增高、横向滚动翻句，极长内容可在卷内滚动，不裁掉列底。 */
.lyric-shell {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4);
}
.lyric-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface-2); border-bottom: 1px solid var(--border);
}
.lyric-stage {
  position: relative;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--gold-50), var(--bg-surface) 120px);
}
[data-theme="dark"] .lyric-stage {
  background: linear-gradient(180deg, rgba(200, 164, 92, .07), var(--bg-surface) 120px);
}
.lyric-scroll {
  /* 书卷容器：纵向高度由列长决定，横向滚动翻句。
     --mn-fit-h 由 views.js 按本曲最长唱词句实测后写入（像素值），
     使「蒙文/汉译各自完整成一句、不折列」；未测出时回落到 --mn-col-h。 */
  display: flex; flex-direction: row; align-items: flex-start;
  gap: var(--sp-5);
  list-style: none; margin: 0;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  /* 高度由唱词列内容决定，不再用固定 max-height 裁掉列底；
     极长句或字号放大时，横/纵方向都可滚动，主页面也可继续纵向滚动。 */
  overflow: auto;
  overscroll-behavior: contain;
  padding: var(--sp-4) var(--sp-5);
  scrollbar-gutter: stable;
}
@media (prefers-reduced-motion: no-preference) { .lyric-scroll { scroll-behavior: smooth; } }

.lyric-row {
  display: flex; flex-direction: row; align-items: flex-start;
  gap: 9px;
  flex: none;
  padding: 7px 10px;
  border-left: 3px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast);
}
.lyric-row:hover { background: var(--bg-hover); }
/* 当前演唱行：左侧金色标尺 + 纵向渐变底色，与音频时间轴严格同步 */
.lyric-row.is-current {
  background: linear-gradient(180deg, var(--gold-100), transparent 82%);
  border-left-color: var(--gold-500);
}
[data-theme="dark"] .lyric-row.is-current {
  background: linear-gradient(180deg, rgba(200, 164, 92, .16), transparent 82%);
}
/* 已唱过的行：弱化处理，形成阅读进度 */
.lyric-row.is-past { opacity: .6; }
.lyric-row.is-past:hover, .lyric-row.is-current { opacity: 1; }

.lyric-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  padding-top: 2px; user-select: none;
}
.lyric-no { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-muted); }
.lyric-tc {
  font-family: var(--font-mono); font-size: 10px; line-height: 1;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.lyric-row.is-current .lyric-no { color: var(--gold-700); font-weight: var(--fw-semibold); }
.lyric-row.is-current .lyric-tc { color: var(--gold-600); }
[data-theme="dark"] .lyric-row.is-current .lyric-no,
[data-theme="dark"] .lyric-row.is-current .lyric-tc { color: var(--gold-300); }

/* 蒙文列：传统竖排（纵向书写、字形直立、列自左向右）。
   列长取 --mn-fit-h（JS 按最长句实测），未测出时回落 --mn-col-h。
   block-size:auto 使超长句仍可向右换列兜底，绝不纵向溢出。 */
.lyric-mn {
  font-family: var(--font-mn);
  font-size: calc(var(--fs-base) * 1.02);
  line-height: 1.95;
  color: var(--text-secondary);
  writing-mode: vertical-lr;
  -webkit-writing-mode: vertical-lr;
  text-orientation: sideways;       /* 蒙文整行旋转 90° 才是正确竖排；用 mixed 会断成孤立笔画 */
  -webkit-text-orientation: sideways;
  text-combine-upright: none;       /* 防止连写蒙文被压成横排合字 */
  -webkit-text-combine-upright: none;
  word-break: keep-all;             /* 只在词边界换列，不切断连写 */
  letter-spacing: .06em;
  inline-size: var(--mn-fit-h, var(--mn-col-h));
  max-inline-size: none;
  block-size: auto;
  max-block-size: none;
  overflow: visible;
}
/* 当前行只变色不变号：字号变化会破坏整卷列对齐 */
.lyric-row.is-current .lyric-mn { color: var(--brand-700); }
[data-theme="dark"] .lyric-row.is-current .lyric-mn { color: var(--gold-200); }

/* 汉译列：同为竖排，与蒙文并排成对；字族/字号/颜色形成清晰区分 */
.lyric-cn {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1.7;
  color: var(--text-primary);
  writing-mode: vertical-lr;
  -webkit-writing-mode: vertical-lr;
  text-orientation: mixed;
  -webkit-text-orientation: mixed;
  text-combine-upright: none;
  letter-spacing: .12em;
  word-break: normal;
  overflow-wrap: normal;
  inline-size: var(--mn-fit-h, var(--mn-col-h));
  max-inline-size: none;
  block-size: auto;
  max-block-size: none;
  overflow: visible;
  padding-left: 2px;
  border-left: 1px dashed var(--border);
}
.lyric-row.is-current .lyric-cn { color: var(--brand-800); }
[data-theme="dark"] .lyric-row.is-current .lyric-cn { color: #fff; }

/* 唱词区响应式：书卷式横向流动在窄屏依旧成立（横向滑动翻句），
   仅通过 --mn-col-h 压缩列长、缩小字号，保证不横爬、不溢出。 */
@media (max-width: 900px) {
  .lyric-scroll { gap: var(--sp-4); padding: var(--sp-3); }
  .lyric-row { gap: 7px; padding: 5px 8px; }
  .lyric-cn { font-size: var(--fs-sm); }
}
@media (max-width: 640px) {
  .lyric-scroll { gap: var(--sp-3); }
  .lyric-row { gap: 6px; }
  .lyric-mn { font-size: var(--fs-sm); }
  .lyric-cn { font-size: var(--fs-sm); letter-spacing: .08em; }
}

/* 转写标注（西里尔/拉丁转写时提示） */
.lyric-script-tag {
  display: inline-block; font-family: var(--font-sans);
  font-size: 10px; line-height: 1.6; padding: 0 5px;
  border-radius: var(--radius-xs); color: var(--text-muted);
  background: var(--bg-surface-2); border: 1px solid var(--border);
  vertical-align: 2px;
}

/* 无音频资源时的提示条 */
.lyric-source {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-2xs); color: var(--text-muted);
}

/* ================= 高亮标释（四类交融要素）· marker 风格 ================
   设计要点：
   1. 方向无关。旧实现用 border-bottom 画下划线，在竖排蒙文里会跑到字形侧面，
      造成「蒙文高亮是歪的、汉译高亮是正的」不一致；现在改为「底色 + 描边 + 圆角」
      的整块 marker，横排竖排表现完全一致。
   2. 蒙文与汉译共用同一套规则，只有类型色不同，视觉语言统一。
   3. 状态齐全：默认 / 悬停 / 键盘聚焦 / 联动突出 / 联动弱化 / 显影关闭。
   4. 颜色全部走 tokens.css 的 --hl-* 令牌，深浅主题自动切换且对比度 ≥7:1。 */
.hl {
  /* 未指定类型时的兜底色（正常都会带 .hl-<type>） */
  --hl-bg: var(--hl-vocab-bg);
  --hl-fg: var(--hl-vocab-fg);
  --hl-line: var(--hl-vocab-line);
  cursor: pointer;
  border: 0;
  font-weight: var(--fw-semibold);
  padding: .04em .2em;
  border-radius: .24em;
  background: var(--hl-bg);
  color: var(--hl-fg);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--hl-line) 42%, transparent);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;       /* 跨行/跨列时每段都带圆角，不断成直角 */
  transition: background var(--dur-fast) var(--ease-std),
              box-shadow var(--dur-fast) var(--ease-std),
              color var(--dur-fast) var(--ease-std),
              opacity var(--dur-fast) var(--ease-std),
              filter var(--dur-fast) var(--ease-std);
}
.hl-vocab    { --hl-bg: var(--hl-vocab-bg);    --hl-fg: var(--hl-vocab-fg);    --hl-line: var(--hl-vocab-line); }
.hl-custom   { --hl-bg: var(--hl-custom-bg);   --hl-fg: var(--hl-custom-fg);   --hl-line: var(--hl-custom-line); }
.hl-name     { --hl-bg: var(--hl-name-bg);     --hl-fg: var(--hl-name-fg);     --hl-line: var(--hl-name-line); }
.hl-religion { --hl-bg: var(--hl-religion-bg); --hl-fg: var(--hl-religion-fg); --hl-line: var(--hl-religion-line); }

/* 悬停 / 键盘聚焦：加深描边并轻抬饱和，明确「可点击查看考释」 */
.hl:hover,
.hl:focus-visible {
  box-shadow: 0 0 0 2px var(--hl-line);
  filter: brightness(.99) saturate(1.08);
}
.hl:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* 蒙汉联动：被指到的那一个（is-active-term）与另一列的对应词（is-linked）
   同步加环强调；同句其它术语淡出，视线自然落在这对蒙汉对照上。 */
.hl.is-active-term,
.hl.is-linked {
  box-shadow: 0 0 0 2px var(--hl-line),
              0 0 0 5px color-mix(in srgb, var(--hl-line) 20%, transparent);
  filter: brightness(1.05) saturate(1.25);
}
.hl.is-dim { opacity: .4; }

/* 「高亮显影」中关闭的类型：淡到近乎隐形但仍占位，可随时恢复对照 */
.hl.is-off { opacity: .24; filter: grayscale(.65); }

/* 同句正被对照阅读时，整行铺一层极淡底色，帮助锁定当前这一对照 */
.lyric-row.is-term-focus { background: var(--bg-hover); }

/* 尊重「减少动效」偏好：不做过渡，状态瞬时切换 */
@media (prefers-reduced-motion: reduce) { .hl { transition: none; } }

/* 播放器 */
.player {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  background: linear-gradient(120deg, var(--n-800), var(--brand-800));
  color: #fff; flex-wrap: wrap;
}
.player .pl-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  color: var(--text-on-gold); display: grid; place-items: center; flex: none;
  box-shadow: 0 4px 12px rgba(200, 164, 92, .35);
  transition: transform var(--dur-fast);
}
.player .pl-btn:hover { transform: scale(1.06); }
.player .pl-btn svg { width: 17px; height: 17px; }
.player .pl-meta { min-width: 0; overflow-wrap: anywhere; font-size: var(--fs-xs); }
.player .pl-title { color: var(--gold-200); font-weight: var(--fw-medium); }
.player .pl-sub { color: var(--player-text-muted); font-size: var(--fs-2xs); }
.seek {
  flex: 1; min-width: 180px; height: 5px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .2); position: relative; cursor: pointer;
}
.seek-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--gold-300), var(--gold-500)); border-radius: var(--radius-pill); width: 0; }
.seek::after { content: ""; position: absolute; inset: -8px 0; }
.seek:focus-visible { outline: 2px solid var(--gold-300); outline-offset: 4px; border-radius: var(--radius-pill); }
.pl-time { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--player-text-muted); font-variant-numeric: tabular-nums; }

/* 音量滑块：透明轨道外保留更大的可点击区域 */
.pl-vol { display: inline-flex; align-items: center; gap: 5px; color: var(--player-text-muted); }
/* 音量图标：紧贴滑杆左侧，明确标示该滑杆的语义 */
.pl-vol-ico { display: inline-flex; align-items: center; opacity: .85; }
.pl-vol:hover .pl-vol-ico { opacity: 1; color: var(--gold-300); }
.pl-vol input[type="range"] {
  width: 74px; height: 32px; background: transparent; cursor: pointer;
  accent-color: var(--gold-400);
}
.pl-rate {
  height: 26px; padding: 0 6px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .12); color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, .18);
  font-size: var(--fs-2xs); font-family: var(--font-mono); cursor: pointer;
}
.pl-rate option { background: var(--n-800); color: #fff; }
.pl-rate:focus-visible { outline: 2px solid var(--gold-300); outline-offset: 1px; }
/* 移动端隐藏次要控件，保留核心播放与进度 */
@media (max-width: 720px) { .pl-vol, .pl-rate { display: none; } }

/* =============================== 8. 图表 ================================= */
.chart-box { position: relative; width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; overflow: visible; }
/* 环形图定尺：限制最大宽度并居中，防止随宽卡片等比放大造成文字/图形错位。
   transform-origin 用百分比时，SVG 元素的参考系是自身包围盒，
   故圆心鼓出效果改由 JS 直接写 translate+scale（见 charts.js donut）。

   ⚠ aspect-ratio 必须和 charts.js 里的 viewBox 保持一致（donut 是 300/210）。
   原因：只给 `width:100%; max-width:360px` 而不锁宽高比时，SVG 元素的实际高度
   由容器/浏览器各自决定，一旦高度被拉长，viewBox 默认的 preserveAspectRatio
   （xMidYMid meet）就会把图形在竖直方向居中留白——**图形看起来整体下沉，
   而中心文字仍按 SVG 坐标贴在环心上，于是用户看到的就是「文字与圆环错位」**。
   锁死 aspect-ratio 后，元素高度 = 宽度 ÷ 比例，图形必然填满，不会再漂。 */
.chart-box--donut svg {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 300 / 210;
  margin-inline: auto;
}
/* 环形图容器：上下留白收一点，环心略微上提。 */
.chart-box--donut { padding-block: 0 4px; }
.chart-box--donut svg { display: block; }
/* 图例贴近圆环下方：留一点空但不要撑开 */
.chart-box--donut + .chart-legend { margin-top: var(--sp-2) !important; }

/* ---- 环形图卡片的竖直定位 ----------------------------------------------
   背景：.grid-2 是 stretch 等高，同排柱状图卡更高，把环形图卡一起拉高，
   多出的空间堆在底部 → 环心低于卡片中心，看着「圆环偏下」。

   踩过的坑（都被实测否决，留作记录以免再犯）：
   1) .card-body{flex:1; justify-content:center}
      卡片高度由 stretch 决定，body 再抢增长 → 余量变大，偏移 20.6→34.2px。
   2) padding-bottom: calc(var(--sp-4) - 20px)
      --sp-4=16px 算出 -4px，**负 padding 非法**，声明被丢弃，数值纹丝不动。
   3) .card{align-self:start} —— 偏移稳定在 12.9px，但卡片不再与右侧柱状图卡
      等高，同一行底边对不齐，整行左轻右重，观感明显更差。已放弃。

   采用方案：保持等高（对齐最重要），只把 body 的上内边距压到 0、下内边距
   收成 6px。实测偏移 20.6px → 4.6px（1440 宽），是「对齐 + 居中」的最优解。 */
.card--chart > .card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 0;
  padding-bottom: 6px;
}
/* 扇区悬停「起伏」动画：沿径向外移并轻微放大，中心文字淡出让位 */
.chart-box--donut .dn-seg {
  transition: transform .22s cubic-bezier(.34, 1.3, .64, 1), filter .22s ease;
  transform-box: view-box;
  cursor: pointer;
}
.chart-box--donut .dn-seg.is-hot { filter: brightness(1.12) saturate(1.1); }
.chart-box--donut .dn-seg:hover { filter: brightness(1.12) saturate(1.1); }
/* 中心文字在扇区悬停时淡出，鼠标移开复原 */
.chart-box--donut .dn-center {
  transition: opacity .2s ease;
  pointer-events: none;
}
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--text-secondary); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chart-legend .lg i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.chart-legend .lg.is-off { opacity: .35; }
.chart-tip {
  position: absolute; z-index: var(--z-tooltip); pointer-events: none;
  background: var(--n-900); color: #fff; font-size: var(--fs-2xs);
  padding: 6px 10px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  white-space: nowrap; opacity: 0; transition: opacity var(--dur-fast);
}
.chart-tip.show { opacity: 1; }
[data-theme="dark"] .chart-tip { background: var(--brand-600); }
.graph-canvas { width: 100%; height: 520px; border-radius: var(--radius-md); background: var(--bg-surface-2); border: 1px solid var(--border); }
.graph-toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

/* =============================== 9. 抽屉 / 模态 ========================== */
.overlay {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  background: rgba(15, 23, 42, .48); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity var(--dur-base) var(--ease-std);
}
.overlay.show { opacity: 1; pointer-events: auto; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-drawer);
  width: min(460px, 100vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  display: flex; flex-direction: column;
  visibility: hidden;
}
.drawer.open { transform: translateX(0); visibility: visible; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-5); border-bottom: 1px solid var(--border); flex: none;
}
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-5); }
.drawer-foot { flex: none; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); background: var(--bg-surface-2); display: flex; gap: var(--sp-2); justify-content: flex-end; flex-wrap: wrap; }
.detail-block { margin-bottom: var(--sp-5); }
.detail-block .db-label { font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: .8px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.detail-block .db-value { font-size: var(--fs-sm); color: var(--text-secondary); line-height: var(--lh-base); }
.db-panel { background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--sp-3); }
.db-quote { border-left: 3px solid var(--brand-600); padding: var(--sp-2) var(--sp-3); font-style: italic; color: var(--text-secondary); background: var(--bg-surface-2); border-radius: 0 var(--radius-md) var(--radius-md) 0; }

.modal-wrap {
  position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center;
  padding: var(--sp-4); pointer-events: none; visibility: hidden;
}
.modal-wrap.show { pointer-events: auto; visibility: visible; }
.modal {
  width: min(560px, 100%); max-height: 86vh; max-height: 86dvh;
  display: flex; flex-direction: column;
  background: var(--bg-surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl); border: 1px solid var(--border);
  transform: scale(.96) translateY(8px); opacity: 0;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base);
  pointer-events: none;
}
.modal-wrap.show .modal { transform: none; opacity: 1; pointer-events: auto; }
.modal-head { padding: var(--sp-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.modal-body { min-height: 0; padding: var(--sp-5); overflow-y: auto; }
.modal-foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; }
.modal-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }

/* =============================== 10. 反馈组件 ============================ */
.toast-host {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--sp-2); max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface); border: 1px solid var(--border);
  border-left: 3px solid var(--brand-600);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); animation: toast-in var(--dur-slow) var(--ease-out);
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast svg { width: 16px; height: 16px; margin-top: 2px; flex: none; }
.toast.success svg { color: var(--success); } .toast.error svg { color: var(--danger); }
.toast.warning svg { color: var(--warning); } .toast.info svg { color: var(--brand-600); }
.toast.out { animation: toast-out var(--dur-base) var(--ease-std) forwards; }

.alert {
  display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md); font-size: var(--fs-sm);
  border: 1px solid var(--border); background: var(--bg-surface-2);
}
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.alert-info { background: var(--info-bg); border-color: rgba(2, 132, 199, .3); color: var(--info-fg); }
.alert-warning { background: var(--warning-bg); border-color: rgba(217, 119, 6, .3); color: var(--warning-fg); }
.alert-danger { background: var(--danger-bg); border-color: rgba(220, 38, 38, .3); color: var(--danger-fg); }
.alert-success { background: var(--success-bg); border-color: rgba(5, 150, 105, .3); color: var(--success-fg); }

/* 骨架屏（加载性能优化：消除布局抖动 CLS） */
.skeleton {
  background: linear-gradient(90deg, var(--bg-inset) 25%, var(--bg-surface-2) 37%, var(--bg-inset) 63%);
  background-size: 400% 100%; border-radius: var(--radius-sm);
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk-line { height: 12px; margin-bottom: 8px; }
.sk-card { height: 132px; border-radius: var(--radius-lg); }
.sk-title { height: 20px; width: 40%; }

/* 空状态 */
.empty-state { padding: var(--sp-10) var(--sp-5); text-align: center; color: var(--text-muted); }
.empty-state .es-icon { width: 52px; height: 52px; margin: 0 auto var(--sp-4); display: grid; place-items: center; border-radius: 50%; background: var(--bg-inset); }
.empty-state .es-icon svg { width: 24px; height: 24px; color: var(--n-400); }
.empty-state h4 { font-size: var(--fs-md); color: var(--text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: var(--fs-sm); max-width: 380px; margin: 0 auto var(--sp-4); }

/* 时间线 */
.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: var(--sp-4); }
.tl-item::before {
  content: ""; position: absolute; left: calc(-1 * var(--sp-6) + 3px); top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-surface); border: 2px solid var(--brand-500);
}
.tl-item.is-warn::before { border-color: var(--warning); }
.tl-item.is-danger::before { border-color: var(--danger); }
.tl-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.tl-meta { font-size: var(--fs-2xs); color: var(--text-muted); }

/* ================================ 工具提示（悬停显示在元素下方） ============
   用 data-tip 声明文案，data-tip-place="top" 可反向显示在元素上方。
   默认放在**下方**：top: calc(100% + 8px)。相比原生 title 的优点：
   ① 可换行不截断；② 样式跟随主题；③ 位置可控制；④ 键盘聚焦也能触发。
   需配合 JS 的边界修正（app.js 中 _placeTip）：靠近视口右缘时改为右对齐，
   靠近下缘时翻到上方，避免提示被裁切。 */
[data-tip] { position: relative; }
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);            /* 默认：元素下方 */
  left: 50%;
  transform: translateX(-50%);
  background: var(--n-900);
  color: #fff;
  font-size: var(--fs-2xs);
  line-height: 1.5;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 260px;
  white-space: normal;
  text-align: center;
  pointer-events: none;
  z-index: var(--z-tooltip);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  animation: tipIn .14s ease-out;
}
[data-theme="dark"] [data-tip]:hover::after,
[data-theme="dark"] [data-tip]:focus-visible::after {
  background: #000;
  border: 1px solid var(--border-strong);
}
/* 反向：显示在元素上方（贴边时由 JS 自动切换） */
[data-tip-place="top"]:hover::after,
[data-tip-place="top"]:focus-visible::after {
  top: auto;
  bottom: calc(100% + 8px);
}
/* 弹层内的菜单项：提示排在右侧，避免遮挡菜单文字 */
.popover-item[data-tip]:hover::after { left: 100%; top: 50%; transform: translateY(-50%); }
/* 靠视口右缘时改为右对齐，防止提示横向溢出被裁切 */
[data-tip-edge="right"]:not(.popover-item):hover::after,
[data-tip-edge="right"]:not(.popover-item):focus-visible::after {
  left: auto;
  right: 0;
  transform: none;
  animation-name: tipInRight;
}
@keyframes tipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-3px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
[data-tip-place="top"]:hover::after { animation-name: tipInTop; }
@keyframes tipInTop {
  from { opacity: 0; transform: translateX(-50%) translateY(3px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.popover-item[data-tip]:hover::after { animation-name: tipInRight; }
@keyframes tipInRight {
  from { opacity: 0; transform: translateY(-50%) translateX(-3px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}

/* 列表项 */
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast);
}
.list-item:last-child { border-bottom: none; }

/* ---- 仪表盘「历史时期分布 / 最近更新曲目」同排 ------------------------------------
   两卡在 .grid-2 里等高，右侧列表有 6 条把它撑到 437px，左侧图表按自身
   540×280 比例只占 ~290px，于是卡片下方空出 100 多 px。
   处理：卡片纵向 flex、body 吃掉余量并把图表竖直居中，让图落在卡片视觉中心，
   而不是贴顶留一大块底白。列表侧同理，条目多时改为内部滚动，避免整页过长。 */
.card--fill { display: flex; flex-direction: column; }
.card--fill > .card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.list-item:hover { background: var(--bg-hover); }
.li-main { min-width: 0; flex: 1; }
.li-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.li-sub { font-size: var(--fs-2xs); color: var(--text-muted); }

/* 进度 */
.progress { height: 6px; border-radius: var(--radius-pill); background: var(--bg-inset); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--brand-600); transition: width var(--dur-slow) var(--ease-out); }

/* 文章卡 */
.article-card { display: flex; flex-direction: column; }
.ac-cover { height: 132px; display: grid; place-items: center; font-size: 40px; }
.ac-cover.name { background: linear-gradient(135deg, #b45309, #78350f); }
.ac-cover.custom { background: linear-gradient(135deg, var(--brand-600), var(--brand-800)); }
.ac-cover.vocab { background: linear-gradient(135deg, #0f766e, #064e3b); }
.ac-cover.method { background: linear-gradient(135deg, #6d28d9, #3b0764); }
.ac-cover.music { background: linear-gradient(135deg, #be123c, #7f1d1d); }

/* =============================== 11. 动画 ================================ */
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: var(--border-strong); border-top-color: var(--brand-600); }

/* =============================== 12. 多端适配 ============================ */
/* 平板：侧边栏默认折叠 */
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  /* minmax(0,1fr) 而非 1fr：折叠成单列后 1fr 的最小值仍是 auto，
     图表等宽内容会把主区域顶开（实测 504px 视口下被撑到 630px，
     右侧内容被 overflow:hidden 裁掉）。 */
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "header" "main" "footer"; }
  .app-sidebar {
    position: fixed; top: var(--header-h); bottom: var(--footer-h); left: 0;
    width: var(--sidebar-w); z-index: var(--z-drawer);
    transform: translateX(-100%); transition: transform var(--dur-slow) var(--ease-out);
    box-shadow: var(--shadow-xl); visibility: hidden;
  }
  .app-sidebar.open { transform: none; visibility: visible; }
  .app-main { padding: var(--sp-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .global-search { max-width: 240px; }
  .brand-sub { display: none; }
}
/* 移动端 */
@media (max-width: 768px) {
  :root { --header-h: 52px; }  .app-header { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .global-search { display: none; }
  .header-btn .btn-text { display: none; }
  .header-btn { width: 34px; padding: 0; justify-content: center; }
  .header-btn.is-accent { width: auto; padding: 0 var(--sp-3); }
  .brand-title { font-size: var(--fs-md); }
  .app-main { padding: var(--sp-3); padding-bottom: calc(64px + var(--sp-3)); }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 140px; min-width: 0; }
  /* 窄屏：竖排歌名与汉语曲名横向并排，消除竖排盒下方空白 */
  .page-head-mn { align-items: center; gap: var(--sp-3); }
  .song-title-mn { --mn-col-h: 4em; padding-left: var(--sp-3); }
  .song-title-mn .mn-v { font-size: var(--fs-md); }
  .song-alias-mn { --mn-col-h: 4em; padding-left: var(--sp-3); }
  .song-alias-mn .mn-v { font-size: var(--fs-sm); }
  .song-card-mn { --mn-col-h: 4em; padding-right: var(--sp-2); }
  .song-card-mn .mn-v { --mn-col-h: 4em; font-size: var(--fs-sm); }
  .song-card-lyric { --mn-col-h: 7em; }
  .card-body { padding: var(--sp-4); }
  .card-head { padding: var(--sp-3) var(--sp-4); }
  .grid-cards { grid-template-columns: minmax(0, 1fr); }
  .lyric-scroll { padding: var(--sp-2) var(--sp-3); }
  .lyric-row { gap: 5px; padding: 4px 6px; }
  .stat-card .sc-value { font-size: var(--fs-3xl); }
  .drawer { width: 100vw; }
  .modal-wrap { padding: var(--sp-2); }
  .modal-head, .modal-body { padding: var(--sp-4); }
  .modal-foot { padding: var(--sp-3) var(--sp-4); }
  .toast-host { left: var(--sp-3); right: var(--sp-3); max-width: none; }
  .app-footer { flex-direction: column; justify-content: center; gap: 2px; height: auto; padding: 6px var(--sp-4); }
  /* 移动端收起「指导单位 / 大创 / 版本号」这组次要信息，但备案号必须保留——
     备案例行要求在所有终端可见，隐藏它是合规风险。 */
  .app-footer .f-links > span,
  .app-footer .f-links > .dot { display: none; }
  .app-footer .f-links { display: flex; gap: var(--sp-3); }
  .filter-bar { grid-template-columns: minmax(0, 1fr); }
  /* 移动端底部标签栏 */
  .mobile-tabbar { display: grid; }
}
@media (max-width: 480px) {
  .grid-cards { gap: var(--sp-3); }
  .stat-card { padding: var(--sp-4); }
  .player { gap: var(--sp-3); padding: var(--sp-3); }
  .player .pl-time { display: none; }
}

/* 移动端底部导航（≤768px 显示） */
.mobile-tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: calc(var(--footer-h) - 8px); z-index: var(--z-header);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--bg-surface); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(15, 23, 42, .08);
  padding-bottom: env(safe-area-inset-bottom);
}
.mt-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 7px 2px; font-size: 10px; color: var(--text-muted);
  transition: color var(--dur-fast);
}
.mt-item svg { width: 19px; height: 19px; }
.mt-item.is-active { color: var(--brand-600); font-weight: var(--fw-semibold); }
[data-theme="dark"] .mt-item.is-active { color: var(--brand-300); }

/* 侧栏遮罩（移动端） */
.sidebar-mask {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none;
  visibility: hidden; transition: opacity var(--dur-base);
}
.sidebar-mask.show { opacity: 1; pointer-events: auto; visibility: visible; }

/* ======================= 曲目表单（新增 / 编辑歌词） ====================== */
.song-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.song-lines-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  padding-top: var(--sp-3); border-top: 1px solid var(--border);
}
.song-lines { display: flex; flex-direction: column; gap: var(--sp-2); }
/* 一句 = 行号 + 蒙文 + 汉译 + 时间轴 + 操作 */
.song-line {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 104px;
  gap: var(--sp-2); align-items: start;
  padding: var(--sp-2);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-surface-2);
}
.song-line-no {
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  color: var(--text-muted); text-align: center; padding-top: 6px;
}
/* 字段区改为两栏：左＝蒙文竖排输入列，右＝汉译 + 时间轴。
   与展示区（.lyric-mn / .lyric-cn）版式一致，做到「编辑所见＝展示所得」。 */
.song-line-fields {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: var(--sp-2);
  min-width: 0;
  align-items: start;
}
.song-line-fields > .mn-input-v { grid-column: 1; grid-row: 1 / span 2; }
.song-line-fields > [data-f="cn"] { grid-column: 2; grid-row: 1; }
.song-line-fields > .song-line-time { grid-column: 2; grid-row: 2; }
.song-line-fields .textarea { min-height: 46px; resize: vertical; line-height: 1.7; }
/* 蒙文唱词输入框：传统竖排（整行旋转 90°），字形与展示区完全一致。
   竖排下 inline-size=纵向书写长度、block-size=横向占宽（见 mongolian.css 说明）。 */
.song-line-fields .mn-input-v {
  writing-mode: vertical-lr;
  -webkit-writing-mode: vertical-lr;
  text-orientation: sideways;
  -webkit-text-orientation: sideways;
  text-combine-upright: none;
  /* 不用 vert：竖排靠整行旋转实现，混用竖排字形特性会二次变换 */
  font-feature-settings: "init" 1, "medi" 1, "fina" 1, "isol" 1, "rclt" 1, "liga" 1, "calt" 1;
  -webkit-font-feature-settings: "init" 1, "medi" 1, "fina" 1, "isol" 1, "rclt" 1, "liga" 1, "calt" 1;
  word-break: keep-all;
  letter-spacing: .06em;
  line-height: 1.9;
  /* 竖排下用物理尺寸最直观：height = 纵向书写长度，width = 横向占宽（列数）。
     长句自动向右换列；宽度不够时横向滚动，绝不纵向溢出。
     允许横向拉伸，录入超长句时可自行加宽。 */
  height: 200px;
  width: 132px;
  min-width: 72px;
  padding: 8px 9px;
  overflow-x: auto;
  overflow-y: hidden;
  resize: horizontal;
}
.song-line-fields .mn-input-v::placeholder { writing-mode: horizontal-tb; }
/* 三列：起始秒 / 时长秒 / 打点按钮。
   原来是 1fr 1fr（两列），加上打点按钮后第三个元素会掉到第二行，
   在两个输入框下方单独占一格，看起来像"多出来一个按钮"。
   auto 列的宽度由按钮自身决定，两个输入框仍然等分剩余空间。 */
.song-line-time { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: var(--sp-2); align-items: center; }
.song-line-time .input { min-height: 30px; font-size: var(--fs-2xs); padding: 0 6px; }
.song-line-ops { display: flex; flex-direction: column; gap: 4px; }
.song-line-ops .btn { padding: 3px 6px; }
/* 蒙文输入框：等宽 + 回鹘式字体，便于蒙科立输入法录入 */
.mn-input {
  font-family: var(--font-mn);
  font-feature-settings: "vert" 1, "init" 1, "medi" 1, "fina" 1, "rclt" 1, "liga" 1, "calt" 1;
  -webkit-font-feature-settings: "vert" 1, "init" 1, "medi" 1, "fina" 1, "rclt" 1, "liga" 1, "calt" 1;
  line-height: 1.9;
}
.mn-input::placeholder { font-family: var(--font-sans); }
/* 宽弹窗（曲目表单内容多）。
   ⚠ 必须同时覆盖 width，不能只写 max-width：
   .modal 是 `width: min(560px, 100%)`，宽度已经定死 560px，
   max-width 只是上限，不会把盒子撑大——所以 is-wide 一直没生效
   （实测加了 is-wide 后 computed width 仍是 560）。 */
.modal-wrap.is-wide .modal { width: min(880px, 100%); max-width: 880px; }
@media (max-width: 640px) {
  .song-line { grid-template-columns: 22px minmax(0, 1fr); }
  .song-line-ops { grid-column: 2; flex-direction: row; }
  /* 窄屏也保持三列：打点按钮是 auto 列，挤掉它会让校准功能在手机上前功尽弃 */
  .song-line-time { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
  /* 窄屏：蒙文竖排框与汉译上下堆叠，避免横向挤压 */
  .song-line-fields {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
  }
  .song-line-fields > .mn-input-v { grid-column: 1; grid-row: 1; }
  .song-line-fields > [data-f="cn"] { grid-column: 1; grid-row: 2; }
  .song-line-fields > .song-line-time { grid-column: 1; grid-row: 3; }
}

/* 批量粘贴区：因 modal() 复用同一容器，不能嵌套弹窗，
   故在曲目表单内原地展开该区域（可折叠）。 */
.song-batchpanel {
  display: flex; flex-direction: column;
  padding: var(--sp-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
}
.song-batchpanel .textarea { min-height: 90px; }

/* ---------------- 音频上传区（曲目表单内） ----------------
   设计要点：
   - 上传中禁用按钮，并用一条细进度条给出"在动"的反馈：fetch 没有上传
     进度事件（XHR 才有），所以这里是**不确定进度**的视觉提示（12% 宽 +
     CSS 动画来回走），而不是真实百分比——画一条假的百分比进度条比不画更糟。
   - 播放器默认隐藏，选中文件后才出现，避免表单一开始就多一个空控件。 */
.audio-slot {
  display: flex; flex-direction: column;
  padding: var(--sp-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
}
.audio-slot-row {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;
}
.audio-slot-row .btn { flex-shrink: 0; gap: 6px; }
.audio-slot-name {
  flex: 1 1 auto; min-width: 0;
  /* 文件名可能很长（audio-<hash>.mp3），单行省略不换行撑高卡片 */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.audio-slot-progress {
  margin-top: var(--sp-2);
  height: 4px; border-radius: 999px;
  background: var(--bg-surface-3, rgba(127,127,127,.18));
  overflow: hidden;
}
.audio-slot-bar {
  height: 100%; width: 0;
  border-radius: inherit;
  background: var(--brand, #b45309);
  transition: width .25s ease;
  animation: audio-slot-walk 1.4s ease-in-out infinite;
}
@keyframes audio-slot-walk {
  0%   { transform: translateX(-30%); }
  50%  { transform: translateX(120%); }
  100% { transform: translateX(-30%); }
}
@media (prefers-reduced-motion: reduce) {
  .audio-slot-bar { animation: none; }
}
.audio-slot audio {
  height: 34px;
  border-radius: var(--radius-sm);
}

/* 打点按钮：与「起始秒 / 时长秒」两个输入框同一行，尺寸对齐输入框高度。
   命中瞬间闪一下品牌色，给"确实写进去了"的即时反馈——校准时这个反馈很重要，
   否则用户会怀疑自己有没有点到，反复乱点。 */
.song-line-time .line-tap {
  flex: 0 0 auto;
  align-self: stretch;
  padding-inline: 6px;
  color: var(--text-muted);
}
.song-line-time .line-tap:hover { color: var(--brand, #b45309); }
.song-line.is-tapped { animation: line-tapped .6s ease; }
@keyframes line-tapped {
  0%   { background: transparent; }
  30%  { background: color-mix(in srgb, var(--brand, #b45309) 14%, transparent); }
  100% { background: transparent; }
}

/* 极窄顶栏：保留主题、无障碍、用户与主导航，隐藏两个次要动作，
   避免 coarse pointer 下 44px 控件把 320/360px 顶栏撑出视口。 */
@media (max-width: 380px) {
  #btn-export, #btn-notify { display: none; }
}

/* 触摸设备：实际控件或透明伪元素命中区均不小于 44px。
   视觉尺寸仍保持原有书卷式密度，不改动桌面端布局。 */
@media (pointer: coarse) {
  .btn, .header-btn, .user-trigger, .nav-item, .popover-item,
  .chip, .pager-btn, .input, .select, .textarea,
  .switch, .checkbox, .lyric-row, .pl-rate, .mt-item,
  .chart-legend .lg, .hl {
    min-height: 44px;
  }
  .btn-icon, .header-btn, .user-trigger, .pager-btn,
  .player .pl-btn, .chart-legend .lg, .hl {
    min-width: 44px;
  }
  .player .pl-btn { width: 44px; height: 44px; }
  .pl-vol, .pl-vol input[type="range"], .audio-slot audio { min-height: 44px; }
  .pl-vol input[type="range"] { height: 44px; }
  /* 5px 视觉轨道 + 上下各约 20px 透明区域 = 45px 命中高度。 */
  .seek::after { inset: -20px 0; }
  .mt-item { min-width: 0; }
}
