  :root {
    --primary: #5B7FFF;
    --primary-light: #E8EDFF;
    --accent: #FF7B9C;
    --accent-light: #FFF0F3;
    --green: #4ECB71;
    --green-light: #E8F8EE;
    --orange: #FFB347;
    --bg: #F8F9FE;
    --card: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --border: #E2E6F0;
    --shadow: 0 4px 20px rgba(91,127,255,0.10);
    --radius: 16px;
    --header-grad: linear-gradient(135deg, #8BA4FF 0%, #A78BFC 100%);
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
  }

  .header {
    background: var(--header-grad);
    color: white;
    padding: 16px 24px;
    text-align: center;
    border-radius: 0 0 32px 32px;
    box-shadow: 0 4px 24px rgba(91,127,255,0.25);
  }

  .header .header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
  }

  .header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
    white-space: nowrap;
  }

  .header .header-sub {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    max-width: 900px;
    margin: 6px auto 0;
  }

  .header .date-display {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    padding: 5px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
  }

  .container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 16px 40px;
  }

  /* Controls */
  .controls {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 18px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .controls label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .controls select, .controls input[type="number"] {
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: white;
    outline: none;
    transition: border 0.2s;
  }

  .controls select:focus, .controls input[type="number"]:focus {
    border-color: var(--primary);
  }

  .controls input[type="number"] { width: 56px; }

  .btn {
    padding: 8px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn-primary { background: var(--primary); color: white; }
  .btn-primary:hover { background: #4A6BE0; transform: translateY(-1px); }

  .btn-accent { background: var(--accent); color: white; }
  .btn-accent:hover { background: #E86A8A; }

  .btn-outline { background: transparent; color: var(--text-light); border: 1.5px solid var(--border); }
  .btn-outline:hover { border-color: var(--primary); color: var(--primary); }

  .btn-hint {
    background: transparent;
    color: var(--orange);
    border: 1.5px solid var(--orange);
  }
  .btn-hint:hover { background: #FFF8ED; }
  .btn-hint.on { background: var(--orange); color: white; }

  .btn-group {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
  }

  /* Type filters */
  .type-section { width: 100%; }
  .type-section .section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
  }

  .type-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
  }

  .type-group .group-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
    min-width: 32px;
    text-align: right;
    margin-right: 2px;
    flex-shrink: 0;
    opacity: 0.7;
  }

  .type-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
  }

  .type-filters label {
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 16px;
    background: var(--primary-light);
    color: var(--primary);
    transition: all 0.2s;
    user-select: none;
  }

  .type-filters label.active { background: var(--primary); color: white; }
  .type-filters label input[type="checkbox"] { display: none; }

  /* Stats bar */
  .stats-bar {
    display: flex;
    gap: 12px;
    padding: 10px 18px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    flex-wrap: wrap;
  }

  .stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-light);
  }

  .stat-item .num {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
  }

  /* Tip banner */
  .tip-banner {
    display: none;
    background: var(--orange);
    color: white;
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    align-items: center;
    gap: 8px;
    line-height: 1.6;
  }
  .tip-banner.show { display: flex; }

  /* Problem sheet */
  .sheet {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 20px;
  }

  .sheet-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px dashed var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* 知识练习（双轨）：列表式 + 选择题选项 */
  .problem-grid.knowledge-grid { grid-template-columns: 1fr; }
  .knowledge-grid .problem-item { min-height: 0; padding: 6px 0; }
  .knowledge-grid .calc-space { min-height: 40px; }
  .choice-opts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 14px; }
  .choice-opt { background: var(--bg, #f5f5f7); border: 1px solid var(--border, #ddd); border-radius: 6px; padding: 2px 8px; }

  @media screen {
    .task-block .problem-grid.knowledge-grid { grid-template-columns: 1fr; }
    .knowledge-grid .problem-item {
      display: grid;
      grid-template-columns: 26px minmax(0, 1fr) 34px;
      align-items: start;
      column-gap: 6px;
      row-gap: 6px;
      padding: 8px;
    }
    .knowledge-grid .num-label { grid-column: 1; grid-row: 1; }
    .knowledge-grid .expr { grid-column: 2; grid-row: 1; min-width: 0; }
    .knowledge-grid .answer-placeholder { grid-column: 3; grid-row: 1; }
    .knowledge-grid .choice-opts {
      grid-column: 2 / 4;
      grid-row: 2;
      min-width: 0;
      margin-top: 0;
    }
    .knowledge-grid .qp-tag,
    .knowledge-grid .probe-mark,
    .knowledge-grid .calc-space { grid-column: 2 / 4; }
  }

  /* 智能方案卡与换一换（P0c） */
  .plan-card { background: var(--bg, #f5f5f7); border: 1px solid var(--border, #ddd); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
  .plan-card-title { font-weight: 700; margin-bottom: 4px; }
  .plan-focus { margin-bottom: 4px; }
  .plan-conflict { margin-top: 8px; padding: 8px 10px; background: #fff8e6; border: 1px solid #e6c75a; border-radius: 8px; font-size: 13px; }
  .plan-conflict-title { font-weight: 600; }
  .plan-conflict ul { margin: 6px 0 0 16px; padding: 0; }
  .plan-ok { color: #2e7d32; font-weight: 600; }
  .modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
  .modal.hidden { display: none; }
  .modal-box { background: #fff; border-radius: 12px; padding: 16px; width: min(92vw, 420px); max-height: 86vh; overflow: auto; }
  .swap-reason { width: 100%; min-height: 72px; box-sizing: border-box; border: 1px solid var(--border, #ddd); border-radius: 8px; padding: 8px; margin-top: 8px; font: inherit; }
  .btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

  .problem-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px;
  }

  .problem-item {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1.5;
    min-height: 42px;
  }

  .problem-item .num-label {
    color: var(--text-light);
    font-size: 11px;
    font-weight: 400;
    min-width: 26px;
    flex-shrink: 0;
  }

  .problem-item .qp-tag {
    display: none;
    font-size: 10px;
    background: var(--orange);
    color: white;
    border-radius: 10px;
    padding: 1px 6px;
    font-weight: 600;
    margin-left: 4px;
    flex-shrink: 0;
  }
  .problem-item .qp-tag.visible { display: inline; }

  .problem-item .answer-placeholder {
    display: inline-block;
    min-width: 34px;
    border-bottom: 2px dotted var(--border);
    margin-left: 2px;
    color: transparent;
    flex-shrink: 0;
  }

  .problem-item .expr { flex: 1; }

  /* Calculation area for print — provides blank lines for working */
  .calc-space {
    display: none;
  }

  .problem-diagram { display: block; width: 150px; height: 112px; margin: 5px auto; }
  .problem-diagram line { stroke: currentColor; stroke-width: .7; opacity: .55; }
  .problem-diagram circle { fill: currentColor; }
  .problem-diagram text { fill: currentColor; font-size: 11px; font-weight: 700; }
  .problem-diagram .diagram-fill { fill: #d9d9d9; stroke: currentColor; stroke-width: .5; }

  .problem-item.fraction .frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 2px;
    font-size: 14px;
  }

  .problem-item.fraction .frac .frac-num {
    border-bottom: 1.5px solid var(--text);
    padding: 0 4px 1px;
  }
  .problem-item.fraction .frac .frac-den { padding: 1px 4px 0; }

  /* Answer key */
  .answers-section {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 2px dashed var(--border);
  }
  .answers-section.hidden { display: none; }

  .answers-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--green);
    margin-bottom: 12px;
    user-select: none;
  }

  .answer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 4px;
  }

  .answer-item {
    font-size: 14px;
    color: var(--text-light);
    padding: 3px 8px;
  }

  .answer-item .num-label {
    color: var(--text-light);
    font-size: 12px;
    min-width: 26px;
    display: inline-block;
  }

  .answer-item .qp-tag {
    display: none;
    font-size: 10px;
    background: var(--orange);
    color: white;
    border-radius: 10px;
    padding: 1px 6px;
    font-weight: 600;
    margin-left: 4px;
  }
  .answer-item .qp-tag.visible { display: inline; }

  /* 查看答案：知识练习答案与解析（G2） */
  .answer-k-section { margin-top: 14px; }
  .answer-k-title { font-size: 14px; font-weight: 600; color: #333; margin-bottom: 8px; }
  .answer-k-card {
    border: 1px solid #eee; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px;
    background: #fcfcff; font-size: 14px; line-height: 1.6;
  }
  .answer-k-q { color: #333; }
  .answer-k-opts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 13px; }
  .answer-k-opt { background: #f5f5f7; border: 1px solid #ddd; border-radius: 6px; padding: 1px 8px; color: #555; }
  .answer-k-opt.hit { background: #e8f5e9; border-color: #2e7d32; color: #2e7d32; font-weight: 600; }
  .answer-k-a { margin-top: 4px; font-weight: 600; color: #2e7d32; }
  .answer-k-s { margin-top: 3px; color: #666; font-size: 13px; }

  /* Password modal */
  .pw-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    justify-content: center;
    align-items: center;
  }
  .pw-overlay.show { display: flex; }

  .pw-modal {
    background: white;
    border-radius: 20px;
    padding: 32px 28px 24px;
    width: 340px;
    max-width: 90vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    text-align: center;
  }

  .pw-modal h3 {
    font-size: 18px;
    margin-bottom: 4px;
  }

  .pw-modal .pw-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 20px;
  }

  .pw-modal input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 18px;
    font-family: inherit;
    text-align: center;
    letter-spacing: 4px;
    outline: none;
    transition: border 0.2s;
  }
  .pw-modal input:focus { border-color: var(--primary); }
  .pw-modal input.error { border-color: var(--accent); animation: shake 0.3s; }

  @keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
  }

  .pw-modal .pw-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
  }

  .pw-modal .pw-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
  }
  .pw-modal .pw-actions .pw-cancel {
    background: var(--bg);
    color: var(--text-light);
  }
  .pw-modal .pw-actions .pw-confirm {
    background: var(--primary);
    color: white;
  }

  .pw-modal .pw-error {
    color: var(--accent);
    font-size: 12px;
    margin-top: 8px;
    display: none;
  }

  @media print {
    body { background: white; height: 100vh; }
    .header { background: #8BA4FF !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; padding: 5px 10px; border-radius: 0; }
    .header .header-row { max-width: 100%; }
    .header h1 { font-size: 14px; }
    .header .date-display { font-size: 10px; padding: 1px 8px; }
    .controls, .stats-bar, .btn-group, .answers-toggle, .answers-section, .tip-banner, .pw-settings, .pw-overlay { display: none !important; }
    .container { max-width: 100%; padding: 2px 6px; height: calc(100vh - 36px); }
    .sheet { box-shadow: none; border: none; border-radius: 0; padding: 2px 0; height: 100%; display: flex; flex-direction: column; }
    .sheet-title { font-size: 9px; margin-bottom: 4px; padding-bottom: 2px; border-bottom-width: 1px; flex-shrink: 0; }
    .sheet-title span { font-size: 9px !important; }
    .problem-grid { 
      grid-template-columns: repeat(3, 1fr);
      grid-template-rows: repeat(10, 1fr);
      gap: 2px;
      flex: 1;
      min-height: 0;
    }
    .problem-item {
      border: 1px solid #ddd;
      border-radius: 3px;
      padding: 3px 5px;
      font-size: 12px;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 1px;
      min-height: 0;
      overflow: hidden;
    }
    .problem-item .expr { width: 100%; flex-shrink: 0; }
    .problem-item .calc-space {
      display: block;
      width: 100%;
      flex: 1;
      min-height: 8px;
      margin-top: 1px;
      border-bottom: 1px dashed #bbb;
    }
    .problem-diagram { width: 34mm; height: 25mm; max-width: 100%; break-inside: avoid; }
    .problem-item .num-label { font-size: 9px; min-width: 17px; flex-shrink: 0; }
    .problem-item .answer-placeholder { min-width: 28px; flex-shrink: 0; }
    .problem-item .qp-tag { display: none !important; }
    .problem-item.fraction .frac { font-size: 11px; }
    @page { margin: 3mm 6mm; size: A4; }
  }

  @media (max-width: 640px) {
    .header { padding: 10px 14px 12px; border-radius: 0 0 22px 22px; }
    .header .header-main { gap: 8px; }
    .header h1 { font-size: 17px; letter-spacing: 0; }
    .header .header-sub { gap: 8px; margin-top: 4px; }
    .header .date-display { font-size: 12px; padding: 3px 10px; }
    .header-parent-btn { font-size: 12px; padding: 4px 10px; }
    .header .conn-status { font-size: 11px; }
    .container { padding: 12px; }
    .sheet { padding: 12px; }
    .problem-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .problem-item { font-size: 14px; padding: 8px; min-height: 36px; }
    .controls { flex-direction: column; align-items: stretch; }
    .btn-group { margin-left: 0; }
  }

/* ────── 服务端模式：连接状态 / 休息日 / 家长对答案 ────── */
.conn-status {
  font-size: 13px;
  color: #2e7d32;
  margin-top: 6px;
}
.conn-status.offline { color: #c62828; }
.header .conn-status { color: rgba(255,255,255,0.92); margin-top: 0; }

.hidden { display: none !important; }

.mark-section {
  box-sizing: border-box;
  max-width: 100%;
  margin-top: 24px;
  padding: 16px;
  border: 1px dashed #bdbdbd;
  border-radius: 8px;
  background: #fafafa;
}
.mark-header h3 { margin: 0 0 6px; font-size: 16px; }
.mark-tip { font-size: 13px; color: #666; }
.mark-grid {
  display: grid;
  max-width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.mark-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  user-select: none;
}
.mark-item.wrong { border-color: #e53935; background: #ffebee; }
.mark-item .mk-no { color: #999; font-size: 12px; }
.mark-item .mk-expr { flex: 1; font-size: 14px; }
.mark-item .mk-ans { font-weight: 600; font-size: 13px; }
.mark-item .mk-status { font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.mark-item .mk-status.ok { color: #2e7d32; background: #e8f5e9; }
.mark-item .mk-status.no { color: #c62828; background: #ffcdd2; }

/* 对答案：知识练习题区（单列、题干可换行、选项、答案徽标） */
.mark-knowledge { margin: 4px 0 12px; }
.mark-k-title { font-size: 14px; font-weight: 600; margin: 10px 0 6px; color: #333; }
#markKnowledgeGrid { grid-template-columns: 1fr; }
.mark-item.knowledge { align-items: flex-start; }
.mark-item.knowledge .mk-kwrap { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mark-item.knowledge .mk-khead { display: flex; gap: 6px; align-items: flex-start; }
.mark-item.knowledge .mk-expr { line-height: 1.5; white-space: normal; }
.mark-item.knowledge .mk-opts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; padding-left: 23px; }
.mark-item.knowledge .mk-opt { background: #f5f5f7; border: 1px solid #ddd; border-radius: 6px; padding: 1px 7px; }
.mark-item.knowledge .mk-ans { color: #2e7d32; font-size: 13px; font-weight: 600; padding-left: 23px; }

.mark-progress, .mark-duration { margin: 12px 0; }
.mark-date-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; }
.mark-date-row input[type="date"] { padding: 4px 6px; border: 1px solid #ccc; border-radius: 4px; }
.progress-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.progress-current { margin: 6px 0; color: #555; font-size: 14px; }
#markProgressHint a { color: #1565c0; }
.progress-fields { display: flex; gap: 12px; flex-wrap: wrap; }
.progress-fields label { font-size: 14px; display: flex; align-items: center; gap: 4px; }
.progress-fields input {
  width: 110px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.duration-error { margin-top: 6px; color: #c0392b; font-size: 13px; }

.mark-result {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #e8f5e9;
  color: #2e7d32;
  font-weight: 600;
}

.btn-mark.done {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #2e7d32;
  cursor: default;
}

@media print {
  .mark-section,
  .mark-btn,
  .conn-status,
  #restBanner {
    display: none !important;
  }
}

/* ────── 今日任务首页 ────── */
.today-card {
  background: linear-gradient(135deg, #eef2ff, #f8f6ff);
  border: 1px solid #d8d4f5;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.today-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 2px 12px;
  margin-bottom: 6px;
}
.today-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 2px 0 4px; }
.today-summary { font-size: 14px; color: #5a5470; margin-bottom: 4px; }
.today-meta { font-size: 13px; color: #8a83a0; }

.rest-card {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed #ccc;
  border-radius: 14px;
  color: #666;
  background: #fafafa;
}
.rest-emoji { font-size: 42px; margin-bottom: 8px; }
.rest-text { font-size: 16px; }

.task-block {
  border: 1px solid #e2e2e2;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.block-title {
  font-size: 14px;
  font-weight: 600;
  color: #444;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}
.task-block .problem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.home-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.home-actions .btn { flex: 1; max-width: 260px; }

/* ────── 家长中心抽屉 ────── */
.parent-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(480px, 100vw);
  background: #fff;
  box-shadow: -4px 0 24px rgba(0,0,0,.18);
  z-index: 100;
  overflow-y: auto;
  padding: 16px;
  border-radius: 16px 0 0 16px;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.drawer-head h3 { margin: 0; font-size: 18px; }
.drawer-close {
  border: none;
  background: #f0f0f0;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
}
.drawer-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.drawer-tabs .tab {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.drawer-tabs .tab.active { background: #5b4bc4; color: #fff; border-color: #5b4bc4; }
.drawer-panel { padding: 4px 0; }
.settings-block { display: flex; flex-direction: column; gap: 12px; }
/* 出题设置：标签列（96px）+ 控件列，标签与设置项一目对应 */
.settings-row { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 4px 12px; font-size: 14px; }
.settings-row input:not([type="checkbox"]), .settings-row select {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 150px;
}
/* 修复：checkbox 不被统一宽度规则拉宽（避免勾选框与文字隔开） */
.settings-row input[type="checkbox"] { width: auto; }
.row-label { color: #444; white-space: nowrap; }
.row-label small { display: block; color: #999; font-size: 11px; line-height: 1.3; margin-top: 1px; font-weight: 400; white-space: normal; }
.row-control { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* 启用开关行（单开关无标签列） */
.settings-row.switch-row { display: flex; gap: 8px; align-items: center; }
.settings-row.switch-row input[type="checkbox"] { width: auto; accent-color: var(--primary); }
/* 知识练习说明 */
.kn-intro { font-size: 12px; color: #888; margin: 2px 0 8px; }
/* 多选项 chip 胶囊：整块可点，选中态主题色 */
.kn-days { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border: 1px solid #d6d9e0; border-radius: 999px; font-size: 13px; cursor: pointer; user-select: none; background: #fff; transition: border-color .15s, background .15s; }
.chip input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--primary); }
.chip.on { border-color: var(--primary); background: var(--primary-light); color: #3a5fdc; }
.soon-list { display: flex; flex-direction: column; gap: 10px; }
.soon-item {
  padding: 12px;
  border: 1px dashed #ddd;
  border-radius: 8px;
  color: #777;
  background: #fafafa;
}

@media (max-width: 640px) {
  .parent-drawer { width: 100vw; border-radius: 16px 16px 0 0; }
}

/* ────── 打印：今日任务分页（每个任务块一页，自动续页） ────── */
@media print {
  .header,
  .today-card,
  .tip-banner,
  .home-actions,
  .parent-drawer,
  .conn-status,
  #restCard {
    display: none !important;
  }
  .container { max-width: 100%; padding: 2px 6px; height: auto; }
  .task-block {
    break-after: page;
    page-break-after: always;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 2px 0;
    margin: 0;
    height: calc(100vh - 36px);
    display: flex;
    flex-direction: column;
  }
  .task-block:last-child { break-after: auto; page-break-after: auto; }
  .block-title { font-size: 10px; margin-bottom: 4px; padding-bottom: 2px; border-bottom-width: 1px; flex-shrink: 0; }
  .task-block .problem-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 2px;
    flex: 1;
    min-height: 0;
  }
  .task-block .problem-item {
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 3px 5px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    min-height: 0;
    overflow: hidden;
  }
  .task-block .problem-item .calc-space {
    display: block;
    width: 100%;
    flex: 1;
    min-height: 8px;
    margin-top: 1px;
    border-bottom: 1px dashed #bbb;
  }
}

.plan-lock-note {
  font-size: 13px;
  color: #7a5c00;
  background: #fff8e1;
  border: 1px solid #f0e0a0;
  border-radius: 6px;
  padding: 8px 10px;
}

/* ────── 学习报告（家长中心） ────── */
.report-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.report-toolbar select { padding: 5px 8px; border: 1px solid #ccc; border-radius: 6px; }
.report-empty { color: #999; padding: 16px 0; }
.rp-card {
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fcfcff;
  font-size: 14px;
  line-height: 1.6;
}
.rp-card b { color: #333; }
.rp-summary { background: #eef2ff; border-color: #d8d4f5; font-weight: 600; color: #3a2f7a; }
.rp-encourage { background: #fff8e1; border-color: #f0e0a0; color: #7a5c00; }
.rp-muted { color: #999; font-size: 13px; }
.rp-weak b { color: #c62828; }
.rp-master { padding: 2px 0; }
.st-mastered { color: #2e7d32; }
.st-practicing { color: #c77800; }
.st-weak { color: #c62828; font-weight: 600; }
.agent-log { margin-top: 12px; border-top: 1px dashed #ddd; padding-top: 10px; }
.agent-log summary { cursor: pointer; font-size: 14px; color: #555; }
.log-item { font-size: 13px; padding: 6px 0; border-bottom: 1px solid #f2f2f2; }

/* ────── 讲解 tab ────── */
.explain-section { margin-bottom: 18px; }
.explain-title { font-size: 15px; font-weight: 600; color: #333; margin-bottom: 8px; }
.intro-item { margin: 3px; }

/* ────── 提前打印 tab ────── */
.adv-items { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.adv-item {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid #e3e3f0; border-radius: 8px; padding: 8px 10px; background: #fafbff; font-size: 13px;
}
.adv-item b { color: #2b2440; }
.adv-item.skipped { background: #f6f6f6; border-style: dashed; color: #888; }
.adv-type { color: #5b4bc4; border: 1px solid #d4d0f0; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.adv-count { color: #555; }
.adv-reason { color: #999; font-size: 12px; flex: 1; }

/* ────── 学习日历 tab ────── */
.cal-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.cal-toolbar b { flex: 1; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: 12px; color: #888; }
.cal-cell {
  border: 1px solid #eee; border-radius: 6px; padding: 4px; min-height: 54px;
  font-size: 12px; position: relative; background: #fff;
}
.cal-cell.empty { background: #fafafa; border-style: dashed; }
.cal-cell.dt-rest { background: #f3f3f3; }
.cal-cell.dt-vacation { background: #fff8e1; }
.cal-cell.dt-exam { background: #ffebee; }
.cal-cell.dt-thinking { background: #e8f5e9; }
.cal-day { font-weight: 600; }
.cal-dt { margin-left: 4px; color: #777; }
.cal-ev { display: block; color: #5b4bc4; font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-dot { position: absolute; right: 4px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: #2e7d32; }
.cal-section { margin-top: 16px; border-top: 1px dashed #ddd; padding-top: 12px; }
.cal-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.cal-form input, .cal-form select { padding: 4px 6px; border: 1px solid #ccc; border-radius: 4px; }
.cal-form textarea.note-text, textarea.note-text { width: 100%; min-height: 88px; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font: inherit; line-height: 1.5; resize: vertical; box-sizing: border-box; }
.kn-custom-kps { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 2px; }
.kn-custom-kps label.chip { margin: 0; }
.cal-weekly { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
.wk-row { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.wk-row select { padding: 3px; border: 1px solid #ccc; border-radius: 4px; }
.cal-cell.dt-light { background: #fffde7; }
.cal-hol { display: block; color: #c62828; font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-active { margin-bottom: 8px; font-size: 13px; }
.cal-active-ok { background: #e8f5e9; border-radius: 8px; padding: 8px 10px; color: #2e7d32; }
.cal-active-warn { background: #fff8e1; border-radius: 8px; padding: 8px 10px; color: #a06000; }
.cal-periods { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.period-card { border: 1px solid #e3e3f0; border-radius: 10px; padding: 10px; background: #fafbff; }
.period-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.period-head b { flex: 1; color: #2b2440; }
.period-dates { color: #777; font-size: 12px; }
.btn-link { border: none; background: none; cursor: pointer; padding: 2px 4px; font-size: 13px; }
.btn-link.danger { color: #c62828; }
.cal-add { margin-top: 8px; font-size: 13px; color: #5b4bc4; }
.cal-add summary { cursor: pointer; }
.hol-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; flex-wrap: wrap; }
.hol-date { color: #777; font-family: ui-monospace, monospace; }
.hol-src { color: #5b4bc4; font-size: 11px; border: 1px solid #d4d0f0; border-radius: 999px; padding: 0 6px; }
.hol-src.builtin { color: #888; border-color: #ddd; }
.cal-tip { font-size: 12px; color: #666; background: #f4f6ff; border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
.cal-tip.warn { color: #a06000; background: #fff8e1; }
.cal-tip.ok { color: #2e7d32; background: #e8f5e9; }
.cal-events { margin-top: 10px; }
.cal-events-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.cal-event-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid #eee; border-radius: 6px; margin-top: 4px; font-size: 12px; }
.cal-event-delete { padding: 2px 8px; font-size: 12px; white-space: nowrap; }

/* ────── 首页预习块 ────── */
.explain-card { font-size: 14px; line-height: 1.7; color: #444; padding: 4px 2px; }
.explain-card b { color: #333; }

/* ────── 思维挑战块（长题干、单列、保留换行） ────── */
.task-block .challenge-grid { grid-template-columns: 1fr; gap: 10px; }
.challenge-grid .problem-item { min-height: 72px; font-size: 14px; }
.challenge-grid .expr-multiline { white-space: pre-line; line-height: 1.5; }
@media print {
  .task-block .problem-grid.challenge-grid { grid-template-columns: 1fr; }
  .task-block .problem-grid.knowledge-grid { grid-template-columns: 1fr; }
  .challenge-grid .problem-item { min-height: 64px; font-size: 13px; }
}

/* ────── 速算弹层 ────── */
.speed-q { font-size: 22px; font-weight: 700; color: #2b2440; margin: 10px 0; text-align: center; }
#speedInput { font-size: 20px; text-align: center; width: 120px; margin: 0 auto; display: block; }
.speed-result { margin-top: 10px; text-align: center; font-weight: 600; color: #2e7d32; }

/* ────── 出题设置：换题入口显眼化 ────── */
.settings-hint { font-size: 13px; color: #666; background: #f4f6ff; border-radius: 8px; padding: 8px 10px; }
.btn-col { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.btn-col .btn { width: 100%; margin: 0; }

/* ────── 家长入口可见性：顶部 + 底部悬浮 ────── */
.header-parent-btn { font-size: 13px; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.home-actions {
  position: sticky;
  bottom: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px;
  border-radius: 12px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  z-index: 50;
}
@media (max-width: 640px) {
  .header-right { flex-direction: column; align-items: flex-end; gap: 4px; }
}

/* ────── 练习块信息栏（用时/得分/答对，屏幕与打印显示） ────── */
.block-meta {
  font-size: 12px;
  color: #666;
  margin: 0 0 8px;
  letter-spacing: 1px;
}
@media print {
  .block-meta { font-size: 10px; margin: 0 0 4px; }
}

/* ────── 统一主题（8 套，与背单词/认证服务同一套主题 id） ────── */
:root[data-theme='chunhai'] {
  --primary: #5f9e6e; --primary-light: #e1f0da; --accent: #f0b0a4; --accent-light: #fdeee7;
  --bg: #eff6e9; --card: #fdfbf4; --text: #3d4a3a; --text-light: #7c8a76; --border: #dcebd3;
  --header-grad: linear-gradient(135deg, #5f9e6e 0%, #7ec48f 100%);
}
:root[data-theme='mint'] {
  --primary: #2f9488; --primary-light: #dcf4ee; --accent: #f0b0a4; --accent-light: #fdeee7;
  --bg: #eaf7f2; --card: #fbfefc; --text: #2f4a44; --text-light: #7a948d; --border: #d5ebe3;
  --header-grad: linear-gradient(135deg, #2f9488 0%, #4fb8ab 100%);
}
:root[data-theme='lavender'] {
  --primary: #8b72be; --primary-light: #e9e1f7; --accent: #f0b0a4; --accent-light: #fdeee7;
  --bg: #f3eff9; --card: #ffffff; --text: #3b3450; --text-light: #7d7395; --border: #e2daf0;
  --header-grad: linear-gradient(135deg, #8b72be 0%, #a98fd6 100%);
}
:root[data-theme='apricot'] {
  --primary: #c97f6f; --primary-light: #f9e5dc; --accent: #8b72be; --accent-light: #f0ecfb;
  --bg: #fbf1ea; --card: #ffffff; --text: #4a3830; --text-light: #8a7368; --border: #f0ddd3;
  --header-grad: linear-gradient(135deg, #c97f6f 0%, #dd9c88 100%);
}
:root[data-theme='pinkblue'] {
  --primary: #6fa8e8; --primary-light: #e3eefb; --accent: #f6c2d4; --accent-light: #fdeef4;
  --bg: #fcebf4; --card: #ffffff; --text: #37465c; --text-light: #7c8aa0; --border: #f0d9e6;
  --header-grad: linear-gradient(135deg, #6fa8e8 0%, #8fbdf0 100%);
}
:root[data-theme='blue'] {
  --primary: #3579cf; --primary-light: #dcebfb; --accent: #f0b0a4; --accent-light: #fdeee7;
  --bg: #deebfb; --card: #ffffff; --text: #2b3a52; --text-light: #6e86a3; --border: #c9ddf2;
  --header-grad: linear-gradient(135deg, #3579cf 0%, #5b97e0 100%);
}
:root[data-theme='pink'] {
  --primary: #e07ba6; --primary-light: #fde8f0; --accent: #8b72be; --accent-light: #f0ecfb;
  --bg: #fff5f8; --card: #ffffff; --text: #55323f; --text-light: #92677a; --border: #f6dbe7;
  --header-grad: linear-gradient(135deg, #e07ba6 0%, #ee9cbf 100%);
}
:root[data-theme='yellow'] {
  --primary: #d9a520; --primary-light: #fbf0cf; --accent: #f0b0a4; --accent-light: #fdeee7;
  --bg: #fff9e6; --card: #ffffff; --text: #544a2c; --text-light: #8f8159; --border: #f0e2b8;
  --header-grad: linear-gradient(135deg, #d9a520 0%, #ecc24f 100%);
}

/* ────── 主题选择器 ────── */
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.theme-item {
  border: 2px solid transparent; border-radius: 12px; padding: 8px; cursor: pointer;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.06); text-align: center;
}
.theme-item.active { border-color: var(--primary); }
.theme-swatches { display: flex; gap: 4px; justify-content: center; margin-bottom: 6px; }
.theme-swatches i { width: 34px; height: 22px; border-radius: 6px; display: inline-block; border: 1px solid rgba(0,0,0,.08); }
.theme-name { font-size: 13px; font-weight: 600; color: var(--text); }
.theme-desc { font-size: 11px; color: var(--text-light); }
.theme-random-row {
  display: block;
  font-size: 14px;
  margin: 6px 0;
  cursor: pointer;
  line-height: 1.5;
}
.theme-random-row input {
  vertical-align: middle;
  margin-right: 6px;
  width: 16px;
  height: 16px;
}
/** 防"文字被压缩成竖条"：flex 行内标签文字保持单行 */
.settings-row,
.progress-fields label,
.type-filters label {
  white-space: nowrap;
}

@media print {
  .theme-item, .theme-random-row, #themeBtn { display: none !important; }
}

/* 绑定弹层："这是我的家长设备" 行（修复 flex 文本被压缩成竖条） */
.bind-parent-row {
  display: block;
  margin: 8px 0;
  font-size: 14px;
  cursor: pointer;
  line-height: 1.5;
}
.bind-parent-row input {
  vertical-align: middle;
  margin-right: 6px;
  width: 16px;
  height: 16px;
}

/* D2/D3/D4：留言诉求类型、智能老师对话、周报留言回应 */
.note-types { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 2px; }
.note-types-label { font-size: 13px; color: #666; margin-right: 2px; }
.note-type-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--primary-light, #eaf0ff); color: #3a5fdc; font-size: 12px; margin-right: 4px; }
.teacher-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.teacher-chat { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; border: 1px solid #e3e6ee; border-radius: 8px; padding: 8px; margin: 8px 0; background: #fafbfd; }
.tc-msg { padding: 6px 10px; border-radius: 8px; font-size: 14px; line-height: 1.5; max-width: 90%; }
.tc-msg b { display: block; font-size: 12px; color: #888; margin-bottom: 2px; }
.tc-me { align-self: flex-end; background: var(--primary, #4c6ef5); color: #fff; }
.tc-me b { color: rgba(255,255,255,.8); }
.tc-ai { align-self: flex-start; background: #fff; border: 1px solid #e3e6ee; white-space: pre-wrap; }
.rp-note-resp { padding: 6px 0; border-bottom: 1px dashed #e8eaf2; font-size: 14px; }
.rp-note-resp:last-child { border-bottom: none; }

/* 多孩子身份与家长模式 */
.header-title-group {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.identity-control { position: relative; margin-top: 0; min-width: 0; }
.identity-button {
  border: 1px solid rgba(255,255,255,.55);
  background: rgba(255,255,255,.18);
  color: white;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: default;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-button.switchable { cursor: pointer; }
.identity-button.switching { opacity: .7; cursor: wait; }
.identity-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 150px;
  padding: 6px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 12px 32px rgba(35,42,70,.18);
}
.identity-menu button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.identity-menu button.active { background: var(--primary-light); color: var(--primary); }
.identity-menu button:disabled { opacity: .6; cursor: wait; }
.parent-mode-card,
.identity-error-card {
  background: white;
  border: 1px solid #e5e1f4;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin: 18px 0;
}
.parent-mode-card h2,
.identity-error-card h2 { margin: 0 0 8px; color: var(--primary); }
.parent-mode-card p,
.identity-error-card p { color: #667085; margin: 0 auto 16px; max-width: 520px; }
body.parent-mode #todayCard,
body.parent-mode #tipBanner,
body.parent-mode #taskBlocks,
body.parent-mode .home-actions { display: none; }
.parent-child-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid #ececf3;
  background: #fafaff;
}
.parent-child-label { font-size: 13px; font-weight: 700; color: #667085; }
.parent-child-options { display: flex; gap: 6px; flex-wrap: wrap; }
.parent-child-options button {
  border: 1px solid #d8d4f5;
  background: white;
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.parent-child-options button.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
@media (max-width: 380px) {
  .header-parent-btn { display: none; }
  .header-title-group { justify-content: center; }
}
@media print {
  .identity-control,
  .identity-error-card,
  .parent-mode-card,
  .parent-child-bar { display: none !important; }
}

/* 学习档案初始化表单 */
.learning-form-box { width: min(94vw, 560px); }
.learning-form { display: grid; gap: 10px; }
.learning-form h4 { margin: 0 0 4px; }
.learning-form .settings-row { grid-template-columns: 132px 1fr; }
.learning-form .inline-options { display: flex; flex-wrap: wrap; gap: 8px; }
.learning-form .inline-options label { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.learning-form .form-error { color: var(--danger, #c0392b); font-size: 13px; }
.learning-form .btn-row { display: flex; justify-content: flex-end; gap: 8px; }

.probe-mark { display:block; font-size:8px; color:#555; line-height:1.2; }
.mk-not-learned { display:flex; align-items:center; gap:3px; font-size:12px; color:#555; }
.mk-not-learned input { width:auto; margin:0; }
.teacher-daily { margin-top:8px; text-align:left; font-size:13px; }
.teacher-daily ul { margin:4px 0 4px 18px; }
