/* ================= Duolingo 風格：路徑、課程、每日目標 ================= */
:root {
  --duo-green: #58cc02; --duo-green-d: #46a302; --duo-green-bg: #d7ffb8;
  --duo-red: #ff4b4b; --duo-red-d: #ea2b2b; --duo-red-bg: #ffdfe0;
  --duo-gold: #ffc800; --duo-gold-d: #e5a800; --duo-blue: #1cb0f6;
  --duo-gray: #e5e5e5; --duo-gray-d: #afafaf;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --duo-green-bg: #1d3a12; --duo-red-bg: #3c1c1f; --duo-gray: #37464f; --duo-gray-d: #52656d; }
}
body { padding-bottom: calc(env(safe-area-inset-bottom) + 64px); }
body.in-lesson { padding-bottom: 0; }
body.in-lesson .topbar, body.in-lesson .tabs { display: none; }

.hstat { font-size: 1rem; font-weight: 800; margin: 0 8px; }
.hstat.fire { color: #ff9600; }
.hstat.bolt { color: var(--duo-gold-d); }

/* 底部分頁列 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 2px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs[hidden] { display: none; }
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; text-decoration: none; color: var(--muted); font-size: .75rem; font-weight: 700;
  border-radius: 12px; margin: 4px;
}
.tabs a b { font-size: 1.4rem; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabs a.active { color: var(--duo-blue); background: color-mix(in srgb, var(--duo-blue) 12%, transparent); }
.tabs a.active b { filter: none; opacity: 1; }

/* 大按鈕（立體效果） */
.btn-big {
  display: block; width: 100%; max-width: 420px; margin: 0 auto;
  padding: 14px 20px; border: 0; border-radius: 16px; font-size: 1.05rem; font-weight: 800; letter-spacing: .04em;
  background: var(--duo-green); color: #fff; box-shadow: 0 4px 0 var(--duo-green-d); text-transform: uppercase;
}
.btn-big:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.btn-big:disabled { background: var(--duo-gray); color: var(--duo-gray-d); box-shadow: 0 4px 0 var(--duo-gray-d); cursor: default; }
.btn.danger { color: var(--duo-red); border-color: var(--duo-red); }

/* 今日卡片 */
.today-card { background: var(--surface); border: 2px solid var(--border); border-radius: 20px; padding: 16px; margin-bottom: 20px; }
.today-top { display: flex; align-items: center; gap: 14px; }
.streak-big { font-size: 2rem; display: flex; align-items: center; gap: 4px; filter: grayscale(1); opacity: .6; }
.streak-big.lit { filter: none; opacity: 1; }
.streak-big b { font-size: 1.6rem; color: #ff9600; }
.goal { flex: 1; }
.goal-h { display: flex; justify-content: space-between; font-weight: 700; font-size: .9rem; color: var(--muted); }
.goal-bar { height: 14px; border-radius: 99px; background: var(--duo-gray); overflow: hidden; margin-top: 6px; }
.goal-bar > div { height: 100%; background: var(--duo-gold); border-radius: 99px; transition: width .5s; }
.week { display: flex; justify-content: space-between; margin: 14px 0 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 13%; }
.day .dl { font-size: .75rem; color: var(--muted); font-weight: 700; }
.day .dc { width: 32px; height: 32px; border-radius: 50%; background: var(--duo-gray); display: grid; place-items: center; font-size: 1rem; }
.day.on .dc { background: #ffe1b8; }
.day.today .dl { color: #ff9600; }
.day.today .dc { outline: 2px solid #ff9600; outline-offset: 2px; }
.plan-msg { text-align: center; color: var(--muted); margin: 10px 0 14px; font-size: .95rem; }

/* 單元與路徑節點 */
.unit { margin-bottom: 18px; }
.unit-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--uc); color: #fff; border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--uc) 70%, #000);
}
.unit-n { font-weight: 800; font-size: 1.1rem; }
.unit-t { opacity: .95; font-size: .9rem; }
.unit-syms { font-family: var(--font-kai); font-size: 1.15rem; text-align: right; }
.nodes { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 30px 0 8px; }
.node-wrap { display: flex; flex-direction: column; align-items: center; position: relative; }
.node {
  width: 72px; height: 66px; border-radius: 50%; border: 0; font-size: 1.8rem; color: #fff;
  background: var(--uc); box-shadow: 0 6px 0 color-mix(in srgb, var(--uc) 65%, #000);
}
.node:active { transform: translateY(5px); box-shadow: 0 1px 0 color-mix(in srgb, var(--uc) 65%, #000); }
.node.done { background: var(--duo-gold); box-shadow: 0 6px 0 var(--duo-gold-d); }
.node.locked { background: var(--duo-gray); box-shadow: 0 6px 0 var(--duo-gray-d); filter: grayscale(1); font-size: 1.4rem; }
.node.current { outline: 6px solid color-mix(in srgb, var(--uc) 30%, transparent); outline-offset: 4px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { outline-color: color-mix(in srgb, var(--uc) 10%, transparent); } }
.node-label { margin-top: 8px; font-size: .8rem; color: var(--muted); }
.bubble {
  position: absolute; top: -38px; background: var(--surface); color: var(--uc); font-weight: 800; font-size: .85rem;
  border: 2px solid var(--border); border-radius: 10px; padding: 4px 10px; animation: bob 1.2s ease-in-out infinite; white-space: nowrap;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; background: var(--surface);
  border-right: 2px solid var(--border); border-bottom: 2px solid var(--border); transform: translateX(-50%) rotate(45deg);
}
@keyframes bob { 50% { transform: translateY(-4px); } }
.review-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px; padding: 14px 16px;
}
.review-card p { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }

/* 課程畫面 */
.lesson { display: flex; flex-direction: column; min-height: 100dvh; margin: -16px -16px calc(-24px - env(safe-area-inset-bottom)); }
.lesson-top { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 12px) 16px 8px; }
.lesson-top .x { font-size: 1.3rem; color: var(--muted); }
.lbar { flex: 1; height: 16px; border-radius: 99px; background: var(--duo-gray); overflow: hidden; }
.lbar > div { height: 100%; background: var(--duo-green); border-radius: 99px; transition: width .4s; box-shadow: inset 0 4px 0 rgba(255, 255, 255, .3); }
.lesson-body { flex: 1; padding: 8px 16px 24px; }
.ex { max-width: 560px; margin: 0 auto; }
.ex-label { font-size: 1.35rem; font-weight: 800; margin: 8px 0 16px; }
.ex-label.new { color: #ce82ff; }
.ex-prompt { text-align: center; margin-bottom: 8px; }
.ex-prompt .emoji { font-size: 3rem; }
.ex .bigsym { font-family: var(--font-kai); font-size: 5rem; line-height: 1.1; text-align: center; }
.ex .bigsym.tone-mark { font-family: var(--font); color: var(--c-tone); }
.intro-card { text-align: center; background: var(--surface); border: 2px solid var(--border); border-radius: 20px; padding: 18px; }
.intro-card h3 { margin: 4px 0; }
.intro-card .tip { font-size: 1.05rem; }
.intro-ex { margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.intro-ex .emoji { font-size: 2.4rem; }
.play.small { width: 56px; height: 56px; font-size: 1.5rem; }
.ex .options .opt { border-width: 2px; border-bottom-width: 4px; border-radius: 14px; position: relative; }
.ex .options.latin .opt { font-family: var(--font); font-weight: 700; }
.opt-n {
  position: absolute; top: 6px; left: 8px; font-size: .7rem; color: var(--muted); font-family: var(--font);
  border: 1px solid var(--border); border-radius: 6px; padding: 0 5px;
}
.opt.sel { border-color: var(--duo-blue); background: color-mix(in srgb, var(--duo-blue) 12%, var(--surface)); color: var(--duo-blue); }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match .opt { min-height: 60px; border-bottom-width: 4px; border-radius: 14px; }
.match .opt.small { font-family: var(--font); font-weight: 700; }
.match .opt:disabled { opacity: .45; }

.lesson-foot {
  position: sticky; bottom: 0; border-top: 2px solid var(--border); background: var(--bg);
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px); transition: background .2s;
}
.lesson-foot.quiet { display: none; }
.foot-inner { max-width: 560px; margin: 0 auto; }
.lesson-foot.is-ok { background: var(--duo-green-bg); border-top-color: transparent; }
.lesson-foot.is-bad { background: var(--duo-red-bg); border-top-color: transparent; }
.lesson-foot.is-ok .foot-msg, .lesson-foot.is-bad .foot-msg { margin-bottom: 12px; font-size: 1.05rem; animation: rise .2s; }
.lesson-foot.is-ok .foot-msg { color: var(--duo-green-d); }
.lesson-foot.is-bad .foot-msg { color: var(--duo-red-d); }
.lesson-foot.is-bad .foot-msg div { font-family: var(--font-kai); font-size: 1.3rem; }
.lesson-foot.is-bad .btn-big { background: var(--duo-red); box-shadow: 0 4px 0 var(--duo-red-d); }
.py-inline { font-family: var(--font); font-size: .9rem; opacity: .8; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.ex .speller .kb { margin-top: 10px; }

.complete { text-align: center; padding: 40px 16px; max-width: 520px; margin: 0 auto; }
.complete-hero { font-size: 5rem; animation: pop .5s; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.15); } }
.complete h2 { color: var(--duo-gold-d); font-size: 1.7rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; margin: 18px 0; }
.tile { border: 2px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.tile-h { font-size: .72rem; font-weight: 800; padding: 4px; background: var(--surface-2); color: var(--muted); }
.tile.xp { border-color: var(--duo-gold); }
.tile.xp .tile-h { background: var(--duo-gold); color: #fff; }
.tile.acc { border-color: var(--duo-green); }
.tile.acc .tile-h { background: var(--duo-green); color: #fff; }
.tile.st { border-color: #ff9600; }
.tile.st .tile-h { background: #ff9600; color: #fff; }
.tile-v { font-size: 1.25rem; font-weight: 800; padding: 10px 4px; }
.complete-note { font-weight: 700; color: #ff9600; }
.complete .btn-big { margin-top: 20px; }

/* 我的 */
.weak { display: flex; flex-wrap: wrap; gap: 8px; }
.weak-sym {
  display: flex; flex-direction: column; align-items: center; border: 2px solid var(--duo-red); border-radius: 12px;
  background: var(--duo-red-bg); padding: 6px 12px; color: var(--duo-red-d);
}
.weak-sym span { font-family: var(--font-kai); font-size: 1.6rem; }
.weak-sym small { font-size: .72rem; }
.goals { display: grid; gap: 8px; }
.goal-opt {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center;
  border: 2px solid var(--border); border-radius: 14px; padding: 10px 14px; background: var(--surface); cursor: pointer;
}
.goal-opt input { grid-row: span 2; }
.goal-opt span { grid-column: 2; color: var(--muted); font-size: .85rem; }
.goal-opt em { grid-row: 1 / span 2; grid-column: 3; font-style: normal; font-weight: 800; color: var(--duo-gold-d); }
.goal-opt.sel { border-color: var(--duo-blue); background: color-mix(in srgb, var(--duo-blue) 8%, var(--surface)); }
.settings-list { border: 2px solid var(--border); border-radius: 14px; background: var(--surface); }
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; gap: 10px; }
.set-row + .set-row { border-top: 1px solid var(--border); }
.set-row input[type=checkbox] { width: 22px; height: 22px; }
.seg { display: flex; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; }
.seg button.sel { background: var(--duo-blue); color: #fff; }

/* 教學影片 */
.vlist { display: grid; gap: 10px; }
.vcard {
  display: flex; gap: 12px; text-align: left; padding: 10px; border: 2px solid var(--border);
  border-radius: 14px; background: var(--surface); align-items: flex-start;
}
.vthumb { position: relative; flex: 0 0 140px; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vplay {
  position: absolute; inset: 0; margin: auto; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; font-size: .9rem;
}
.vinfo { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.vinfo b { font-size: .95rem; line-height: 1.3; }
.vinfo small { color: var(--muted); }
.vinfo span { font-size: .85rem; color: var(--muted); line-height: 1.35; }
@media (max-width: 420px) { .vthumb { flex-basis: 112px; } }

.vmodal {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .75);
  display: grid; place-items: center; padding: 16px;
}
.vbox { width: min(900px, 100%); background: var(--surface); border-radius: 14px; overflow: hidden; }
.vframe { position: relative; aspect-ratio: 16 / 9; background: #000; }
.vframe iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
.vtitle { flex: 1; min-width: 0; font-weight: 700; font-family: var(--font); }
.vbar a { color: var(--duo-blue); font-weight: 700; text-decoration: none; }

/* 隱私權政策頁 */
.privacy section { background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 4px 18px 10px; margin-top: 14px; }
.privacy h1 { font-size: 1.3rem; }
.privacy .muted { color: var(--muted); }
html.native .install { display: none !important; }
.nowrap { white-space: nowrap; }
