/* AI辅助学 · 基础样式（移动优先，无外部依赖）
   M1 阶段手写 CSS 保证可用与可控；进入视觉设计阶段再统一评估是否切换 Tailwind。 */

:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-soft: color-mix(in srgb, var(--green) 12%, #ffffff);
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d5d9df;
  --bg: #f7f8fa;
  --card: #ffffff;
  --surface-soft: #f5f6f8;
  --sidebar-bg: #151b28;
  --sidebar-active: #243047;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .05);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--green-dark);
  text-decoration: none;
  transition: color .16s ease;
}
a:hover { text-decoration: underline; }

/* 键盘可达性：只用 focus-visible，鼠标点击不出现难看的框 */
a:focus-visible,
button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--green) 55%, transparent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- 通用图标 ---------- */
.icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: none;
}
.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--green-dark);
  margin-bottom: 12px;
  transition: background-color .2s var(--ease), transform .2s var(--ease);
}
.icon-badge .icon { width: 21px; height: 21px; }

/* ---------- 顶栏 ---------- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(6px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -.2px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px;
  height: 22px;
  flex: none;
  color: var(--ink);
}
.nav-links { display: flex; align-items: center; gap: 14px; font-size: 15px; }
.nav-user { color: var(--ink-soft); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-login { color: var(--ink-soft); }

/* ---------- 布局 ---------- */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  animation: rise .34s var(--ease) both;
}
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 20px 40px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color .18s var(--ease), border-color .18s var(--ease),
              box-shadow .18s var(--ease), transform .14s var(--ease);
}
.btn:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--green) 24%, transparent);
}
.btn:active {
  transform: translateY(0) scale(.995);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--green) 20%, transparent);
}
.btn[disabled],
.btn.is-busy {
  opacity: .72;
  cursor: progress;
  transform: none;
  box-shadow: none;
}
.btn-sm { padding: 6px 14px; font-size: 14px; }
.btn-lg { padding: 14px 28px; font-size: 17px; }
.btn-block { width: 100%; margin-top: 18px; }
.btn.ghost { background: var(--card); color: var(--green-dark); }
.btn.ghost:hover { background: var(--green-soft); }
.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: #e9b8b3;
}
.btn-danger-outline:hover {
  background: var(--danger-soft);
  border-color: #dda29b;
  box-shadow: 0 8px 18px rgba(180, 35, 24, .10);
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  color: var(--green-dark);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: color .16s ease;
}
.linklike:hover { text-decoration: underline; }
.inline { display: inline; margin: 0; }

/* ---------- 首页 ---------- */
.hero { padding: 32px 0 12px; }
.hero h1 {
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1.25;
  margin: 0 0 14px;
  letter-spacing: -0.6px;
}
.lead { color: var(--ink-soft); font-size: 17px; max-width: 560px; margin: 0 0 22px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.muted { color: var(--muted); }

.features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 34px;
}
@media (min-width: 640px) {
  .features { grid-template-columns: repeat(2, 1fr); }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
}
.card h3 { margin: 0 0 8px; font-size: 17px; }
.card p { margin: 0; color: #4b5563; font-size: 14.5px; }

.feature h3 { margin-bottom: 6px; }

@media (hover: hover) {
  .feature:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(16, 24, 40, .09);
    border-color: var(--line-strong);
  }
  .feature:hover .icon-badge {
    background: #dcf2e5;
    transform: scale(1.05);
  }
}

.platforms { margin-top: 32px; text-align: center; }
.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 0;
  margin: 8px 0 0;
}
.chips li {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-soft);
  transition: border-color .18s var(--ease), transform .18s var(--ease);
}
.chips li:hover { border-color: var(--line-strong); transform: translateY(-1px); }

/* ---------- 表单 ---------- */
.auth {
  max-width: 420px;
  margin: 12px auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: var(--shadow-sm);
  animation: rise .34s var(--ease) both;
}
.auth.wide { max-width: 620px; }
.auth h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.3px; }
.auth > .muted { margin: 0 0 18px; font-size: 14px; }

.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 14px; font-weight: 600; margin-top: 12px; }
.form input[type="text"],
.form input[type="password"],
.form input[type="email"],
.form select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  background: var(--card);
  color: var(--ink);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background-color .18s var(--ease);
}
.form input:hover,
.form select:hover { border-color: var(--line-strong); }
.form input:focus,
.form select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent);
}
.checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400 !important;
  font-size: 13.5px !important;
  color: #4b5563;
  margin-top: 14px;
  line-height: 1.5;
}
.checkbox input { margin-top: 3px; }
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  font-size: 14px;
}

.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row input { flex: 1; }
.captcha-img {
  height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

/* ---------- 提示 ---------- */
.alert {
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  animation: rise .26s var(--ease) both;
}
.alert.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.err { background: var(--danger-soft); border-color: #fbd5d0; color: var(--danger); }

/* ---------- 我的 ---------- */
.section-title {
  margin: 34px 0 12px;
  font-size: 17px;
  letter-spacing: -.2px;
}
.danger-title { color: var(--danger); }
.danger-note { color: var(--muted); font-size: 14px; margin: 0 0 4px; max-width: 540px; }

.kv {
  display: grid;
  grid-template-columns: 88px 1fr;
  margin: 16px 0 0;
  font-size: 14.5px;
  border-top: 1px solid var(--line);
}
.kv dt,
.kv dd {
  margin: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.kv dt { color: var(--muted); }
.kv dd { color: var(--ink); }

.mt { margin-top: 24px; }
.signout { margin-top: 28px; }

@media (max-width: 480px) {
  .container { padding: 16px 14px 48px; }
  .nav { padding: 12px 14px; }
  .auth { padding: 20px 16px; border-radius: 12px; }
  .btn-lg { padding: 13px 20px; font-size: 16px; }
  .kv { grid-template-columns: 72px 1fr; }
  .nav-user { max-width: 96px; }
}

/* 尊重系统「减少动态效果」设置 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =====================================================================
   应用内布局：深色侧边栏 + 顶栏搜索 + 卡片内容区
   ===================================================================== */
.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar-bg);
  color: #aeb8c9;
  display: flex;
  flex-direction: column;
  padding: 16px 12px 14px;
  overflow-y: auto;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.2px;
}
.sb-brand:hover { text-decoration: none; }
.sb-brand .brand-mark { width: 20px; height: 20px; color: #f2f7fb; }

.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  margin-bottom: 12px;
}
.sb-user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sb-user-meta strong {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-user-meta span { font-size: 12px; color: #7f8ba0; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  color: #eef3fa;
  background: #2d3a4e;
  flex: none;
}
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }

.sb-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sb-section { display: block; }
.sb-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 14px 0 4px;
  padding: 4px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #5d6a80;
  font: inherit;
  font-size: 11.5px;
  letter-spacing: .12em;
  text-align: left;
  cursor: pointer;
  transition: color .16s var(--ease), background-color .16s var(--ease);
}
.sb-group:hover { color: #9aa8bf; background: rgba(255, 255, 255, .04); }
.sb-group .chev {
  width: 14px;
  height: 14px;
  flex: none;
  opacity: .65;
  transition: transform .22s var(--ease);
}
.sb-section.is-collapsed .chev { transform: rotate(-90deg); }
.sb-items {
  overflow: hidden;
  transition: max-height .26s var(--ease), opacity .18s var(--ease);
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 9px;
  color: #aeb8c9;
  font-size: 14.5px;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}
.sb-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sb-item.is-active { background: var(--sidebar-active); color: #fff; }
.sb-item .icon { width: 18px; height: 18px; opacity: .8; }
.sb-item.is-active .icon { opacity: 1; color: #5ed68f; }
.sb-logout {
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  font-size: 14.5px;
  cursor: pointer;
  text-align: left;
}
.sb-foot {
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding-top: 8px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---------- 顶栏 ---------- */
.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 64px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.search { position: relative; display: flex; align-items: center; flex: 1; max-width: 480px; }
.search-icon {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: #9aa4b2;
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: background-color .18s var(--ease), border-color .18s var(--ease),
              box-shadow .18s var(--ease);
}
.search input:focus {
  outline: none;
  background: var(--card);
  border-color: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 12%, transparent);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: #f1f3f6; color: var(--ink); }
.topbar-user { display: inline-flex; align-items: center; }
.menu-btn { display: none; }

.app-body { padding: 22px 24px 48px; max-width: 1180px; width: 100%; }

/* ---------- 页头 ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.3px; }
.page-head .muted { margin: 0; font-size: 14px; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- 快捷入口 ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.tile:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(16, 24, 40, .07);
  border-color: var(--line-strong);
}
.tile-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.tile-icon.green { background: #e8f5ee; color: #15803d; }
.tile-icon.blue { background: #e8effc; color: #2563eb; }
.tile-icon.orange { background: #fdf1e5; color: #c2410c; }
.tile-icon.red { background: #fdecec; color: #b42318; }
.tile-body { display: flex; flex-direction: column; min-width: 0; }
.tile-body strong { font-size: 14.5px; font-weight: 600; }
.tile-body em {
  font-style: normal;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 内容区 ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); gap: 14px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 16px; }
.more { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.more:hover { color: var(--green-dark); text-decoration: none; }
.more .icon { width: 14px; height: 14px; }
.mt-panel { margin-top: 14px; }

.empty { text-align: center; padding: 26px 12px 10px; }
.empty.compact { padding: 16px 6px 6px; }
.empty-icon {
  display: inline-flex;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
  color: var(--muted);
  margin-bottom: 10px;
}
.empty-title { margin: 0 0 4px; font-weight: 600; font-size: 14.5px; }
.empty .muted { margin: 0 auto 14px; font-size: 13px; max-width: 320px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed-empty { color: var(--muted); font-size: 13.5px; padding: 6px 0; }

.page-narrow { max-width: 640px; }

.sb-overlay { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 252px;
    transform: translateX(-100%);
    transition: transform .24s var(--ease);
    z-index: 50;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .32);
  }
  .sidebar.is-open { transform: none; }
  .sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 30, .45);
    z-index: 45;
    opacity: 0;
    transition: opacity .2s var(--ease);
  }
  .sb-overlay.is-open { display: block; opacity: 1; }
  .menu-btn { display: inline-flex; }
  .topbar { height: 58px; padding: 0 14px; gap: 10px; }
  .app-body { padding: 16px 14px 40px; }
}
@media (max-width: 560px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 19px; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 6px; }
}

html.sb-lock { overflow: hidden; }

/* =====================================================================
   界面偏好：主题 / 主题色 / 字号 / 密度 / 动效
   由 <html data-theme data-accent data-font data-density data-motion> 控制，
   值来自 users.extra["prefs"]（app/web/prefs.py），只接受白名单值。
   ===================================================================== */

/* ---- 主题色（只换主色，浅色底由 --green-soft 的 color-mix 自动派生） ---- */
html[data-accent="blue"] { --green: #2563eb; --green-dark: #1d4ed8; }
html[data-accent="violet"] { --green: #7c5cff; --green-dark: #6a45f0; }
html[data-accent="amber"] { --green: #d97706; --green-dark: #b45309; }
html[data-accent="graphite"] { --green: #475569; --green-dark: #334155; }

/* ---- 深色主题 ---- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e131b;
  --card: #161d29;
  --surface-soft: #1d2634;
  --ink: #e7ecf3;
  --ink-soft: #c2cbd8;
  --muted: #8d99ab;
  --line: #232d3c;
  --line-strong: #31405a;
  --green-soft: color-mix(in srgb, var(--green) 20%, transparent);
  --sidebar-bg: #0b1017;
  --sidebar-active: #212d42;
  --danger-soft: #2c1210;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow: 0 10px 28px rgba(0, 0, 0, .45);
}
/* 跟随系统：纯 CSS 切换，避免 JS 执行前的白闪 */
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --bg: #0e131b;
    --card: #161d29;
    --surface-soft: #1d2634;
    --ink: #e7ecf3;
    --ink-soft: #c2cbd8;
    --muted: #8d99ab;
    --line: #232d3c;
    --line-strong: #31405a;
    --green-soft: color-mix(in srgb, var(--green) 20%, transparent);
    --sidebar-bg: #0b1017;
    --sidebar-active: #212d42;
    --danger-soft: #2c1210;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 10px 28px rgba(0, 0, 0, .45);
  }
}

/* ---- 深色下的点状色，避免浅色块刺眼 ---- */
html[data-theme="dark"] .alert.ok { background: #10241a; border-color: #1d4a32; color: #7ee2a8; }
html[data-theme="dark"] .alert.err { background: #2a1210; border-color: #5a221d; color: #ff9c92; }
html[data-theme="dark"] .tile-icon.green { background: #10241a; color: #5ed68f; }
html[data-theme="dark"] .tile-icon.blue { background: #111c33; color: #8cb0ff; }
html[data-theme="dark"] .tile-icon.orange { background: #2a1a0e; color: #f0a26b; }
html[data-theme="dark"] .tile-icon.red { background: #2a1210; color: #ff8b80; }
html[data-theme="dark"] .icon-badge { background: var(--green-soft); color: #7ee2a8; }
html[data-theme="dark"] .btn.ghost:hover { background: var(--surface-soft); }
html[data-theme="dark"] .form input,
html[data-theme="dark"] .form select { background: var(--surface-soft); }
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] .alert.ok { background: #10241a; border-color: #1d4a32; color: #7ee2a8; }
  html[data-theme="system"] .alert.err { background: #2a1210; border-color: #5a221d; color: #ff9c92; }
  html[data-theme="system"] .tile-icon.green { background: #10241a; color: #5ed68f; }
  html[data-theme="system"] .tile-icon.blue { background: #111c33; color: #8cb0ff; }
  html[data-theme="system"] .tile-icon.orange { background: #2a1a0e; color: #f0a26b; }
  html[data-theme="system"] .tile-icon.red { background: #2a1210; color: #ff8b80; }
  html[data-theme="system"] .icon-badge { background: var(--green-soft); color: #7ee2a8; }
  html[data-theme="system"] .btn.ghost:hover { background: var(--surface-soft); }
  html[data-theme="system"] .form input,
  html[data-theme="system"] .form select { background: var(--surface-soft); }
}

/* ---- 字号（整块内容缩放，侧栏保持稳定） ---- */
html[data-font="s"] .app-body,
html[data-font="s"] .container { zoom: .94; }
html[data-font="l"] .app-body,
html[data-font="l"] .container { zoom: 1.07; }

/* ---- 界面密度 ---- */
html[data-density="compact"] .app-body { padding: 14px 20px 40px; }
html[data-density="compact"] .panel { padding: 14px; }
html[data-density="compact"] .tile { padding: 10px 12px; }
html[data-density="compact"] .page-head { margin-bottom: 14px; }
html[data-density="compact"] .mt-panel { margin-top: 10px; }
html[data-density="compact"] .sb-item { padding: 7px 11px; }
html[data-density="compact"] .kv dt,
html[data-density="compact"] .kv dd { padding: 8px 0; }
html[data-density="compact"] .section-title { margin-top: 26px; }

/* ---- 关闭动效 ---- */
html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}

/* ---- 设置页：分段选择器 / 主题色圆点 ---- */
.pref-form { gap: 0; margin-top: 8px; }
.pref { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.pref legend { padding: 0; margin: 0 0 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  max-width: 100%;
  flex-wrap: wrap;
}
.seg-item { position: relative; margin: 0 !important; font-weight: 400 !important; }
.seg-item input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.seg-item span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  transition: background-color .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}
.seg-item input:checked + span {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.seg-item input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 1px; }
.seg-sm .seg-item span { min-width: 54px; padding: 6px 12px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin: 0 !important;
  cursor: pointer;
  font-weight: 400 !important;
}
.swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.swatch-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .10);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.swatch input:checked + .swatch-dot {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--green);
  transform: scale(1.04);
}
.swatch input:focus-visible + .swatch-dot { outline: 2px solid var(--green); outline-offset: 3px; }
.swatch-label { font-size: 11.5px; color: var(--muted); }
.pref-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 2px; }
.pref-actions .hint { margin: 0; }

/* ---- 栏目切换动画：离场淡出 + 落地淡入 ---- */
.app-body { animation: page-in .28s var(--ease); }
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
body.is-leaving .app-body {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .14s ease, transform .14s ease;
}



/* ---------- 工作台（第 4 轮） ---------- */
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-actions .icon { width: 16px; height: 16px; }
.dash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}
.dash-item:last-child { border-bottom: 0; padding-bottom: 0; }
.dash-time {
  flex: none;
  width: 48px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.dash-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.dash-title { font-weight: 500; overflow-wrap: anywhere; }
.dash-meta { color: var(--muted); font-size: 12px; }
.dash-item .badge { margin-left: auto; }
.badge.done { background: var(--green-soft); color: var(--green-dark); }

/* 站点 Logo（后台可上传替换） */
.brand-logo { width: 22px; height: 22px; border-radius: 6px; object-fit: contain; display: inline-block; }
.sb-brand .brand-logo { width: 20px; height: 20px; }

/* ---- 头像上传与昵称编辑 ---- */
.avatar { object-fit: cover; object-position: center; flex: none; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; font-size: 26px; }
.profile-edit { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.profile-forms { flex: 1 1 320px; display: grid; gap: 14px; min-width: 0; }
.profile-forms form { display: grid; gap: 8px; }
.profile-forms .btn { justify-self: start; }

.due-tip { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); font-size: 12.5px; }
.due-tip a { color: var(--danger); display: inline-flex; gap: 6px; align-items: center; }
.due-tip .icon { width: 15px; height: 15px; }

.pn-placeholder-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.pn-placeholder-grid > div { background: var(--surface-soft); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px; display: grid; gap: 6px; text-align: center; }
.pn-ph-value { font-size: 22px; font-weight: 700; color: var(--muted); }
.pn-app-days { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.pn-app-days span { font-size: 12px; color: var(--ink-soft); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
@media (max-width: 640px) { .pn-placeholder-grid { grid-template-columns: 1fr; } }

.plan-panel { padding: 16px 18px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.plan-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; align-content: start; background: var(--card); }
.plan-card.is-current { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 12%, transparent); }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-price { margin: 0; font-size: 22px; font-weight: 700; }
.plan-price .muted { font-size: 12.5px; font-weight: 500; }
.plan-features { margin: 0; padding-left: 18px; color: var(--ink-soft); font-size: 13px; display: grid; gap: 4px; }
.plan-card .btn { justify-self: start; margin-top: 4px; }

/* ---- 学习轨迹推荐 ---- */
.rec-panel { margin-bottom: 16px; }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.rec-card { margin: 0; }
.rec-card button {
  width: 100%; height: 100%; text-align: left; display: grid; gap: 6px; align-content: start;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  padding: 14px 16px; cursor: pointer; font: inherit; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.rec-card button:hover { border-color: var(--green); box-shadow: var(--shadow); transform: translateY(-1px); }
.rec-icon { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--green-soft); color: var(--green-dark); }
.rec-icon .icon { width: 18px; height: 18px; }
.rec-card.tone-danger .rec-icon { background: var(--danger-soft); color: var(--danger); }
.rec-card.tone-warn .rec-icon { background: #fdf3e3; color: #b45309; }
.rec-card.tone-info .rec-icon { background: #eaf1fe; color: #1d4ed8; }
.rec-title { font-weight: 650; font-size: 15px; line-height: 1.45; }
.rec-desc { color: var(--muted); font-size: 13px; line-height: 1.5; }
.rec-cta { color: var(--green-dark); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.rec-cta .icon { width: 14px; height: 14px; }

/* 会员标识 */
.vip-badge { display:inline-flex; align-items:center; margin-left:6px; padding:1px 7px; border-radius:999px; font-size:10px; font-weight:700; color:#7a4b00; background:linear-gradient(135deg,#ffe9a8,#f6c453); border:1px solid #e8b53a; vertical-align:middle; letter-spacing:.4px; }
.vip-badge.family { background:linear-gradient(135deg,#ffd9b0,#ef9d4e); color:#6b2f00; border-color:#d98b3c; }
.plan-card.is-current .plan-name-row { display:flex; align-items:center; gap:6px; }

.avatar.has-frame-gold { box-shadow: 0 0 0 2px #f0b429, 0 0 0 5px rgba(240, 180, 41, .18); }
.avatar.has-frame-silver { box-shadow: 0 0 0 2px #94a3b8, 0 0 0 5px rgba(148, 163, 184, .18); }

/* ---- 账号主页：学习阶段 / AI 辅助选科 ---- */
.advice-box { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; background: var(--surface-soft); }
.advice-box summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.advice-result { margin-top: 14px; display: grid; gap: 10px; }
.advice-combo { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card); }
.advice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.advice-combo ul { margin: 6px 0 8px; padding-left: 18px; }
.advice-combo li { margin: 2px 0; }
