:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #20242a;
  --muted: #6b7280;
  --line: #e2e7ee;
  --teal: #2f9e8f;
  --teal-dark: #14776b;
  --blue: #3b82f6;
  --coral: #ef7a5f;
  --yellow: #f2bd4b;
  --green-soft: #e6f5f1;
  --blue-soft: #eaf2ff;
  --coral-soft: #fff0ec;
  --yellow-soft: #fff7dc;
  --shadow: 0 16px 40px rgba(31, 41, 55, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  line-height: 1.5;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(47, 158, 143, 0.07), rgba(59, 130, 246, 0.04) 260px, rgba(255, 255, 255, 0) 420px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 76px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1200px;
  padding: 18px 16px 12px;
}

.brand-block {
  align-items: center;
  display: flex;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: var(--teal);
  border-radius: 8px;
  color: white;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  gap: 1px;
  height: 52px;
  place-items: center;
  justify-content: center;
  line-height: 1.08;
  width: 52px;
}

.brand-mark span {
  display: block;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand-block h1 {
  font-size: 24px;
  line-height: 1.15;
}

.brand-block p {
  color: var(--muted);
  font-size: 13px;
  max-width: 54vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-block > div:last-child {
  min-width: 0;
}

.mode-switch,
.segmented {
  background: #edf2f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  gap: 2px;
  grid-auto-flow: column;
  padding: 3px;
}

.mode-btn,
.segment-btn {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.mode-btn.active,
.segment-btn.active {
  background: white;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  color: var(--ink);
  font-weight: 700;
}

.layout {
  display: grid;
  gap: 18px;
  grid-template-columns: 178px minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1200px;
  padding: 0 16px 24px;
}

.side-nav {
  align-self: start;
  display: grid;
  gap: 8px;
  position: sticky;
  top: 12px;
}

.nav-btn {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  text-align: left;
}

.nav-btn span {
  align-items: center;
  background: #e9edf3;
  border-radius: 7px;
  color: #475569;
  display: grid;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  height: 28px;
  place-items: center;
  width: 28px;
}

.nav-btn.active {
  background: white;
  border-color: var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 800;
}

.nav-btn.active span {
  background: var(--teal);
  color: white;
}

.main-panel {
  min-width: 0;
}

.screen {
  display: grid;
  gap: 12px;
}

.screen-head {
  align-items: end;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.screen-title {
  display: grid;
  gap: 4px;
}

.screen-title h2 {
  font-size: 23px;
}

.screen-title p {
  color: var(--muted);
  font-size: 13px;
}

.stat-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.stat strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 4px;
}

.band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 14px;
}

.band.compact {
  box-shadow: none;
}

.band-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.band-title h3 {
  font-size: 17px;
}

.band-title small {
  color: var(--muted);
}

.two-col {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.three-col {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-row {
  display: grid;
  gap: 6px;
}

.form-row.full {
  grid-column: 1 / -1;
}

.full {
  grid-column: 1 / -1;
}

.form-row label {
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.input,
.select,
.textarea {
  background: #fff;
  border: 1px solid #d6dde8;
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 9px 11px;
  width: 100%;
}

.textarea {
  min-height: 112px;
  resize: vertical;
}

.textarea.small {
  min-height: 74px;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 158, 143, 0.14);
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  align-items: center;
  background: #fff;
  border: 1px solid #d6dde8;
  border-radius: 8px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  gap: 7px;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  text-decoration: none;
}

.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.btn.blue {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.btn.coral {
  background: var(--coral);
  border-color: var(--coral);
  color: white;
}

.btn.danger {
  background: #fff5f5;
  border-color: #fecaca;
  color: #b42318;
}

.btn.ghost {
  background: transparent;
}

.is-busy button,
.is-busy input,
.is-busy select,
.is-busy textarea {
  pointer-events: none;
}

.busy-overlay {
  align-items: center;
  background: rgba(15, 23, 42, 0.18);
  display: none;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 1000;
}

.busy-overlay.show {
  display: flex;
}

.busy-card {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 16px 18px;
}

.busy-spinner {
  animation: spin 0.8s linear infinite;
  border: 3px solid #dbe4ed;
  border-top-color: var(--teal);
  border-radius: 999px;
  height: 24px;
  width: 24px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn.icon {
  border-radius: 8px;
  min-width: 40px;
  padding: 0;
}

.task-list,
.course-list,
.mistake-list,
.exercise-list,
.point-list {
  display: grid;
  gap: 8px;
}

.task-item,
.course-item,
.mistake-item,
.exercise-item,
.point-event,
.reward-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  padding: 12px;
}

.point-event {
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
}

.reward-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.reward-item {
  align-content: space-between;
  min-height: 86px;
}

.reward-item strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.reward-item span {
  color: var(--teal-dark);
  font-weight: 900;
}

.point-table-wrap {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  width: 100%;
}

.point-table {
  border-collapse: collapse;
  min-width: 820px;
  width: 100%;
}

.point-table th,
.point-table td {
  border: 1px solid #111827;
  padding: 8px 10px;
  vertical-align: top;
}

.point-table th {
  background: #f8fafc;
  color: #111827;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.point-table tbody tr:nth-child(7n + 1) td {
  border-top-width: 2px;
}

.point-table .week-cell {
  background: #fbfdff;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  vertical-align: middle;
  width: 84px;
}

.point-table .date-cell {
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  width: 92px;
}

.point-table .number-cell {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.point-table .number-cell.teal,
.point-cell-list strong.teal {
  color: var(--teal-dark);
}

.point-table .number-cell.coral,
.point-cell-list strong.coral {
  color: #c2412d;
}

.point-table .number-cell.strong {
  color: #111827;
}

.point-table .today-row {
  background: #eefaf7;
}

.point-table .future-row {
  color: #94a3b8;
}

.point-cell-list {
  display: grid;
  gap: 4px;
  min-height: 20px;
}

.point-cell-list span {
  overflow-wrap: anywhere;
}

.point-cell-list strong {
  font-size: 13px;
}

.point-empty-cell {
  color: var(--muted);
  height: 72px;
  text-align: center;
  vertical-align: middle !important;
}

.task-main {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

.item-title {
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.item-body {
  color: #4b5563;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.item-body.clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.analysis-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}

.detail-box {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #4b5563;
  display: grid;
  gap: 4px;
  padding: 9px 10px;
}

.detail-box strong {
  color: var(--ink);
  font-size: 13px;
}

.detail-box p {
  font-size: 14px;
}

.mistake-filter-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(120px, 1fr)) auto auto;
}

.mistake-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 10px;
}

.summary-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.summary-chip {
  background: var(--green-soft);
  border-radius: 999px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  min-height: 26px;
  padding: 4px 10px;
}

.summary-chip.coral {
  background: var(--coral-soft);
  color: #c2412d;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  align-items: center;
  background: #eef2f7;
  border-radius: 999px;
  color: #475569;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  min-height: 24px;
  padding: 0 9px;
}

.pill.teal {
  background: var(--green-soft);
  color: var(--teal-dark);
}

.pill.blue {
  background: var(--blue-soft);
  color: #1d4ed8;
}

.pill.coral {
  background: var(--coral-soft);
  color: #c2412d;
}

.pill.yellow {
  background: var(--yellow-soft);
  color: #8a5a00;
}

.timer {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #111827;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  min-width: 92px;
  padding: 7px 10px;
  text-align: center;
}

.parent-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.empty {
  align-items: center;
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  color: var(--muted);
  display: grid;
  min-height: 120px;
  padding: 20px;
  place-items: center;
  text-align: center;
}

.import-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.import-tab {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  flex: 0 0 auto;
  font-weight: 800;
  min-height: 40px;
  padding: 0 12px;
}

.import-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.paste-zone {
  align-items: center;
  background: #f8fafc;
  border: 1.5px dashed #b8c4d6;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  place-items: center;
  text-align: center;
}

.paste-zone.large {
  min-height: 190px;
}

.paste-zone:focus,
.paste-zone:hover {
  background: var(--green-soft);
  border-color: var(--teal);
  outline: none;
}

.paste-zone strong {
  color: var(--ink);
  font-size: 18px;
}

.paste-zone span {
  font-size: 13px;
}

.file-inline {
  max-width: 260px;
}

.hidden-file {
  height: 1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.camera-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.camera-actions .btn {
  min-width: 108px;
}

.compact-input {
  flex: 1 1 220px;
}

.confirm-list {
  display: grid;
  gap: 10px;
}

.pending-task {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(140px, 1.2fr) 100px 120px 140px 120px;
  padding: 10px;
}

.pending-task .wide {
  grid-column: span 2;
}

.ocr-text {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #475569;
  font-size: 13px;
  margin-bottom: 10px;
  padding: 10px;
  white-space: pre-wrap;
}

.weekday-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.weekday-row label,
.check-line {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
}

.field-grid {
  color: #4b5563;
  display: grid;
  font-size: 13px;
  gap: 4px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.source-line {
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}

.subject-group {
  display: grid;
  gap: 8px;
}

.group-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 4px 2px 0;
}

.group-title h3 {
  font-size: 16px;
}

.group-title small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.group-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.canvas-wrap {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

#annotationCanvas {
  display: block;
  height: auto;
  max-height: 420px;
  max-width: 100%;
  touch-action: none;
  width: 100%;
}

.preview-img {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  max-height: 220px;
  max-width: 100%;
  object-fit: contain;
}

.report-row {
  align-items: stretch;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.metric-line + .metric-line {
  border-top: 1px solid var(--line);
}

.progress {
  background: #e8edf4;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress span {
  background: var(--teal);
  display: block;
  height: 100%;
}

.toast {
  background: #111827;
  border-radius: 8px;
  bottom: 90px;
  color: white;
  left: 50%;
  max-width: min(520px, calc(100vw - 32px));
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bottom-nav {
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: none;
  gap: 4px;
  left: 0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  position: fixed;
  right: 0;
  z-index: 10;
}

.bottom-nav .nav-btn {
  flex: 1 1 0;
  flex-direction: column;
  font-size: 12px;
  gap: 4px;
  justify-content: center;
  min-height: 54px;
  padding: 4px 2px;
  text-align: center;
}

.bottom-nav .nav-btn span {
  height: 24px;
  width: 24px;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .layout {
    display: block;
    padding: 0 12px 22px;
  }

  .side-nav {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  .topbar {
    align-items: flex-start;
    padding: 14px 12px 10px;
  }

  .brand-block h1 {
    font-size: 21px;
  }

  .brand-block p {
    max-width: 100%;
  }

  .mode-switch {
    flex: 0 0 auto;
  }

  .screen-head {
    align-items: stretch;
    display: grid;
  }

  .screen-title h2 {
    font-size: 22px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mistake-filter-grid,
  .mistake-summary {
    grid-template-columns: 1fr;
  }

  .two-col,
  .three-col,
  .form-grid,
  .report-row {
    grid-template-columns: 1fr;
  }

  .task-main {
    grid-template-columns: 1fr;
  }

  .point-event {
    grid-template-columns: 1fr;
  }

  .reward-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pending-task {
    grid-template-columns: 1fr;
  }

  .pending-task .wide {
    grid-column: auto;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .timer {
    min-width: 100%;
  }

  .band {
    padding: 14px;
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 8px;
  }

  .brand-mark {
    font-size: 12px;
    height: 46px;
    width: 46px;
  }

  .mode-btn {
    min-height: 32px;
    padding: 0 9px;
  }

  .actions .btn {
    flex: 1 1 auto;
  }

  .stat strong {
    font-size: 22px;
  }
}
