/* 独立站外壳覆盖样式（只随网页构建加载，不进 APK 单文件）
 *
 * 原则：**只做减法，不改他设计的排版**。
 *   · 底部导航 5 格 → 3 格（首页 / 案例 / 设置），网格列数必须同步，否则会换行；
 *   · 结果页 dock 6 格 → 5 格（撤「随手记」，留 技 / 时 / 格 / 断 / 画）；
 *   · 案例库撤「用户库」切换与筛选里用不到的术数；
 *   · 设置页撤「云同步口令 / AI 接入 / 后台保活」，换成一行「账号」。
 * 选择器全部挂在 body.xj-web 下，绝不影响 APK 与 xuanji-pan 那两个全功能出口。
 */

/* ── 登录门 ─────────────────────────────────────────────────────────── */
.xj-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface, #11110f);
  color: var(--fg, #f3efe5);
  -webkit-tap-highlight-color: transparent;
}
.xj-gate[hidden] { display: none; }
.xj-gate-card {
  width: 100%;
  max-width: 340px;
}
.xj-gate-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 34px;
}
.xj-gate-brand svg { width: 58px; height: 58px; }
.xj-gate-brand h1 {
  margin: 0;
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: .32em;
  text-indent: .32em;
  color: var(--fg, #f3efe5);
}
.xj-gate-brand p {
  margin: 0;
  font-size: 12px;
  letter-spacing: .18em;
  text-indent: .18em;
  color: var(--muted, #8b8478);
}
.xj-gate-form { display: flex; flex-direction: column; gap: 12px; }
.xj-gate-form[hidden] { display: none; }
.xj-gate-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.xj-gate-field span {
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted, #8b8478);
}
.xj-gate-field input {
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line, #2c2a25);
  border-radius: 12px;
  background: color-mix(in srgb, var(--fg, #f3efe5) 4%, transparent);
  color: var(--fg, #f3efe5);
  font-size: 16px; /* ≥16px：iOS Safari 不会因聚焦自动放大页面 */
  outline: none;
  transition: border-color .16s ease;
}
.xj-gate-field input:focus { border-color: var(--accent, #d5a85a); }
.xj-gate-submit {
  height: 48px;
  margin-top: 6px;
  border: 1px solid var(--accent, #d5a85a);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent, #d5a85a) 16%, transparent);
  color: var(--accent, #d5a85a);
  font-size: 15px;
  letter-spacing: .2em;
  text-indent: .2em;
  font-family: inherit;
}
.xj-gate-submit:disabled { opacity: .45; }
.xj-gate-switch {
  display: block;
  margin: 16px auto 0;
  border: 0;
  background: none;
  color: var(--muted, #8b8478);
  font-size: 13px;
  letter-spacing: .06em;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: color-mix(in srgb, var(--muted, #8b8478) 45%, transparent);
}
.xj-gate-msg {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--accent, #d5a85a);
  text-align: center;
}
.xj-gate-msg[data-kind="error"] { color: #d4715f; }
.xj-gate-foot {
  margin-top: 26px;
  font-size: 11px;
  line-height: 1.7;
  color: color-mix(in srgb, var(--muted, #8b8478) 72%, transparent);
  text-align: center;
}

/* ── 导航 / dock / 案例库 ───────────────────────────────────────────── */
body.xj-web .bottom-nav { grid-template-columns: repeat(3, 1fr) !important; }
body.xj-web .analysis-dock { grid-template-columns: repeat(5, 1fr) !important; }
/* 「随手记」整格撤掉：学生只记断语。不藏会变成 6 个按钮挤 5 列、第二行掉出一个「画」。 */
body.xj-web .analysis-dock .analysis-btn[data-tool="note"] { display: none !important; }

/*
  罗盘从 9 卡换成 4 卡后，相邻卡从 40° 拉到 90°：
  90° 那张会落到圆心水平线上，卡底直接贴容器底（原来那张 40° 的卡被 translateY(-130px) 抬着，
  底边那 30px 溢出看不出来）。这里把半径收到 96、卡底改成贴容器，四张卡就都落在盘面里；
  容器高度仍是原来的 168px，不会把首页顶长。
  只作用于独立站，APK 的九卡罗盘一个像素不动。
*/
body.xj-web .method-grid.method-wheel { height: 168px; --wheel-r: 96px; }
body.xj-web .method-wheel .method-card { margin-bottom: 0; }
body.xj-web .method-wheel-arc { width: 192px; height: 96px; margin-left: -96px; }
body.xj-web .method-wheel-arc::after { width: 128px; height: 64px; margin-left: -64px; }

/* 首页内容本来就比一屏高，原先底部只留 32px ⇒ 滚到底还有一截压在固定导航下面。
   固定导航 72px（+ 安全区），这里补足，只补首页，不动结果页的 dock 留白。 */
body.xj-web #screen-home .page { padding-bottom: calc(72px + env(safe-area-inset-bottom) + 10px); }

/* 案例库：撤「用户库」切换、命主排序、以及用不到的术数筛选 */
body.xj-web #case-view-toggle,
body.xj-web #profile-sort-btn,
body.xj-web #case-profiles,
body.xj-web #profile-page-title { display: none !important; }

/* 案例库管理条：只留存档与分类筛选。
   「批量选择 / 对齐用户库 / 建用户库 / 设置问事分类」都是给整套案例库运营用的，
   学生只做「记住这一局 + 写条断语」，这些按钮留着只会误点。 */
body.xj-web #case-batch-toggle,
body.xj-web #case-link-profiles,
body.xj-web #case-cases-to-profiles,
body.xj-web #case-category-create { display: none !important; }
/* 案例卡上的「未关联」是命主档案的挂接状态，学生版没有命主这层概念 */
body.xj-web .case-owner,
body.xj-web .case-owner-inline { display: none !important; }

/* 设置页：撤同步口令 / AI / 保活，换成账号行 */
body.xj-web #sync-row,
body.xj-web #sync-panel,
body.xj-web #ai-row,
body.xj-web #ai-panel,
body.xj-web #keepalive-row { display: none !important; }

/* 账号行（外壳自己插进设置列表的） */
.xj-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--line, #2c2a25);
}
.xj-account-row .xj-account-main { min-width: 0; }
.xj-account-row strong { display: block; font-size: 14px; font-weight: 500; }
.xj-account-row small {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted, #8b8478);
}
.xj-account-row button {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line, #2c2a25);
  border-radius: 9px;
  background: var(--surface, #11110f);
  color: var(--muted, #8b8478);
  font-size: 12.5px;
  font-family: inherit;
}

/* 断语：只留一段可写的断语；其余字段由脚本按 data-j-field 隐藏 */
body.xj-web .judgement-editor .ai-organize,
body.xj-web .judgement-editor .ai-log-open,
body.xj-web .judgement-editor [data-j-new],
body.xj-web .judgement-editor [data-j-tech-open],
body.xj-web .judgement-editor .technique-chosen,
body.xj-web .judgement-editor .technique-picker { display: none !important; }

/* iOS 键盘弹起时，固定底栏不要浮在键盘上方 */
body.xj-web.xj-keyboard .bottom-nav { display: none !important; }

/* ── 邀请码管理（管理员）────────────────────────────────────────────── */
.xj-admin-panel {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(0, 0, 0, .55);
}
.xj-admin-panel[hidden] { display: none; }
.xj-admin-card {
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--surface, #11110f);
  border-top: 1px solid var(--line, #2c2a25);
}
.xj-admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.xj-admin-head h2 {
  margin: 0;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 19px;
  font-weight: 400;
  letter-spacing: .16em;
}
.xj-admin-head button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line, #2c2a25);
  border-radius: 9px;
  background: none;
  color: var(--muted, #8b8478);
  font-size: 12.5px;
  font-family: inherit;
}
.xj-admin-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px 74px;
  gap: 8px;
}
.xj-admin-create input {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line, #2c2a25);
  border-radius: 10px;
  background: transparent;
  color: var(--fg, #f3efe5);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}
.xj-admin-create input:focus { border-color: var(--accent, #d5a85a); }
.xj-admin-create button {
  height: 40px;
  border: 1px solid var(--accent, #d5a85a);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent, #d5a85a) 14%, transparent);
  color: var(--accent, #d5a85a);
  font-size: 13.5px;
  font-family: inherit;
}
.xj-admin-hint {
  margin: 10px 0 12px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted, #8b8478);
}
.xj-invite-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.xj-admin-empty {
  margin: 18px 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted, #8b8478);
}
.xj-invite-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line, #2c2a25) 70%, transparent);
}
.xj-invite-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--accent, #d5a85a);
}
.xj-invite-row span { font-size: 12.5px; }
.xj-invite-row small { font-size: 11px; color: var(--muted, #8b8478); grid-column: 1 / 3; }
.xj-invite-row.is-used code { color: var(--muted, #8b8478); text-decoration: line-through; }
.xj-invite-row button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line, #2c2a25);
  border-radius: 8px;
  background: none;
  color: var(--muted, #8b8478);
  font-size: 11.5px;
  font-family: inherit;
}
.xj-toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 9600;
  max-width: 80vw;
  padding: 10px 16px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--fg, #f3efe5) 92%, transparent);
  color: var(--surface, #11110f);
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.xj-toast.show { opacity: 1; transform: translate(-50%, 0); }
