/* ============ Sitree 儿童静坐 · 可爱 pastel 风格 ============ */

:root {
  --green: #7bc96f;
  --green-dark: #5aa64f;
  --pink: #ffb6c1;
  --yellow: #ffd93d;
  --blue: #a8d8ea;
  --purple: #d5b8f0;
  --cream: #fff9ec;
  --text: #5a4a42;
  --danger: #ff8a80;
  --danger-dark: #e5635a;
  --radius: 24px;
  --shadow: 0 6px 18px rgba(120, 90, 60, 0.12);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Comic Sans MS", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #fff6e0 0%, #e8f7ef 55%, #e3f2fd 100%);
  font-size: 17px;
}

.hidden { display: none !important; }

.view { min-height: 100vh; min-height: 100dvh; }

h1, h2, h3 { margin: 0.4em 0; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; color: #8a7568; }

button { font-family: inherit; cursor: pointer; }
input, select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  border: 2px solid #eadfce;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fffdf7;
  outline: none;
  width: 100%;
}
input:focus, select:focus { border-color: var(--green); }

.hint { font-size: 0.85rem; color: #a08d7d; }
.error-text { color: var(--danger-dark); font-size: 0.95rem; text-align: center; }

/* ---------- 通用按钮 ---------- */
.btn {
  border: none;
  border-radius: 16px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: bold;
  background: #f2ead9;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { filter: brightness(0.92); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-big { font-size: 1.15rem; padding: 15px 26px; border-radius: 20px; }

/* ---------- 登录 / 注册 ---------- */
#view-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  background: var(--cream);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.logo { font-size: 56px; }
.app-title { color: var(--green-dark); font-size: 2rem; margin: 0; }
.subtitle { color: #a08d7d; margin-top: 4px; }
.tabs {
  display: flex;
  gap: 8px;
  background: #f2ead9;
  border-radius: 16px;
  padding: 6px;
  margin: 18px 0;
}
.tab {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 10px;
  font-size: 1.05rem;
  font-weight: bold;
  background: transparent;
  color: #a08d7d;
}
.tab.active { background: #fff; color: var(--green-dark); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .hint { margin: 0; text-align: left; }

/* ---------- 首页 ---------- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card {
  background: var(--cream);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.home-header { display: flex; align-items: center; gap: 14px; }
.user-meta { flex: 1; min-width: 0; }
.btn-settings-entry {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  font-size: 26px;
  background: #f2ead9;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, background 0.2s ease;
}
.btn-settings-entry:hover { background: #ead9bd; transform: rotate(30deg); }
.btn-settings-entry:active { transform: scale(0.92); }

/* 设置页头部 */
.settings-header { display: flex; align-items: center; gap: 14px; }
.settings-title { margin: 0; }
.btn-back { padding: 10px 18px; }
.avatar {
  font-size: 34px;
  background: var(--blue);
  border-radius: 50%;
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nickname-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nickname { font-size: 1.3rem; font-weight: bold; }
.level-badge {
  background: linear-gradient(135deg, var(--yellow), #ffb700);
  color: #7a5b00;
  font-weight: bold;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.95rem;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.ach-item {
  background: #fff;
  border-radius: 18px;
  padding: 12px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: inset 0 0 0 2px #f3ecdd;
}
.ach-emoji { font-size: 30px; }
.ach-name { font-size: 0.85rem; color: #8a7568; }
.ach-item b { font-size: 1.2rem; color: var(--green-dark); }
.total-line { margin: 12px 0 0; color: #8a7568; }
.total-line b { color: var(--green-dark); }

/* 时长选择 */
.dur-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.dur-btn {
  border: 2px solid #eadfce;
  background: #fffdf7;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
  transition: all 0.15s ease;
}
.dur-btn.active { background: var(--green); border-color: var(--green); color: #fff; }

/* 动画选择 */
.anim-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.anim-card {
  border: 2px solid #eadfce;
  background: #fffdf7;
  border-radius: 18px;
  padding: 14px 8px;
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.anim-card .anim-emoji { font-size: 34px; }
.anim-card.active { border-color: var(--green); background: #eef8ea; box-shadow: var(--shadow); }

#music-select { margin-bottom: 6px; }

/* 大圆形开始按钮 */
.btn-start {
  display: block;
  margin: 22px auto 4px;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #9fe394, var(--green) 65%, var(--green-dark));
  color: #fff;
  font-size: 1.5rem;
  font-weight: bold;
  box-shadow: 0 10px 24px rgba(90, 166, 79, 0.4);
  transition: transform 0.15s ease;
  animation: breathe-btn 2.6s ease-in-out infinite;
}
.btn-start:active { transform: scale(0.94); }
@keyframes breathe-btn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* 历史记录 */
.record-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.record-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fffdf7;
  border-radius: 14px;
  padding: 10px 14px;
  flex-wrap: wrap;
  font-size: 0.95rem;
}
.record-item .r-time { color: #a08d7d; font-size: 0.85rem; }
.record-item .r-status-ok { color: var(--green-dark); font-weight: bold; }
.record-item .r-status-fail { color: #c98a80; }

/* 设置 */
.inline-form { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 140px; }

/* 管理面板 */
.table-wrap { overflow-x: auto; }
#admin-users { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
#admin-users th, #admin-users td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid #f0e7d6;
  white-space: nowrap;
}
#admin-users th { color: #8a7568; background: #f8f2e4; }
.invite-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.invite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fffdf7;
  border-radius: 14px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.invite-code { font-family: "Courier New", monospace; font-weight: bold; font-size: 1.1rem; letter-spacing: 2px; }
.invite-used { color: #c98a80; font-size: 0.85rem; }
.invite-fresh { color: var(--green-dark); font-size: 0.85rem; font-weight: bold; }

/* ---------- 静坐视图 ---------- */
#view-meditate {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #dff3ff 0%, #fdf6e3 70%, #e9f7e3 100%);
  overflow: hidden;
}
.btn-stop {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  z-index: 10;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.85);
  color: #b0836f;
  box-shadow: var(--shadow);
}

/* 阶段一：深呼吸 */
.breath-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 46px;
}
.breath-circle {
  width: clamp(150px, 34vmin, 300px);
  height: clamp(150px, 34vmin, 300px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #bdecb4, var(--green) 70%);
  box-shadow: 0 0 60px rgba(123, 201, 111, 0.45);
  transform: scale(0.85);
  transition: transform 4s ease-in-out;
}
.breath-circle.inhale { transform: scale(1.35); }
.breath-circle.exhale { transform: scale(0.85); }
.breath-text { font-size: clamp(1.3rem, 1rem + 2vw, 2.1rem); font-weight: bold; color: #6d8f5f; }

/* 阶段二：主动画（动画区随视口缩放，SVG 等比缩放不变形） */
.med-main {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 8px;
}
.med-anim {
  width: min(88vw, 1100px);
  height: 62vh;
  height: 62dvh;
  max-height: 720px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.med-anim svg { width: 100%; height: 100%; }
.anim-wrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.med-phrase {
  font-size: clamp(1.05rem, 0.85rem + 1.5vw, 1.7rem);
  font-weight: bold;
  color: #6d8f5f;
  text-align: center;
  min-height: 2.4em;
  padding: 0 16px;
  transition: opacity 0.6s ease;
}
.med-phrase.fading { opacity: 0; }

/* 动画元素通用过渡 */
.anim-wrap .anim-trans { transition: opacity 0.9s ease, transform 0.9s ease; }

/* 云朵 / 太阳 */
.cloud-1 { animation: drift 14s ease-in-out infinite alternate; }
.cloud-2 { animation: drift 18s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(26px); } }
.sun-rays { animation: sunspin 30s linear infinite; transform-origin: 60px 58px; }
@keyframes sunspin { to { transform: rotate(360deg); } }

/* 鸡蛋 / 恐龙蛋晃动 */
.wobble { animation: wobble 0.6s ease-in-out infinite; transform-origin: 200px 255px; }
@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

/* ---------- 祝贺画面 ---------- */
#view-congrats {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #fff3d6 0%, #ffe4ec 60%, #e3f2fd 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti span {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  animation: confetti-fall linear infinite;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); }
}
.congrats-card {
  position: relative;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 28px 26px;
  text-align: center;
  max-width: 440px;
  width: 100%;
}
.congrats-emoji { font-size: 60px; animation: bounce 1s ease infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.congrats-anim { width: min(62vw, 360px); margin: 0 auto; }
.congrats-anim svg { width: 100%; height: auto; }
.congrats-sub { color: #8a7568; }

/* ---------- 弹窗 / 提示 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(90, 74, 66, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-card {
  background: var(--cream);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 26px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}
.modal-text { font-size: 1.15rem; font-weight: bold; }
.modal-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(90, 74, 66, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 1rem;
  max-width: 86vw;
  text-align: center;
  box-shadow: var(--shadow);
}

/* ---------- 响应式 ---------- */
@media (max-width: 480px) {
  html, body { font-size: 16px; }
  .ach-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
  .btn-start { width: 150px; height: 150px; font-size: 1.3rem; }
}
@media (min-width: 481px) and (max-width: 720px) {
  .ach-grid { grid-template-columns: repeat(4, 1fr); }
}
