/* ==========================================================================
   精听与词汇 · 公共样式表（web/shared/base.css）
   视觉基准：土黄米色底 + 陶土橙主色 + 白色卡片 + 胶囊控件
   用法：<link rel="stylesheet" href="/shared/base.css">
   所有页面只需引用本文件，再按需追加自己的页面样式。
   ========================================================================== */

:root {
  /* 色彩 */
  --bg: #f4f0e8;
  --bg-elevated: #fbf8f3;
  --surface: #ffffff;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --ink-faint: #8a847c;
  --line: #e7e0d4;
  --line-strong: #d6cec0;
  --accent: #c96442;
  --accent-hover: #b4532f;
  --accent-soft: #f3e4dc;
  --book-blue: #2f6fed;
  --ok: #3f6f4e;
  --ok-soft: #e4f2e8;
  --warn: #9a6b1f;
  --warn-soft: #fbf0da;
  --danger: #b42318;
  --danger-soft: #fbecea;

  /* 形状 / 阴影 */
  --radius: 18px;          /* 卡片 */
  --radius-sm: 12px;       /* 表单 */
  --radius-pill: 999px;    /* 胶囊 */
  --shadow: 0 10px 30px rgba(28, 25, 23, .06);
  --shadow-soft: 0 2px 8px rgba(28, 25, 23, .04);

  /* 字体与尺寸 */
  --font: "Microsoft YaHei", "微软雅黑", system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif;
  --sidebar-w: 132px;
  --control-h: 40px;
  --space: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #f8e8df 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #efe8dc 0%, transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 布局：左侧窄侧栏 + 右侧内容 ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: rgba(251, 248, 243, .92);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
  padding: 22px 8px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 7px;
  padding: 0 2px 12px; margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  border-radius: 50%; font-size: 13px; font-weight: 700; letter-spacing: .5px;
}
.brand-name {
  font-size: 12px; font-weight: 300; letter-spacing: .02em;
  white-space: nowrap; color: #2b2b2b;
}
.brand-logo {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: block; object-fit: contain;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  display: block; width: 100%; text-align: left;
  padding: 10px 9px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--bg-elevated); color: var(--ink); }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-btn.sub { padding-left: 18px; font-size: 12px; color: var(--ink-soft); }
.side-bottom {
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.content { flex: 1; min-width: 0; padding: 22px 26px 60px; }

/* ---------- 页头 ---------- */
.page-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 4px 0 16px;
}
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { color: var(--ink-soft); }
.page-head .page-title, .page-head .page-sub { margin: 0; }
.page-head .spacer { flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card + .card { margin-top: 14px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }

/* ---------- 按钮（胶囊） ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-elevated); border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-soft { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: #edd6c8; border-color: #edd6c8; color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg-elevated); border-color: transparent; color: var(--ink); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 30px; padding: 4px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }

/* ---------- 标签 / 胶囊 chip ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 600; margin-right: 6px;
}
.tag-gray { background: #eeebe4; color: var(--ink-soft); }
.tag-green { background: var(--ok-soft); color: var(--ok); }
.tag-red { background: var(--danger-soft); color: var(--danger); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong); background: var(--bg-elevated);
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active, .chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.chip .chip-count { font-size: 11px; font-weight: 500; opacity: .75; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.input, .textarea, select.input {
  width: 100%; min-height: var(--control-h); padding: 9px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { border-radius: var(--radius-sm); min-height: 110px; resize: vertical; padding: 12px 16px; }
.input:focus, .textarea:focus, select.input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--ink-faint); }
.field-hint { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 6px; min-height: 18px; }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow);
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-elevated); color: var(--ink-soft); font-weight: 600; white-space: nowrap;
}
.table tbody tr:hover td { background: var(--bg-elevated); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; text-align: right; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; color: var(--ink); }
.stat-value.accent { color: var(--accent); }
.stat-label { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* ---------- 进度条 ---------- */
.progress {
  height: 8px; border-radius: var(--radius-pill);
  background: #ece7de; overflow: hidden;
}
.progress-bar {
  height: 100%; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #d98667, var(--accent));
  transition: width .25s ease;
}
.progress-text { font-size: 12px; color: var(--ink-faint); }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--bg-elevated); }
.list-item .grow { flex: 1; min-width: 0; }

/* ---------- 空状态 / 加载 ---------- */
.empty {
  text-align: center; padding: 56px 20px; color: var(--ink-soft);
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty-title { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--ink-faint); }
.loading { padding: 40px; text-align: center; color: var(--ink-faint); font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1c1917; color: #fff;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 14px; z-index: 200;
  box-shadow: 0 8px 24px rgba(28, 25, 23, .28);
  max-width: min(90vw, 520px);
}
.toast.is-error { background: var(--danger); }
.toast.is-ok { background: var(--ok); }

/* ---------- 用户胶囊 ---------- */
.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.chip-role {
  flex: 0 0 auto; font-style: normal; font-size: 10px;
  padding: 1px 6px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent); font-weight: 500;
}

/* ---------- 登录页 ---------- */
.login-page {
  flex: 1; min-height: calc(100vh - 120px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 20px 16px;
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 10px 30px rgba(28, 25, 23, .06);
  padding: 36px 34px 30px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-logo {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; letter-spacing: 1px;
  border: 1px solid #ecd3c6;
}
.login-logo-img {
  width: 132px; height: auto; display: block; margin: 0 auto;
}
.login-title { font-size: 26px; font-weight: 800; text-align: center; letter-spacing: .18em; margin-top: 14px; }
.login-en { text-align: center; font-size: 12px; color: var(--ink-faint); letter-spacing: .22em; margin-top: 4px; }
.login-sub { text-align: center; font-size: 12px; color: var(--ink-faint); margin: 16px 0 0; line-height: 1.8; }
.login-hint { text-align: center; font-size: 12px; color: var(--ink-faint); margin: 6px 0 0; }
.login-btn { width: 100%; margin-top: 6px; min-height: 44px; font-size: 15px; letter-spacing: .18em; }

/* ---------- 站点页脚 ---------- */
.site-foot {
  margin-top: 28px; padding-top: 12px;
  border-top: 1px solid var(--line);
  text-align: center; font-size: 12px; color: var(--ink-faint);
}

/* ---------- 工具类 ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 14px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 12px; }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 24px; }
.mb { margin-bottom: 14px; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ---------- 响应式：390px 手机 ---------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; min-height: 100vh; }
  .content { padding: 16px 14px 48px; width: 100%; }
  .sidebar {
    width: 100%; flex: 0 0 auto; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; align-items: center; gap: 10px;
    padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand { border-bottom: 0; padding: 0 8px 0 0; margin: 0; flex: 0 0 auto; }
  .brand-name { display: none; }
  .side-nav { flex-direction: row; gap: 4px; }
  .nav-btn { width: auto; padding: 7px 12px; white-space: nowrap; }
  .side-bottom { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; align-items: center; }
  .page-title { font-size: 18px; }
  .card-pad { padding: 16px; }
  .login-page { min-height: auto; padding: 8px 0 24px; }
  .login-card { padding: 26px 20px 22px; }
  .table th, .table td { padding: 8px 10px; }
}
@media (max-width: 480px) {
  .login-title { font-size: 22px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .field-row { flex-direction: column; gap: 0; }
}

/* 登录页专用：<=600px 折叠品牌栏，卡片占满宽度（不影响学生/管理端） */
@media (max-width: 600px) {
  body.page-login .sidebar { display: none; }
  body.page-login .content { width: 100%; padding: 16px; }
  body.page-login .login-page {
    min-height: calc(100vh - 120px);
    padding: 16px 0 24px;
    gap: 12px;
  }
  body.page-login .login-card {
    width: 100%;
    max-width: 100%;
    padding: 26px 18px 22px;
    border-radius: 16px;
  }
  body.page-login .login-brand { margin-bottom: 14px; }
  body.page-login .login-title { font-size: 23px; letter-spacing: .12em; }
  body.page-login .login-en { font-size: 11px; letter-spacing: .08em; }
  body.page-login .login-btn { min-height: 42px; letter-spacing: .12em; }
  body.page-login .site-foot { margin-top: 20px; }
}

/* 登录页元素在任何宽度都不撑破容器 */
.login-en { white-space: normal; overflow-wrap: anywhere; }

/* ---------- 减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
