/* app.css —— 手机优先，大按钮，单屏一件事 */
:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #6b7280;
  --line: #e5e9f0;
  --blue: #2f6df6;
  --blue-soft: #e8efff;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "HarmonyOS Sans SC", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: rgba(238, 242, 247, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 16px;
}
#pageTitle { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  background: #fff; color: var(--blue);
  font-size: 22px; line-height: 1;
  box-shadow: var(--shadow);
  display: grid; place-items: center;
}

/* ---------- 主体 ---------- */
main {
  padding: 4px 16px calc(96px + var(--safe-b));
  min-height: calc(100vh - 140px);
}
.view { display: none; animation: fade 0.18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* 今日大卡 */
.hero {
  background: linear-gradient(135deg, #2f6df6, #5b8cff 60%, #7aa2ff);
  color: #fff;
  border-radius: 20px;
  padding: 22px 20px;
  margin: 8px 0 14px;
  box-shadow: 0 10px 26px rgba(47, 109, 246, 0.28);
}
.hero .big { font-size: 44px; font-weight: 800; line-height: 1.1; letter-spacing: -1px; }
.hero .sub { opacity: 0.9; font-size: 14px; margin-top: 2px; }
.hero .hero-actions { display: flex; gap: 10px; margin-top: 16px; }
.hero .hero-actions button {
  flex: 1; padding: 12px; border-radius: 12px; font-weight: 700; font-size: 15px;
  background: rgba(255, 255, 255, 0.22); color: #fff;
  backdrop-filter: blur(4px);
}
.hero .hero-actions button.solid { background: #fff; color: var(--blue); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-grid .cell { background: #f7f9fc; border-radius: 12px; padding: 12px 10px; text-align: center; }
.stat-grid .num { font-size: 22px; font-weight: 800; }
.stat-grid .lbl { font-size: 12px; color: var(--muted); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 18px; border-radius: 13px; font-weight: 700; font-size: 15px;
  background: #f2f5fa; color: var(--ink);
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.ghost { background: transparent; color: var(--blue); padding: 8px 10px; }
.btn.danger { background: #fdeaea; color: var(--red); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* 表单 */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
select, input[type="text"], textarea {
  width: 100%; padding: 12px 13px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; outline: none;
  font-size: 15px; appearance: none;
}
select:focus, input[type="text"]:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 76px; line-height: 1.5; }

.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; padding: 12px; border-radius: 12px; background: #f2f5fa; font-weight: 700; font-size: 15px;
  border: 1.5px solid transparent;
}
.seg button.on { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 13px; border-radius: 999px; background: #f2f5fa; font-size: 13.5px; font-weight: 600;
  border: 1.5px solid transparent;
}
.chip.on { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }

/* 错题列表 */
.qitem {
  display: flex; gap: 12px; padding: 12px; background: #fff; border-radius: 14px;
  box-shadow: var(--shadow); margin-bottom: 10px; align-items: flex-start;
}
.qitem img { width: 62px; height: 62px; object-fit: cover; border-radius: 10px; background: #f2f5fa; flex: none; }
.qitem .title { font-weight: 700; font-size: 14.5px; }
.qitem .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; flex: none; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #2f6df6;
  background: #e8efff;
  border-radius: 6px;
  padding: 1px 6px;
  margin-right: 6px;
  vertical-align: 1px;
}
.dot.red { background: var(--red); }
.dot.yellow { background: var(--yellow); }
.dot.green { background: var(--green); }

/* 覆盖层（录题 / 复习 / 详情） */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.overlay.hidden { display: none; }
.sheet-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: rgba(238, 242, 247, 0.95);
  backdrop-filter: blur(12px);
}
.sheet-head .t { font-weight: 700; font-size: 17px; }
.sheet-body { padding: 4px 16px calc(28px + var(--safe-b)); flex: 1; }
.sheet-foot {
  position: sticky; bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, rgba(238, 242, 247, 0));
  display: flex; gap: 10px;
}
.sheet-foot .btn { flex: 1; }

/* 图片编辑 */
.cv-wrap { background: #fff; border-radius: 14px; padding: 8px; box-shadow: var(--shadow); }
#edCanvas { width: 100%; height: auto; display: block; border-radius: 10px; touch-action: none; }
.tools { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tools button {
  flex: 1 1 auto; min-width: 74px; padding: 11px 10px; border-radius: 11px;
  background: #fff; box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600;
}
.tools button.on { background: var(--blue); color: #fff; }
.brush-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
input[type="range"] { flex: 1; accent-color: var(--blue); }

/* 复习卡 */
.rv-img { width: 100%; border-radius: 14px; background: #fff; box-shadow: var(--shadow); display: block; }
.rv-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); color: var(--muted); }
.rate-bar { display: flex; gap: 8px; }
.rate-bar button {
  flex: 1; padding: 16px 6px; border-radius: 14px; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow); background: #fff;
}
.rate-bar .r1 { color: var(--red); }
.rate-bar .r2 { color: var(--yellow); }
.rate-bar .r3 { color: var(--green); }
.progress { height: 6px; border-radius: 999px; background: #dfe6f0; overflow: hidden; margin-bottom: 12px; }
.progress > i { display: block; height: 100%; background: var(--blue); border-radius: 999px; transition: width 0.25s; }

/* 统计 */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13.5px; }
.bar-row .name { width: 84px; flex: none; color: var(--muted); }
.bar { flex: 1; height: 10px; border-radius: 999px; background: #eef2f8; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; }
.bar-row .val { width: 34px; text-align: right; font-weight: 700; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 4px 0;
}
.tabbar button span { font-size: 19px; line-height: 1.1; }
.tabbar button.on { color: var(--blue); }
.tabbar .tab-add { color: #fff; }
.tabbar .tab-add span {
  width: 40px; height: 40px; border-radius: 14px; background: var(--blue);
  display: grid; place-items: center; margin-top: -18px; font-size: 22px;
  box-shadow: 0 8px 18px rgba(47, 109, 246, 0.35);
}
.tabbar .tab-add.on { color: var(--blue); }

/* 提示 */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92); color: #fff;
  padding: 11px 18px; border-radius: 12px; font-size: 14px;
  z-index: 90; max-width: 86vw; text-align: center;
  transition: opacity 0.2s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

.empty { text-align: center; color: var(--muted); padding: 44px 20px; }
.empty .e { font-size: 42px; display: block; margin-bottom: 8px; opacity: 0.5; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; }
.kv .k { color: var(--muted); flex: none; }
.kv .v { text-align: right; word-break: break-all; }

/* ---------- 周报 ---------- */
.report-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.75;
  background: #f7f9fc;
  border-radius: 12px;
  padding: 12px;
}

/* ---------- 打印 / 存 PDF ---------- */
.print-card { margin-bottom: 18px; }
.print-h { font-weight: 700; font-size: 14px; margin-bottom: 6px; color: #334155; }
.print-cause { font-weight: 400; color: #b45309; margin-left: 8px; font-size: 13px; }
.print-card img { width: 100%; border-radius: 8px; display: block; border: 1px solid #e5e9f0; }
.print-a { font-size: 13px; color: #475569; margin-top: 6px; white-space: pre-wrap; }

@media print {
  .topbar, .tabbar, .toast, .no-print, main, .sheet-head, .sheet-foot { display: none !important; }
  html, body { background: #fff !important; height: auto; }
  .overlay { position: static !important; inset: auto; overflow: visible !important; background: #fff; display: block; }
  .overlay.hidden { display: none !important; }
  .sheet-body { padding: 0 !important; }
  .print-card { page-break-inside: avoid; break-inside: avoid; }
  .print-card img { max-height: 60vh; width: auto; max-width: 100%; margin: 0 auto; }
  .print-h { font-size: 13px; }
}
