/* ===== Tata 学习小助手 · 蓝色系 ===== */
/* hidden 属性优先：防止 display:flex 等规则盖住 hidden，导致弹窗关不掉 */
[hidden] { display: none !important; }
:root {
  --blue-900: #1e3a8a;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-300: #93c5fd;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;
  --accent:   #f59e0b;
  --green:    #16a34a;
  --red:      #dc2626;
  --text:     #1e293b;
  --text-sub: #64748b;
  --bg:       #eaf2fd;
  --card:     #ffffff;
  --radius:   20px;
  --shadow:   0 4px 16px rgba(37, 99, 235, .10);
  --tz-line:      #93c5fd;
  --tz-line-dash: #bfdbfe;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: linear-gradient(180deg, #dbeafe 0%, var(--bg) 30%);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  overscroll-behavior-y: contain;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }

/* ===== 头部 ===== */
.app-header {
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 20px 22px;
  border-radius: 0 0 28px 28px;
  box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { font-size: 40px; }
.brand h1 { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.brand-sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.icon-btn { font-size: 22px; width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; transition: transform .15s; }
.icon-btn:active { transform: scale(.9); }

/* ===== Tab 栏 ===== */
.tab-bar {
  display: flex; gap: 10px; max-width: 760px; margin: -16px auto 0; padding: 0 16px;
  position: relative; z-index: 5;
}
.tab-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 0; border-radius: 18px; font-size: 16px; font-weight: 700;
  background: #fff; color: var(--text-sub); box-shadow: var(--shadow);
  transition: all .2s;
}
.tab-btn .tab-icon { font-size: 20px; }
.tab-btn.active { background: var(--blue-600); color: #fff; transform: translateY(-2px); }

/* ===== 主区 ===== */
.app-main { max-width: 760px; margin: 0 auto; padding: 18px 16px 60px; }
.tab-panel { display: none; animation: fadeIn .25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-title { font-size: 18px; font-weight: 800; margin-bottom: 14px; color: var(--blue-900); }

/* ===== 学科选择 ===== */
.subject-pills, .filter-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-pills { margin-bottom: 0; }
.pill {
  padding: 8px 16px; border-radius: 999px; font-size: 15px; font-weight: 700;
  background: var(--blue-50); color: var(--blue-700); border: 2px solid var(--blue-100);
  transition: all .15s;
}
.pill.active { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.pill.mini { padding: 5px 12px; font-size: 13px; }

/* ===== 上传区 ===== */
.upload-area { display: block; }
.upload-inner {
  border: 2.5px dashed var(--blue-300); border-radius: 16px; background: var(--blue-50);
  padding: 26px 16px; text-align: center; color: var(--blue-700); font-weight: 700;
  transition: background .15s;
}
.upload-area:active .upload-inner { background: var(--blue-100); }
.upload-icon { font-size: 40px; margin-bottom: 6px; }
.upload-hint { font-size: 12px; color: var(--text-sub); font-weight: 400; margin-top: 4px; }

.photo-preview-wrap { position: relative; margin-bottom: 12px; }
.photo-preview-wrap img {
  width: 100%; max-height: 320px; object-fit: contain; border-radius: 14px;
  background: #f1f5f9; display: block;
}
.photo-remove { position: absolute; top: 8px; right: 8px; background: rgba(30,41,59,.65); }

.note-input {
  width: 100%; border: 2px solid var(--blue-100); border-radius: 14px;
  padding: 10px 14px; font-size: 16px; resize: none; margin-bottom: 12px; color: var(--text);
}
.note-input:focus { outline: none; border-color: var(--blue-500); }

/* ===== 按钮 ===== */
.btn {
  padding: 12px 20px; border-radius: 14px; font-size: 16px; font-weight: 800;
  transition: transform .12s, opacity .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-ghost { background: var(--blue-50); color: var(--blue-700); border: 2px solid var(--blue-100); }
.btn-danger { background: #fef2f2; color: var(--red); border: 2px solid #fecaca; }
.btn-block { width: 100%; }
.link-btn { color: var(--blue-600); font-weight: 700; text-decoration: underline; font-size: 14px; }

/* ===== AI 提示 ===== */
.ai-tip-card { background: #fffbeb; border: 2px solid #fde68a; }
.ai-tip-card p { font-size: 14px; line-height: 1.7; color: #92400e; }

/* ===== 记录列表 ===== */
.list-header { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 12px; flex-wrap: wrap; gap: 8px; }
.list-header .card-title { margin-bottom: 0; }
.count-badge {
  display: inline-block; min-width: 26px; text-align: center; background: var(--blue-100);
  color: var(--blue-700); border-radius: 999px; font-size: 13px; padding: 2px 8px; vertical-align: 2px;
}
.mistake-list { display: flex; flex-direction: column; gap: 12px; }
.mistake-item {
  display: flex; gap: 12px; background: var(--card); border-radius: 18px; padding: 12px;
  box-shadow: var(--shadow);
}
.mistake-thumb {
  width: 86px; height: 86px; border-radius: 12px; object-fit: cover; background: var(--blue-50);
  flex-shrink: 0; cursor: pointer;
}
.mistake-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mistake-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.subject-tag { font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 999px; background: var(--blue-100); color: var(--blue-700); }
.mistake-date { font-size: 12px; color: var(--text-sub); }
.mistake-note-text { font-size: 14px; margin-top: 6px; color: var(--text); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mistake-note-text.empty { color: #cbd5e1; font-style: italic; }
.mistake-status { font-size: 12px; margin-top: 6px; color: var(--text-sub); }
.mistake-status.done { color: var(--green); font-weight: 700; }
.mistake-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.mini-btn {
  font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 10px;
  background: var(--blue-50); color: var(--blue-700); border: 1.5px solid var(--blue-100);
}
.mini-btn.danger { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.mini-btn:disabled { opacity: .5; }

.empty-state { text-align: center; padding: 34px 0 10px; color: var(--text-sub); }
.empty-icon { font-size: 44px; margin-bottom: 8px; }

/* ===== 汉字模块 ===== */
.voice-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.mic-btn {
  width: 74px; height: 74px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  box-shadow: 0 6px 16px rgba(37,99,235,.4);
  display: flex; align-items: center; justify-content: center; transition: transform .15s;
}
.mic-btn .mic-icon { font-size: 32px; }
.mic-btn:active { transform: scale(.92); }
.mic-btn.listening { animation: pulse 1.1s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(37,99,235,.45); }
  70% { box-shadow: 0 0 0 18px rgba(37,99,235,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}
.voice-status { font-size: 16px; font-weight: 700; color: var(--blue-900); }
.voice-status small { display: block; font-weight: 400; color: var(--text-sub); margin-top: 3px; font-size: 12px; }

.manual-row { display: flex; gap: 10px; margin-bottom: 12px; }
.char-input {
  flex: 1; border: 2px solid var(--blue-100); border-radius: 14px; padding: 12px 16px;
  font-size: 18px; text-align: center; letter-spacing: 4px;
}
.char-input:focus { outline: none; border-color: var(--blue-500); }

.quick-chars { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.quick-label { font-size: 13px; color: var(--text-sub); }
.quick-char {
  width: 40px; height: 40px; border-radius: 12px; font-size: 18px; font-weight: 800;
  background: var(--blue-50); color: var(--blue-700); border: 2px solid var(--blue-100);
}
.quick-char:active { background: var(--blue-100); }

.hanzi-stage-card { text-align: center; }
.hanzi-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.current-char-badge {
  width: 58px; height: 58px; border-radius: 16px; background: var(--blue-600); color: #fff;
  font-size: 30px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(37,99,235,.35);
}
.char-actions { display: flex; gap: 8px; }
.char-actions .btn { font-size: 14px; padding: 9px 14px; }

.tianzige-wrap { display: flex; justify-content: center; }
.tianzige {
  position: relative; width: min(320px, 82vw); aspect-ratio: 1;
  border-radius: 12px; overflow: hidden; background: #fff;
  box-shadow: inset 0 0 0 2px var(--tz-line);
}
.tianzige-grid { position: absolute; inset: 0; width: 100%; height: 100%; }
#writer-target { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

.quiz-feedback { min-height: 26px; margin-top: 12px; font-size: 16px; font-weight: 800; }
.quiz-feedback.good { color: var(--green); }
.quiz-feedback.bad { color: var(--red); }

.hanzi-history { display: flex; flex-wrap: wrap; gap: 8px; }
.hist-char {
  width: 52px; height: 52px; border-radius: 14px; font-size: 24px; font-weight: 800;
  background: var(--card); color: var(--blue-700); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.hist-char:active { background: var(--blue-50); }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 560px; border-radius: 24px 24px 0 0;
  padding: 20px; max-height: 88vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { font-size: 20px; color: var(--blue-900); }
.modal-head .icon-btn { background: var(--blue-50); }
.section-title { font-size: 16px; font-weight: 800; color: var(--blue-900); margin: 16px 0 6px; }
.section-desc { font-size: 13px; color: var(--text-sub); line-height: 1.7; margin-bottom: 10px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.field input {
  width: 100%; border: 2px solid var(--blue-100); border-radius: 12px; padding: 11px 14px;
  font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--blue-500); }
.data-row { display: flex; gap: 10px; margin-top: 8px; }
.test-result { margin-top: 10px; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.6; }
.test-result.ok { background: #f0fdf4; color: var(--green); border: 1.5px solid #bbf7d0; }
.test-result.fail { background: #fef2f2; color: var(--red); border: 1.5px solid #fecaca; }
.modal-foot { margin-top: 18px; }

/* ===== 练习卷（屏幕预览 + 打印共用） ===== */
.sheet {
  background: #fff; color: #111; max-width: 760px; margin: 16px auto; padding: 28px 30px;
  border-radius: 12px; box-shadow: var(--shadow); font-size: 15px; line-height: 1.9;
}
.sheet-head { text-align: center; border-bottom: 3px double #1d4ed8; padding-bottom: 12px; margin-bottom: 16px; }
.sheet-head h1 { font-size: 22px; color: #1d4ed8; letter-spacing: 2px; }
.sheet-head p { font-size: 13px; color: #555; margin-top: 4px; }
.sheet h2.section { font-size: 17px; color: #1d4ed8; margin: 18px 0 10px; }
.sheet .q-item { margin-bottom: 14px; page-break-inside: avoid; }
.sheet .q-stem { font-weight: 600; }
.sheet .q-blank { display: inline-block; min-width: 120px; border-bottom: 1.5px solid #333; }
.sheet .q-lines { margin-top: 8px; }
.sheet .q-lines .line { border-bottom: 1.5px solid #94a3b8; height: 30px; }
.sheet .answer-box { margin-top: 8px; border: 1.5px dashed #94a3b8; border-radius: 8px; min-height: 56px; padding: 8px 12px; color: #64748b; font-size: 13px; }
.sheet .analysis { background: #f1f5f9; border-radius: 8px; padding: 8px 12px; font-size: 13px; color: #334155; margin-top: 6px; }
.sheet .recog-block { background: #eff6ff; border-left: 4px solid #1d4ed8; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }
.sheet .recog-block .label { font-weight: 800; color: #1d4ed8; }
.sheet .answers-page { page-break-before: always; }
.sheet .wrong-photo { text-align: center; margin: 12px 0; }
.sheet .wrong-photo img { max-width: 70%; border: 1px solid #cbd5e1; border-radius: 8px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: rgba(30,41,59,.92); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: 14px; z-index: 99; max-width: 86vw; text-align: center;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== 打印样式 ===== */
@media print {
  body > *:not(#print-area) { display: none !important; }
  body { background: #fff; }
  #print-area { display: block !important; }
  #print-area .no-print { display: none !important; }
  .sheet { box-shadow: none; margin: 0; max-width: none; border-radius: 0; padding: 10mm 12mm; }
  @page { size: A4; margin: 10mm; }
}
#print-area { display: none; }

@media (min-width: 700px) {
  .modal { border-radius: 24px; margin-bottom: 10vh; }
}

/* ===== 拼音找字 ===== */
.pinyin-display {
  display: flex; align-items: center; gap: 10px;
  background: var(--blue-50); border-radius: 14px; padding: 10px 16px; margin-bottom: 12px;
}
.pinyin-display span:first-child {
  flex: 1; font-size: 34px; font-weight: 700; color: var(--blue-700);
  font-family: 'PingFang SC', sans-serif; min-height: 44px; line-height: 44px;
}
#pinyin-pad {
  width: 100%; height: 230px; display: block;
  background: #fff; border: 2.5px dashed var(--blue-300); border-radius: 16px;
  touch-action: none; cursor: crosshair;
}
.chip-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.chip-row .chip-label { font-size: 13px; color: var(--text-sub); }
.chip-row button {
  min-width: 52px; padding: 8px 14px; font-size: 22px; font-weight: 700;
  border-radius: 12px; border: 2px solid var(--blue-300); background: #fff; color: var(--blue-700);
}
.chip-row button.chip-best { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.tone-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.tone-btn {
  padding: 10px 16px; font-size: 17px; font-weight: 600; border-radius: 999px;
  border: 2px solid var(--blue-300); background: #fff; color: var(--blue-700);
}
.tone-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.kb-details { margin-top: 12px; }
.kb-details summary { cursor: pointer; color: var(--text-sub); font-size: 14px; padding: 6px 0; }
.kb { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 8px; }
.kb button {
  padding: 10px 0; font-size: 22px; font-weight: 700; border-radius: 12px;
  border: 2px solid var(--blue-100); background: var(--blue-50); color: var(--blue-700);
}
.pinyin-results {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 10px; margin-top: 10px;
}
.pinyin-results .py-char {
  padding: 12px 0 8px; font-size: 36px; line-height: 1.2; border-radius: 14px;
  border: 2px solid var(--blue-100); background: #fff; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.pinyin-results .py-char small { font-size: 12px; color: var(--text-sub); font-weight: 400; }
.pinyin-results .py-char.exact { border-color: var(--blue-600); background: var(--blue-50); }
.pinyin-results .py-group-title {
  grid-column: 1 / -1; font-size: 14px; color: var(--text-sub); margin-top: 6px;
}

/* ===== 笔顺数字图 ===== */
.num-stroke-box {
  margin-top: 12px; background: #fff; border: 2px solid var(--blue-100);
  border-radius: 14px; padding: 10px;
}
.num-stroke-box svg { width: 60%; max-width: 250px; display: block; margin: 0 auto; }
.num-stroke-box .num-caption, .num-loading {
  text-align: center; font-size: 13px; color: var(--text-sub); margin-top: 6px;
}

/* ===== 练习卷分节版式 ===== */
.sheet .sec-block { margin-top: 16px; }
.sheet .sec-name {
  font-size: 17px; color: var(--blue-900); margin: 0 0 4px;
  padding-left: 8px; border-left: 4px solid var(--blue-600);
}
.sheet .sec-instr { font-size: 13px; color: var(--text-sub); margin: 0 0 8px 12px; }
.sheet .q-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 22px;
}
.sheet .q-mini {
  font-size: 16px; padding: 7px 2px; border-bottom: 1px dotted #cbd5e1;
  color: var(--text); line-height: 1.6; min-height: 32px;
}
.sheet .q-mini .q-no { color: var(--text-sub); margin-right: 2px; }
.sheet .q-blank {
  display: inline-block; min-width: 44px; border-bottom: 1.5px solid #94a3b8;
  height: 1em; vertical-align: -2px;
}
.sheet .sheet-tip {
  margin-top: 18px; font-size: 14px; color: var(--text-sub);
  background: var(--blue-50); border-radius: 8px; padding: 8px 12px;
}
.sheet .q-list .q-item { margin-top: 10px; }
@media (min-width: 640px) {
  .sheet .q-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ===== 题干内可书写填空框（一年级手写大小） ===== */
.sheet .writable {
  display: inline-block; width: 1.9em; height: 1.45em;
  border: 1.5px solid #94a3b8; border-radius: 5px;
  vertical-align: -0.28em; margin: 0 2px; background: #fff;
}
.sheet .o-box {
  display: inline-block; width: 1.6em; height: 1.6em;
  border: 1.5px solid #94a3b8; border-radius: 50%;
  vertical-align: -0.38em; margin: 0 2px; background: #fff;
}
