:root {
  --bg: #0b1220;
  --bg2: #0f1a30;
  --card: #15203a;
  --card2: #1b294a;
  --line: #243353;
  --txt: #e8eefc;
  --muted: #93a4c4;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --grad: linear-gradient(135deg, #2563eb, #4f46e5);
  --green: #22c55e;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 16px;
  --radius2: 12px;
  --shadow: 0 6px 20px rgba(0,0,0,.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--txt);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
#app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* 顶栏 */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  background: rgba(11,18,32,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar-title { font-size: 19px; font-weight: 800; letter-spacing: .5px; }
.appbar-gear {
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  font-size: 17px; width: 38px; height: 38px; border-radius: 11px;
}
.appbar-gear:active { transform: scale(.94); }

.view { flex: 1; padding: 16px 16px 96px; max-width: 760px; width: 100%; margin: 0 auto; }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: rgba(15,26,48,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px; font-size: 11px; cursor: pointer; position: relative;
}
.tab .ico { font-size: 20px; line-height: 1; filter: grayscale(1) opacity(.7); }
.tab.active { color: var(--accent2); }
.tab.active .ico { filter: none; }
.tab.active::before {
  content: ""; position: absolute; top: 4px; width: 26px; height: 3px;
  border-radius: 3px; background: var(--accent2);
}

/* 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card > h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.mt8 { margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 38px 12px; font-size: 14px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 12px; padding: 12px 16px; font-size: 14px; font-weight: 700;
  cursor: pointer; background: var(--grad); color: #fff; min-height: 46px; transition: transform .06s;
}
.btn:active { transform: scale(.97); }
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: var(--card2); color: var(--txt); border: 1px solid var(--line); }
.btn.green { background: linear-gradient(135deg,#16a34a,#22c55e); }
.btn.red { background: linear-gradient(135deg,#dc2626,#f87171); }
.btn.amber { background: linear-gradient(135deg,#d97706,#fbbf24); color: #1a1205; }
.btn.sm { min-height: 38px; padding: 8px 13px; font-size: 13px; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* 表单 */
input, textarea, select {
  width: 100%; background: var(--bg2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  font-size: 15px; font-family: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 130px; resize: vertical; line-height: 1.65; }
label.fld { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 7px; font-weight: 600; }

/* 标签/徽章 */
.chip { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 3px 9px; border-radius: 8px; background: rgba(59,130,246,.15); color: var(--accent2); font-weight: 600; }

/* 进度条 */
.progress { height: 8px; background: var(--bg2); border-radius: 6px; overflow: hidden; margin: 12px 0; }
.progress > i { display: block; height: 100%; background: var(--grad); border-radius: 6px; transition: width .25s; }

/* 首页 hero */
.hero { background: var(--grad); border: none; color: #fff; border-radius: var(--radius); padding: 20px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.hero .hi { font-size: 14px; opacity: .9; }
.hero .big { font-size: 30px; font-weight: 800; margin-top: 4px; }
.hero .cd-num { font-size: 56px; font-weight: 900; line-height: 1; letter-spacing: 1px; }
.hero .cd-sub { opacity: .92; margin-top: 6px; font-size: 13px; }

/* 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.stat .num { font-size: 28px; font-weight: 800; color: var(--accent2); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* 快捷入口 */
.quick { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.quick a, .quick button {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--card2); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; color: var(--txt); cursor: pointer; font-size: 14px; font-weight: 700;
}
.quick .q-ico { font-size: 22px; }
.quick .q-sub { font-size: 11px; color: var(--muted); font-weight: 500; }

/* 刷题 */
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.q-stem { font-size: 17px; line-height: 1.7; margin: 12px 0 14px; font-weight: 600; }
.opt {
  display: flex; align-items: flex-start; gap: 11px; width: 100%; text-align: left;
  background: var(--bg2); border: 1.5px solid var(--line); color: var(--txt);
  border-radius: 13px; padding: 13px 14px; margin-bottom: 10px; font-size: 15px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.opt .optkey { flex: none; width: 24px; height: 24px; border-radius: 7px; background: var(--card2); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--muted); }
.opt.sel { border-color: var(--accent2); background: rgba(59,130,246,.12); }
.opt.sel .optkey { background: var(--accent); color: #fff; }
.opt.right { border-color: var(--green); background: rgba(34,197,94,.15); }
.opt.right .optkey { background: var(--green); color: #06281a; }
.opt.wrong { border-color: var(--red); background: rgba(248,113,113,.15); }
.opt.wrong .optkey { background: var(--red); color: #2a0606; }
.opt:disabled { cursor: default; }
.explain { background: rgba(251,191,36,.1); border-left: 3px solid var(--amber); border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.7; margin-top: 14px; }
.explain b { color: var(--amber); }

/* 模块筛选 pills */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: var(--bg2); border: 1px solid var(--line); color: var(--muted); border-radius: 20px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.pill.on { background: var(--grad); color: #fff; border-color: transparent; font-weight: 700; }

/* 分段控件 */
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; background: none; border: none; color: var(--muted); padding: 11px; font-size: 13px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--grad); color: #fff; }

/* 列表 */
.li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: none; }
.li-main { font-size: 15px; font-weight: 600; }
.li-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.li-act { display: flex; gap: 8px; flex: none; }

/* 搜索 */
.search { position: relative; }
.search input { padding-left: 38px; }
.search::before { content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .6; }

/* 打卡 */
.cal { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; }
.cal .wd { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 4px; }
.cal .d { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 13px; border-radius: 9px; background: var(--bg2); color: var(--muted); }
.cal .d.on { background: linear-gradient(135deg,#16a34a,#22c55e); color: #06281a; font-weight: 800; }
.cal .d.today { outline: 2px solid var(--accent2); outline-offset: -2px; }
.bar { display: flex; align-items: flex-end; gap: 5px; height: 130px; }
.bar .col { flex: 1; background: linear-gradient(180deg,var(--accent2),var(--accent)); border-radius: 6px 6px 0 0; min-height: 3px; }
.bar .col span { display: block; text-align: center; font-size: 9px; color: var(--muted); margin-top: 4px; }
.flame { font-size: 22px; }

/* 笔记 markdown 预览 */
.preview { line-height: 1.8; font-size: 15px; }
.preview h1, .preview h2, .preview h3, .preview h4 { margin: 14px 0 8px; line-height: 1.4; }
.preview h4 { font-size: 16px; color: var(--accent2); }
.preview ul { padding-left: 18px; margin: 6px 0; }
.preview li { margin: 4px 0; }
.preview code { background: var(--bg2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.preview b { color: #fff; }
.note-title { font-size: 16px; font-weight: 700; }
.note-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* 通用 */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(0,0,0,.82); color: #fff; padding: 11px 20px; border-radius: 22px; font-size: 13px; z-index: 80; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 80%; text-align: center; }
.toast.show { opacity: 1; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg2); width: 100%; max-width: 600px; border-radius: 18px 18px 0 0; padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; border-top: 1px solid var(--line); }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.hidden { display: none !important; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.fade-in { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 热点页 */
.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.badge.green { background: rgba(34,197,94,.18); color: var(--green); border: 1px solid rgba(34,197,94,.4); }
.badge.amber { background: rgba(251,191,36,.16); color: var(--amber); border: 1px solid rgba(251,191,36,.4); }
.quote { margin-top: 10px; background: var(--bg2); border-left: 3px solid var(--accent2); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.tags { margin-top: 7px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip.sm { font-size: 11px; padding: 2px 8px; }
.chip.国内 { background: rgba(59,130,246,.15); color: var(--accent2); border-color: rgba(59,130,246,.35); }
.chip.国际 { background: rgba(168,85,247,.15); color: #c084fc; border-color: rgba(168,85,247,.35); }
.chip.法律 { background: rgba(34,197,94,.15); color: var(--green); border-color: rgba(34,197,94,.35); }
.chip.申论 { background: rgba(251,191,36,.15); color: var(--amber); border-color: rgba(251,191,36,.35); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--accent2); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.pills.scroll { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.pills.scroll .pill { flex: none; }
.cd-sub { font-size: 13px; color: var(--muted); }
.cd-num { font-size: 40px; font-weight: 900; line-height: 1; }
.btn.accent { background: linear-gradient(135deg,#0ea5e9,#38bdf8); }
