/* 1st-Grade AI Dual-Camera Study Companion & English Tutor - Tactile Starlight UI */
:root {
  --bg-deep: #0b1326;
  --bg-card: rgba(22, 32, 56, 0.88);
  --bg-card-solid: #162038;
  --border-glow: rgba(96, 165, 250, 0.28);
  --gold: #fbbf24;
  --gold-deep: #d97706;
  --cyan: #38bdf8;
  --blue: #3b82f6;
  --green: #34d399;
  --purple: #a855f7;
  --coral: #fb7185;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 20% 15%, #172554 0%, #0b1326 55%, #070c1a 100%);
  color: var(--text-main);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

/* Ruby Pinyin Typography for 1st Graders */
ruby {
  ruby-align: center;
  ruby-position: over;
}
rt {
  font-size: 0.46em;
  font-weight: 600;
  color: #bae6fd;
  letter-spacing: 0.03em;
  line-height: 1.15;
  padding-bottom: 2px;
}

/* App Shell: Top Bar + Main Stage + Bottom Voice/Action Bar */
.app-shell {
  display: grid;
  grid-template-rows: 64px 1fr 84px;
  width: 100vw;
  height: 100vh;
  padding: 12px 20px;
  gap: 12px;
}

/* Top Status Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  padding: 0 20px;
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
}
.status-pills {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 13.5px;
  font-weight: 600;
  color: #e2e8f0;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
}
.dot.online {
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}
.dot.warn {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}
.star-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.22), rgba(217, 119, 6, 0.28));
  border: 1.5px solid rgba(251, 191, 36, 0.65);
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
  color: var(--gold);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.star-counter:active { transform: scale(0.95); }

/* Views Container */
.views-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.view-screen {
  display: none;
  width: 100%;
  height: 100%;
  animation: fadeIn 0.24s ease-out;
}
.view-screen.active {
  display: grid;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Common Glass Card & Owl Avatar */
.glass-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-glow);
  border-radius: 26px;
  padding: 18px 22px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}
.owl-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.owl-img {
  width: 210px;
  height: 210px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 36px rgba(56, 189, 248, 0.35);
  animation: floatOwl 3.6s ease-in-out infinite;
}
.owl-img.speaking {
  border-color: var(--green);
  box-shadow: 0 0 46px rgba(52, 211, 153, 0.75);
  animation: speakPulse 0.8s ease-in-out infinite;
}
@keyframes floatOwl {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-7px); }
}
@keyframes speakPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.speech-bubble {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96));
  border: 1.5px solid rgba(251, 191, 36, 0.55);
  border-radius: 22px;
  padding: 14px 18px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.65;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

/* ==========================================================================
   SCREEN 1: Welcome Hub (ui_0_welcome_hub)
   ========================================================================== */
#view-welcome {
  grid-template-columns: 38% 1fr;
  gap: 20px;
}
.welcome-left {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}
.parent-note-card {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.16), rgba(30, 41, 59, 0.92));
  border: 1.5px solid rgba(251, 191, 36, 0.65);
  border-radius: 22px;
  padding: 14px 18px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.55;
  color: #fef3c7;
}
.portal-list {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}
.portal-btn {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 28px;
  border-radius: 28px;
  border: none;
  cursor: pointer;
  text-align: left;
  color: #fff;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.16s;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4), inset 0 3px 2px rgba(255, 255, 255, 0.38), inset 0 -5px 0 rgba(0, 0, 0, 0.24);
}
.portal-btn:hover { transform: translateY(-3px); filter: brightness(1.05); }
.portal-btn:active { transform: translateY(2px) scale(0.985); }
.portal-btn.blue { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 78%, #f59e0b 100%); }
.portal-btn.green { background: linear-gradient(135deg, #22c55e 0%, #16a34a 78%, #ea580c 100%); }
.portal-btn.purple { background: linear-gradient(135deg, #a855f7 0%, #7e22ce 78%, #eab308 100%); }
.portal-icon {
  width: 78px;
  height: 78px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.4);
}
.portal-text h2 { font-size: 32px; font-weight: 900; margin-bottom: 4px; }
.portal-text p { font-size: 16px; opacity: 0.92; font-weight: 600; }
.portal-num {
  margin-left: auto;
  font-size: 46px;
  font-weight: 900;
  opacity: 0.85;
  text-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

/* ==========================================================================
   SCREEN 2: Study Companion Main Desk (ui_1_study_companion)
   ========================================================================== */
#view-study {
  grid-template-columns: 64% 1fr;
  gap: 18px;
}
.study-main {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
}
.study-hero {
  display: grid;
  grid-template-columns: 1fr 250px;
  align-items: center;
  gap: 20px;
}
.timer-ring-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.timer-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.timer-digits { font-size: 46px; font-weight: 900; letter-spacing: 1px; color: #fff; }
.timer-sub { font-size: 15px; color: var(--gold); font-weight: 700; margin-top: 2px; }
.task-list-card h3 { font-size: 22px; margin-bottom: 10px; color: var(--gold); }
.task-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.65);
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.task-item.done { color: var(--green); border-color: rgba(52, 211, 153, 0.45); }

/* Dual-Camera Matrix Panel */
.cam-matrix {
  display: grid;
  grid-template-rows: 58% 1fr;
  gap: 12px;
}
.cam-card {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: #090f1d;
  border: 2px solid rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-card video, .cam-card img.snapshot-view {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cam-label {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(15, 23, 42, 0.82);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  z-index: 4;
  border: 1px solid rgba(255,255,255,0.15);
}
.cam-badge-bottom {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.9);
  color: #fff;
  padding: 5px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
  z-index: 4;
}
.focus-brackets {
  position: absolute;
  inset: 14% 12%;
  border: 2.5px dashed rgba(52, 211, 153, 0.78);
  border-radius: 16px;
  pointer-events: none;
  z-index: 3;
}

/* ==========================================================================
   SCREEN 3: Homework Step-by-Step Guided Blackboard (ui_4_homework_solver)
   ========================================================================== */
#view-homework {
  grid-template-columns: 38% 1fr;
  gap: 18px;
}
.blackboard-frame {
  background: linear-gradient(180deg, #1b2e26 0%, #13221c 100%);
  border: 8px solid #855836;
  border-radius: 26px;
  padding: 20px 26px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.5), inset 0 0 40px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.apple-boxes {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  margin: 12px 0;
}
.apple-box {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(251, 191, 36, 0.65);
  border-radius: 18px;
  padding: 12px;
  text-align: center;
}
.apple-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 32px;
  min-height: 82px;
  align-items: center;
}
.apple-item.taken {
  opacity: 0.24;
  filter: grayscale(0.8);
  text-decoration: line-through;
}
.math-step-box {
  background: rgba(251, 191, 36, 0.14);
  border: 1.5px solid var(--gold);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 20px;
  font-weight: 800;
  color: #fef3c7;
  margin-bottom: 10px;
}

/* ==========================================================================
   SCREEN 4: English Speaking Tutor Blackboard (ui_2_english_tutor)
   ========================================================================== */
#view-english {
  grid-template-columns: 23% 1fr 26%;
  gap: 16px;
}
.word-stage {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  align-items: center;
}
.word-illust {
  width: 230px;
  height: 230px;
  border-radius: 24px;
  object-fit: cover;
  background: #fff;
  border: 4px solid rgba(255,255,255,0.85);
  box-shadow: 0 10px 26px rgba(0,0,0,0.4);
}
.syllable-word {
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 2px;
}
.syl-0 { color: #fb7185; }
.syl-1 { color: #4ade80; }
.syl-2 { color: #c084fc; }
.syl-3 { color: #38bdf8; }
.phonetic-txt { font-size: 26px; color: #cbd5e1; margin: 4px 0; }
.meaning-txt { font-size: 30px; font-weight: 800; color: var(--gold); margin-bottom: 8px; }
.sentence-bar {
  background: rgba(0, 0, 0, 0.28);
  border-radius: 16px;
  padding: 10px 18px;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
}

/* ==========================================================================
   SCREEN 6 & 7: Star Treasure Chest & Hardware Calibration
   ========================================================================== */
#view-treasure {
  grid-template-columns: 60% 1fr;
  gap: 18px;
}
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 10px;
  height: calc(100% - 44px);
}
.vocab-card-mini {
  background: rgba(30, 41, 59, 0.92);
  border: 1.5px solid rgba(148, 163, 184, 0.3);
  border-radius: 20px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s;
}
.vocab-card-mini:hover { transform: translateY(-4px); border-color: var(--gold); }
.vocab-card-mini img { width: 92px; height: 92px; border-radius: 16px; object-fit: cover; }

#view-settings {
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.ctrl-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  border: 1px solid #334155;
  font-size: 14px;
  margin-top: 6px;
}

/* ==========================================================================
   BOTTOM ACTION & FULL-DUPLEX WAVEFORM BAR
   ========================================================================== */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border-glow);
  border-radius: 24px;
  padding: 0 20px;
  backdrop-filter: blur(14px);
}
.wave-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 520px;
}
#waveCanvas {
  width: 240px;
  height: 44px;
}
.tactile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35), inset 0 2px 1px rgba(255,255,255,0.35), inset 0 -3px 0 rgba(0,0,0,0.22);
  transition: transform 0.14s ease;
}
.tactile-btn:active { transform: scale(0.95); }
.btn-coral { background: linear-gradient(135deg, #fb7185, #e11d48); }
.btn-blue  { background: linear-gradient(135deg, #38bdf8, #2563eb); }
.btn-green { background: linear-gradient(135deg, #34d399, #059669); }
.btn-gold  { background: linear-gradient(135deg, #fbbf24, #d97706); color: #1e1b4b; }
.btn-slate { background: linear-gradient(135deg, #475569, #334155); }

/* ==========================================================================
   SCREEN 5: Gentle Posture Reminder Modal Overlay (ui_5_posture_alert)
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 38, 0.82);
  backdrop-filter: blur(10px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.posture-modal {
  width: 780px;
  background: linear-gradient(160deg, #1e293b, #0f172a);
  border: 3px solid var(--gold);
  border-radius: 32px;
  padding: 28px 34px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.65);
}
.progress-track {
  width: 100%;
  height: 16px;
  background: #334155;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--green));
  transition: width 0.3s linear;
}
.toast-fly {
  position: fixed;
  top: 82px;
  right: 28px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #0f172a;
  font-size: 20px;
  font-weight: 900;
  padding: 12px 24px;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(251, 191, 36, 0.5);
  z-index: 200;
  display: none;
}
