/* EngSpeak HK v2 — modern light design */
:root {
  --bg: #f5f6fb; --card: #ffffff; --ink: #1b2138; --muted: #7a83a0;
  --brand1: #6366f1; --brand2: #a855f7; --teal: #0ea5a4; --green: #16a34a;
  --red: #e11d48; --amber: #d97706; --line: #e8eaf3;
  --shadow: 0 6px 24px rgba(35, 46, 89, .08);
  --grad: linear-gradient(135deg, var(--brand1), var(--brand2));
  --r: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang HK", "Noto Sans TC", sans-serif;
  font-size: 16px; line-height: 1.6; min-height: 100%;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}
#main { max-width: 620px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 16px 16px; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
h1 { font-size: 26px; letter-spacing: -.3px; }
h2 { font-size: 21px; letter-spacing: -.3px; }
h3 { font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.spacer { height: 10px; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 0 16px; }
.topbar h2 { flex: 1; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 14px; border: 0; background: var(--card);
  box-shadow: var(--shadow); font-size: 17px; color: var(--ink); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.pill { background: var(--card); box-shadow: var(--shadow); border: 0; border-radius: 999px; padding: 8px 15px; font-size: 13px; font-weight: 600; color: var(--brand1); }

/* cards */
.card { background: var(--card); border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.tappable:active { transform: scale(.98); transition: transform .08s; }
.hero {
  background: var(--grad); color: #fff; border-radius: 24px; padding: 22px 20px;
  margin-bottom: 16px; box-shadow: 0 10px 30px rgba(99, 102, 241, .3); position: relative; overflow: hidden;
}
.hero::after { content: ''; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hero .hi { font-size: 22px; font-weight: 700; }
.hero .sub { opacity: .92; font-size: 14px; margin-top: 2px; }
.hero .chips { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.hero .chip { background: rgba(255,255,255,.2); backdrop-filter: blur(4px); border-radius: 999px; padding: 5px 13px; font-size: 13px; font-weight: 600; }

/* menu rows */
.menu { display: flex; align-items: center; gap: 14px; }
.menu .ic { width: 48px; height: 48px; border-radius: 15px; display: flex; align-items: center; justify-content: center; font-size: 23px; flex-shrink: 0; }
.ic.indigo { background: #eef0ff; } .ic.teal { background: #e6f7f6; } .ic.rose { background: #fdeef2; }
.ic.amber { background: #fdf3e3; } .ic.green { background: #eaf7ee; } .ic.violet { background: #f6eefe; }
.menu .tx { flex: 1; min-width: 0; }
.menu .tt { font-weight: 700; font-size: 16px; }
.menu .ds { color: var(--muted); font-size: 13px; }
.menu .arrow { color: #c3c9dd; font-size: 20px; }
.badge { background: var(--red); color: #fff; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.badge.ok { background: var(--green); }

/* couple */
.couple { display: flex; gap: 12px; }
.couple .half { flex: 1; text-align: center; border-radius: 15px; padding: 12px 8px; background: #f3f4fb; }
.couple .half.me { background: #eef0ff; }
.couple .nm { font-size: 13px; color: var(--muted); font-weight: 600; }
.couple .mn { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.couple .st { font-size: 12px; color: var(--muted); }

/* buttons */
.btn { display: block; width: 100%; border: 0; border-radius: 15px; padding: 14px; font-size: 16px; font-weight: 700; }
.btn.grad { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,.35); }
.btn.soft { background: #eef0ff; color: var(--brand1); }
.btn.line { background: var(--card); border: 1.5px solid var(--line); color: var(--ink); }
.btn:active { transform: scale(.98); }
.btn.sm { width: auto; padding: 9px 16px; font-size: 14px; border-radius: 12px; }
.btnrow { display: flex; gap: 10px; }
.btnrow .btn { flex: 1; }
#toTop {
  position: fixed; right: 18px; bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 60; width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: var(--grad); color: #fff; box-shadow: 0 10px 28px rgba(99,102,241,.32);
  font-size: 24px; font-weight: 800; line-height: 1; opacity: 0; transform: translateY(12px) scale(.94);
  pointer-events: none; transition: opacity .18s ease, transform .18s ease;
}
#toTop.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* inputs */
input, textarea, select {
  background: var(--card); border: 1.5px solid var(--line); color: var(--ink);
  border-radius: 14px; padding: 13px 14px; font-size: 16px; width: 100%; font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--brand1); }
textarea { min-height: 110px; resize: vertical; }

/* login */
.login-wrap { min-height: 88vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; max-width: 340px; margin: 0 auto; }
.logo-big { text-align: center; margin-bottom: 8px; }
.logo-big .em { font-size: 56px; display: block; }
.logo-big h1 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.who-row { display: flex; gap: 12px; }
.who { flex: 1; background: var(--card); border: 2px solid var(--line); border-radius: var(--r); font-size: 15px; font-weight: 700; padding: 16px 6px; color: var(--ink); box-shadow: var(--shadow); }
.who .em { font-size: 30px; display: block; margin-bottom: 4px; }
.who.sel { border-color: var(--brand1); background: #eef0ff; }
.err { color: var(--red); font-size: 14px; min-height: 20px; text-align: center; }

/* news */
.tag { font-size: 11px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; border-radius: 7px; padding: 2px 8px; display: inline-block; margin-bottom: 6px; }
.tag.local{background:#eef0ff;color:#5158d8}.tag.international{background:#e6f2fd;color:#1272c4}
.tag.education{background:#eaf7ee;color:#178041}.tag.tech{background:#f6eefe;color:#8b2fd6}
.tag.football{background:#eaf7ee;color:#0f7a4d}.tag.engineering{background:#fdf3e3;color:#b56a08}
.tag.ai{background:#fdeef2;color:#cf2960}
.news-h { font-size: 17px; font-weight: 700; line-height: 1.4; }
.news-zh { color: var(--muted); font-size: 14px; margin-top: 3px; }
.art-title { font-size: 21px; font-weight: 800; line-height: 1.35; letter-spacing: -.3px; }
.art-en { font-size: 17px; line-height: 1.85; margin: 14px 0; }
.zh-block { background: #f3f4fb; border-radius: 14px; padding: 12px 14px; color: #5a6382; font-size: 15px; margin: 10px 0; }
.art-bilingual { margin: 14px 0; }
.reading-pair { margin: 0 0 16px; }
.en-sentence { font-size: 17px; line-height: 1.8; margin: 0 0 6px; color: var(--ink); }
.zh-sentence { font-size: 15px; line-height: 1.65; margin: 0; color: #5a6382; transition: filter .18s ease, opacity .18s ease; }
.zh-sentence.blurred { filter: blur(5px); opacity: .62; user-select: none; }
.show-zh-sentences .zh-sentence.blurred { filter: none; opacity: 1; user-select: text; }
.seg-ctrl { display: flex; background: #ecEEf7; background: #eceef7; border-radius: 12px; padding: 3px; margin: 10px 0; }
.seg-ctrl button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 8px 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg-ctrl button.sel { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(35,46,89,.1); }
.gcard { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.gcard:last-child { border-bottom: 0; }
.gcard .gw { font-weight: 800; color: var(--brand1); }
.gcard .add { margin-left: auto; flex-shrink: 0; background: #eef0ff; color: var(--brand1); border: 0; border-radius: 10px; padding: 6px 12px; font-weight: 700; font-size: 13px; }
.gcard .mini-actions { margin-left: auto; display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.gcard .mini-actions .add { margin-left: 0; min-width: 52px; padding: 6px 8px; }
.choice { display: block; width: 100%; text-align: left; background: #f3f4fb; color: var(--ink); border: 1.5px solid transparent; border-radius: 13px; padding: 11px 14px; margin-top: 8px; font-size: 15px; }
.choice.right { background: #eaf7ee; border-color: var(--green); }
.choice.wrong { background: #fdeef2; border-color: var(--red); }

/* vocab */
.vcard { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 30px 20px; text-align: center; margin-bottom: 14px; min-height: 210px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.vcard .w { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.grades { display: flex; gap: 10px; }
.grades button { flex: 1; border: 0; border-radius: 14px; padding: 13px; font-size: 15px; font-weight: 700; color: #fff; }
.g-again { background: var(--red); } .g-good { background: var(--brand1); } .g-easy { background: var(--green); }

/* chat */
.scen-bar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.scen-bar::-webkit-scrollbar { display: none; }
.scen-bar button { white-space: nowrap; background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.scen-bar button.sel { border-color: var(--brand1); color: var(--brand1); background: #eef0ff; }
.chat-log { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 12px; min-height: 38vh; }
.msg { max-width: 86%; padding: 11px 15px; border-radius: 18px; font-size: 15px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.msg.ai { align-self: flex-start; background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
.msg.sys { align-self: center; color: var(--muted); font-size: 13px; }
.msg .spk { border: 0; background: none; font-size: 15px; padding: 0 0 0 6px; }
.chat-row { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: calc(78px + env(safe-area-inset-bottom)); }
.chat-row input { flex: 1; }
.micbtn {
  width: 52px; height: 52px; border-radius: 50%; border: 0; font-size: 22px; flex-shrink: 0;
  background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.4);
  display: flex; align-items: center; justify-content: center;
}
.micbtn.rec { background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(225,29,72,.45)} 70%{box-shadow:0 0 0 16px rgba(225,29,72,0)} 100%{box-shadow:0 0 0 0 rgba(225,29,72,0)} }
.sendbtn { width: 52px; height: 52px; border-radius: 50%; border: 0; font-size: 19px; background: var(--card); box-shadow: var(--shadow); color: var(--brand1); flex-shrink: 0; }
.fb { border-left: 4px solid var(--brand1); }
.fb h4 { color: var(--green); margin: 10px 0 4px; font-size: 15px; }
.fb .imp { margin: 8px 0; padding: 9px 12px; background: #fdf8ec; border-radius: 12px; font-size: 14px; }

/* learn hub */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin-bottom: 0; text-align: center; padding: 18px 10px; }
.grid2 .em { font-size: 30px; display: block; margin-bottom: 6px; }
.grid2 .tt { font-weight: 700; font-size: 15px; }
.grid2 .ds { color: var(--muted); font-size: 12px; }

/* yt player */
.ytwrap { position: relative; padding-top: 56.25%; border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 12px; background: #000; }
.ytwrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ytposter { background-size: cover; background-position: center; }
.ytposter::before { content: ''; position: absolute; inset: 0; background: rgba(12, 16, 32, .42); }
.ytshade {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; padding: 18px; text-align: center; color: #fff;
}
.ytshade .muted { color: rgba(255,255,255,.82); font-size: 12px; max-width: 360px; }
.ytplay, .ytopen {
  border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 800; font-size: 15px;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
}
.ytplay { background: #fff; color: var(--ink); }
.ytopen { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.line-item { padding: 10px 12px; border-radius: 13px; margin-bottom: 6px; background: var(--card); box-shadow: var(--shadow); }
.line-item.now { outline: 2px solid var(--brand1); }
.line-item .en { font-size: 15px; font-weight: 600; }
.line-item .zh { font-size: 13px; color: var(--muted); }
.line-item .tools { display: flex; gap: 8px; margin-top: 6px; }
.line-item .tools button { background: #f3f4fb; border: 0; border-radius: 9px; padding: 5px 11px; font-size: 12px; font-weight: 700; color: var(--brand1); }
.score-big { font-size: 40px; font-weight: 800; text-align: center; }
.worddots span { display: inline-block; margin: 2px 3px; padding: 3px 9px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.worddots .hit { background: #eaf7ee; color: var(--green); }
.worddots .miss { background: #fdeef2; color: var(--red); }

/* interview */
.iq-comp { font-size: 12px; font-weight: 800; color: var(--amber); letter-spacing: .5px; }
.star-row { display: flex; gap: 8px; margin: 8px 0; }
.star-row span { flex: 1; text-align: center; border-radius: 10px; padding: 6px 2px; font-size: 12px; font-weight: 700; background: #fdeef2; color: var(--red); }
.star-row span.on { background: #eaf7ee; color: var(--green); }

/* report */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin: 12px 0 4px; }
.bars .b { flex: 1; background: var(--grad); border-radius: 7px 7px 3px 3px; min-height: 4px; opacity: .85; }
.bars-lab { display: flex; gap: 6px; }
.bars-lab span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.levelbar { height: 10px; border-radius: 999px; background: #eceef7; overflow: hidden; margin: 8px 0 4px; }
.levelbar i { display: block; height: 100%; background: var(--grad); border-radius: 999px; }

/* tabbar */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 50;
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}
#tabbar button { flex: 1; background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 600; line-height: 1.3; border-radius: 12px; padding: 4px 0; }
#tabbar .ti { display: block; font-size: 20px; filter: grayscale(1) opacity(.55); }
#tabbar button.sel { color: var(--brand1); }
#tabbar button.sel .ti { filter: none; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 20px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 99; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.skel { background: linear-gradient(90deg,#eceef7 25%,#f5f6fb 50%,#eceef7 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; height: 60px; margin-bottom: 10px; }
@keyframes sk { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
