/* ============================================================
   拾验社 ShiyanClub · 全局样式（设计契约单一实现）
   温馨教研风 minimal-light：赤陶橙主色 + 杏黄点缀 + 暖纸底
   ============================================================ */

:root {
  /* 页面自带浅色/深色两套主题；声明 color-scheme 让原生滚动条、表单控件跟随主题 */
  color-scheme: light dark;
  --primary: #C05B3C; --primary-hover: #A84A2E; --primary-soft: #F7E6DD;
  --accent: #E9B44C; --accent-soft: #FBF1DB;
  --bg: #FAF6EF; --surface: #FFFFFF; --border: #EAE2D4;
  --text: #2E2823; --text-sub: #857768;
  --success: #5F9E6E; --warning: #D97E2B; --danger: #C74440;
  --c-phys: #4E7CA6; --c-chem: #C05B3C; --c-bio: #6E8F4E;
  --font-display: Georgia, "Songti SC", "STSong", "SimSun", serif;
  --font-body: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Consolas, "Courier New", monospace;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --sh-sm: 0 1px 2px rgba(62, 48, 42, .06);
  --sh-md: 0 6px 18px rgba(62, 48, 42, .08);
  --sh-lg: 0 16px 40px rgba(62, 48, 42, .13);
  --sidebar-w: 232px;
  --stage-bg: #F4EDE1;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 14px; line-height: 1.6; color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--primary-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #CFCCBE; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- App Shell（每页逐字一致，禁止改动） ---------------- */
.app-nav {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: #FFFDF9;
  border-right: 1px solid var(--border);
  color: var(--text); display: flex; flex-direction: column;
  padding: 20px 14px 16px;
}
.app-main {
  margin-left: var(--sidebar-w); min-height: 100vh;
  padding: 28px 32px 48px;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(192, 91, 60, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(192, 91, 60, .05) 1px, transparent 1px);
  background-size: 24px 24px;
}
.page-wrap { max-width: 1120px; margin: 0 auto; }

.nav-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--primary); color: #FFF7EC;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-text { font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: .5px; color: var(--text); line-height: 1.2; }
.brand-text em { display: block; font-style: normal; font-family: var(--font-mono); font-size: 9px; letter-spacing: 2.5px; color: #B3A48F; font-weight: 400; }

.nav-menu { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: #6E6053; font-size: 14px; font-weight: 500;
  transition: background .18s ease, color .18s ease;
}
/* hidden 属性优先于 display:flex（管理后台入口按角色隐藏） */
.nav-item[hidden] { display: none !important; }
.nav-item:hover { background: #F5EDE1; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item .ic { flex: none; }

/* 主题开关：侧栏底部独立按钮（不混在导航菜单里） */
.theme-toggle {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 12px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-sub);
  font-family: inherit; font-size: 13px; font-weight: 600;
  text-align: left; cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.theme-toggle:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft); }
.theme-toggle .ic { flex: none; }

.nav-footer { border-top: 1px solid var(--border); padding-top: 14px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 15px;
}
.user-meta b { display: block; font-size: 13px; color: var(--text); font-weight: 600; }
.user-meta i { display: block; font-style: normal; font-size: 11px; color: var(--text-sub); }

/* ---------------- 通用组件 ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.card-pad { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--r-md);
  padding: 9px 16px; font-size: 14px; font-weight: 600; line-height: 1;
  transition: all .18s ease; white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover:not(:disabled) { background: #D5E7DE; }
.btn-accent { background: var(--accent); color: #12312A; }
.btn-accent:hover:not(:disabled) { background: #D9952F; transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }

.input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); padding: 9px 13px; font-size: 14px; outline: none;
  transition: border .18s ease, box-shadow .18s ease;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 95, 75, .12); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7366' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.tag-phys { background: #E3ECF4; color: var(--c-phys); }
.tag-chem { background: #F7E6DD; color: var(--c-chem); }
.tag-bio { background: #EAF0E2; color: var(--c-bio); }
.tag-coming { background: #F0E9DA; color: #9A8A6B; }
.tag-soft { background: var(--primary-soft); color: var(--primary); }

/* 页头 */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.25; }
.page-sub { color: var(--text-sub); font-size: 13px; margin-top: 4px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 14px; }
.sec-title { font-family: var(--font-display); font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.sec-title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--accent); }
.sec-link { font-size: 13px; color: var(--primary); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.sec-link:hover { text-decoration: underline; }

/* 实验卡（工作台/实验库共用） */
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
/* ---------------- 实验库 · 教材目录树（人教版 → 册 → 实验） ---------------- */
.lib-toolbar { padding: 14px 18px; }
.lib-toolbar-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.lib-path { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-sub); }
.lib-path .ic { color: var(--primary); }
.lib-path b { font-family: var(--font-display); font-size: 15px; color: var(--text); }
.lib-path i { font-style: normal; color: var(--text-dim, #B3A48F); }
.lib-filter-toggle.on { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.lib-filter-panel { display: none; margin-top: 13px; padding-top: 13px; border-top: 1px dashed var(--border); }
.lib-filter-panel.open { display: block; }
.lib-filter-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.lib-filter-row + .lib-filter-row { margin-top: 11px; }

.lib-version-head { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; }
.lib-version-icon {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.lib-version-main { display: flex; flex-direction: column; line-height: 1.35; }
.lib-version-main b { font-family: var(--font-display); font-size: 18px; }
.lib-version-main span { font-size: 12px; color: var(--text-sub); }
.lib-version-tip { margin-left: auto; font-size: 12px; color: var(--text-sub); }

.lib-books { display: flex; flex-direction: column; gap: 14px; }
.lib-book {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--sh-sm); overflow: hidden;
}
.lib-book-head {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 13px 16px; border: none; border-bottom: 1px solid var(--border);
  background: #FFFDF9; transition: background .16s ease;
}
.lib-book-head:hover { background: var(--primary-soft); }
.lib-book-subj { flex: none; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.lib-book-name { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.lib-book-count { font-size: 12px; color: var(--text-sub); }
.lib-caret { margin-left: auto; flex: none; display: inline-flex; color: var(--text-sub); transform: rotate(90deg); transition: transform .18s ease; }
.collapsed > .lib-book-body { display: none; }
.collapsed > .lib-book-head .lib-caret { transform: rotate(0deg); }
.lib-book-body { padding: 4px 16px 16px; }
/* 不按章分组：一册的实验平铺成网格，一行排满 4 个 */
.lib-book-body .exp-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }

.exp-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--sh-sm); cursor: pointer; display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.exp-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: #CFCDBC; }
.exp-card.is-coming { cursor: default; opacity: .78; }
.exp-card.is-coming:hover { transform: none; box-shadow: var(--sh-sm); border-color: var(--border); }
.exp-link { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.exp-card.is-coming .exp-link { cursor: default; }

/* 卡片右下角：这个实验被改编过几次，点开看所有版本（与互动数同一行） */
.exp-versions {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: auto; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--primary);
  font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: border-color .16s ease, background .16s ease;
}
.exp-versions:hover { border-color: var(--primary); background: var(--primary-soft); }
.exp-versions b { font-size: 11.5px; font-weight: 600; }
.exp-versions .ic { flex: none; }

/* 卡片右上角：学科文字（物理 / 化学 / 生物），颜色沿用学科标签色 */
.exp-subj {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  font-size: 11px; font-weight: 600; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 999px;
  box-shadow: 0 1px 4px rgba(20, 16, 12, .18);
}

/* 版本弹窗列表 */
.ver-tip { font-size: 12px; color: var(--text-sub); line-height: 1.65; margin-bottom: 14px; }
.ver-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; padding: 1px; }
.ver-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: #FDFBF6; transition: border-color .15s ease, background .15s ease;
}
.ver-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.ver-main { min-width: 0; flex: 1; }
.ver-head { display: flex; align-items: center; gap: 7px; }
.ver-head b { font-size: 13px; }
.ver-head em {
  font-style: normal; font-size: 10.5px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 5px;
  background: var(--accent-soft); color: #A67C1A;
}
.ver-head time { margin-left: auto; font-size: 11px; color: var(--text-sub); }
.ver-name {
  margin: 3px 0; font-size: 12px; color: var(--text-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ver-meta { display: flex; gap: 10px; font-size: 11.5px; color: var(--text-sub); }
.ver-meta span { display: inline-flex; align-items: center; gap: 3px; }
.ver-root {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 12px; padding: 9px; border-radius: 9px;
  border: 1px dashed var(--border); font-size: 12.5px; font-weight: 600; color: var(--primary);
}
.ver-root:hover { background: var(--primary-soft); }
.exp-cover { position: relative; aspect-ratio: 16 / 8.2; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, .92); }
.continue-thumb { width: 88px; height: 56px; border-radius: 10px; flex: none; border: 1px solid var(--border); background: #F4EDE1; display: block; }
.cover-phys { background: linear-gradient(135deg, #4E7CA6, #3A6285); }
.cover-chem { background: linear-gradient(135deg, #C05B3C, #9A4527); }
.cover-bio { background: linear-gradient(135deg, #6E8F4E, #547239); }
.exp-cover::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, .09) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .09) 1px, transparent 1px);
  background-size: 18px 18px;
}
.exp-thumb { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.exp-cover { isolation: isolate; }
.exp-cover .dur {
  position: absolute; right: 10px; bottom: 10px; z-index: 1;
  background: rgba(0, 0, 0, .32); color: #fff; font-size: 11px;
  padding: 3px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px;
}
.exp-cover .coming-badge {
  position: absolute; left: 10px; top: 10px; z-index: 1;
  background: rgba(0, 0, 0, .35); color: #FFE9BF; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
}
/* 实验库标识：可拖拽 / 参数演示 */
.exp-cover .inter-badge,
.exp-cover .demo-badge {
  position: absolute; left: 10px; top: 10px; z-index: 1;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  backdrop-filter: blur(2px);
}
.exp-cover .inter-badge { background: rgba(20, 16, 12, .58); color: #FFE9BF; border: 1px solid rgba(233, 180, 76, .6); }
.exp-cover .inter-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #E9B44C; }
.exp-cover .demo-badge { background: rgba(20, 16, 12, .34); color: rgba(255, 255, 255, .74); border: 1px solid rgba(255, 255, 255, .2); }
.exp-cover .demo-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, .5); }
.exp-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.exp-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
/* 实验名只占一行，超出用省略号 */
.exp-title-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-title .ic { color: var(--text-sub); flex: none; }
.exp-desc { font-size: 12.5px; color: var(--text-sub); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.exp-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.exp-plays { margin-left: auto; font-size: 12px; color: var(--text-sub); display: inline-flex; align-items: center; gap: 4px; }

/* tabs */
.tabs { display: inline-flex; gap: 4px; background: #F1E9DA; border-radius: var(--r-md); padding: 4px; }
.tab {
  border: none; background: transparent; border-radius: 7px;
  padding: 7px 16px; font-size: 13px; font-weight: 600; color: var(--text-sub);
  transition: all .18s ease;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--sh-sm); }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; font-weight: 500; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: #E3D8C6; transition: background .18s ease; position: relative; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--sh-sm); transition: transform .18s ease; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(14px); }

/* range slider */
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--primary) var(--fill, 50%), #EBDFCC var(--fill, 50%));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--primary); box-shadow: var(--sh-sm); cursor: grab;
  transition: transform .15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2.5px solid var(--primary); cursor: grab; }

/* table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-sub); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 14px; border-bottom: 1px solid #F1EADF; font-size: 13.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: #FBF7EE; }
.table-wrap { overflow-x: auto; }

/* 状态徽标 */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.status-ready { color: var(--success); } .status-ready::before { background: var(--success); }
.status-processing { color: var(--warning); } .status-processing::before { background: var(--warning); animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* modal */
.modal-mask {
  position: fixed; inset: 0; z-index: 90; background: rgba(20, 30, 26, .45);
  display: none; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-mask.open { display: flex; animation: fadeIn .18s ease; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  width: 520px; max-width: 100%; max-height: 90vh; overflow: auto;
  animation: rise .25s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.modal-x { border: none; background: #F5EEE1; color: var(--text-sub); width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; transition: all .15s ease; }
.modal-x:hover { background: var(--danger); color: #fff; }
.modal-body { padding: 16px 22px 22px; }

/* toast */
#toast-root { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 7px;
  background: #3E302A; color: #F7EEE2; font-size: 13px; font-weight: 500;
  padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--sh-lg);
  opacity: 0; transform: translateY(-8px); transition: all .25s ease;
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--primary); }
.toast-danger { background: var(--danger); }

/* empty / skeleton */
.empty { text-align: center; padding: 56px 20px; color: var(--text-sub); }
.empty .ic { width: 40px; height: 40px; color: #C8C5B4; margin-bottom: 10px; }
.empty b { display: block; font-size: 15px; color: var(--text); margin-bottom: 4px; }
.skl { border-radius: var(--r-md); background: linear-gradient(90deg, #F0E8DA 25%, #FAF4EA 50%, #F0E8DA 75%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { to { background-position: -135% 0; } }

/* reveal 页面载入编排 */
.reveal { opacity: 0; transform: translateY(10px); animation: rise .5s ease forwards; animation-delay: var(--d, 0s); }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } }

/* 统计卡 */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-card { padding: 16px 18px; display: flex; align-items: center; gap: 13px; }
.stat-ic { width: 40px; height: 40px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.stat-ic.green { background: var(--primary-soft); color: var(--primary); }
.stat-ic.amber { background: var(--accent-soft); color: #A67C1A; }
.stat-ic.blue { background: #E3ECF4; color: var(--c-phys); }
.stat-ic.red { background: #F7E6DD; color: var(--c-chem); }
.stat-num { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-sub); }

/* ---------------- 演示台 play ---------------- */
.play-topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.play-topbar .crumb { font-size: 13px; color: var(--text-sub); display: inline-flex; align-items: center; gap: 5px; }
.play-topbar .crumb a { color: var(--primary); font-weight: 600; }
.play-topbar .crumb a:hover { text-decoration: underline; }
.play-topbar h1 { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.play-topbar .spacer { flex: 1; }

.play-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.stage-card { padding: 16px; }
.stage-wrap { position: relative; border-radius: var(--r-md); overflow: hidden; background: var(--stage-bg); border: 1px solid var(--border); display: flex; }
/* 全屏：整块演示区进全屏，动画 + 操作按钮 + 参数/读数 + 说明 + 曲线一起看 */
.fs-shell:fullscreen {
  height: 100vh; overflow: hidden; padding: 18px 22px 20px;
  background: var(--bg);
  display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 14px;
}
.fs-shell:fullscreen .play-grid {
  height: 100%; min-height: 0; align-items: stretch;
  grid-template-columns: minmax(0, 1fr) 300px;
}
.fs-shell:fullscreen .stage-card { display: flex; flex-direction: column; padding: 12px; min-height: 0; }
.fs-shell:fullscreen .stage-wrap { flex: 1; min-height: 0; }
.fs-shell:fullscreen #stage { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.fs-shell:fullscreen .stage-toolbar { margin-top: 10px; }
.fs-shell:fullscreen .panel-stack { overflow-y: auto; }
.fs-shell:fullscreen .chart-canvas-wrap { min-height: 200px; }
#fs-exit { display: none; }
.fs-shell:fullscreen #fs-exit { display: inline-flex; }
.fs-shell:fullscreen #ai-open { display: none; }
#stage { display: block; width: 100%; height: auto; align-self: center; }
.stage-endtip {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(62, 48, 42, .82); color: #FBF2E4; font-size: 12.5px;
  padding: 6px 14px; border-radius: 999px; display: none; align-items: center; gap: 6px;
  backdrop-filter: blur(3px);
}
.stage-endtip.show { display: inline-flex; animation: rise .3s ease; }
.stage-toolbar { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.stage-toolbar #ai-open { margin-left: auto; }
.stage-toolbar .divider { width: 1px; height: 22px; background: var(--border); }
.speed-select { width: 88px; padding: 7px 26px 7px 10px; font-size: 13px; }

/* 可操作实验：交互条 / 浮动微调 / 学生模式 */
#stage { touch-action: none; user-select: none; -webkit-user-select: none; }
.interact-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--primary-soft);
}
.interact-bar[hidden] { display: none; }
.ib-hint { flex: 1 1 200px; min-width: 160px; font-size: 12.5px; color: var(--text-sub); line-height: 1.5; }
.ib-tools { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ib-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.ib-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--r-sm); padding: 7px 11px; font-size: 12.5px; font-weight: 600;
  line-height: 1; white-space: nowrap; transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.ib-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.ib-btn:disabled { opacity: .42; cursor: not-allowed; }
.ib-btn.on { background: var(--surface); border-color: var(--primary); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.stage-nudge {
  position: absolute; transform: translate(-50%, -100%); z-index: 5;
  display: flex; align-items: center; gap: 3px; padding: 3px;
  background: rgba(255, 253, 249, .95); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--sh-sm); pointer-events: auto;
}
.stage-nudge[hidden] { display: none; }
.stage-nudge button {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 700; line-height: 1;
}
.stage-nudge button:hover { border-color: var(--primary); color: var(--primary); }
.stage-nudge span {
  max-width: 200px; padding: 0 3px; font-size: 11px; color: var(--text-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.student-title { display: none; font-family: var(--font-display); font-size: 18px; font-weight: 700; }
#student-btn[hidden] { display: none; }
body.student-mode .app-nav,
body.student-mode .panel-stack,
body.student-mode .play-bottom,
body.student-mode .stage-toolbar,
body.student-mode .play-topbar .crumb,
body.student-mode .play-topbar #sim-select,
body.student-mode .play-topbar #exp-tags,
body.student-mode .play-topbar #fav-btn,
body.student-mode .play-topbar #fs-btn,
body.student-mode .play-topbar #export-btn { display: none !important; }
body.student-mode .app-main { margin-left: 0; padding: 18px 20px 24px; }
body.student-mode .page-wrap { max-width: none; }
body.student-mode .play-grid { grid-template-columns: minmax(0, 1fr); }
body.student-mode .play-topbar { justify-content: flex-end; margin-bottom: 12px; }
body.student-mode .student-title { display: block; margin-right: auto; }
body.student-mode .stage-card { padding: 12px; }
html[data-theme="dark"] .stage-nudge { background: rgba(28, 23, 18, .95); }


.panel-stack { display: flex; flex-direction: column; gap: 14px; }
.panel-title { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 7px; margin-bottom: 12px; }
.panel-title .ic { color: var(--primary); }

.param-row { margin-bottom: 14px; }
.param-row:last-child { margin-bottom: 2px; }
.param-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.param-name { font-size: 13px; font-weight: 500; }
.param-val { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 1px 8px; border-radius: 6px; }

.ro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ro { background: #FAF4EA; border: 1px solid #F0E6D6; border-radius: var(--r-md); padding: 8px 11px; }
.ro label { display: block; font-size: 11px; color: var(--text-sub); margin-bottom: 1px; }
.ro b { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--text); }
.ro small { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-sub); margin-left: 2px; }

.teach-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.teach-list li { font-size: 13px; color: var(--text); display: flex; gap: 8px; line-height: 1.55; }
.teach-list li::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 8px; }

/* 数据曲线卡：与右侧教学卡等高，画布吃掉剩余高度 */
.chart-card { padding: 16px 20px 12px; display: flex; flex-direction: column; }
.chart-canvas-wrap { position: relative; flex: 1; min-height: 170px; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }

/* 演示台底部一行：数据曲线（左）× 实验说明要点（右），两卡等高 */
.play-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; margin-top: 18px; align-items: stretch; }

/* 导出弹窗 */
.fmt-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.fmt-opt { position: relative; }
.fmt-opt input { position: absolute; opacity: 0; pointer-events: none; }
.fmt-opt .box {
  border: 1.5px solid var(--border); border-radius: var(--r-md); padding: 12px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  cursor: pointer; transition: all .18s ease;
}
.fmt-opt .box b { font-size: 13px; }
.fmt-opt .box span { font-size: 11px; color: var(--text-sub); line-height: 1.4; }
.fmt-opt .box .ic { width: 20px; height: 20px; color: var(--text-sub); }
.fmt-opt input:checked + .box { border-color: var(--primary); background: var(--primary-soft); }
.fmt-opt input:checked + .box .ic, .fmt-opt input:checked + .box b { color: var(--primary); }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.export-progress { padding: 8px 0 2px; }
.export-step { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-sub); padding: 5px 0; }
.export-step.done { color: var(--text); }
.export-step .ic { color: var(--primary); }
.bar { height: 6px; border-radius: 999px; background: #ECEADF; overflow: hidden; margin: 12px 0 4px; }
.bar i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .3s ease; }
.export-ok { text-align: center; padding: 14px 0 4px; }
.export-ok .ok-ic { width: 52px; height: 52px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }

/* ---------------- 响应式（手机：底部标签栏） ---------------- */
@media (max-width: 1080px) {
  .play-grid, .play-bottom { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app-nav {
    inset: auto 0 0 0; width: 100%; height: 60px;
    flex-direction: row; align-items: stretch; padding: 0 6px;
    border-right: 0; border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(62, 48, 42, .1);
  }
  .nav-brand { display: none; }
  .nav-menu { flex-direction: row; margin-top: 0; width: 100%; justify-content: space-around; gap: 0; }
  /* 侧栏整体收成底部标签栏，主题开关改为悬浮按钮（不占用菜单位） */
  .nav-footer { display: block; border-top: 0; padding-top: 0; }
  .nav-footer .user-card { display: none; }
  .theme-toggle {
    position: fixed; right: 14px; bottom: 74px; z-index: 70;
    width: 40px; height: 40px; padding: 0; margin: 0;
    border-radius: 50%; justify-content: center;
    background: var(--surface); box-shadow: 0 3px 14px rgba(62, 48, 42, .16);
  }
  .theme-toggle .nav-label { display: none; }
  .nav-item { flex-direction: column; gap: 3px; padding: 6px 16px; font-size: 10.5px; border-radius: 10px; align-items: center; }
  .app-main { margin-left: 0; padding: 18px 14px 84px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .stage-toolbar .btn span { display: none; }
  .stage-toolbar .btn { padding: 9px 12px; }
}
@media (max-width: 560px) {
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .fmt-group { grid-template-columns: 1fr; }
  .ro-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 22px; }
}

/* 管理员需求池 */
.wish-list { display: flex; flex-direction: column; gap: 12px; }
.wish-item { display: flex; flex-direction: column; gap: 8px; }
.wish-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.wish-status { font-size: 11px; font-weight: 600; color: #9A8A6B; background: #F0E9DA; border-radius: 999px; padding: 3px 9px; }
.wish-status.done { color: var(--success); background: #E4F0E6; }
.wish-time { margin-left: auto; font-size: 12px; color: var(--text-sub); }
.wish-content { font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.wish-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 52px 20px; color: var(--text-sub); text-align: center; }
.wish-empty b { font-size: 15px; color: var(--text); }

/* ---------------- 登录 / 注册 ---------------- */
.user-card { cursor: pointer; border-radius: var(--r-md); transition: background .15s ease; }
.user-card:hover { background: var(--primary-soft); }
.avatar-guest { background: #EFE7D8; color: #8A7A63; }
html[data-theme="dark"] .avatar-guest { background: #332A21; color: #A89A87; }
.auth-sub { font-size: 13px; color: var(--text-sub); line-height: 1.65; margin-bottom: 14px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px; }
.auth-tabs[hidden] { display: none !important; }
.auth-tab { flex: 1; border: none; background: none; border-radius: 4px; padding: 8px 6px; font-size: 13px; font-family: inherit; color: var(--text-sub); cursor: pointer; transition: background .15s, color .15s; }
.auth-tab:hover { color: var(--text); }
.auth-tab.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--sh-sm); }
.auth-hint { margin-top: 10px; font-size: 11.5px; color: var(--text-sub); line-height: 1.6; }
.auth-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin: 12px 0 6px; }
.auth-label span { font-weight: 500; color: var(--text-sub); font-size: 11.5px; }
.auth-code { font-family: var(--font-mono); font-size: 22px; letter-spacing: 6px; text-align: center; }
.auth-actions { display: flex; gap: 10px; margin-top: 16px; }
.auth-actions .btn { flex: 1; }
.auth-sent { font-size: 12.5px; color: var(--text-sub); margin-bottom: 4px; }
.auth-dev { margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--primary); background: var(--primary-soft); border-radius: var(--r-sm); padding: 8px 10px; }
.auth-resend { border: none; background: none; color: var(--primary); font-size: 12.5px; margin-top: 12px; padding: 0; }
.auth-resend:hover { text-decoration: underline; }
.auth-note { margin-top: 16px; font-size: 11.5px; color: var(--text-sub); border-top: 1px dashed var(--border); padding-top: 10px; }

/* 页面级登录闸 */
.auth-gate { min-height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.auth-gate-ic { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.auth-gate h1 { font-family: var(--font-display); font-size: 22px; }
.auth-gate p { color: var(--text-sub); font-size: 13px; max-width: 430px; }
.auth-gate .btn { margin-top: 6px; }
.auth-gate-tip { font-size: 11.5px; color: var(--text-sub); }

/* ---------------- 管理员：用户统计 + 需求池 ---------------- */
.admin-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.admin-stat { padding: 16px 18px; }
.admin-stat b { display: block; font-family: var(--font-display); font-size: 24px; line-height: 1.2; }
.admin-stat span { font-size: 12px; color: var(--text-sub); }
.admin-stat em { display: block; font-style: normal; font-size: 11px; color: var(--text-sub); margin-top: 4px; }
.admin-sec { margin-top: 26px; }
.admin-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.admin-sec-head h2 { font-family: var(--font-display); font-size: 17px; }
.admin-sec-head span { font-size: 12px; color: var(--text-sub); }
.admin-table { font-size: 12.5px; }
.admin-table .mono { font-family: var(--font-mono); font-size: 12px; }
.admin-role { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.admin-role.admin { color: var(--primary); background: var(--primary-soft); }
.admin-role.user { color: var(--text-sub); background: #F0E9DA; }
html[data-theme="dark"] .admin-role.user { background: #332A21; }
.admin-empty { padding: 28px; text-align: center; color: var(--text-sub); font-size: 13px; }
.admin-panel .wish-list { margin-top: 4px; }
@media (max-width: 960px) { .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------------- 管理员：模型配置 ---------------- */
.config-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.config-card { margin-bottom: 16px; }
.config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 22px; }
.config-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.config-field > label { font-size: 12.5px; font-weight: 700; color: var(--text); }
.config-field > small { font-size: 11.5px; line-height: 1.55; color: var(--text-sub); }
.config-field code { font-family: var(--font-mono); font-size: 11px; background: var(--primary-soft); color: var(--primary); border-radius: 4px; padding: 1px 4px; }
.config-wide { grid-column: 1 / -1; }
.config-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.config-key-row { display: flex; align-items: center; gap: 8px; }
.config-key-row .input { flex: 1; min-width: 0; }
.config-textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
.config-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 4px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.config-msg { margin-right: auto; font-size: 12.5px; color: var(--text-sub); line-height: 1.5; }
.config-msg .ok { color: var(--primary); font-weight: 600; }
.config-msg .err { color: #C0392B; font-weight: 600; }
html[data-theme="dark"] .config-msg .err { color: #F2907F; }
.config-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; line-height: 1; padding: 6px 10px; border-radius: 999px; background: #F0E9DA; color: var(--text-sub); white-space: nowrap; }
html[data-theme="dark"] .config-chip { background: #332A21; }
.config-chip.ok { background: var(--primary-soft); color: var(--primary); }
.config-chip.warn { background: #F7E6DD; color: #B54A3B; }
html[data-theme="dark"] .config-chip.warn { background: #3B2A21; color: #F2907F; }
.config-note b { display: block; font-size: 13px; margin-bottom: 8px; color: var(--text); }
.config-note p { font-size: 12.5px; line-height: 1.75; color: var(--text-sub); }
@media (max-width: 760px) {
  .config-grid { grid-template-columns: 1fr; }
  .config-key-row { flex-wrap: wrap; }
  .config-key-row .input { flex-basis: 100%; }
}

/* ---------------- 深色主题（暗场投影 / 深色 PPT） ---------------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15120F; --surface: #201B16; --border: #3A322A;
  --text: #F2EADB; --text-sub: #A89A87; --text-dim: #7E7263;
  --primary: #E0714C; --primary-hover: #F0835D; --primary-soft: #3B2A21;
  --accent: #E9B44C; --accent-soft: #3A2E1B;
  --c-phys: #7FAEDB; --c-chem: #E0714C; --c-bio: #92B46A;
  --paper: #2A231C;
  --stage-bg: #12100D;
  --sh-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --sh-md: 0 6px 18px rgba(0, 0, 0, .5);
  --sh-lg: 0 16px 40px rgba(0, 0, 0, .65);
}
html[data-theme="dark"] .app-nav { background: #1C1712; }
html[data-theme="dark"] .brand-mark { color: #FFF3E3; }
html[data-theme="dark"] .brand-text em { color: #8B7F6D; }
html[data-theme="dark"] .nav-item { color: #C6B9A5; }
html[data-theme="dark"] .nav-item:hover { background: #2A231C; }
html[data-theme="dark"] .nav-item.active { background: var(--primary-soft); color: var(--primary); }
html[data-theme="dark"] .tabs { background: #2A231C; border-color: #3A322A; }
html[data-theme="dark"] .tabs button.active { background: var(--surface); }
html[data-theme="dark"] .ro { background: #2A231C; border-color: #3A322A; }
html[data-theme="dark"] .table td { border-bottom-color: #332C24; }
html[data-theme="dark"] .table tbody tr:hover { background: #2A231C; }
html[data-theme="dark"] .modal-x { background: #2A231C; }
html[data-theme="dark"] .bar { background: #332A22; }
html[data-theme="dark"] .skl { background: linear-gradient(90deg, #2A231C 25%, #332A22 50%, #2A231C 75%); background-size: 400% 100%; }
html[data-theme="dark"] .tag-soft { background: #332A22; color: #B7A992; }
html[data-theme="dark"] .tag-coming { background: #332A22; color: #A2926F; }
html[data-theme="dark"] .continue-thumb { background: #2A231C; }
html[data-theme="dark"] .tag-phys { background: rgba(127, 174, 219, .16); }
html[data-theme="dark"] .tag-chem { background: rgba(224, 113, 76, .16); }
html[data-theme="dark"] .tag-bio { background: rgba(146, 180, 106, .16); }
html[data-theme="dark"] .stat-ic.blue { background: rgba(127, 174, 219, .16); }
html[data-theme="dark"] .stat-ic.red { background: rgba(224, 113, 76, .16); }
html[data-theme="dark"] .stat-ic.green { background: rgba(146, 180, 106, .16); }
html[data-theme="dark"] .empty .ic { color: #6B6152; }
html[data-theme="dark"] .btn-soft:hover:not(:disabled) { background: #33302A; }
html[data-theme="dark"] .backdrop { background: rgba(0, 0, 0, .6); }
html[data-theme="dark"] .exp-card { background: var(--surface); }
html[data-theme="dark"] .exp-card:hover { border-color: #4E4438; }
html[data-theme="dark"] .exp-versions { background: #2A231C; }
html[data-theme="dark"] .exp-versions:hover { background: #3A2A22; }
html[data-theme="dark"] .ver-item { background: #221C17; }
html[data-theme="dark"] .ver-item:hover { background: #3A2A22; }
html[data-theme="dark"] .ver-head em { background: #3A301C; color: #E9B44C; }
html[data-theme="dark"] .exp-cover { color: rgba(255, 255, 255, .92); }
html[data-theme="dark"] .lib-book-head { background: #221C17; }
html[data-theme="dark"] .lib-book-head:hover { background: #3A2A22; }
html[data-theme="dark"] .lib-version-icon { background: var(--primary-soft); }
html[data-theme="dark"] .lib-filter-toggle.on { background: var(--primary-soft); }

/* ============================================================
   演示台 · AI 修改 + 点赞评论（后端迭代闭环）
   ============================================================ */
.play-community { margin-top: 18px; grid-template-columns: minmax(0, 1fr); }
.ai-hint { font-size: 12.5px; color: var(--text-sub); line-height: 1.6; margin-bottom: 12px; }
.ai-hint b { color: var(--primary); }

/* AI 修改弹窗：按钮唤出，发布 / 取消 */
.ai-modal { width: 640px; }
.ai-modal .chat-log { max-height: min(44vh, 340px); border-top: none; padding-top: 0; }
.ai-modal-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border);
}
.ai-modal-actions .ai-tip { margin-right: auto; font-size: 11.5px; color: var(--text-sub); }

.chat-log {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 250px; overflow-y: auto;
  padding: 6px 4px 10px; border-top: 1px dashed var(--border);
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg .bubble {
  max-width: 86%; padding: 9px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  animation: rise .25s ease;
}
.chat-msg.ai .bubble { background: #FAF4EA; border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg.user .bubble { background: var(--primary); color: #FFF7EC; border-bottom-right-radius: 4px; }

.chat-input { display: flex; gap: 10px; align-items: flex-end; }
.chat-input textarea {
  flex: 1; min-height: 46px; max-height: 120px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  padding: 9px 11px; font-size: 13px; line-height: 1.5;
}
.chat-input textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chat-input .btn { white-space: nowrap; }

.chat-suggests { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chat-suggests button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-sub);
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  transition: border-color .15s, color .15s;
}
.chat-suggests button:hover { border-color: var(--primary); color: var(--primary); }

.ai-result {
  margin-top: 4px; padding: 12px; border-radius: var(--r-md);
  background: var(--accent-soft); border: 1px solid #EFDFC0;
  animation: rise .3s ease;
}
.ai-result b { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ai-result b .ic { color: var(--primary); }
.ai-result p { font-size: 12.5px; color: var(--text-sub); margin: 6px 0 10px; line-height: 1.6; }
.ai-result-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* 点赞：讨论区条上的迷你按钮，不抢讨论区的视觉 */
.like-mini {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-sub);
  font-size: 12px; font-weight: 600; line-height: 1;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.like-mini:hover { border-color: #E9B44C; color: #A67C1A; }
.like-mini .ic { width: 13px; height: 13px; color: var(--text-sub); }
.like-mini b { font-size: 12px; font-weight: 700; color: inherit; }
.like-mini.liked { background: var(--accent-soft); border-color: #E9B44C; color: #A67C1A; }
.like-mini.liked .ic { fill: #E9B44C; color: #E9B44C; }
.like-mini.liked b { color: #A67C1A; }
.like-mini.pop { animation: like-pop .3s ease; }
@keyframes like-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* 讨论区（论坛样式：楼层 + 回复 + 评论点赞） */
.forum-card .panel-title { margin-bottom: 12px; }
.forum-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 16px 0 10px; padding-top: 13px; border-top: 1px dashed var(--border);
}
.forum-bar-title { font-size: 13px; font-weight: 700; color: var(--text); }
.forum-bar-right { display: inline-flex; align-items: center; gap: 10px; }
.forum-bar-tip { font-size: 11.5px; color: var(--text-sub); }

.forum-list {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 360px; overflow-y: auto; padding: 1px 2px 2px;
}
.post {
  display: flex; gap: 10px; padding: 12px 13px;
  border: 1px solid var(--border); border-radius: 12px;
  background: #FDFBF6; transition: border-color .16s ease;
}
.post:hover { border-color: #DCD2BE; }
.post-floor {
  flex: none; width: 32px; padding-top: 2px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: var(--primary); letter-spacing: .3px;
}
.post-body { min-width: 0; flex: 1; }
.post-head { display: flex; align-items: center; gap: 8px; }
.post-head .avatar-sm { width: 26px; height: 26px; font-size: 12px; }
.post-user { display: flex; align-items: center; gap: 6px; min-width: 0; }
.post-user b { font-size: 13px; font-weight: 700; }
.post-badge {
  font-style: normal; font-size: 10.5px; font-weight: 700; line-height: 1;
  padding: 3px 6px; border-radius: 5px;
}
.post-badge.owner { background: var(--accent-soft); color: #A67C1A; border: 1px solid #EFDFC0; }
.post-badge.me { background: var(--primary-soft); color: var(--primary); }
.post-head time { margin-left: auto; font-size: 11px; color: var(--text-sub); white-space: nowrap; }
.post-text { margin: 8px 0 9px; font-size: 13px; line-height: 1.7; word-break: break-word; }

.post-actions { display: flex; align-items: center; gap: 8px; }
.post-act {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid transparent; background: transparent;
  padding: 4px 8px; border-radius: 7px;
  font-size: 12px; font-weight: 600; color: var(--text-sub);
  transition: background .15s ease, color .15s ease;
}
.post-act:hover { background: var(--primary-soft); color: var(--primary); }
.post-act.on { color: #A67C1A; background: var(--accent-soft); }
.post-act.on .ic { fill: #E9B44C; color: #E9B44C; }
.post-act-sm { padding: 2px 7px; font-size: 11.5px; }

.post-replies {
  margin-top: 9px; padding-left: 11px;
  border-left: 2px solid var(--border);
  display: flex; flex-direction: column; gap: 9px;
}
.reply { display: flex; gap: 8px; }
.avatar-xs {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #FFF7EC;
  display: inline-flex; align-items: center; justify-content: center;
}
.reply-body { min-width: 0; }
.reply-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.reply-head b { font-size: 12px; }
.reply-head span { font-size: 11.5px; color: var(--text-sub); }
.reply-head time { font-size: 11px; color: var(--text-sub); }
.reply-body p { margin: 2px 0 3px; font-size: 12.5px; line-height: 1.65; word-break: break-word; }

.reply-form { display: flex; gap: 6px; margin-top: 9px; }
.reply-form .input { flex: 1; padding: 7px 10px; font-size: 12.5px; }

.forum-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 10px; color: var(--text-sub); text-align: center;
}
.forum-empty .ic { color: #C9BB9F; }
.forum-empty b { font-size: 13px; color: var(--text); }
.forum-empty span { font-size: 12px; line-height: 1.6; }

.avatar-sm {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.comment-input { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.comment-input .input { flex: 1; }

/* 实验库：改编版徽标与互动数 */
.derived-badge {
  position: absolute; left: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(20, 16, 12, .55); color: #FFF4E3;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  backdrop-filter: blur(2px);
}
.derived-badge .ic { color: var(--accent); }
.tag-derived {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); color: #A67C1A; border: 1px solid #EFDFC0;
}
.derived-line {
  font-size: 12.5px; color: var(--text-sub); margin: -6px 0 12px;
  display: flex; align-items: center; gap: 6px; line-height: 1.6;
}
.derived-line .ic { color: var(--primary); }
.derived-line a { color: var(--primary); font-weight: 600; }
.exp-inter { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-sub); margin-top: 8px; }
.exp-inter span { display: inline-flex; align-items: center; gap: 4px; }
.exp-inter .ic { color: var(--text-sub); }
.exp-origin { margin-left: auto; color: var(--primary); font-weight: 500; }
.exp-origin .ic { color: var(--primary); }

/* 改编简介：演示台右侧「这一版改了什么」 */
.derived-summary {
  margin: 0 0 12px; padding: 10px 12px;
  border-radius: 10px; background: var(--accent-soft); border: 1px solid #EFDFC0;
}
.ds-head {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: #A67C1A; margin-bottom: 6px;
}
.ds-head .ic { color: var(--primary); }
.derived-summary p { font-size: 12.5px; line-height: 1.65; color: var(--text-sub); }
.ds-list { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 4px; }
.ds-list li { font-size: 12.5px; line-height: 1.6; color: var(--text-sub); }

/* 版本弹窗里的改编简介一行 */
.ver-summary {
  margin: 2px 0 3px; font-size: 11.5px; line-height: 1.55; color: var(--text-sub);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* 侧栏消息中心未读角标 */
.nav-badge {
  margin-left: auto; flex: none; min-width: 17px; height: 17px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: #C05B3C; color: #FFF7EC;
  font-style: normal; font-size: 10.5px; font-weight: 700; line-height: 1;
}

/* ================= 消息中心 ================= */
.inbox-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin: 10px 0 16px;
}
.inbox-sub { margin-top: 5px; font-size: 12.5px; color: var(--text-sub); }
.inbox-actions { display: inline-flex; align-items: center; gap: 12px; }
.inbox-unread { font-size: 12px; font-weight: 600; color: var(--primary); }
.inbox-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.inbox-tabs button {
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-sub);
  font-size: 12.5px; font-weight: 600; line-height: 1;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.inbox-tabs button:hover { border-color: var(--primary); color: var(--primary); }
.inbox-tabs button.on { background: var(--primary); border-color: var(--primary); color: #FFF7EC; }
.inbox-card { padding: 12px 14px; }
.inbox-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 260px); overflow-y: auto; padding: 1px; }
.notice {
  position: relative; display: flex; gap: 11px;
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: #FDFBF6; transition: border-color .16s ease, background .16s ease;
}
.notice:hover { border-color: #DCD2BE; background: #FFFDF8; }
.notice[data-exp] { cursor: pointer; }
.notice.unread { background: #FFFBF0; border-color: #F0E2C4; }
.notice.unread:hover { border-color: var(--primary); }
.notice-ic {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.notice-ic.t-LIKE, .notice-ic.t-COMMENT_LIKE { background: #FBE9E2; color: #C05B3C; }
.notice-ic.t-COMMENT_LIKE { background: #FBE9E2; }
.notice-ic.t-COMMENT, .notice-ic.t-REPLY { background: #E6EDF5; color: #4E7CA6; }
.notice-ic.t-DERIVED { background: #F7EFD8; color: #A67C1A; }
.notice-ic.t-SYSTEM { background: #EFEBE2; color: #857768; }
.notice-main { min-width: 0; flex: 1; }
.notice-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.notice-head b { font-size: 13px; font-weight: 700; }
.notice-head em {
  font-style: normal; font-size: 10.5px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 5px; background: var(--primary-soft); color: var(--primary);
}
.notice-head time { margin-left: auto; font-size: 11px; color: var(--text-sub); white-space: nowrap; }
.notice-main p { margin: 5px 0 0; font-size: 12.5px; line-height: 1.65; color: var(--text-sub); word-break: break-word; }
.notice-exp {
  margin-top: 6px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; color: var(--primary);
}
.notice-dot {
  flex: none; align-self: flex-start; width: 7px; height: 7px; margin-top: 4px;
  border-radius: 50%; background: transparent;
}
.notice.unread .notice-dot { background: #C05B3C; }

html[data-theme="dark"] .chat-msg.ai .bubble { background: #2A231C; border-color: #3A322A; }
html[data-theme="dark"] .ai-result { background: #2F2718; border-color: #4A3D22; }
html[data-theme="dark"] .ai-result b .ic,
html[data-theme="dark"] .derived-line .ic { color: var(--primary); }
html[data-theme="dark"] .chat-suggests button { background: #2A231C; border-color: #3A322A; color: #C6B9A5; }
html[data-theme="dark"] .like-mini { background: #2A231C; border-color: #3A322A; color: #C6B9A5; }
html[data-theme="dark"] .like-mini .ic { color: #C6B9A5; }
html[data-theme="dark"] .like-mini.liked { background: #3A301C; border-color: #6B5629; color: #E9B44C; }
html[data-theme="dark"] .like-mini.liked b { color: #E9B44C; }
html[data-theme="dark"] .derived-summary { background: #2F2718; border-color: #4A3D22; }
html[data-theme="dark"] .ds-head { color: #E9B44C; }
html[data-theme="dark"] .notice { background: #221C17; border-color: #3A322A; }
html[data-theme="dark"] .notice:hover { background: #2A231C; border-color: #4E4438; }
html[data-theme="dark"] .notice.unread { background: #2F2718; border-color: #4A3D22; }
html[data-theme="dark"] .notice-ic.t-LIKE,
html[data-theme="dark"] .notice-ic.t-COMMENT_LIKE { background: #3A2A22; color: #E0714C; }
html[data-theme="dark"] .notice-ic.t-COMMENT,
html[data-theme="dark"] .notice-ic.t-REPLY { background: #2A3038; color: #8FB0CC; }
html[data-theme="dark"] .notice-ic.t-DERIVED { background: #3A301C; color: #E9B44C; }
html[data-theme="dark"] .notice-ic.t-SYSTEM { background: #302A23; color: #B9AB96; }
html[data-theme="dark"] .inbox-tabs button { background: #221C17; border-color: #3A322A; color: #C6B9A5; }
html[data-theme="dark"] .inbox-tabs button.on { background: var(--primary); border-color: var(--primary); color: #1A1510; }
html[data-theme="dark"] .post { background: #221C17; border-color: #3A322A; }
html[data-theme="dark"] .post:hover { border-color: #4E4438; }
html[data-theme="dark"] .post-act:hover { background: #3A2A22; }
html[data-theme="dark"] .post-act.on { background: #3A301C; color: #E9B44C; }
html[data-theme="dark"] .post-badge.owner { background: #3A301C; border-color: #6B5629; color: #E9B44C; }
html[data-theme="dark"] .post-badge.me { background: #3A2A22; color: #E1B79A; }
html[data-theme="dark"] .avatar-sm { background: #3A2A22; color: #E1B79A; }
html[data-theme="dark"] .tag-derived { background: #3A301C; border-color: #6B5629; color: #E9B44C; }

/* ================= 离线版（offline/）：没有账号与社区，隐藏在线专属入口 ================= */
body.offline-mode [data-online-only] { display: none !important; }
