:root {
  --bg: #2864d7;
  --bg-deep: #2148b9;
  --accent: #35c7ec;
  --accent-light: #9beafa;
  --white: #fff;
  --ink: #173b91;
  --shadow: 0 12px 30px rgba(10, 45, 140, .26);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at 50% 20%, #4386ed 0, var(--bg) 48%, var(--bg-deep) 100%);
  color: var(--white);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }

.app {
  width: min(100%, 600px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}

.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  margin: 0 auto;
  font-size: clamp(17px, 4.4vw, 20px);
  font-weight: 800;
  letter-spacing: .08em;
  opacity: .96;
}
.pill, .icon-button {
  color: var(--white);
  background: rgba(66, 209, 239, .9);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 6px 16px rgba(0, 47, 140, .2);
  transition: transform .15s ease;
}
.pill:active, .icon-button:active { transform: scale(.95); }
.pill {
  border-radius: 999px;
  padding: 10px 16px;
  font-size: clamp(13px, 3.5vw, 15px);
  font-weight: 700;
  white-space: nowrap;
}
.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timer-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: clamp(12px, 2.5vh, 32px);
}
.timer-visual {
  width: min(72vw, 360px);
  aspect-ratio: 1;
  position: relative;
  margin: 0 auto;
  padding: 0;
}

/* Picture Mode */
.picture-wrap {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  overflow: hidden;
  background: #d9f5f7;
  border: 3px solid rgba(255, 255, 255, .82);
  box-shadow: 0 8px 24px rgba(10, 45, 140, .28);
}
.picture-wrap img, .picture-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.picture-wrap img:not([src=""]) { z-index: 1; }
.picture-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--ink);
  background: linear-gradient(145deg, #fff4bf, #bcecf1);
  font-size: clamp(44px, 12vw, 70px);
  text-align: center;
}
.picture-placeholder span {
  font-size: clamp(14px, 3.6vw, 20px);
  line-height: 1.35;
  font-weight: 700;
}
.visual-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.visual-overlay #coverSector {
  fill: var(--bg);
}

.progress-ring {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .2));
}
.progress-ring path {
  fill: none;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.progress-ring .ring-trail {
  stroke: rgba(255, 255, 255, .28);
  stroke-width: 5;
}
.progress-ring #progressArc {
  stroke: var(--accent-light);
  stroke-width: 5;
}

.pointer-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.pointer-overlay #sweepLine {
  stroke: #ffffff;
  stroke-width: 4.2;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 4px rgba(10, 45, 140, .35));
}
.pointer-overlay #sweepDot {
  fill: var(--accent-light);
  stroke: #ffffff;
  stroke-width: 2.2;
  filter: drop-shadow(0 2px 6px rgba(10, 45, 140, .5));
}

/* Sandglass Mode */
.timer-visual.mode-sandglass .picture-wrap,
.timer-visual.mode-sandglass .visual-overlay,
.timer-visual.mode-sandglass .progress-ring,
.timer-visual.mode-sandglass .pointer-overlay {
  display: none;
}
.sandglass {
  position: absolute;
  inset: 2%;
  z-index: 6;
  width: 96%;
  height: 96%;
  overflow: visible;
  filter: drop-shadow(0 10px 16px rgba(16, 62, 150, .26));
}
.sandglass[hidden] { display: none; }
.timer-visual.mode-sandglass .sandglass { display: block !important; }
.sandglass .glass-body {
  fill: url(#glassFill);
  stroke: #b9f3fa;
  stroke-width: 4.5;
}
.sandglass .sand-shape {
  fill: url(#sandFill);
}
.sandglass .sand-texture {
  fill: url(#sandSpeckles);
  pointer-events: none;
}
.sandglass .sand-particle {
  fill: #ffe28a;
  opacity: .92;
}
.sandglass .sand-particle:nth-child(3n) { fill: #f8c94f; }
.sandglass .sand-particle:nth-child(4n) { fill: #fffbe0; }
.sandglass .sand-stream-line {
  stroke: #fcd96a;
  stroke-linecap: round;
  opacity: .85;
}
.sandglass .glass-highlight {
  fill: none;
  stroke: rgba(255, 255, 255, .55);
  stroke-width: 2.4;
  stroke-linecap: round;
}
.sandglass .glass-cap-svg {
  fill: #a9ecf4;
  stroke: #d8fbff;
  stroke-width: 2;
}

/* Time & Status */
.time {
  margin-top: clamp(14px, 2.5vh, 24px);
  font-size: clamp(52px, 15vw, 92px);
  font-weight: 800;
  line-height: .95;
  letter-spacing: .02em;
  text-shadow: 0 5px 6px rgba(20, 55, 145, .25);
  font-variant-numeric: tabular-nums;
}
.urgent .time {
  color: #ffe07a;
  animation: urgent-pulse .8s ease-in-out infinite alternate;
}
.status {
  margin-top: clamp(8px, 1.4vh, 14px);
  min-height: 28px;
  font-size: clamp(16px, 4.2vw, 20px);
  font-weight: 800;
  letter-spacing: .03em;
  opacity: .96;
  text-align: center;
}

/* Controls */
.main-controls {
  display: flex;
  gap: clamp(12px, 3vw, 18px);
  margin-top: clamp(16px, 2.8vh, 28px);
  width: 100%;
  justify-content: center;
}
.primary, .secondary {
  min-width: clamp(126px, 32vw, 148px);
  height: clamp(48px, 6.5vh, 56px);
  padding: 0 clamp(18px, 4vw, 24px);
  border-radius: 999px;
  font-weight: 800;
  font-size: clamp(16px, 4vw, 18px);
  box-shadow: var(--shadow);
  transition: transform .15s ease, background-color .2s ease;
}
.primary {
  color: var(--white);
  background: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), var(--shadow);
}
.secondary {
  color: var(--white);
  background: rgba(48, 194, 232, .85);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.16), var(--shadow);
}
.primary:active, .secondary:active, .round-button:active {
  transform: scale(.95);
}

/* Quick Actions */
.quick-actions {
  display: flex;
  gap: clamp(8px, 2.5vw, 16px);
  margin-top: clamp(14px, 2.5vh, 24px);
  justify-content: center;
  width: 100%;
}
.round-button {
  width: clamp(54px, 13.5vw, 66px);
  height: clamp(54px, 13.5vw, 66px);
  border-radius: 50%;
  color: var(--white);
  background: rgba(41, 199, 235, .92);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
  transition: transform .15s ease;
}
.round-button span {
  font-size: clamp(20px, 5.2vw, 25px);
  line-height: 1;
}
.round-button small {
  font-size: clamp(10px, 2.6vw, 11px);
  font-weight: 700;
}

/* Settings Panel & Celebration Modal */
.settings-panel, .celebration {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 440px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  color: #183a85;
  background: rgba(255,255,255,.98);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 28, 100, .35);
}
.step-hint {
  margin: 0 0 18px;
  color: #7182ac;
  font-size: 15px;
  text-align: center;
}
.style-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.style-option {
  min-height: 140px;
  padding: 16px 10px;
  border: 2px solid #c7d5f0;
  border-radius: 18px;
  background: #f8fbff;
  color: #183a85;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.style-option.selected {
  border-color: #1670d5;
  box-shadow: 0 0 0 3px rgba(22,112,213,.15);
  background: #eef7ff;
}
.style-option small {
  color: #7182ac;
  font-size: 12px;
  font-weight: 500;
}
.style-emoji {
  font-size: 40px;
  line-height: 1;
}
.next-step {
  display: block;
  width: 100%;
  margin-top: 18px;
}
.advanced-settings[hidden], .style-step[hidden] {
  display: none;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}
.falling-emoji {
  position: absolute;
  top: -10vh;
  animation: fall-and-spin var(--fall-time) ease-in forwards;
  font-size: var(--size);
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.12));
}
.image-status {
  min-height: 18px;
  margin: -4px 0 5px;
  color: #7182ac;
  font-size: 12px;
}
.image-status[data-kind="success"] { color: #1e9b76; }
.image-status[data-kind="error"] { color: #d04b5a; }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-heading h2 { margin: 0 0 16px; font-size: 22px; }
.close {
  background: none;
  color: #5571af;
  font-size: 30px;
  line-height: 1;
  padding: 0 4px;
}

.settings-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  font-weight: 700;
  font-size: 15px;
}
.settings-panel input[type="number"], .settings-panel select {
  width: 140px;
  padding: 8px 10px;
  border: 1px solid #b9c9ea;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}
.quiet-mode-button {
  width: 100%;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1.5px solid #b8dfd3;
  border-radius: 14px;
  color: #176e5a;
  background: #effbf6;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.quiet-mode-button span {
  font-size: 15px;
  font-weight: 800;
}
.quiet-mode-button small {
  color: #527b72;
  font-size: 11px;
  line-height: 1.4;
}
.quiet-mode-button[aria-pressed="true"] {
  border-color: #27a98a;
  background: #dff7ed;
  box-shadow: 0 0 0 3px rgba(39, 169, 138, .12);
}
.file-label {
  padding: 10px 0;
  border-top: 1px solid #e1e8f7;
}
.file-label input[type="file"] {
  max-width: 180px;
  font-size: 12px;
}
.preview-sound {
  align-self: flex-start;
  margin-top: 4px;
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--ink);
  background: #e6f2ff;
  font-size: 14px;
  font-weight: 700;
}
.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.small {
  min-width: 0;
  height: 44px;
  padding: 0 18px;
  font-size: 15px;
}
.tip {
  color: #7182ac;
  font-size: 12px;
  margin: 14px 0 0;
}

.celebration {
  bottom: 50%;
  transform: translate(-50%, 50%);
  text-align: center;
}
.celebration h2 {
  font-size: 30px;
  margin: 0 0 8px;
}
.confetti {
  font-size: 64px;
  animation: bounce 1s infinite alternate;
}

/* Themes */
body.theme-pink {
  --bg: #8d59d8;
  --bg-deep: #653cb2;
  --accent: #ff9bcb;
  --accent-light: #ffd0e6;
  --ink: #67389d;
}
body.theme-green {
  --bg: #27a98a;
  --bg-deep: #16806f;
  --accent: #7cdbb7;
  --accent-light: #c3f5df;
  --ink: #197e6c;
}

@keyframes bounce {
  to { transform: translateY(-9px) rotate(8deg); }
}
@keyframes urgent-pulse {
  to { transform: scale(1.05); text-shadow: 0 0 24px rgba(255, 224, 122, .75); }
}
@keyframes fall-and-spin {
  0% { transform: translate3d(0, -12vh, 0) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate3d(var(--drift), 115vh, 0) rotate(var(--rotation)); opacity: .95; }
}

@media (max-height: 700px) {
  .timer-area { margin-top: 8px; }
  .timer-visual { width: min(54vh, 300px); }
  .time { margin-top: 10px; font-size: clamp(44px, 12vw, 68px); }
  .status { margin-top: 4px; font-size: 13px; min-height: 20px; }
  .main-controls { margin-top: 12px; }
  .primary, .secondary { height: 46px; min-width: 118px; font-size: 15px; }
  .quick-actions { margin-top: 10px; }
  .round-button { width: 48px; height: 48px; }
  .round-button span { font-size: 17px; }
  .round-button small { font-size: 9px; }
}

/* ========================================================
   儿童锁模式 (Child Lock Mode)
   ======================================================== */
body.child-locked .topbar .brand,
body.child-locked #settingsButton,
body.child-locked .main-controls,
body.child-locked .quick-actions {
  display: none !important;
}

[hidden] {
  display: none !important;
}

body.child-locked #childLockButton {
  background: rgba(43, 192, 230, 0.95);
  box-shadow: 0 4px 16px rgba(0, 35, 110, 0.3);
}

body.child-locked .timer-visual.locked-ready {
  cursor: pointer;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .12);
}

.child-lock-banner {
  display: none !important;
  margin-top: auto;
  margin-bottom: max(16px, env(safe-area-inset-bottom));
  width: min(92%, 420px);
  padding: 12px 20px;
  background: rgba(43, 192, 230, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(10, 45, 140, 0.28);
  animation: banner-fade-in 0.3s ease;
  z-index: 5;
}

body.child-locked .child-lock-banner {
  display: flex !important;
}

@keyframes banner-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================================
   通用半屏弹窗 (Bottom Sheet & Modal Backdrop)
   ======================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 25, 65, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  animation: modal-fade-in 0.22s ease;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-backdrop.nested {
  z-index: 110;
  background: rgba(10, 25, 65, 0.65);
}

.bottom-sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #f4f8ff;
  border-radius: 28px 28px 0 0;
  padding: 12px 20px max(24px, env(safe-area-inset-bottom));
  color: #173b91;
  box-shadow: 0 -10px 40px rgba(0, 20, 70, 0.28);
  animation: sheet-slide-up 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  max-height: 85dvh;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 42px;
  height: 5px;
  background: #ccd7ed;
  border-radius: 3px;
  margin: 0 auto 10px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #173b91;
}

.sheet-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2ebf8;
  color: #637ea7;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.sheet-close:active {
  background: #d0def3;
}

/* ========================================================
   滚动式时间选择器 (Wheel Picker & Quick Grid)
   ======================================================== */
.sheet-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: 0 4px 16px rgba(23, 59, 145, 0.06);
  margin-bottom: 16px;
}

.card-subtitle {
  font-size: 14px;
  font-weight: 700;
  color: #687da6;
  margin-bottom: 10px;
}

.picker-container {
  position: relative;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  user-select: none;
  overflow: hidden;
  background: linear-gradient(180deg, #fafcff 0%, #ffffff 50%, #fafcff 100%);
  border-radius: 14px;
}

.picker-container::before,
.picker-container::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 56px;
  pointer-events: none;
  z-index: 3;
}

.picker-container::before {
  top: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 100%);
}

.picker-container::after {
  bottom: 0;
  background: linear-gradient(0deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 100%);
}

.picker-highlight {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  height: 48px;
  background: rgba(225, 238, 255, 0.75);
  border-radius: 12px;
  pointer-events: none;
  z-index: 1;
}

.picker-col-wrapper {
  display: flex;
  align-items: center;
  z-index: 2;
}

.wheel-picker {
  width: 76px;
  height: 160px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 56px 0;
  box-sizing: border-box;
  outline: none;
}

.wheel-picker::-webkit-scrollbar {
  display: none;
}

.wheel-item {
  height: 48px;
  line-height: 48px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: #93a5c3;
  scroll-snap-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, color 0.12s ease, font-size 0.12s ease;
}

.wheel-item.selected {
  color: #173b91;
  font-size: 32px;
  font-weight: 900;
  transform: scale(1.08);
}

.picker-unit {
  font-size: 15px;
  font-weight: 800;
  color: #6a7fa8;
  margin-left: 2px;
}

.picker-divider {
  font-size: 28px;
  font-weight: 900;
  color: #173b91;
  margin: 0 4px;
  z-index: 2;
}

.quick-pick-section {
  margin-bottom: 8px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quick-btn {
  height: 46px;
  background: #dbe7fa;
  color: #183a85;
  font-size: 15px;
  font-weight: 700;
  border-radius: 14px;
  transition: all 0.15s ease;
}

.quick-btn:active {
  background: #ccdff8;
  transform: scale(0.96);
}

.quick-btn.active {
  background: #2864d7;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(40, 100, 215, 0.35);
}

/* ========================================================
   场景管理与预设 (Scene Sheet & Presets)
   ======================================================== */
.scene-sheet {
  max-height: 86vh;
  max-height: 86dvh;
}

.scene-favorites-wrap {
  margin-bottom: 12px;
}
.scene-list-title span {
  font-weight: 500;
}
.scene-favorites {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.scene-favorite-btn {
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid #dbe6f8;
  border-radius: 14px;
  background: #fff;
  color: #173b91;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  text-align: left;
}
.scene-favorite-btn:active {
  background: #edf4ff;
  transform: scale(.98);
}
.scene-favorite-btn .scene-emoji {
  grid-row: 1 / 3;
  align-self: center;
}
.scene-favorite-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scene-favorite-time {
  color: #7b8fae;
  font-size: 12px;
  font-weight: 700;
}
.scene-manager {
  margin-bottom: 12px;
}
.scene-manager summary {
  padding: 10px 12px;
  border: 1px solid #dbe6f8;
  border-radius: 12px;
  background: #eaf2ff;
  color: #365b9f;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  list-style-position: inside;
}
.scene-manager[open] summary {
  margin-bottom: 8px;
}
.scene-manager .custom-scene-card {
  margin-bottom: 0;
}

/* 自定义场景卡片 */
.custom-scene-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(23, 59, 145, 0.08);
  margin-bottom: 12px;
  border: 1.5px solid #dbe6f8;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.custom-scene-card.editing {
  border-color: #2864d7;
  box-shadow: 0 0 0 3px rgba(40, 100, 215, 0.18);
}
.card-subtitle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.custom-card-title {
  font-size: 14px;
  font-weight: 800;
  color: #173b91;
}
.text-btn {
  background: none;
  border: none;
  color: #5571af;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
}
.text-btn:hover {
  color: #2864d7;
}

.custom-scene-inputs {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.custom-scene-inputs input[type="text"] {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 1px solid #b9c9ea;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: #173b91;
  background: #fafcff;
  outline: none;
}
.custom-scene-inputs input[type="text"]:focus {
  border-color: #2864d7;
  background: #fff;
}

.custom-time-input-wrap {
  display: flex;
  align-items: center;
  background: #fafcff;
  border: 1px solid #b9c9ea;
  border-radius: 12px;
  padding: 0 10px;
  height: 44px;
  flex-shrink: 0;
}
.custom-time-input-wrap input[type="number"] {
  width: 48px;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 800;
  color: #173b91;
  text-align: center;
  outline: none;
}
.custom-time-input-wrap .unit-text {
  font-size: 13px;
  font-weight: 700;
  color: #687da6;
  margin-left: 2px;
}

.emoji-picker-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
  scrollbar-width: none;
}
.emoji-picker-row::-webkit-scrollbar {
  display: none;
}
.emoji-pick-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #f0f4fa;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.12s, background-color 0.15s;
}
.emoji-pick-btn:active {
  transform: scale(0.92);
}
.emoji-pick-btn.selected {
  background: #2864d7;
  box-shadow: 0 0 0 2px #fff, 0 3px 8px rgba(40,100,215,0.3);
}

.scene-list-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.scene-list-title {
  font-size: 13px;
  font-weight: 700;
  color: #7b8fae;
  margin-bottom: 8px;
}
.scene-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
}
.scene-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(20, 50, 120, 0.05);
  cursor: pointer;
  transition: transform 0.12s, background-color 0.15s;
}
.scene-item:active {
  background: #edf4ff;
  transform: scale(0.98);
}
.scene-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.scene-emoji {
  font-size: 24px;
  line-height: 1;
}
.scene-name {
  font-size: 15px;
  font-weight: 700;
  color: #173b91;
}
.scene-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.scene-time-tag {
  font-size: 14px;
  font-weight: 700;
  color: #7b8fae;
  font-variant-numeric: tabular-nums;
}
.scene-edit-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef4ff;
  color: #2864d7;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.scene-edit-btn:active {
  background: #d8e6ff;
}
.scene-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffe3e6;
  color: #e54b60;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.scene-delete-btn:active {
  background: #ffd0d5;
}

.save-scene-content input[type="text"]:focus {
  border-color: #2864d7;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.emoji-btn {
  height: 44px;
  background: #f0f4fa;
  border-radius: 12px;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s, background-color 0.15s;
}

.emoji-btn:active {
  transform: scale(0.92);
}

.emoji-btn.selected {
  background: #2864d7;
  box-shadow: 0 0 0 2px #fff, 0 4px 10px rgba(40,100,215,0.3);
}

.full-width {
  width: 100%;
  margin-top: 8px;
}

/* ========================================================
   家长算术验证弹窗 (Math Verify Modal)
   ======================================================== */
.math-sheet {
  text-align: center;
}

.sheet-desc {
  margin: 0 0 16px;
  font-size: 14px;
  color: #6b7da3;
}

.math-box {
  background: #ffffff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(20, 50, 120, 0.08);
}

.math-question {
  font-size: 38px;
  font-weight: 900;
  color: #173b91;
  margin-bottom: 18px;
  letter-spacing: 0.04em;
}

.math-input-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.math-input-row input {
  width: 130px;
  height: 48px;
  border: 2px solid #b9c9ea;
  border-radius: 12px;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  color: #173b91;
  outline: none;
  background: #fafcff;
}

.math-input-row input:focus {
  border-color: #2864d7;
  background: #ffffff;
}

.math-tip {
  margin: 12px 0 0;
  color: #e54b60;
  font-size: 13px;
  font-weight: 700;
}


/* V23: classroom and home use */
.app { gap: 14px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.timer-area { margin-top: 0; }
.display-toolbar { width: 100%; display: flex; justify-content: flex-end; }
.display-toolbar .pill { font-size: 13px; padding: 9px 14px; }
.ready-preview .visual-overlay, .ready-preview .pointer-overlay { opacity: 0; }
.picture-wrap img { width: 100%; height: 100%; object-fit: cover; }
.status { font-size: clamp(20px, 4vw, 28px); line-height: 1.4; text-align: center; }
.quick-actions { flex-wrap: wrap; margin-top: 0; }
.round-button small { font-size: 12px; }
.extend-controls { display: none; gap: 12px; }
.timer-active .extend-controls { display: flex; }
.extend-controls button { border-radius: 20px; padding: 10px 18px; color: #173b91; background: #eaf4ff; }
body.child-locked .extend-controls, body.child-locked .display-toolbar { display: none; }
.app-notice { max-width: 560px; padding: 10px 16px; margin: 0; border-radius: 12px; background: #eef7ff; color: #173b91; font-size: 14px; }
.duration-sheet, .scene-sheet { overflow-y: auto; }
.duration-sheet > *, .scene-sheet > * { flex-shrink: 0; }
.scene-list-wrap { overflow: visible; }
.custom-scene-inputs { flex-wrap: wrap; }
.custom-scene-inputs input[type="text"] { flex-basis: 100%; }
.custom-time-input-wrap input { width: 54px; }
.scene-item-left { min-width: 0; gap: 6px; }
.scene-name { overflow-wrap: anywhere; }
.scene-item { padding: 10px; gap: 6px; }
.scene-item-right { gap: 3px; }
.scene-edit-btn, .scene-delete-btn, .scene-pin-btn { min-width: 36px; height: 40px; border-radius: 10px; }
.scene-pin-btn { color: #8c6500; background: #fff2cd; font-size: 21px; }
.settings-panel input[type="text"] { width: 60%; min-width: 0; border: 1px solid #b9c9ea; border-radius: 8px; padding: 8px; }
.confetti { animation: none; }
.confetti.animated { animation: bounce 1s infinite alternate; }
.celebration .panel-actions { justify-content: center; flex-wrap: wrap; }
.action-dialog { border: 0; width: min(90vw, 420px); border-radius: 22px; padding: 24px; color: #173b91; }
.action-dialog::backdrop { background: rgba(10, 25, 65, .65); }
.action-dialog h2 { font-size: 22px; }
.action-dialog p { line-height: 1.7; }
.presentation .app { width: 100%; }
.presentation .quick-actions { display: none; }
.presentation .timer-visual { width: min(65vh, 70vw, 760px); }
.presentation .time { font-size: clamp(60px, 12vh, 150px); }
.presentation .status { font-size: clamp(26px, 5vh, 50px); }
.presentation .main-controls { margin-top: 0; }
@media (min-width: 900px) and (orientation: landscape) {
  .presentation .timer-area { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 1400px; }
  .presentation .timer-visual { grid-row: 1 / 3; width: min(70vh, 48vw); }
  .presentation .time { align-self: end; text-align: center; }
  .presentation .status { align-self: start; }
}
@media (max-width: 400px) {
  .quick-actions { max-width: 300px; gap: 12px; }
  .round-button { width: 72px; height: 56px; border-radius: 18px; }
  .scene-time-tag { font-size: 12px; }
  .scene-name { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body:not(.presentation) .app { gap: 8px; }
body:not(.presentation) .timer-visual { width: min(68vw, 38dvh, 340px); }
body:not(.presentation) .time { margin-top: 8px; font-size: clamp(48px, 10dvh, 88px); }
body:not(.presentation) .main-controls { margin-top: 8px; }
body:not(.presentation) .status { margin-top: 2px; }
@media (min-width: 900px) and (orientation: landscape) {
  .presentation .app { gap: 8px; }
  .presentation .timer-visual { width: min(52dvh, 48vw); }
}

.music-settings { margin: 16px 0; padding: 12px; border: 1px solid #c8d9ef; border-radius: 16px; }
.music-settings legend { font-weight: 800; padding: 0 6px; }
.music-settings select { max-width: 65%; }
.music-preview-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-panel input[type="range"] { width: 42%; min-width: 70px; accent-color: #2864d7; }
.settings-panel output { min-width: 36px; font-size: 13px; }
.settings-panel .tip { line-height: 1.6; overflow-wrap: anywhere; }
.confetti-piece { position: absolute; top: -24px; width: 10px; height: 17px; border-radius: 3px; animation: confetti-fall var(--fall-time) ease-in forwards; }
.confetti-piece:nth-child(3n) { width: 12px; height: 12px; border-radius: 50%; }
.confetti-piece:nth-child(5n) { width: 7px; height: 22px; }
@keyframes confetti-fall {
  0% { transform: translate3d(0, -20px, 0) rotate(0); opacity: 0; }
  12% { opacity: 1; }
  90% { opacity: .9; }
  100% { transform: translate3d(var(--drift), 105vh, 0) rotate(var(--rotation)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .confetti-piece { animation: none; opacity: .7; } }
