:root {
  color-scheme: light;
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #24233a;
  background: #dff4ff;
  --ink: #24233a;
  --muted: #696884;
  --purple: #6d5bff;
  --purple-dark: #5543e4;
  --pink: #ff73b6;
  --yellow: #ffd84d;
  --cyan: #59dded;
  --mint: #7fe5b5;
  --red: #ff6b6b;
  --cream: #fffaf2;
  --card: rgba(255, 255, 255, .95);
  --line: rgba(36, 35, 58, .12);
  --outline: 2px solid rgba(36, 35, 58, .12);
  --shadow: 0 8px 0 rgba(77, 66, 154, .08), 0 16px 32px rgba(64, 89, 125, .11);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 12%, rgba(255,255,255,.95) 0 42px, transparent 43px),
    radial-gradient(circle at 16% 15%, rgba(255,255,255,.72) 0 25px, transparent 26px),
    linear-gradient(180deg, #7edcf7 0 18%, #bcecff 41%, #f7fbff 76%, #fff9ec 100%);
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 4px solid rgba(109, 91, 255, .25); outline-offset: 2px; }

.sky-decor { position: fixed; z-index: 0; pointer-events: none; border-radius: 999px; filter: blur(.1px); }
.decor-a { width: 180px; height: 180px; right: -55px; top: 72px; background: rgba(255,216,77,.8); box-shadow: inset -15px -17px 0 rgba(255,164,67,.17); }
.decor-b { width: 88px; height: 88px; left: 3%; top: 44%; background: rgba(255,115,182,.54); transform: rotate(18deg); border-radius: 36px; }
.decor-c { width: 130px; height: 36px; right: 12%; bottom: 9%; background: rgba(126,229,181,.55); transform: rotate(-12deg); }

.app-shell { position: relative; z-index: 1; width: min(1120px, calc(100% - 24px)); margin: 0 auto; padding: 18px 0 54px; }
.splash-card, .auth-card, .game-card, .panel, .task-card, .summary-card, .notice-card {
  border: var(--outline);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.splash-card { width: min(480px, 100%); margin: 13vh auto 0; padding: 36px; text-align: center; }
.kicker { margin: 0 0 6px; color: var(--purple); font-size: .72rem; font-weight: 950; letter-spacing: .15em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 5vw, 4rem); line-height: .98; letter-spacing: -.05em; }
h2 { margin-bottom: 6px; font-size: clamp(1.2rem, 2vw, 1.6rem); letter-spacing: -.03em; }
h3 { margin-bottom: 6px; font-size: 1.08rem; }
.muted { color: var(--muted); }
.tiny { font-size: .8rem; line-height: 1.5; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* 蛋仔吉祥物 (Egg-shaped mascot) */
.mini-mascot, .mascot {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 52px;
  border: 2.5px solid #2c2a4b;
  border-radius: 47% 47% 44% 44%;
  background: linear-gradient(145deg, #ffec70, #ffb34c);
  box-shadow: inset -7px -7px 0 rgba(255, 128, 63, .18), 0 5px 0 rgba(64, 48, 97, .11);
  transform: rotate(-3deg);
  flex-shrink: 0;
}
.mini-mascot::before, .mini-mascot::after, .mascot::before, .mascot::after {
  content: "";
  position: absolute;
  top: 19px;
  width: 5px;
  height: 7px;
  border-radius: 50%;
  background: #2c2a4b;
}
.mini-mascot::before, .mascot::before { left: 16px; }
.mini-mascot::after, .mascot::after { right: 16px; }
.mini-mascot span::before, .mascot span::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 11px;
  width: 14px;
  height: 6px;
  border-bottom: 2.5px solid #2c2a4b;
  border-radius: 50%;
  transform: translateX(-50%);
}

/* 紧凑顶栏 (Compact Header) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  border: var(--outline);
  box-shadow: 0 4px 12px rgba(64, 89, 125, .06);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mascot { width: 42px; height: 38px; }
.brand-mascot::before, .brand-mascot::after { top: 14px; width: 4px; height: 5px; }
.brand-mascot::before { left: 12px; }
.brand-mascot::after { right: 12px; }
.brand-mascot span::before { bottom: 8px; width: 10px; height: 5px; border-bottom-width: 2px; }
.brand-title { margin: 0; font-size: 1.02rem; font-weight: 950; letter-spacing: -.02em; }
.brand-sub { margin: 1px 0 0; color: var(--muted); font-size: .72rem; }

.header-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.header-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 850;
  border: 1.5px solid rgba(36, 35, 58, .1);
}
.star-chip { background: #fffbe6; color: #8e6a00; border-color: #ffd84d; }
.time-chip { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }

.header-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 玩具糖果按键 */
.pill, .ghost-button, .primary-button, .danger-button, .soft-button, .task-button, .status-toggle {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 850;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.pill:hover, .ghost-button:hover, .primary-button:hover, .danger-button:hover, .soft-button:hover, .task-button:hover { transform: translateY(-1px); }
.primary-button { padding: 10px 18px; background: var(--purple); color: white; box-shadow: 0 4px 0 var(--purple-dark); }
.primary-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--purple-dark); }
.ghost-button { padding: 8px 14px; background: rgba(255,255,255,.9); border: 1.5px solid rgba(36,35,58,.15); font-size: .84rem; }
.soft-button { padding: 8px 14px; background: #eef0ff; color: #5346c7; font-size: .84rem; }
.danger-button { padding: 8px 14px; background: #fff0f0; color: #b9414d; font-size: .84rem; }
.btn-small { padding: 6px 12px; font-size: .8rem; border-radius: 999px; }

/* 贴纸徽章 (Sticker badges) */
.sticker-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 950;
  letter-spacing: .08em;
  padding: 3px 9px;
  border-radius: 8px;
  box-shadow: 0 2px 0 rgba(0,0,0,.08);
  margin-bottom: 4px;
}
.yellow-badge { background: #ffd84d; color: #6b5300; }
.purple-badge { background: #ded9ff; color: #4838b0; }
.mint-badge { background: #c5f7dc; color: #0f663c; }

/* 登录/设置页面 */
.auth-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr); gap: 20px; align-items: stretch; padding-top: 4vh; }
.auth-hero { position: relative; overflow: hidden; min-height: 440px; padding: 36px; border-radius: 30px; background: linear-gradient(145deg, rgba(109,91,255,.96), rgba(255,115,182,.9)); color: white; box-shadow: 0 12px 0 rgba(65,54,153,.14), 0 28px 50px rgba(69,71,132,.18); }
.auth-hero::after { content: ""; position: absolute; width: 180px; height: 180px; right: -40px; bottom: -30px; border-radius: 50%; background: rgba(255,216,77,.95); box-shadow: inset -15px -15px 0 rgba(255,166,43,.2); }
.auth-hero h1 { max-width: 600px; font-size: clamp(2.5rem, 6vw, 4.8rem); }
.auth-hero p { max-width: 480px; line-height: 1.6; color: rgba(255,255,255,.92); }
.auth-hero .mascot { position: absolute; right: 14%; bottom: 12%; width: 100px; height: 90px; z-index: 2; background: linear-gradient(145deg, #6cf0f1, #54bde9); transform: rotate(8deg); }
.auth-card { padding: 30px; align-self: center; }
.auth-card h2 { font-size: 1.5rem; }
.form-stack { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: .8rem; font-weight: 850; color: #4e4d68; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 2px solid rgba(36,35,58,.12);
  border-radius: 14px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
  font-size: .9rem;
}
.field textarea { min-height: 72px; resize: vertical; }
.role-tabs, .date-tabs { display: flex; gap: 6px; padding: 4px; border-radius: 999px; background: #f0f1fb; }
.role-tab, .date-tab { flex: 1; border: 0; border-radius: 999px; padding: 7px 12px; background: transparent; cursor: pointer; color: var(--muted); font-weight: 850; font-size: .84rem; }
.role-tab.active, .date-tab.active { background: white; color: var(--purple); box-shadow: 0 2px 7px rgba(73,62,149,.12); }
.form-error { margin: 2px 0 0; min-height: 1.2em; color: #b23b49; font-size: .82rem; font-weight: 700; }

/* 孩子端布局：首屏直击打卡 */
.child-main { display: grid; gap: 20px; }
.section-first { margin-top: 4px; }
.section { margin-top: 18px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.compact-head { align-items: center; }
.section-title-wrap h2 { margin: 0; }
.task-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

/* 任务卡片 (Task card) */
.task-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 180px;
  padding: 16px;
  overflow: hidden;
  border-radius: 20px;
  border: var(--outline);
  background: #fff;
  box-shadow: 0 5px 0 rgba(73,68,130,.06), 0 12px 20px rgba(54,77,108,.08);
  transition: transform .15s ease;
}
.task-card::after { content: ""; position: absolute; width: 64px; height: 64px; right: -18px; top: -18px; border-radius: 50%; background: var(--task-soft, #eef0ff); z-index: 0; }
.task-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; position: relative; z-index: 1; }
.task-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: var(--task-soft, #eef0ff); font-size: 1.4rem; transform: rotate(-2deg); }
.task-points-chip { font-size: .8rem; font-weight: 950; color: #5345c2; background: #f3f2ff; padding: 4px 8px; border-radius: 8px; }
.task-card h3 { margin: 0 0 5px; font-size: 1rem; position: relative; z-index: 1; }
.task-card p { flex: 1; margin-bottom: 10px; color: var(--muted); font-size: .8rem; line-height: 1.45; position: relative; z-index: 1; }
.task-button { width: 100%; padding: 9px 12px; background: var(--task-color, var(--purple)); color: white; box-shadow: 0 3px 0 color-mix(in srgb, var(--task-color, var(--purple)) 75%, #272044); font-size: .86rem; position: relative; z-index: 1; }
.task-button[disabled] { background: #ebeaf2; color: #8a899a; box-shadow: none; cursor: default; transform: none; }
.task-card.pending { border-color: #f7b731; }
.task-card.approved { border-color: #20bf6b; }
.status-chip { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; margin-bottom: 8px; padding: 4px 8px; border-radius: 999px; background: #f1efff; color: #5e50cb; font-size: .72rem; font-weight: 850; position: relative; z-index: 1; }
.bedtime-select { margin-bottom: 8px; border: 1.5px solid rgba(36,35,58,.15); border-radius: 10px; padding: 6px 8px; background: #fff; font-size: .84rem; position: relative; z-index: 1; }

/* 紧凑次级周进度条 */
.compact-progress-card {
  padding: 16px 20px;
  border-radius: 20px;
  border: var(--outline);
  background: linear-gradient(135deg, #ffffff, #f7f9ff);
  box-shadow: var(--shadow);
}
.progress-info-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 12px; }
.mini-score-tag { background: #fff4d1; color: #826300; padding: 6px 14px; border-radius: 12px; font-weight: 900; font-size: .95rem; border: 1.5px solid #ffe382; }
.progress-track-wrap { display: flex; align-items: center; gap: 14px; }
.progress-shell { flex: 1; height: 14px; border: 2.5px solid rgba(36,35,58,.18); border-radius: 99px; background: rgba(36,35,58,.06); overflow: hidden; }
.progress-shell span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffc048, #ffd84d); transition: width .25s ease; }
.progress-percent-label { font-size: .85rem; font-weight: 900; color: #4e4d68; min-width: 38px; text-align: right; }

/* 家长端紧凑顶栏状态卡 */
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compact-parent-hero .compact-hero { min-height: unset; padding: 18px; border-radius: 20px; }
.score-hero { background: linear-gradient(145deg, #755fff, #9970ff 48%, #ff79ba); color: white; border-color: rgba(255,255,255,.38); }
.score-number { display: flex; align-items: flex-end; gap: 6px; margin: 4px 0; }
.score-number strong { font-size: 3.2rem; line-height: .85; letter-spacing: -.06em; }
.score-number span { margin-bottom: 4px; font-size: 1.3rem; }
.boss-card { background: linear-gradient(145deg, #eefbff, #fff9e6); }

/* 行为规则配置表 (Parent Rules Table) */
.rules-table-container {
  overflow-x: auto;
  border: var(--outline);
  border-radius: 20px;
  background: white;
  box-shadow: var(--shadow);
}
.rules-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: .85rem;
}
.rules-table th {
  background: #f6f7fc;
  padding: 12px 14px;
  font-weight: 850;
  color: #55546e;
  border-bottom: 2px solid rgba(36, 35, 58, .1);
  white-space: nowrap;
}
.rules-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(36, 35, 58, .07);
  vertical-align: middle;
}
.rule-row:hover { background: #fafbff; }
.rule-disabled { opacity: .55; background: #fcfcfd; }

.col-order { width: 55px; text-align: center; }
.col-name { min-width: 170px; }
.col-type { width: 110px; }
.col-score { min-width: 120px; }
.col-freq { width: 100px; }
.col-enabled { width: 90px; text-align: center; }
.col-action { width: 75px; text-align: right; }

.type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 850;
  white-space: nowrap;
}
.badge-growth { background: #e0f2fe; color: #0369a1; }
.badge-training { background: #fef3c7; color: #b45309; }
.badge-weekly-challenge { background: #ede9fe; color: #6d28d9; }
.badge-responsibility { background: #fee2e2; color: #b91c1c; }
.badge-redline { background: #ffe4e6; color: #be123c; }

.freq-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  background: #f1f2f6;
  color: #57606f;
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-toggle {
  padding: 4px 10px;
  font-size: .74rem;
  border: 1px solid transparent;
}
.status-toggle.is-enabled { background: #dcfce7; color: #15803d; }
.status-toggle.is-disabled { background: #f3f4f6; color: #6b7280; }

/* 规则行内编辑表单 */
.rule-row-editing { background: #f7f6ff; }
.rule-edit-form { padding: 16px; }
.edit-form-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.form-actions { display: flex; gap: 8px; }
.edit-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.field-disabled { opacity: .45; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 850;
  cursor: pointer;
  padding: 10px 0;
}
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; }
.bedtime-editor-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 12px;
  border: 1.5px solid rgba(109,91,255,.2);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.bedtime-opt-row { display: flex; align-items: center; gap: 6px; font-size: .84rem; }
.input-tiny { width: 64px; padding: 5px 8px; border-radius: 8px; border: 1.5px solid rgba(36,35,58,.15); text-align: center; }

/* 通用列表与面板 */
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { padding: 18px; }
.compact-panel { padding: 14px 18px; }
.summary-row, .list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(36,35,58,.08); font-size: .86rem; }
.summary-row:last-child, .list-row:last-child { border-bottom: 0; }
.pending-list, .recent-list { display: grid; gap: 8px; margin-top: 10px; }
.pending-item, .recent-item { padding: 12px; border-radius: 16px; background: #f8f7ff; border: 1px solid rgba(36,35,58,.08); }
.pending-actions { display: flex; gap: 8px; margin-top: 8px; }
.pending-actions button { flex: 1; }
.notice-card { padding: 14px 16px; background: #fff7d7; }
.notice-card strong { color: #806700; }
.redline-card { background: linear-gradient(145deg, #fff3f5, #fff); }
.empty-state { padding: 16px; border-radius: 16px; background: #f7f7fb; color: var(--muted); text-align: center; font-size: .86rem; }

.parent-grid { display: grid; grid-template-columns: .82fr 1.18fr; gap: 14px; }
.quick-form { display: grid; gap: 10px; }
.parent-identity-card { background: linear-gradient(150deg, #fffef9, #f2f0ff 72%); }
.pin-settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-settings-grid .soft-button { grid-column: 1 / -1; justify-self: start; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(16px); padding: 10px 16px; border-radius: 999px; background: #25233c; color: white; font-weight: 800; font-size: .85rem; box-shadow: 0 8px 24px rgba(36,35,58,.25); opacity: 0; transition: .2s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #a93f4d; }

@media (max-width: 900px) {
  .auth-layout, .hero-grid, .parent-grid, .two-column { grid-template-columns: 1fr; }
  .task-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pin-settings-grid { grid-template-columns: 1fr; }
  .pin-settings-grid .soft-button { grid-column: auto; }
}

@media (max-width: 600px) {
  .app-shell { width: min(100% - 16px, 1120px); padding-top: 10px; }
  .app-header { border-radius: 20px; padding: 10px 12px; }
  .brand-title { font-size: .9rem; }
  .brand-mascot { width: 36px; height: 32px; }
  .header-actions { width: auto; margin-left: auto; }
  .header-actions .ghost-button { padding: 6px 10px; font-size: .76rem; }
  .header-chips { width: 100%; gap: 6px; }
  .header-chip { padding: 5px 9px; font-size: .74rem; }
  .section { margin-top: 14px; }
  .section-head { margin-bottom: 8px; }
  .task-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .task-card { min-height: 148px; padding: 11px; border-radius: 17px; }
  .task-card-header { margin-bottom: 7px; }
  .task-icon { width: 36px; height: 36px; border-radius: 12px; font-size: 1.2rem; }
  .task-card h3 { font-size: .9rem; line-height: 1.25; }
  .task-card p { margin-bottom: 7px; font-size: .72rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .task-button { padding: 7px 8px; font-size: .78rem; }
  .task-points-chip { font-size: .7rem; padding: 3px 6px; }
  .bedtime-select { padding: 5px 6px; font-size: .74rem; }
  .edit-fields-grid { grid-template-columns: 1fr; }
}
