/* ============================================================
   作业小管家 · 样式
   ============================================================ */

:root {
  --bg: #F6F4EF;
  --card: #FFFFFF;
  --ink: #1F2933;
  --ink-2: #5C6672;
  --ink-3: #98A2AE;
  --line: #EAE6DD;
  --line-strong: #DDD8CB;

  --primary: #E8654A;
  --primary-deep: #D4523B;
  --primary-tint: #FDEEE9;
  --ok: #2E9E6E;
  --ok-tint: #E9F6F0;
  --weekend: #7C5CE0;
  --weekend-tint: #F0EBFC;
  --routine: #0E8F84;
  --routine-tint: #E5F5F3;
  --warn-bg: #FBF3E4;
  --warn-ink: #9A6B15;
  --danger: #D5493C;
  --danger-tint: #FBEDEA;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(31, 41, 51, .04), 0 4px 16px rgba(31, 41, 51, .06);
  --shadow-lg: 0 12px 48px rgba(23, 28, 36, .22);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[v-cloak] { display: none; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  cursor: pointer;
}
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
input, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #FCFBF8;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232, 101, 74, .13);
}
textarea { resize: vertical; min-height: 88px; }
select {
  padding: 10px 10px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #FCFBF8;
  outline: none;
}

/* ---------- 图标 ---------- */
.ic {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.ic.xs { width: .85em; height: .85em; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(246, 244, 239, .86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
}
.logo { width: 30px; height: 30px; border-radius: 8px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(31, 41, 51, .06); color: var(--ink); }
.icon-btn.subtle { color: var(--ink-3); }
.icon-btn.subtle:hover { color: var(--danger); background: var(--danger-tint); }

/* ---------- 布局 ---------- */
.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 110px;
}
.panel { margin-top: 4px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.date-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .2px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 孩子切换 ---------- */
.student-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 14px;
  scrollbar-width: none;
}
.student-bar::-webkit-scrollbar { display: none; }
.student-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px 7px 8px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .12s, background .15s, color .15s, border-color .15s;
}
.student-chip:active { transform: scale(.96); }
.student-chip.active {
  background: #23272F;
  border-color: #23272F;
  color: #fff;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.add-chip {
  padding: 8px 13px;
  border-style: dashed;
  color: var(--ink-3);
  background: transparent;
}

.no-student {
  text-align: center;
  padding: 44px 20px;
}
.no-student p { color: var(--ink-2); margin: 0 0 14px; }

/* ---------- 视图切换 / 进度 ---------- */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #EFECE3;
  border-radius: 13px;
}
.seg button {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  transition: color .15s, background .15s;
}
.seg button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(31, 41, 51, .1);
}
.seg.tabs { font-size: 0; }
.seg.tabs button { font-size: 14px; padding: 8px 16px; }

.progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 2px 14px;
}
.progress-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #E9E4D9;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4FBF8B, var(--ok));
  transition: width .3s ease;
}
.progress-text {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ---------- 任务列表 ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }

/* 分组 */
.task-group { margin: 2px 0 4px; }
.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px 8px 2px;
}
.group-head.collapsible { cursor: pointer; user-select: none; }
.group-head.collapsible:active .group-title { opacity: .7; }
.group-dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }
.group-done-ic {
  width: 16px;
  height: 16px;
  color: var(--ok);
  stroke-width: 2.5;
  flex: none;
}
.group-title { font-size: 14px; font-weight: 700; }
.group-count { font-size: 12px; color: var(--ink-3); }
.group-head .chev {
  margin-left: auto;
  color: var(--ink-3);
  transition: transform .15s;
}
.group-head .chev.closed { transform: rotate(-90deg); }
.group-body { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: opacity .2s;
}
.task-card.done { opacity: .62; }

.check {
  width: 27px;
  height: 27px;
  margin-top: 1px;
  border: 2px solid #C6CCD4;
  border-radius: 999px;
  background: transparent;
  color: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  flex: none;
  transition: background .15s, border-color .15s, color .15s;
}
.check .ic { width: 15px; height: 15px; stroke-width: 3; }
.check:hover { border-color: var(--ok); color: #D9EBE2; }
.task-card.done .check {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-content { font-size: 15px; font-weight: 500; word-break: break-word; }
.task-card.done .task-content { text-decoration: line-through; color: var(--ink-3); }
.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.subj { border: 1px solid transparent; }
.pill.routine { color: var(--routine); background: var(--routine-tint); }
.pill.due.today { color: var(--primary); background: var(--primary-tint); }
.pill.due.weekend { color: var(--weekend); background: var(--weekend-tint); }
.pill.date { color: var(--ink-3); background: #F1EEE7; }

/* ---------- 空状态 / 骨架 ---------- */
.empty {
  text-align: center;
  padding: 34px 20px 20px;
  color: var(--ink-2);
}
.empty p { margin: 10px 0 16px; }
.empty.small { padding: 18px; }
.empty-art { width: 118px; height: 118px; }

.skel-list { display: flex; flex-direction: column; gap: 10px; }
.skel-card {
  height: 74px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #EFECE4 40%, #F7F5F0 50%, #EFECE4 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #F2814F, #E4573F);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 6px 22px rgba(228, 87, 63, .42);
  transition: transform .12s, box-shadow .15s;
}
.fab:hover { box-shadow: 0 8px 26px rgba(228, 87, 63, .5); }
.fab:active { transform: scale(.95); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, transform .12s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); }
.btn-ghost { background: #F0EDE5; color: var(--ink-2); }
.btn-ghost:hover { background: #E8E4DA; color: var(--ink); }
.btn-danger-ghost { background: var(--danger-tint); color: var(--danger); }
.btn-danger-ghost:hover { background: #F6DDD8; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 20px; font-size: 15px; }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.add-row { margin-top: 4px; }

/* ---------- 抽屉 / 弹层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(24, 28, 34, .46);
  animation: fadeIn .18s ease;
}
.sheet {
  width: 100%;
  max-height: 88dvh;
  overflow-y: auto;
  background: #FDFCFA;
  border-radius: 22px 22px 0 0;
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease;
}
.sheet.small { max-width: 100%; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}
.sheet-actions .btn { flex: 1; padding: 12px; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } }

@media (min-width: 720px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet {
    max-width: 540px;
    border-radius: 22px;
    padding-bottom: 24px;
  }
  .sheet.small { max-width: 460px; }
}

/* ---------- 表单域 ---------- */
.field { margin-bottom: 15px; }
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.field-row { display: flex; gap: 14px; }
.field-row > .field { flex: 1; min-width: 0; }

.hint { font-size: 12px; color: var(--ink-3); margin: 9px 2px 0; }
.hint.center { text-align: center; }
.hint.top { margin: 0 2px 12px; font-size: 13px; color: var(--ink-2); }
.hint b { color: var(--ink); }

.notice {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.info { background: var(--routine-tint); color: var(--routine); }

/* 学生选择 chips */
.student-select { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px 8px 10px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.mini-chip.active { border-color: var(--primary); background: var(--primary-tint); }
.mini-chip .dot { width: 10px; height: 10px; border-radius: 999px; }

/* 图片选择 */
.img-picker { display: flex; gap: 10px; }
.pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: #F6F4EE;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.pick-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-tint); }
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: rgba(23, 28, 36, .62);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
}

/* 条目编辑 */
.row-item { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.row-item input { flex: 1; }

/* ---------- 分析中 ---------- */
.sheet-body.center { text-align: center; padding: 46px 20px; }
.spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 16px;
  border-radius: 999px;
  border: 3.5px solid var(--primary-tint);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.analyzing-text { font-weight: 600; margin: 0 0 4px; }

.ai-badge {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--ok-tint);
  color: var(--ok);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}
.ai-notes { font-weight: 400; color: var(--ink-2); }

/* ---------- 管理 ---------- */
.add-bar { display: flex; gap: 10px; margin-bottom: 10px; }
.add-bar input { flex: 1; min-width: 0; }
.sel-subject { width: 118px; flex: none; }
.manage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.manage-row input { flex: 1; min-width: 0; }
.color-dot {
  width: 28px;
  height: 28px;
  flex: none;
  border: none;
  border-radius: 999px;
  padding: 0;
  box-shadow: inset 0 0 0 2.5px rgba(255, 255, 255, .8), 0 1px 4px rgba(31, 41, 51, .2);
}

/* 开关 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #D6D1C6;
  transition: background .15s;
  pointer-events: none;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform .15s;
  box-shadow: 0 1px 3px rgba(31, 41, 51, .25);
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- AI 记录 ---------- */
.sub-item {
  border-bottom: 1px solid var(--line);
}
.sub-item > details > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 2px;
  cursor: pointer;
  list-style: none;
}
.sub-item > details > summary::-webkit-details-marker { display: none; }
.sub-item > details[open] > summary { border-bottom: 1px dashed var(--line); }
.sub-status.ok { color: var(--ok); background: var(--ok-tint); }
.sub-status.bad { color: var(--danger); background: var(--danger-tint); }
.sub-type {
  font-size: 12px;
  color: var(--ink-2);
  background: #F1EEE7;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.sub-time { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.sub-body { padding: 10px 2px 12px; }
.sub-line { font-size: 13px; color: var(--ink-2); margin: 4px 0; word-break: break-word; }
.sub-line b { color: var(--ink); }
.sub-err { color: var(--danger); }
.sub-tasks {
  margin: 6px 0;
  padding-left: 20px;
  font-size: 13.5px;
  color: var(--ink);
}
.sub-tasks li { margin: 3px 0; }
.thumbs.tiny {
  display: flex;
  gap: 8px;
  margin: 6px 0;
}
.thumbs.tiny img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.raw-details { margin-top: 8px; }
.raw-details > summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  list-style: none;
}
.raw-details > summary::-webkit-details-marker { display: none; }
.raw-details > summary:hover { color: var(--ink-2); }
.raw-details pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #F4F2EC;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ink-2);
  max-height: 260px;
  overflow-y: auto;
}

/* ---------- 登录 ---------- */
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 330px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px 28px;
  text-align: center;
}
.login-logo { width: 52px; height: 52px; border-radius: 13px; }
.login-card h1 { font-size: 20px; margin: 14px 0 4px; }
.login-tip { color: var(--ink-3); font-size: 13px; margin: 0 0 18px; }
.login-card input { margin-bottom: 12px; text-align: center; }
.login-err { color: var(--danger); font-size: 13px; margin: 0 0 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  background: rgba(30, 35, 43, .92);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  max-width: 86vw;
  animation: toastIn .2s ease;
  box-shadow: 0 6px 24px rgba(23, 28, 36, .3);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
}

/* ---------- 桌面微调 ---------- */
@media (min-width: 720px) {
  .topbar { padding: 14px 26px; }
  .wrap { padding-top: 22px; }
  .fab { right: calc(50% - 336px); }
}
