/* =========================================================
 * 学习工作台 — 朴素工具风
 * 参考：Notion / 飞书 的克制设计
 * 白底细边框 / 系统字体 / 单一强调色 / 无渐变无毛玻璃
 * ========================================================= */
:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --ink: #37352f;
  --ink-soft: #787774;
  --brand: #2b6de8;
  --brand-deep: #1d4fbf;
  --brand-bg: #eaf1fd;
  --ok: #1f9d55;
  --ok-bg: #e6f4ec;
  --warn: #b7791f;
  --warn-bg: #faf3e3;
  --bad: #d03f3f;
  --bad-bg: #fdecec;
  --line: #e8e7e4;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 15, 15, .06);
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, .04);
  --tabbar-h: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

#app { max-width: 640px; margin: 0 auto; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); }

/* ========== 平板/大屏适配 ========== */
@media (min-width: 768px) {
  #app { max-width: 920px; }
  .view { padding: 26px 30px 0; }
  .view-head h2 { font-size: 20px; }
  .kcard-title { font-size: 18px; line-height: 1.5; }
  .kcard-content { font-size: 16px; line-height: 1.9; }
  .kcard-body { padding: 14px 24px; }
  .kcard-head { padding: 18px 24px 0; }
  .kcard-foot { padding: 0 24px 16px; }
  .kcard-ico { width: 44px; height: 44px; font-size: 22px; }
  .kcard-feedback { font-size: 14px; }
  .btn { font-size: 14.5px; padding: 10px 18px; }
  .sub { font-size: 13.5px; }
  .tabbar { max-width: 920px; }
  .modal { max-width: 720px; border-radius: 14px; margin-bottom: 60px; }
  .field textarea { font-size: 15px; }
  .cal-day { font-size: 14px; }
}

/* ========== 顶部 ========== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: 0; color: var(--ink); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  font-size: 11px; background: var(--bg); color: var(--ink-soft);
  padding: 3px 10px; border-radius: 6px; font-weight: 600;
  white-space: nowrap; border: 1px solid var(--line);
}
.chip.sync-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.sync-offline { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.sync-syncing { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.stats-row { display: flex; gap: 8px; margin-top: 12px; }
.stat {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 4px; text-align: center;
}
.stat-num { display: block; font-size: 17px; font-weight: 700; color: var(--ink); }
.stat small { font-size: 11px; color: var(--ink-soft); }

/* ========== 视图 ========== */
.view { padding: 18px 16px 0; animation: viewin .18s ease; }
@keyframes viewin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.view-head h2 { font-size: 17px; margin: 0; font-weight: 700; }
.sub { font-size: 12px; color: var(--ink-soft); margin: 4px 0 0; line-height: 1.6; }

.card-list { display: flex; flex-direction: column; gap: 12px; }

/* ========== 知识点卡片 ========== */
.kcard {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
}
.kcard-head { display: flex; align-items: center; gap: 10px; padding: 13px 15px 0; }
.kcard-ico {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex: none;
}
.kcard-meta { flex: 1; min-width: 0; }
.kcard-course { font-size: 12.5px; font-weight: 600; }
.kcard-order { font-size: 11px; color: var(--ink-soft); }
.kcard-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 6px; flex: none; }
.badge-now { background: var(--brand-bg); color: var(--brand-deep); }
.badge-done { background: var(--ok-bg); color: var(--ok); }
.badge-review { background: var(--warn-bg); color: var(--warn); }
.badge-fail { background: var(--bad-bg); color: var(--bad); }
.badge-review-due { background: var(--bad-bg); color: var(--bad); }

.kcard-body { padding: 11px 15px; }
.kcard-title { font-size: 15.5px; font-weight: 700; margin: 0 0 7px; line-height: 1.5; }
.kcard-content {
  font-size: 13.5px; line-height: 1.8; color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
}
.kcard-content a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.kcard-content .sec { display: block; font-weight: 700; margin-top: 9px; color: var(--ink); }
.kcard-content .code {
  display: block; background: #f6f6f4; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 11px; margin: 5px 0; font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; color: #44403a;
}
.try-box {
  background: var(--brand-bg); border-radius: 8px; padding: 9px 12px; margin-top: 9px;
  font-size: 12.5px; color: var(--brand-deep);
}
.try-box b { color: var(--brand-deep); }
.kcard-content.collapsed {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-more { font-size: 12px; color: var(--brand); cursor: pointer; margin-top: 7px; font-weight: 600; user-select: none; }
.kcard-foot { padding: 0 15px 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kcard-feedback {
  width: 100%; background: var(--bg); border-radius: 8px;
  padding: 9px 12px; font-size: 12.5px; color: var(--ink-soft);
  border-left: 3px solid var(--brand);
}
.kcard-feedback b { color: var(--ink); }

/* ========== 按钮 ========== */
.btn {
  border: 1px solid transparent; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; cursor: pointer; font-family: inherit;
  transition: transform .06s ease, opacity .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-deep); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.btn-bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.btn-ghost { background: var(--brand-bg); color: var(--brand-deep); border-color: transparent; }
.btn-plain { background: var(--bg); color: var(--ink-soft); border-color: var(--line); }
.btn-block { width: 100%; padding: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ========== 课程卡片 ========== */
.ccard {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line); padding: 14px 15px;
  display: flex; align-items: center; gap: 13px; cursor: pointer;
  transition: transform .08s ease;
}
.ccard:active { transform: scale(.98); }
.ccard-ico {
  width: 46px; height: 46px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 23px;
}
.ccard-info { flex: 1; min-width: 0; }
.ccard-name { font-size: 15px; font-weight: 700; margin: 0 0 3px; }
.ccard-desc { font-size: 12px; color: var(--ink-soft); margin: 0 0 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 5px; background: #eeedea; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; transition: width .3s ease; }
.ccard-pct { font-size: 12px; color: var(--ink-soft); flex: none; font-weight: 600; }

/* ========== 记录/历史卡片 ========== */
.hcard {
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; border: 1px solid var(--line);
}
.hcard-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }
.hcard-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.hcard-title { font-weight: 700; font-size: 14px; margin: 5px 0 2px; }
.hcard-time { font-size: 11px; color: var(--ink-soft); margin-left: auto; }
.hcard-fb { font-size: 12.5px; color: var(--ink-soft); margin: 7px 0 0; line-height: 1.6; background: var(--bg); border-radius: 8px; padding: 8px 10px; }

/* ========== 我的页 ========== */
.mine-user {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; display: flex; align-items: center; gap: 13px;
}
.mine-avatar {
  width: 50px; height: 50px; border-radius: 50%; background: var(--brand-bg);
  color: var(--brand-deep); display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; border: 1px solid var(--line); flex: none;
}
.mine-user-info { flex: 1; min-width: 0; }
.mine-user-name { font-size: 17px; font-weight: 700; margin: 0 0 3px; }
.mine-user-sub { font-size: 12px; color: var(--ink-soft); margin: 0; }
.mine-group { display: flex; flex-direction: column; gap: 9px; }
.mine-card {
  background: var(--card); border-radius: var(--radius);
  padding: 13px 15px; display: flex; align-items: center; gap: 12px; cursor: pointer;
  border: 1px solid var(--line);
}
.mine-card:active { transform: scale(.98); }
.mine-ico {
  width: 36px; height: 36px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: var(--bg); border: 1px solid var(--line);
}
.mine-card-body { flex: 1; min-width: 0; }
.mine-card-title { font-size: 14px; font-weight: 700; }
.mine-card-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.mine-arrow { color: #c4c2bc; font-size: 16px; }

/* 开关 */
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; background: #dcdad6;
  transition: background .2s; cursor: pointer;
}
.switch i::after {
  content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ========== 日历 ========== */
.cal-card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; border: 1px solid var(--line);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); font-weight: 700;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.cal-title { font-size: 14.5px; font-weight: 700; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-week span { text-align: center; font-size: 11px; color: var(--ink-soft); font-weight: 600; padding: 3px 0; }
.cal-day {
  aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 500; color: var(--ink); position: relative;
}
.cal-day.other { color: #d4d2cd; }
.cal-day.today { border: 1.5px solid var(--brand); font-weight: 700; color: var(--brand-deep); }
.cal-day.done { background: var(--brand-bg); color: var(--brand-deep); font-weight: 700; }
.cal-day.done.today { border-color: var(--brand); }
.cal-stats {
  background: var(--card); border-radius: var(--radius);
  padding: 13px 14px; display: flex; gap: 8px; border: 1px solid var(--line);
}
.cal-stat { flex: 1; text-align: center; }
.cal-stat b { display: block; font-size: 17px; color: var(--ink); font-weight: 700; }
.cal-stat span { font-size: 11px; color: var(--ink-soft); }

/* ========== 底部导航 ========== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 640px; margin: 0 auto;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  font-size: 10.5px; color: var(--ink-soft); font-weight: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: inherit; position: relative;
  transition: color .12s;
}
.tab-ico { font-size: 20px; }
.tab.active { color: var(--brand); font-weight: 700; }
.tab-badge {
  position: absolute; top: 6px; right: calc(50% - 24px);
  min-width: 16px; height: 16px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ========== 用户选择层 ========== */
.user-gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ug-card {
  width: 100%; max-width: 380px; background: var(--card);
  border-radius: 14px; padding: 28px 22px; text-align: center;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: ugpop .22s ease;
}
@keyframes ugpop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.ug-logo { font-size: 42px; margin-bottom: 6px; }
.ug-card h2 { margin: 0 0 4px; font-size: 19px; font-weight: 700; }
.ug-sub { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 16px; }
.ug-users { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.ug-user {
  background: var(--brand-bg); color: var(--brand-deep); border: none;
  border-radius: 8px; padding: 7px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: transform .08s;
}
.ug-user:active { transform: scale(.95); }
.ug-form input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 13px; font-size: 14.5px; font-family: inherit; text-align: center;
  background: var(--bg); outline: none; margin-bottom: 9px;
}
.ug-form input:focus { border-color: var(--brand); background: var(--card); }

/* ========== 弹窗 ========== */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 30, 28, .4);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .15s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 14px 14px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.modal .sub { margin: 0 0 14px; }
.modal-actions { display: flex; gap: 9px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--ink-soft); }
.field input[type="text"], .field input[type="time"], .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--ink);
  background: var(--bg); outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); background: var(--card); }

.stars { display: flex; gap: 7px; }
.star {
  flex: 1; text-align: center; padding: 8px 0; border-radius: 8px;
  background: var(--bg); font-size: 16px; cursor: pointer; user-select: none;
  border: 1.5px solid transparent; transition: all .1s;
}
.star.sel { background: var(--brand-bg); border-color: var(--brand); }
.star-label { display: block; font-size: 10px; color: var(--ink-soft); margin-top: 2px; font-weight: 600; }
.star.sel .star-label { color: var(--brand-deep); }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; flex: none; transition: all .1s;
}
.swatch.sel { border-color: var(--ink); transform: scale(1.12); }

/* ========== Toast ========== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 26px); z-index: 99;
  transform: translateX(-50%) translateY(8px);
  background: rgba(40, 40, 38, .94); color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none;
  transition: all .22s ease; max-width: 82vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== 空状态 ========== */
.empty { text-align: center; color: var(--ink-soft); padding: 40px 20px; font-size: 13.5px; line-height: 1.9; }
.empty .big { font-size: 40px; display: block; margin-bottom: 10px; }
