* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: linear-gradient(180deg, #eaf1f9 0%, #f7f9fc 45%, #f2f5f9 100%);
  color: #1d2530;
  min-height: 100vh;
}
#app { max-width: 620px; margin: 0 auto; padding: 0 16px 92px; }

#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 10px;
  background: linear-gradient(180deg, rgba(234,241,249,.96), rgba(234,241,249,.75) 70%, transparent);
  backdrop-filter: blur(10px);
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.brand span { display: block; font-size: 11px; font-weight: 500; color: #7a8798; letter-spacing: 1px; margin-top: 2px; }
.lang-switch { display: flex; background: #fff; border-radius: 999px; padding: 3px; box-shadow: 0 2px 10px rgba(30,50,80,.08); }
.lang-switch button { border: 0; background: transparent; font-size: 12px; padding: 6px 12px; border-radius: 999px; color: #6b7a8c; font-weight: 600; }
.lang-switch button.active { background: #1d2530; color: #fff; }

h2.section { font-size: 13px; color: #7a8798; font-weight: 700; letter-spacing: 1px; margin: 22px 4px 10px; text-transform: uppercase; }

.card {
  background: #fff; border-radius: 20px; padding: 16px 18px;
  box-shadow: 0 6px 22px rgba(30,50,80,.07);
  margin-bottom: 12px;
}
.pattern-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pattern-en { font-size: 20px; font-weight: 800; color: #1d2530; }
.pattern-zh { font-size: 13px; color: #7a8798; margin-top: 4px; }
.pattern-it { font-size: 13px; color: #e8552d; font-weight: 600; margin-top: 2px; }
.chev { color: #c3ccd8; font-size: 20px; }
.card:active { transform: scale(.99); }

.hero {
  background: linear-gradient(135deg, #1d2530 0%, #33415a 100%);
  color: #fff; border-radius: 24px; padding: 20px;
  box-shadow: 0 12px 30px rgba(25,40,70,.22);
  margin-top: 8px;
}
.hero h1 { font-size: 20px; margin: 0 0 6px; }
.hero p { margin: 0; font-size: 13px; color: #b9c6d8; line-height: 1.6; }
.hero .stats { display: flex; gap: 20px; margin-top: 16px; }
.hero .stat b { display: block; font-size: 22px; color: #ffb08f; }
.hero .stat span { font-size: 11px; color: #b9c6d8; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 14px; padding: 12px 18px;
  font-size: 14px; font-weight: 700; background: #e8552d; color: #fff;
  width: 100%; margin-top: 12px;
}
.btn.ghost { background: #f0f4f9; color: #33415a; }
.btn.audio { width: auto; padding: 8px 14px; margin: 0; font-size: 13px; background: #f0f4f9; color: #33415a; border-radius: 999px; }
.btn.audio.it { background: #fff2ec; color: #e8552d; }

.example { padding: 14px 0; border-bottom: 1px solid #eef2f7; }
.example:last-child { border-bottom: 0; }
.ex-en { font-size: 17px; font-weight: 700; line-height: 1.45; }
.ex-it { font-size: 15px; color: #e8552d; font-weight: 600; margin-top: 4px; line-height: 1.4; }
.ex-zh { font-size: 13px; color: #7a8798; margin-top: 4px; }
.ex-actions { display: flex; gap: 8px; margin-top: 10px; }

.note { background: #f6f8fb; border-radius: 14px; padding: 12px 14px; font-size: 13px; color: #5a6778; line-height: 1.65; margin-top: 12px; }
.note b { color: #1d2530; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(20,30,45,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
#modal.hidden { display: none; }
.modal-card {
  background: #fff; width: 100%; max-width: 620px; max-height: 86vh; overflow-y: auto;
  border-radius: 26px 26px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.close { border: 0; background: #f0f4f9; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; color: #5a6778; flex: 0 0 auto; }

/* quiz */
.quiz-card { text-align: center; padding: 26px 18px; }
.quiz-q { font-size: 28px; font-weight: 800; line-height: 1.3; }
.quiz-a { margin-top: 14px; font-size: 16px; color: #e8552d; font-weight: 700; }
.quiz-sub { font-size: 13px; color: #7a8798; margin-top: 6px; }
.quiz-actions { display: flex; gap: 10px; margin-top: 18px; }

/* dialogue */
.dline { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eef2f7; }
.dline:last-child { border-bottom: 0; }
.who { flex: 0 0 26px; height: 26px; border-radius: 50%; background: #1d2530; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.dbody { flex: 1; }
.dbody .ex-en, .dbody .ex-it, .dbody .ex-zh { font-size: 14px; }
.dbody .ex-en { font-size: 15px; }

/* tabbar */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px);
  border-top: 1px solid #e8eef5;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  max-width: 620px; margin: 0 auto;
}
#tabbar button { border: 0; background: transparent; color: #93a0b1; font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 12px; border-radius: 12px; }
#tabbar button b { font-size: 16px; font-weight: 800; }
#tabbar button.active { color: #e8552d; }

.progress-bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff8a5c, #e8552d); border-radius: 999px; transition: width .3s; }

.muted { color: #93a0b1; font-size: 12px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 0; background: #fff; color: #6b7a8c; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px; box-shadow: 0 2px 10px rgba(30,50,80,.06); white-space: nowrap; }
.chip.on { background: #1d2530; color: #fff; }

.ex-actions { flex-wrap: wrap; }

.vrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.vrow .pattern-en { line-height: 1.3; }
.vrow .pattern-it { margin-top: 2px; }

html, body { overscroll-behavior: none; }
#topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
.install-hint {
  position: fixed; left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom));
  background: #1d2530; color: #fff; border-radius: 16px; padding: 14px 16px;
  font-size: 13px; line-height: 1.5; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 10px 30px rgba(20,30,45,.3); z-index: 40;
}
.install-hint button { border: 0; background: #e8552d; color: #fff; border-radius: 10px; padding: 8px 12px; font-size: 12px; font-weight: 700; flex: 0 0 auto; }

#tabbar button { padding: 4px 6px; font-size: 10px; }
#tabbar button b { font-size: 15px; }
.plan-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin-top: 10px; }
.plan-cell { aspect-ratio: 1; border-radius: 8px; background: #eef2f7; color: #93a0b1; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.plan-cell.done { background: #e8552d; color: #fff; }
.plan-cell.today { outline: 2px solid #1d2530; }
.task { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eef2f7; }
.task:last-child { border-bottom: 0; }
.task .cb { width: 24px; height: 24px; border-radius: 8px; border: 2px solid #d5dde8; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #fff; }
.task .cb.on { background: #2fa36b; border-color: #2fa36b; }
.task .tl { flex: 1; font-size: 14px; line-height: 1.4; }
.task .go { border: 0; background: #f0f4f9; color: #33415a; border-radius: 10px; padding: 6px 10px; font-size: 12px; font-weight: 700; }

.scen-opt { text-align: left; background: #f7f9fc; color: #1d2530; margin-top: 8px; line-height: 1.35; }
.scen-opt small { color: #7a8798; font-weight: 500; font-size: 12px; }

.chat { max-height: 44vh; overflow-y: auto; padding: 4px 2px; }
.bubble { max-width: 88%; padding: 10px 12px; border-radius: 14px; margin: 6px 0; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.bubble.user { background: #1d2530; color: #fff; margin-left: auto; }
.bubble.ai { background: #f2f5f9; color: #1d2530; }
