:root {
  --bg: #F6F3EE;
  --card: #FFFFFF;
  --ink: #2E2A26;
  --ink-2: #6E655C;
  --ink-3: #9C938A;
  --line: #EAE3DA;
  --accent: #E07A3F;
  --accent-soft: #FDF1E7;
  --green: #3F8F55;
  --green-soft: #EDF7EF;
  --amber: #B4802A;
  --amber-soft: #FBF3E3;
  --gray-soft: #F1EEE9;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(46, 42, 38, .04), 0 8px 24px rgba(46, 42, 38, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------- 登录 */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, #FDEEE0 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, #EAF3EA 0%, transparent 45%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 22px;
  padding: 36px 28px 30px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.login-card h1 {
  font-size: 21px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: .3px;
}

.login-card .sub {
  color: var(--ink-3);
  font-size: 13px;
  margin: 0 0 26px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 7px;
  letter-spacing: .5px;
}

.field input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  font-size: 16px;
  background: #FCFAF7;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, background .15s;
}

.field input:focus {
  border-color: var(--accent);
  background: #fff;
}

.btn {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity .15s;
}

.btn:active { opacity: .85; }
.btn[disabled] { opacity: .55; cursor: default; }

.hint {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
  min-height: 18px;
}

.hint.error { color: #C0522F; }

/* ---------------------------------------------------------- 主界面 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(246, 243, 238, .92);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px 0;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 17px;
  flex: 0 0 auto;
}

.who { flex: 1; min-width: 0; }
.who .name { font-size: 16px; font-weight: 600; }
.who .meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 12.5px;
  border-radius: 9px;
  padding: 7px 12px;
  cursor: pointer;
}

.datestrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 12px;
  scrollbar-width: none;
}
.datestrip::-webkit-scrollbar { display: none; }

.dchip {
  flex: 0 0 auto;
  min-width: 66px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: all .15s;
}
.dchip .d { font-size: 12.5px; color: var(--ink-2); }
.dchip .w { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.dchip.on {
  background: var(--accent);
  border-color: var(--accent);
}
.dchip.on .d, .dchip.on .w { color: #fff; }

main { padding: 18px 14px 60px; max-width: 680px; margin: 0 auto; }

.section { margin-bottom: 22px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 10px;
}
.section-head .t { font-size: 14.5px; font-weight: 600; }
.section-head .c { font-size: 12px; color: var(--ink-3); }

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

/* 照片墙 */

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.gallery figure {
  position: relative;
  margin: 0;
  aspect-ratio: 1 / 1;
  border-radius: 11px;
  overflow: hidden;
  background: var(--gray-soft);
  cursor: zoom-in;
  touch-action: manipulation;
  transition: transform .12s ease-out, opacity .12s;
}

/* 手指按下去立刻有反馈，不会觉得"点了没反应" */
.gallery figure:active { transform: scale(.96); opacity: .78; }


.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery figure.narrow img { object-fit: contain; background: #EDE8E1; }

/* 照片是"滚到眼前才开始加载"的，所以先给一个呼吸感的占位，
   让家长知道这块正在来，而不是空白或坏掉 */
.gallery figure:not(.ok):not(.broken)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, var(--gray-soft) 30%, #F1ECE5 50%, var(--gray-soft) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .gallery figure:not(.ok):not(.broken)::after { animation: none; }
}

.videos { display: grid; gap: 10px; }

/* 视频卡片：默认只有封面+播放键，点一下才真正开始加载并播放 */
.vcard {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(255,255,255,.14) 0%, transparent 62%),
    linear-gradient(150deg, #4A423B 0%, #2A2521 60%, #201C19 100%);
  cursor: pointer;
}

.vcard video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.vplay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 12.5px;
  letter-spacing: .5px;
}

.vicon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .34);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px;
  transition: transform .15s, background .15s;
}

.vcard:active .vicon { transform: scale(.93); background: rgba(255,255,255,.26); }

.vtxt { color: rgba(255,255,255,.82); }

.vcard.playing .vplay { display: none; }

/* 视频卡片右下角的下载键：不用先进全屏再找下载 */
.vdl {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(20, 17, 15, .58);
  border: 1px solid rgba(255, 255, 255, .28);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 12px;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
}

.vdl svg { display: block; }
.vdl:active { background: rgba(20, 17, 15, .78); }
.vcard.playing .vdl { display: none; }

/* 微信里下载必然要跳浏览器，提前说明，免得家长以为页面坏了 */
.wx-tip {
  margin-top: 9px;
  padding: 8px 11px;
  border-radius: 9px;
  background: #FDF3EA;
  border: 1px solid #F3E0CE;
  color: #8A6440;
  font-size: 11.5px;
  line-height: 1.6;
}

/* 照片加载不出来（如 HEIC）时的兜底 */
.gallery figure.broken {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-3);
  font-size: 11.5px;
  line-height: 1.5;
  padding: 6px;
}
.gallery figure.broken .ph small { display: block; color: var(--accent); margin-top: 3px; }

/* 文档（PDF）卡片 */

.docs { display: grid; gap: 10px; }

.doc {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 13px;
  box-shadow: var(--shadow);
}

.doc-ico {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }

.doc-acts { flex: 0 0 auto; display: flex; gap: 7px; align-items: center; }

.btn-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 12.5px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn-mini.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-mini:active { opacity: .8; }
.btn-mini[disabled] { opacity: .55; }

/* 家长嘱托 */

.note-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow);
}

.note-text {
  font-size: 14px;
  color: #453F39;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.note-hint { font-size: 11.5px; color: var(--ink-3); flex: 1; min-width: 0; }
.note-hint.error { color: #C0522F; }
.note-hint.ok { color: var(--green); }

.note-card textarea {
  width: 100%;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #FCFAF7;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.7;
  padding: 11px 13px;
  outline: none;
  resize: vertical;
}
.note-card textarea:focus { border-color: var(--accent); background: #fff; }

.lb-name {
  flex: 1;
  min-width: 0;
  margin: 0 10px;
  font-size: 12.5px;
  color: #B7AEA5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-bar-r { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.lb-btn {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #F3EEE8;
  font-size: 12.5px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.lb-btn:active { background: rgba(255, 255, 255, .26); }

/* PDF 查看器：页面按宽度铺满，上下滚动看全页 */
.pdf-stage {
  overflow-y: auto;
  overflow-x: hidden;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}

.pdf-stage img {
  width: 100%;
  max-width: 900px;
  height: auto;
  margin: 0 auto;
  display: block;
  background: #fff;
  border-radius: 6px;
}

.pdf-stage .lb-nav { position: fixed; top: 50%; }


/* 饮食 */

.meal {
  border-top: 1px solid var(--line);
  padding-top: 13px;
  margin-top: 13px;
}
.meal:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

.meal-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.meal-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.dish {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.dish .nm { flex: 1; min-width: 0; font-size: 14px; }

.tag {
  flex: 0 0 auto;
  font-size: 11.5px;
  border-radius: 7px;
  padding: 3px 8px;
  white-space: nowrap;
}
.tag.good { background: var(--green-soft); color: var(--green); }
.tag.mid  { background: var(--amber-soft); color: var(--amber); }
.tag.none { background: var(--gray-soft);  color: var(--ink-3); }

.dish .note { font-size: 12px; color: var(--ink-3); }

/* 教学内容 */

.teaching {
  white-space: pre-wrap;
  font-size: 14px;
  color: #453F39;
  line-height: 1.85;
}

/* 生活记录 */

.life-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.life-item {
  background: #FCFAF7;
  border-radius: 11px;
  padding: 10px 12px;
}
.life-item .k { font-size: 11.5px; color: var(--ink-3); }
.life-item .v { font-size: 14px; margin-top: 2px; }

/* 空态 / 骨架 */

.state {
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px;
  padding: 40px 20px;
}

/* 灯箱 */

.lightbox {
  position: fixed;
  inset: 0;
  background: #14110F;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  color: #EDE8E1;
  font-size: 13px;
  flex: 0 0 auto;
}

.lb-close {
  background: rgba(255,255,255,.12);
  border: 0;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
  line-height: 1;
}

.lb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: filter .35s ease-out, transform .35s ease-out;
}

/* 高清图没到位之前一直保持明显模糊 —— 关键：家长长按保存拿到的是
   屏幕上「当前显示的那张」，所以绝不能让过渡用的压缩图看起来像成品，
   否则家长会在这一两秒里长按、只存到压缩版本。
   注意只作用于灯箱照片（#lbImg）。PDF 预览页不加 .ready，不能用 img 通配，
   否则 PDF 每一页都会被糊掉。 */
#lbImg:not(.ready) {
  filter: blur(18px) saturate(1.08);
  transform: scale(1.05);
}

/* 照片还糊着的时候，屏幕正中给一条明确的"还不能存"提示 */
.lb-wait {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(20, 17, 15, .74);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  z-index: 3;
}

#lbImg:not(.ready) ~ .lb-wait { opacity: 1; }

.lb-spin {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(20, 17, 15, .62);
  backdrop-filter: blur(6px);
  color: #EFEAE4;
  font-size: 12px;
  pointer-events: none;
  transition: opacity .2s;
}

.lb-spin.off { opacity: 0; }

.spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .28);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}

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


.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.lb-nav.prev { left: 10px; }
.lb-nav.next { right: 10px; }

.lb-tip {
  text-align: center;
  color: #9A9188;
  font-size: 11.5px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  flex: 0 0 auto;
  line-height: 1.5;
  transition: color .2s;
}

/* 高清图没就绪：橙色警示，别急着长按 */
.lb-tip.live { color: #FFC98A; font-size: 12.5px; font-weight: 500; }

/* 高清图已就绪：绿色，可以长按保存了 */
.lb-tip.ok { color: #6FDDA0; font-size: 13px; font-weight: 600; }

@media (min-width: 560px) {
  .gallery { grid-template-columns: repeat(4, 1fr); }
}
