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

:root {
  --ink: #1C1C1E;
  --ink-2: #6B6B70;
  --ink-3: #A1A1A6;
  --line: #E6E4DF;
  --line-2: #D6D3CC;
  --bg: #FFFFFF;
  --surface: #F7F5F1;
  --danger: #D64545;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; }

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

input, textarea {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

/* ---------- 家长端 ---------- */

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px 120px;
  min-height: 100vh;
}

.tophead {
  padding: 28px 0 6px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.tophead h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
}
.tophead .sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-2);
}

/* 家长端的「立即同步」小按钮 */.sync-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  transition: background .2s, color .2s;
}
.sync-btn:active { background: var(--line); }
.sync-btn.off { color: var(--ink-2); opacity: .8; }
.sync-btn.bad { color: var(--danger); }
.sync-btn.spin svg { animation: syncspin .9s linear infinite; }
@keyframes syncspin { to { transform: rotate(360deg); } }

.section {
  margin-top: 22px;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 2px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 6px 0;
  z-index: 2;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 0.5px solid var(--line);
  transition: background .15s;
}
.row:last-child { border-bottom: none; }
.row:active { background: var(--surface); }

.circle {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.6px solid var(--line-2);
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s, background .18s, border-color .18s;
}
.circle svg { width: 13px; height: 13px; opacity: 0; transition: opacity .18s; }
.circle.tap { transform: scale(1.18); }

.row.done .circle {
  background: #6B6B70;
  border-color: #6B6B70;
}
.row.done .circle svg { opacity: 1; }

.row-body { flex: 1; min-width: 0; }
.row-title {
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}
.row-detail {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 3px;
  line-height: 1.4;
  word-break: break-word;
}
.row.done .row-title,
.row.done .row-detail {
  color: var(--ink-3);
  text-decoration: line-through;
  text-decoration-color: var(--ink-3);
}

.pill {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--ink-2);
  background: var(--surface);
  border-radius: 20px;
  padding: 3px 9px;
  margin-top: 2px;
  white-space: nowrap;
}

.empty {
  text-align: center;
  padding: 80px 20px 40px;
  color: var(--ink-3);
}
.empty .big { font-size: 15px; color: var(--ink-2); margin-bottom: 6px; }
.empty .small { font-size: 13px; }

/* 悬浮输入条 */
.fabbar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(56px + var(--safe-b));
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 30;
}
.fab {
  pointer-events: auto;
  background: #FFFFFF;
  border: 0.5px solid var(--line-2);
  border-radius: 24px;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 4px 18px rgba(0,0,0,.09);
}
.fab:active { transform: scale(.97); }

/* 底部导航 */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(18px);
  border-top: 0.5px solid var(--line);
  padding-bottom: var(--safe-b);
  z-index: 31;
}
.tabbar button {
  flex: 1;
  padding: 11px 0 13px;
  font-size: 11px;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.tabbar button.on { color: var(--ink); font-weight: 500; }
.tabbar svg { width: 22px; height: 22px; }

/* ---------- Sheet ---------- */

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 50;
}
.sheet-mask.on { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #FFFFFF;
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
  z-index: 51;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  padding-bottom: var(--safe-b);
}
.sheet.on { transform: translateY(0); }
.sheet.tall { height: 90vh; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  flex: 0 0 auto;
}
.sheet-head .t { font-size: 16px; font-weight: 500; }
.sheet-head button { font-size: 15px; color: var(--ink-2); min-width: 48px; }
.sheet-head button.primary { color: var(--ink); font-weight: 500; text-align: right; }
.sheet-head button:disabled { color: var(--ink-3); }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 24px;
  -webkit-overflow-scrolling: touch;
}
.sheet-foot {
  flex: 0 0 auto;
  padding: 12px 20px calc(14px + var(--safe-b));
  border-top: 0.5px solid var(--line);
  display: flex;
  gap: 10px;
}

textarea.paste {
  width: 100%;
  min-height: 200px;
  font-size: 16px;
  line-height: 1.6;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  resize: none;
}
textarea.paste::placeholder { color: var(--ink-3); }

.hintline {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 10px;
  line-height: 1.5;
}

.btn {
  flex: 1;
  padding: 15px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  background: var(--surface);
  color: var(--ink);
}
.btn.primary { background: #1C1C1E; color: #FFF; }
.btn.primary:disabled { background: #D6D3CC; color: #FFF; }
.btn:active { opacity: .85; }

/* 确认卡 */
.rcard {
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  transition: opacity .18s, background .18s;
}
.rcard.off { opacity: .4; }

.rcard-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.rcard-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #1C1C1E;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.rcard.off .rcard-check { background: #D6D3CC; }
.rcard-check svg { width: 12px; height: 12px; }

.subj-tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.rcard-del {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-3);
  padding: 4px 6px;
}

.rcard input {
  width: 100%;
  font-size: 16px;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 0.5px solid var(--line);
}
.rcard input:focus { border-bottom-color: var(--ink-3); }
.rcard .detail-in {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 400;
  margin-top: 6px;
}

.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chip {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink-2);
}
.chip.on { background: #1C1C1E; color: #FFF; }

.skel {
  height: 84px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #F3F1EC 25%, #EAE7E1 37%, #F3F1EC 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease infinite;
  margin-bottom: 10px;
}
@keyframes sk { 0%{background-position:100% 0} 100%{background-position:0 0} }

.loading-tip {
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
  padding: 10px 0 18px;
}

/* ---------- 一周 ---------- */

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 18px;
  font-size: 14px;
  color: var(--ink-2);
}
.week-nav button { font-size: 20px; padding: 4px 12px; color: var(--ink-2); }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.wd {
  border-radius: 12px;
  padding: 10px 2px;
  text-align: center;
  background: var(--surface);
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.wd .d { font-size: 11px; color: var(--ink-3); }
.wd .n { font-size: 13px; font-weight: 500; }
.wd.full { background: #E1F5EE; }
.wd.full .n { color: #0F6E56; }
.wd.today { outline: 1.5px solid #1C1C1E; }
.wd.future .n { color: var(--ink-3); }

.stats { margin-top: 26px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 13px 0;
  border-bottom: 0.5px solid var(--line);
  font-size: 15px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .v { font-size: 15px; font-weight: 500; }
.stat-big {
  padding: 22px 0 6px;
}
.stat-big .num { font-size: 44px; font-weight: 600; letter-spacing: -1px; }
.stat-big .lbl { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

/* ---------- 设置 ---------- */

.set-group { margin-top: 26px; }
.set-group > .gl {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.set-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--line);
  font-size: 15px;
}
.set-item input[type="text"] {
  text-align: right;
  font-size: 15px;
  color: var(--ink-2);
  width: 160px;
}
.set-group .btn {
  display: block;
  width: 100%;
  margin-top: 10px;
}
.switch {
  width: 48px; height: 28px;
  border-radius: 20px;
  background: #D6D3CC;
  position: relative;
  transition: background .2s;
}
.switch.on { background: #34C759; }
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #FFF;
  transition: transform .2s;
}
.switch.on::after { transform: translateX(20px); }

.danger { color: var(--danger); }

.codebox {
  width: 100%;
  height: 130px;
  font-size: 11px;
  font-family: ui-monospace, Menlo, monospace;
  background: var(--surface);
  border-radius: 10px;
  padding: 10px;
  resize: none;
  margin-top: 8px;
  word-break: break-all;
}

/* ---------- 孩子端 ---------- */

.kid {
  min-height: 100vh;
  padding: 0 24px 30px;
  background: #FDFCFA;
}
.kid-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 12px;
}
.kid-date { font-size: 17px; color: var(--ink-2); }
.kid-count { font-size: 20px; font-weight: 600; }

/* 家庭码展示 */
.pair-code {
  margin: 10px 0 4px;
  padding: 14px 12px;
  border-radius: 10px;
  background: #F4F1EC;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: 1px;
  word-break: break-all;
  text-align: center;
  color: var(--ink);
  user-select: all;
  -webkit-user-select: all;
}
.pair-hint {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
  margin: 6px 0 14px;
}

/* 孩子端未连上手机时的提示条：只给家长看，孩子不会有兴趣点 */

.kid-conn {
  margin: -6px 0 14px;
  padding: 11px 16px;
  border-radius: 12px;
  background: #FFF3E0;
  color: #8A5200;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.kid-conn b { font-weight: 600; text-decoration: underline; }
.kid-conn[hidden] { display: none; }

/* 一次性提示：告诉家长长按日期能进设置，看过就不再出现 */
.kid-tip1 {
  margin: -8px 0 12px;
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}
.kid-tip1[hidden] { display: none; }

.kbar {
  height: 12px;
  border-radius: 8px;
  background: #EAE7E1;
  overflow: hidden;
  margin-bottom: 24px;
}
.kbar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, #5DCAA5, #378ADD);
  transition: width .45s cubic-bezier(.32,.72,0,1);
}

.kgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.kcard {
  border-radius: 22px;
  padding: 22px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform .18s, filter .3s, opacity .3s;
  user-select: none;
  -webkit-user-select: none;
}
.kcard:active { transform: scale(.97); }
.kcard.done { filter: grayscale(.75); opacity: .62; }
.kcard.done .ktitle { text-decoration: line-through; text-decoration-thickness: 1.5px; }

.ksubj {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 12px;
}
.ktitle {
  font-size: clamp(21px, 3.1vw, 30px);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.5px;
  flex: 1;
  word-break: break-word;
  /* 让标题在剩余空间里居中，短标题就不会堆在上半、下面空一大块 */
  display: grid;
  align-content: center;
}
.kdetail {
  font-size: 15px;
  margin-top: 10px;
  opacity: .75;
  line-height: 1.4;
}
.kcircle {
  position: absolute;
  top: 18px; right: 18px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: .32;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .25s, transform .25s;
}
.kcircle svg { width: 22px; height: 22px; opacity: 0; transition: opacity .2s; }
.kcard.done .kcircle { opacity: 1; }
.kcard.done .kcircle svg { opacity: 1; }

.klisten {
  width: 100%;
  margin-top: 28px;
  padding: 18px;
  border-radius: 18px;
  background: #FFFFFF;
  border: 0.5px solid var(--line);
  font-size: 17px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.kempty {
  text-align: center;
  padding: 120px 20px;
  color: var(--ink-2);
}
.kempty .t1 { font-size: 34px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.kempty .t2 { font-size: 17px; }

/* 庆祝层 */
.celebrate {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.96);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 90;
  gap: 18px;
}
.celebrate.on { display: flex; }
.celebrate .c1 { font-size: 46px; font-weight: 700; letter-spacing: -1px; }
.celebrate .c2 { font-size: 19px; color: var(--ink-2); }
.spark {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 3px;
  animation: fly 1.5s ease-out forwards;
}
@keyframes fly {
  0% { transform: translate(0,0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(360deg); opacity: 0; }
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(28,28,30,.92);
  color: #FFF;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 100;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 撤销确认层 */
.confirm-layer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 95;
  padding: 30px;
}
.confirm-layer.on { display: flex; }
.confirm-box {
  background: #FFF;
  border-radius: 22px;
  padding: 32px 26px 22px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}
.confirm-box .q { font-size: 21px; font-weight: 600; margin-bottom: 22px; }
.confirm-box button {
  width: 100%;
  padding: 18px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 10px;
}
.confirm-box .yes { background: #FCEBEB; color: #A32D2D; }
.confirm-box .no { background: var(--surface); }

/* ---------- 登录 / 同步 ---------- */

.auth-layer {
  position: fixed;
  inset: 0;
  background: rgba(250,249,246,.97);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 24px;
  overflow-y: auto;
}
.auth-layer.on { display: flex; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #FFF;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px 26px 22px;
  box-shadow: 0 18px 50px rgba(28,28,30,.07);
}
.auth-mark {
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.auth-card h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 10px;
  letter-spacing: -.01em;
}
.auth-card p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0 0 22px;
}

.auth-input {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 17px;
  letter-spacing: .02em;
  background: #FFF;
  margin-bottom: 10px;
}
.auth-input:focus { border-color: var(--ink); }

.auth-sent {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 10px;
}

.auth-resend {
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0 6px;
  display: block;
}
.auth-resend:disabled { color: var(--ink-3); text-decoration: none; }

.auth-err {
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
  line-height: 1.4;
  margin: 6px 0 10px;
}

.auth-btn {
  width: 100%;
  background: var(--ink);
  color: #FFF;
  border-radius: 14px;
  padding: 16px;
  font-size: 17px;
  font-weight: 500;
}
.auth-btn:disabled { opacity: .45; }

.auth-skip {
  width: 100%;
  padding: 16px 0 6px;
  font-size: 13px;
  color: var(--ink-3);
}

#syncAction {
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
