/* 学习助手 — 移动优先样式
   给孩子用：大字号、大按钮、少干扰 */

:root {
  --bg: #fbf9f5;
  --surface: #ffffff;
  --surface-2: #f6f2ea;
  --ink: #1f2328;
  --ink-2: #5b6470;
  --ink-3: #8d949e;
  --line: #ebe6dd;
  --brand: #3f6fe4;
  --brand-soft: #eef3ff;
  --warn: #e8622f;
  --warn-soft: #fff1ea;
  --ok: #1e9e6a;
  --ok-soft: #e9f8f1;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(31, 35, 40, .05), 0 8px 24px -12px rgba(31, 35, 40, .16);
  --tab-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { overscroll-behavior-y: none; }

#app { min-height: 100dvh; }

#view {
  padding: 18px 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

/* ── 底部导航 ── */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 50;
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: .02em;
}

.tabbar svg {
  width: 23px; height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabbar a[aria-current="page"] { color: var(--brand); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.1; }

/* ── 通用排版 ── */
h1 { font-size: 22px; line-height: 1.35; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 640; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 620; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 13px; color: var(--ink-3); }

.page-head { margin-bottom: 18px; }
.page-head .sub { color: var(--ink-2); font-size: 14px; }

/* ── 卡片 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card.flat { box-shadow: none; }
.card.tinted { background: var(--brand-soft); border-color: #dbe6ff; }

/* ── 今日任务 ── */
.task {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform .12s ease, border-color .12s ease;
}
.task:active { transform: scale(.985); }

.task .ico {
  flex: 0 0 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--surface-2);
}

.task .body { flex: 1; min-width: 0; }
.task .body strong { display: block; font-size: 16px; font-weight: 620; }
.task .body span { display: block; font-size: 13px; color: var(--ink-2); margin-top: 1px; }

.task .state {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
}
.task .state.done { background: var(--ok-soft); color: var(--ok); }
.task .state.todo { background: var(--warn-soft); color: var(--warn); }

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
  width: 100%;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.sm { min-height: 38px; font-size: 14px; padding: 0 14px; width: auto; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ── 输入 ── */
textarea, input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  resize: vertical;
  -webkit-appearance: none;
}
textarea { min-height: 170px; }
textarea:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea::placeholder { color: var(--ink-3); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; }

.hint-box {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.55;
  color: #2c4a8f;
  margin-bottom: 12px;
}
.hint-box b { font-weight: 650; }

.counter { text-align: right; font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }

/* ── 错因选择 ── */
.err-group { margin-bottom: 16px; }
.err-group > .gl {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.err-group > .gl::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.err-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.err-opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.err-opt .t { font-size: 14.5px; font-weight: 620; }
.err-opt .d { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.err-opt:active { transform: scale(.985); }
.err-opt[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.err-opt[aria-pressed="true"].is-careless {
  border-color: var(--warn);
  background: var(--warn-soft);
}

/* ── 列表 ── */
.item {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.item .row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.item .tag {
  font-size: 11.5px;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}
.item .tag.careless { background: var(--warn-soft); color: var(--warn); }
.item .date { font-size: 12px; color: var(--ink-3); margin-left: auto; }
.item .text {
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.chip {
  flex: 0 0 auto;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  font-family: inherit;
}
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* ── 点评 ── */
.review { border-left: 3px solid var(--brand); padding-left: 14px; margin-top: 14px; }
.review .layer { margin-bottom: 12px; }
.review .layer:last-child { margin-bottom: 0; }
.review .lt {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.review .lc { font-size: 15px; line-height: 1.65; }

.sugg { margin-top: 8px; padding: 11px 13px; background: var(--surface-2); border-radius: var(--radius-sm); }
.sugg .orig { font-size: 14px; color: var(--ink-2); text-decoration: line-through; text-decoration-color: #c9c2b4; }
.sugg .alt { font-size: 15px; font-weight: 600; color: var(--brand); margin: 3px 0; }
.sugg .why { font-size: 12.5px; color: var(--ink-3); }

/* ── 打卡 ── */
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.check-item:last-child { border-bottom: 0; }
.check-box {
  flex: 0 0 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  margin-top: 1px;
  transition: background .15s, border-color .15s;
}
.check-item[aria-checked="true"] .check-box {
  background: var(--ok);
  border-color: var(--ok);
}
.check-item[aria-checked="true"] .check-box::after {
  content: "";
  width: 6px; height: 11px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.check-item .ct { font-size: 15px; line-height: 1.5; }
.check-item .cd { font-size: 12.5px; color: var(--ink-3); }

/* ── 统计 ── */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 10px;
  text-align: center;
}
.stat .v { font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.stat .l { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.stat.warn .v { color: var(--warn); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-row .bl { flex: 0 0 92px; font-size: 13px; color: var(--ink-2); }
.bar-row .bt { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-row .bf { height: 100%; border-radius: 999px; background: var(--brand); transition: width .4s ease; }
.bar-row .bf.careless { background: var(--warn); }
.bar-row .bn { flex: 0 0 22px; text-align: right; font-size: 13px; font-weight: 600; }

/* ── 错题详情 ── */
.item[data-id] { cursor: pointer; transition: border-color .15s, transform .12s; }
.item[data-id]:hover { border-color: #d5cdbd; }
.item[data-id]:active { transform: scale(.99); }

.detail-stem { font-size: 16px; line-height: 1.65; margin: 10px 0 4px; }
.ans-row { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; font-size: 15px; }
.ans-k { flex: 0 0 44px; font-size: 12.5px; color: var(--ink-3); }
.ans-v { font-weight: 620; }
.ans-v.bad { color: var(--warn); text-decoration: line-through; text-decoration-color: #f0bda8; }
.ans-v.good { color: var(--ok); }
.explain {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-2);
}

.judge-box { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14.5px; line-height: 1.65; }
.judge-box:empty { display: none; }
.judge-box.ok { background: var(--ok-soft); color: #14724d; }
.judge-box.bad { background: var(--warn-soft); color: #a8410f; }

/* 四档自评 */
.review-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.review-opt {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.review-opt b { font-size: 15px; font-weight: 620; }
.review-opt span { font-size: 12px; color: var(--ink-3); }
.review-opt:hover { border-color: var(--brand); }
.review-opt:active { transform: scale(.98); }
.review-opt:disabled { opacity: .45; pointer-events: none; }

/* 变式题 */
.variant { padding: 14px 0; border-bottom: 1px solid var(--line); }
.variant:first-child { padding-top: 4px; }
.variant:last-child { border-bottom: 0; padding-bottom: 0; }
.v-q { display: flex; gap: 9px; font-size: 15px; line-height: 1.65; }
.v-no {
  flex: 0 0 20px; height: 20px; margin-top: 3px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand);
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.v-row { display: flex; gap: 8px; margin-top: 10px; }
.v-in {
  flex: 1; min-width: 0; height: 44px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px;
}
.v-in:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.v-res { font-size: 13px; margin-top: 8px; }
.v-res:empty { display: none; }
.v-res.ok { color: var(--ok); }
.v-res.bad { color: var(--warn); }

.small { font-size: 14px; line-height: 1.6; }

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(63, 111, 228, .35); }
  100% { box-shadow: 0 0 0 14px rgba(63, 111, 228, 0); }
}
.pulse { animation: pulseRing 1.2s ease-out 2; }

/* ── 空状态 ── */
.empty {
  text-align: center;
  padding: 42px 20px;
  color: var(--ink-3);
}
.empty .e-ico { font-size: 34px; margin-bottom: 10px; opacity: .6; }
.empty p { font-size: 14px; margin: 0; }

/* ── toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: rgba(31, 35, 40, .93);
  color: #fff;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 100;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 加载 ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #efeade 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease infinite;
  border-radius: var(--radius-sm);
  height: 60px;
  margin-bottom: 10px;
}
@keyframes sk {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ── 平板 ── */
@media (min-width: 700px) {
  #view { padding-left: 24px; padding-right: 24px; max-width: 720px; }
  .err-grid { grid-template-columns: repeat(3, 1fr); }
  h1 { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
