:root {
  --bg: #F3F6FB;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  --primary: #1D4ED8;
  --primary-soft: #DBEAFE;
  --success: #059669;
  --danger: #DC2626;
  --warning: #D97706;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 56px;
  --header-h: 48px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0B1220;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { border: 0; background: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* Desktop phone frame */
.phone-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
  background:
    radial-gradient(circle at 20% 10%, rgba(37, 99, 235, 0.25), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(5, 150, 105, 0.18), transparent 35%),
    #0B1220;
}

.phone {
  width: min(420px, 100%);
  height: min(860px, calc(100vh - 48px));
  background: var(--bg);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid rgba(255,255,255,.08);
}

@media (max-width: 480px) {
  .phone-shell { padding: 0; background: var(--bg); }
  .phone {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }
}

.app-header {
  min-height: var(--header-h);
  padding: 8px 14px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.app-header .back {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text);
  background: #F1F5F9;
  flex-shrink: 0;
}
.app-header .back svg {
  width: 20px;
  height: 20px;
  display: block;
}
.app-header .back:active {
  background: #E2E8F0;
}
.app-header .title-wrap { flex: 1; min-width: 0; }
.app-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.app-header .right-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.chip.ok { background: #DCFCE7; color: #166534; }
.chip.info { background: var(--primary-soft); color: var(--primary); }

.app-main {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
}
.app-main.no-tab { padding-bottom: calc(18px + var(--safe-bottom)); }

.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 20;
}
.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10px;
}
.tabbar button.active { color: var(--primary); font-weight: 700; }
.tabbar .ico { font-size: 18px; line-height: 1; }

.page { padding: 14px; animation: fade .22s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hero {
  background: linear-gradient(145deg, #1E3A8A 0%, #1D4ED8 55%, #0EA5E9 120%);
  color: #fff;
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -30px; top: -30px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.hero .eyebrow {
  font-size: 12px;
  opacity: .85;
  margin-bottom: 6px;
}
.hero h2 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.25;
  position: relative;
  z-index: 1;
}
.hero p {
  margin: 0;
  font-size: 13px;
  opacity: .9;
  line-height: 1.5;
  position: relative;
  z-index: 1;
  max-width: 92%;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.stat {
  background: rgba(255,255,255,.14);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  position: relative;
  z-index: 1;
}
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 11px; opacity: .85; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 10px;
}
.section-title h3 {
  margin: 0;
  font-size: 15px;
}
.section-title span {
  font-size: 12px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(226,232,240,.8);
  overflow: hidden;
}
.card + .card { margin-top: 10px; }

.assess-grid {
  display: grid;
  gap: 10px;
}
.assess-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  width: 100%;
}
.assess-card .badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
}
.assess-card h4 { margin: 0 0 4px; font-size: 15px; }
.assess-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.assess-card .meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
}

.child-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.child-item:last-child { border-bottom: 0; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.child-item .info { flex: 1; min-width: 0; }
.child-item .name {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  gap: 6px;
  align-items: center;
}
.child-item .name em {
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: #F1F5F9;
  padding: 2px 6px;
  border-radius: 6px;
}
.child-item .desc {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
.child-item .arrow { color: #CBD5E1; font-size: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #F1F5F9; color: var(--text); }
.btn-block { width: 100%; }
.btn-outline {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.detail-hero {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.detail-hero .row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.kv .cell {
  background: #F8FAFC;
  border-radius: 12px;
  padding: 10px;
}
.kv .cell label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.kv .cell b { font-size: 13px; }

/* Assessment page */
.progress-panel {
  background: var(--card);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.progress-panel .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}
.progress-panel .top strong { color: var(--text); }
.bar {
  height: 8px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2563EB, #38BDF8);
  border-radius: inherit;
  width: 0;
  transition: width .25s ease;
}

.domain-head {
  padding: 14px 14px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.domain-head h3 { margin: 0; font-size: 15px; }
.domain-head .level { font-size: 11px; color: var(--muted); }
.link {
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.item-card {
  background: var(--card);
  margin: 0 12px 10px;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--line);
}
.item-card .idx {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.item-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.35;
}
.item-card .desc {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.score-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.score-row button {
  border: 1px solid #BFDBFE;
  color: #1E40AF;
  background: #fff;
  border-radius: 8px;
  min-height: 40px;
  padding: 4px 2px;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 600;
}
.score-row button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.note-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.note-row input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  min-width: 0;
  color: var(--text);
}

.assess-footer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.assess-footer .btn { min-height: 44px; font-size: 13px; }
.btn-fail {
  border: 1px solid #FECACA;
  color: var(--danger);
  background: #fff;
  border-radius: 12px;
  font-weight: 700;
}
.btn-pass {
  border: 1px solid #BFDBFE;
  color: var(--primary);
  background: #fff;
  border-radius: 12px;
  font-weight: 700;
}

/* Report */
.report-summary {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.score-big {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 8px 0 4px;
}
.score-big b { font-size: 36px; color: var(--primary); line-height: 1; }
.score-big span { color: var(--muted); font-size: 13px; }

.bars { margin-top: 14px; display: grid; gap: 10px; }
.bars .row { display: grid; grid-template-columns: 84px 1fr 36px; gap: 8px; align-items: center; }
.bars .row label { font-size: 12px; color: var(--muted); }
.bars .row .track {
  height: 10px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
}
.bars .row .track i {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.bars .row em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.insight {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  font-size: 13px;
  line-height: 1.55;
  color: #92400E;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  background: rgba(15,23,42,.92);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 50;
  white-space: nowrap;
}
.toast.show { opacity: 1; bottom: 96px; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: none;
  align-items: flex-end;
  z-index: 60; /* 高于 tabbar(20) / toast(50)，避免挡住点击 */
}
.modal-mask.show { display: flex; }
.sheet {
  width: 100%;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  position: relative;
  z-index: 61;
  pointer-events: auto;
}
.sheet .actions button {
  pointer-events: auto;
  position: relative;
  z-index: 1;
}
.sheet h3 { margin: 0 0 8px; font-size: 16px; }
.sheet p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.sheet .actions { display: grid; gap: 8px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.field-full { grid-column: 1 / -1; }
.field span em { color: var(--danger); font-style: normal; }
.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  background: #F8FAFC;
  outline: none;
}
.field input:focus,
.field select:focus {
  border-color: #93C5FD;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.form-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #F1F5F9;
  color: var(--muted);
  font-weight: 600;
}
