:root {
  --brand-50:#e6f2ff; --brand-100:#cce5ff; --brand-500:#1e90ff;
  --brand-600:#1878d6; --brand-700:#1261ad;
  --ink-900:#0f1b2d; --ink-700:#33445c; --ink-500:#6b7a90;
  --ink-300:#a8b3c2; --ink-100:#e8edf3;
  --surface:#ffffff; --canvas:#f5f9ff;
  --danger:#ff4d4f; --success:#22c55e; --warning:#f59e0b;
  --r-sm:10px; --r-md:16px; --r-lg:24px; --r-full:999px;
  --sh-sm:0 1px 3px rgba(15,27,45,.06);
  --sh-md:0 8px 24px rgba(30,144,255,.12);
  --sh-lg:0 16px 48px rgba(30,144,255,.18);
  --font:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;
}
* { box-sizing: border-box; }
body { margin:0; font-family:var(--font); color:var(--ink-900); background:var(--canvas); -webkit-font-smoothing:antialiased; }
.btn { border:0; border-radius:var(--r-full); padding:12px 20px; font-size:15px; font-weight:600; cursor:pointer; transition:transform .12s ease,box-shadow .2s ease,background .2s ease; min-height:44px; }
.btn:active { transform:scale(.97); }
.btn-primary { background:var(--brand-500); color:#fff; box-shadow:var(--sh-md); }
.btn-primary:hover { background:var(--brand-600); }
.btn-block { width:100%; }
.auth-page { min-height:100vh; display:grid; place-items:center; background:radial-gradient(1200px 600px at 50% -10%,var(--brand-100),var(--canvas)); }
.auth-card { width:min(400px,92vw); background:var(--surface); border-radius:var(--r-lg); padding:32px; box-shadow:var(--sh-lg); }
.brand { text-align:center; margin-bottom:24px; }
.brand-logo { font-size:56px; line-height:1; }
.brand h1 { margin:12px 0 4px; font-size:24px; }
.brand-sub { margin:0; color:var(--ink-500); font-size:14px; }
.field { display:block; margin-bottom:16px; }
.field span { display:block; font-size:13px; color:var(--ink-700); margin-bottom:6px; }
.field input { width:100%; padding:12px 14px; border:1px solid var(--ink-100); border-radius:var(--r-sm); font-size:15px; font-family:inherit; background:var(--surface); outline:none; }
.field input:focus { border-color:var(--brand-500); box-shadow:0 0 0 3px var(--brand-50); }
.form-msg { min-height:20px; font-size:13px; color:var(--danger); }

/* 控制台 */
.topbar { display:flex; align-items:center; justify-content:space-between; padding:16px 24px; background:var(--surface); border-bottom:1px solid var(--ink-100); position:sticky; top:0; z-index:10; }
.topbar-brand { display:flex; align-items:center; gap:8px; font-weight:700; }
.topbar-logo { font-size:24px; }
.btn-ghost { background:transparent; color:var(--ink-700); }
.btn-sm { padding:8px 16px; font-size:14px; min-height:40px; }
.container { max-width:960px; margin:0 auto; padding:32px 24px; }
.section-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.section-head h2 { margin:0; font-size:20px; }
.child-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:16px; }
.child-card { background:var(--surface); border-radius:var(--r-md); padding:16px; box-shadow:var(--sh-sm); display:flex; flex-direction:column; gap:12px; }
.child-avatar { width:48px; height:48px; border-radius:var(--r-full); background:var(--brand-50); color:var(--brand-700); display:grid; place-items:center; font-weight:700; font-size:18px; }
.child-meta h3 { margin:0 0 4px; font-size:17px; }
.child-meta p { margin:0; color:var(--ink-500); font-size:13px; }
.empty-state { grid-column:1/-1; text-align:center; padding:48px; color:var(--ink-500); }
.muted { color:var(--ink-300); font-size:13px; }
.dialog { border:0; border-radius:var(--r-lg); padding:24px; width:min(440px,92vw); }
.dialog::backdrop { background:rgba(15,27,45,.4); }
.dialog-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
.field select, .field textarea { width:100%; padding:12px 14px; border:1px solid var(--ink-100); border-radius:var(--r-sm); font-size:15px; font-family:inherit; background:var(--surface); outline:none; }

/* 卡片底部布局调整 */
.card-action.flex-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.card-action.flex-row .btn-primary {
  flex: 1; /* 开始陪学按钮占满剩余空间 */
}
.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 77, 79, 0.3);
  padding: 0 16px;
  min-height: 44px;
  border-radius: 12px;
  font-size: 14px;
}
.btn-danger-outline:hover {
  background: rgba(255, 77, 79, 0.05);
  border-color: var(--danger);
}

/* ================= 控制台 Pro Max 最终版 ================= */
.dash-page { background: #f4f7fb; }
.topbar { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(12px); padding: 16px 32px; border-bottom: 1px solid rgba(0,0,0,0.04); }
.topbar-brand { font-size: 20px; font-weight: 900; color: var(--brand-600); letter-spacing: 1px; }

.container { max-width: 1040px; margin: 0 auto; padding: 40px 24px; }
.section-head h2 { font-size: 28px; margin-bottom: 8px; color: #111827; font-weight: 800; }
.section-head .muted { font-size: 14px; color: #6b7280; }

/* 网格与卡片 */
.child-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 24px; }
.child-card { 
  background: #ffffff; border-radius: 24px; padding: 28px; 
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04); 
  display: flex; flex-direction: column; 
  border: 1px solid #f1f5f9; 
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%; /* 保证高度撑满 */
}
.child-card:hover { transform: translateY(-6px); box-shadow: 0 20px 40px rgba(30, 144, 255, 0.08); border-color: #e2e8f0; }

.child-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; position: relative; }
.child-avatar { width: 56px; height: 56px; border-radius: 20px; background: linear-gradient(135deg, #e0f2fe, #bae6fd); color: #0284c7; display: grid; place-items: center; font-weight: 800; font-size: 24px; flex-shrink: 0; }
.child-meta { flex: 1; }
.child-meta h3 { font-size: 20px; margin: 0 0 6px 0; color: #0f172a; font-weight: 700; }
.tag { display: inline-block; padding: 4px 10px; background: #f0fdf4; color: #16a34a; border-radius: 8px; font-size: 12px; font-weight: 600; }
.edit-btn { position: absolute; right: 0; top: 0; background: none; border: none; font-size: 18px; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; padding: 4px; }
.edit-btn:hover { opacity: 1; }

/* 详情区 - 解决错位的关键 */
.child-details { 
  flex: 1; /* 占据剩余空间，把按钮推到底部 */
  display: flex; flex-direction: column; gap: 12px; 
  margin-bottom: 24px; 
}
.child-desc { 
  margin: 0; font-size: 14px; color: #475569; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; 
  overflow: hidden; text-overflow: ellipsis; /* 限制最多2行，超出显示省略号 */
  background: #f8fafc; padding: 12px 16px; border-radius: 12px;
}
.child-desc strong { color: #1e293b; font-weight: 700; margin-right: 4px; }

/* 底部按钮区 */
.card-action.flex-row { display: flex; gap: 12px; align-items: stretch; margin-top: auto; }
.card-action .btn-primary { border-radius: 14px; font-size: 15px; height: 48px; display: flex; align-items: center; justify-content: center; }
.btn-danger-outline { background: #fff1f2; color: #e11d48; border: none; padding: 0 20px; border-radius: 14px; font-weight: 600; font-size: 14px; cursor: pointer; transition: background 0.2s; }
.btn-danger-outline:hover { background: #ffe4e6; }
.btn-icon { border: none; background: none; cursor: pointer; padding: 0; }

/* 弹窗与表单 */
.dialog { border: none; border-radius: 24px; padding: 32px; width: min(480px, 92vw); box-shadow: 0 24px 60px rgba(0,0,0,0.15); }
.dialog::backdrop { background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); }
.dialog h3 { margin-top: 0; font-size: 24px; color: #0f172a; margin-bottom: 24px; }
.form-row { display: flex; gap: 16px; }
.field span { font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 8px; }
.field input, .field select, .field textarea { border-radius: 12px; border: 1.5px solid #e2e8f0; padding: 12px 16px; transition: border-color 0.2s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-500); box-shadow: 0 0 0 4px rgba(30,144,255,0.1); }

/* 手机端适配 */
@media (max-width: 768px) {
  .container { padding: 24px 16px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .section-head button { width: 100%; }
  .child-grid { grid-template-columns: 1fr; }
  .child-desc { -webkit-line-clamp: 3; } /* 手机端显示3行 */
  .form-row { flex-direction: column; gap: 0; }
}

/* ================= 语音教室 ================= */
.chat-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, var(--brand-50), #fff 60%);
}
.chat-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; background: transparent;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: #fff; box-shadow: var(--sh-sm);
  font-size: 20px; cursor: pointer; display: grid; place-items: center;
}
.chat-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--ink-700);
  background: #fff; padding: 8px 16px; border-radius: 20px; box-shadow: var(--sh-sm);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-300); }
.dot.loading { background: var(--warning); animation: blink 1s infinite; }
.dot.ok { background: var(--success); }
.dot.error { background: var(--danger); }
@keyframes blink { 50% { opacity: .4; } }

.chat-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
}
.ai-avatar {
  width: 140px; height: 140px; border-radius: 50%;
  background: #fff; box-shadow: 0 20px 40px rgba(30,144,255,0.15);
  display: grid; place-items: center; font-size: 70px; margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.ai-name { font-size: 28px; font-weight: 800; color: var(--ink-900); margin: 0 0 8px; }
.ai-state { font-size: 16px; color: var(--ink-500); margin: 0 0 48px; }

.mic-wrapper { position: relative; margin-bottom: 24px; }
.mic-btn {
  width: 100px; height: 100px; border-radius: 50%; border: none;
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  color: #fff; font-size: 40px; cursor: pointer;
  box-shadow: 0 12px 30px rgba(30,144,255,0.4);
  transition: transform 0.15s ease, background 0.2s ease;
  display: grid; place-items: center;
}
.mic-btn:active { transform: scale(0.92); }

.hint { font-size: 13px; color: var(--ink-300); }

.subtitle-panel {
  background: #fff; border-top-left-radius: 24px; border-top-right-radius: 24px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.03); padding: 20px 24px;
  height: 25vh; display: flex; flex-direction: column;
}
.subtitle-head { font-size: 13px; font-weight: 600; color: var(--ink-500); margin-bottom: 12px; }
.subtitle-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.subtitle-line { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-900); }
.subtitle-line.ai { color: var(--brand-700); font-weight: 500; }
.subtitle-empty { margin: auto; text-align: center; color: var(--ink-300); font-size: 14px; }

@media (max-width: 768px) {
  .ai-avatar { width: 120px; height: 120px; font-size: 60px; }
  .ai-name { font-size: 24px; }
  .mic-btn { width: 88px; height: 88px; font-size: 36px; }
}

/* 登录注册底部链接 */
.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-500);
}
.auth-footer a {
  color: var(--brand-500);
  text-decoration: none;
  font-weight: 600;
}
.auth-footer a:hover {
  text-decoration: underline;
}

/* 文字输入区样式 */
.input-area {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--ink-100);
}
.input-area input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--ink-100);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  background: #f8fafc;
}
.input-area input:focus {
  border-color: var(--brand-500);
  background: #fff;
}
