/* 速算技巧 · Mental Maths Tricks — the module's own stylesheet.
 *
 * The same palette, type and shapes the station and the other modules use (styles.css,
 * maths/styles.css), so a child moving between lessons is not walking into a different-looking
 * site. Nothing here is shared with the station's stylesheet: the module is framed on its own
 * page and has to stand up on its own, exactly like the maths and copybook modules. */
:root{
  --navy:#173b70; --blue:#2f6df6; --sky:#eaf3ff; --yellow:#ffd75e;
  --ink:#17233f; --muted:#6b7890; --line:#dbe5f1; --bg:#f4f8fd;
  --ok:#28a879; --ok-soft:#eafaf5; --ok-line:#bfe3cd;
  --red:#df5b63; --red-soft:#fdeff0;
  --card:#fff;
  --shadow:0 14px 34px rgba(28,62,110,.10);
  --shadow-soft:0 1px 2px rgba(23,59,112,.06), 0 8px 24px rgba(23,59,112,.07);
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0; padding:0;}
body{
  font-family:system-ui,-apple-system,"Segoe UI","Helvetica Neue",Arial,"PingFang SC","Microsoft YaHei",sans-serif;
  font-size:16px; line-height:1.5; background:var(--bg); color:var(--ink);
  padding:calc(14px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
  min-height:100vh;
}
h1{font-size:1.45rem; font-weight:850; letter-spacing:-.02em; color:var(--navy); margin:0;}
h2{font-size:1.05rem; font-weight:850; color:var(--navy); margin:0 0 8px;}
p{margin:0 0 10px;}
button{font:inherit; color:inherit; cursor:pointer;}
input{font:inherit;}

/* ------------------------------------------------------------------ header */
header.top{display:flex; align-items:center; gap:10px; margin-bottom:14px;}
.brand{display:flex; align-items:center; gap:10px; border:0; background:none; padding:0; text-align:left;}
.brand-mark{
  width:38px; height:38px; border-radius:12px; background:var(--navy); color:var(--yellow);
  display:grid; place-items:center; font-weight:900; font-size:1.1rem; flex:0 0 38px;
}
.brand .t{display:block; font-size:.72rem; font-weight:900; letter-spacing:.12em; text-transform:uppercase; color:var(--blue);}
.brand strong{display:block; font-size:1.06rem; letter-spacing:-.01em; color:var(--navy); font-weight:850;}
.lang{margin-left:auto; display:flex; gap:6px;}
.lang button{
  border:1px solid var(--line); background:#fff; border-radius:11px; padding:8px 12px;
  font-size:13px; font-weight:800; color:var(--navy); transition:.16s;
}
.lang button.active{background:var(--navy); border-color:var(--navy); color:#fff;}

.wrap{width:min(880px,100%); margin:0 auto;}
.view{display:none;}
.view.on{display:block;}

/* ------------------------------------------------------------------ panels and buttons */
.panel{background:var(--card); border:1px solid var(--line); border-radius:20px; padding:18px; box-shadow:var(--shadow-soft); margin-bottom:16px;}
.lead{background:linear-gradient(160deg,#fff,#f3f8ff); border:1px solid var(--line); border-radius:20px; padding:18px; box-shadow:var(--shadow-soft); margin-bottom:18px;}
.lead h2{font-size:1.12rem;}
.lead ul{margin:8px 0 0; padding-left:20px; color:var(--muted); font-size:.92rem;}
.lead li{margin:4px 0;}
.primary,.ghost{border-radius:14px; padding:13px 18px; font-weight:850; border:1px solid transparent; transition:.16s;}
.primary{background:var(--blue); color:#fff;}
.primary:hover{filter:brightness(1.05);}
.primary[disabled]{opacity:.45; cursor:default;}
.ghost{background:var(--sky); color:var(--navy); border-color:transparent;}
.ghost:hover{border-color:#a9c4ea;}
.small{padding:9px 13px; font-size:.86rem; border-radius:12px;}
.row{display:flex; gap:10px; flex-wrap:wrap; align-items:center;}
.spacer{margin-left:auto;}

/* ------------------------------------------------------------------ the list of tricks */
.group{margin:22px 0 0;}
.group-head{display:flex; align-items:center; gap:10px; margin-bottom:10px;}
.group-head h2{margin:0;}
.group-head .zh{color:var(--muted); font-size:.9rem; font-weight:700;}
.group-head .count{margin-left:auto; font-size:.82rem; font-weight:800; color:var(--blue); white-space:nowrap;}
.trick-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:12px;}
.trick{
  border:1px solid var(--line); background:var(--card); border-radius:17px; padding:14px;
  text-align:left; display:block; box-shadow:var(--shadow-soft); transition:.16s;
}
.trick:hover{border-color:#a9c4ea; transform:translateY(-2px);}
.trick .top{display:flex; align-items:flex-start; gap:9px;}
.trick .no{
  flex:0 0 auto; min-width:30px; height:30px; border-radius:10px; background:var(--sky); color:var(--navy);
  font-weight:900; font-size:.82rem; display:grid; place-items:center; padding:0 7px;
}
.trick .no.added{background:#fff5d6; color:#8a6100;}
.trick .titles{flex:1; min-width:0;}
.trick .titles strong{display:block; font-size:.98rem; font-weight:800; letter-spacing:-.01em;}
.trick .titles small{display:block; color:var(--muted); font-size:.8rem; margin-top:1px;}
.trick .tick{color:var(--ok); font-weight:900;}
.bar{height:7px; background:#e8eef6; border-radius:99px; overflow:hidden; margin:11px 0 7px;}
.bar i{display:block; height:100%; width:0; border-radius:inherit; background:linear-gradient(90deg,var(--blue),#53b8ff); transition:width .35s;}
.bar.done i{background:linear-gradient(90deg,var(--ok),#5ed0a6);}
.trick .foot{display:flex; justify-content:space-between; font-size:.78rem; color:var(--muted); font-weight:700;}
.trick.done{background:var(--ok-soft); border-color:var(--ok-line);}

/* ------------------------------------------------------------------ the trick screen */
.back{border:0; background:none; color:var(--blue); font-weight:800; padding:6px 0 12px;}
.trick-head{display:flex; align-items:flex-start; gap:11px; margin-bottom:12px;}
.trick-head .no{flex:0 0 auto; min-width:38px; height:38px; border-radius:12px; background:var(--navy); color:var(--yellow); font-weight:900; display:grid; place-items:center; padding:0 9px;}
.trick-head .no.added{background:var(--yellow); color:#6b4a00;}
.trick-head h1{font-size:1.28rem;}
.trick-head .en{display:block; color:var(--muted); font-weight:700; font-size:.88rem; margin-top:2px;}
.idea{font-size:1rem; font-weight:700; color:var(--navy); background:var(--sky); border-radius:14px; padding:12px 14px; margin:0 0 10px;}
.idea-en{color:var(--muted); font-size:.9rem; margin:0;}
ol.method{margin:10px 0 0; padding-left:22px;}
ol.method li{margin:5px 0; font-size:.94rem;}
.demo{margin-top:12px; border:1px dashed #c9d9ee; border-radius:14px; padding:12px 14px; background:#fbfdff;}
.demo .q{font-size:1.15rem; font-weight:850; color:var(--navy); margin-bottom:6px;}
.demo ol{margin:0; padding-left:20px; color:var(--muted); font-size:.9rem;}
.demo .ans{font-weight:850; color:var(--ok);}
.teach-foot{margin-top:12px;}

.qcard{background:var(--card); border:1px solid var(--line); border-radius:20px; padding:18px; box-shadow:var(--shadow); margin-bottom:16px;}
.qtop{display:flex; align-items:center; gap:10px; font-size:.82rem; font-weight:800; color:var(--muted);}
.qtop .dots{display:flex; gap:4px; margin-left:auto;}
.dot{width:9px; height:9px; border-radius:99px; background:#e2eaf5;}
.dot.on{background:var(--blue);}
.dot.right{background:var(--ok);}
.dot.wrong{background:var(--red);}
.qtext{font-size:clamp(1.6rem,7vw,2.4rem); font-weight:900; letter-spacing:.01em; color:var(--navy); margin:14px 0 4px; text-align:center; word-break:break-word;}
.qsub{text-align:center; color:var(--muted); font-size:.86rem; margin-bottom:14px;}
.answer{
  display:flex; gap:9px; align-items:center; justify-content:center; flex-wrap:wrap;
}
.answer input{
  width:min(260px,100%); border:2px solid var(--line); border-radius:15px; padding:13px 15px;
  background:#fbfdff; outline:none; font-size:1.35rem; font-weight:800; text-align:center;
  font-variant-numeric:tabular-nums;
}
.answer input:focus{border-color:var(--blue); box-shadow:0 0 0 4px #e6efff;}
.answer input.good{border-color:var(--ok); background:var(--ok-soft);}
.answer input.bad{border-color:var(--red); background:var(--red-soft);}
.answer button{width:auto; margin:0; padding:14px 22px;}
.feedback{min-height:24px; margin:12px 0 0; font-weight:800; text-align:center;}
.feedback.good{color:var(--ok);}
.feedback.bad{color:var(--red);}
.feedback .steps{display:block; font-weight:700; color:var(--muted); margin-top:8px;}
.qfoot{display:flex; justify-content:center; gap:10px; margin-top:12px; flex-wrap:wrap;}

.summary{text-align:center;}
.summary .big{font-size:2.6rem; font-weight:900; color:var(--navy); margin:6px 0;}

/* ------------------------------------------------------------------ the question's own AI teacher */
.teacher{background:linear-gradient(170deg,#fff,#f6faff); border:1px solid var(--line); border-radius:20px; padding:16px; box-shadow:var(--shadow-soft); margin-bottom:16px;}
.teacher-head{display:flex; align-items:center; gap:9px;}
.teacher-head .face{width:34px; height:34px; border-radius:12px; background:var(--navy); color:var(--yellow); display:grid; place-items:center; font-size:1rem;}
.teacher-head strong{display:block; font-size:.96rem; color:var(--navy);}
.teacher-head small{display:block; color:var(--muted); font-size:.78rem;}
.teacher-head .scope{margin-left:auto; background:var(--sky); color:var(--navy); border-radius:99px; padding:5px 10px; font-size:.74rem; font-weight:800; white-space:nowrap;}
.log{margin:12px 0; display:flex; flex-direction:column; gap:8px; max-height:340px; overflow:auto;}
.msg{border-radius:14px; padding:10px 13px; font-size:.92rem; line-height:1.55; white-space:pre-wrap; word-break:break-word;}
.msg.teacher{background:var(--sky); color:var(--navy);}
.msg.child{background:#eef2f8; color:var(--ink); align-self:flex-end; max-width:88%;}
.msg.note{background:#fff8e2; color:#7a5a00; font-size:.86rem;}
.ask{display:flex; gap:8px;}
.ask input{
  flex:1; min-width:0; border:1px solid var(--line); border-radius:13px; padding:12px 14px;
  background:#fff; outline:none;
}
.ask input:focus{border-color:var(--blue); box-shadow:0 0 0 3px #e6efff;}
.ask button{flex:0 0 auto; padding:12px 16px;}
.status{color:var(--muted); font-size:.78rem; margin:9px 0 0;}

/* ------------------------------------------------------------------ small screens */
@media(max-width:640px){
  body{padding-left:11px; padding-right:11px;}
  .trick-grid{grid-template-columns:1fr;}
  .qtext{font-size:1.7rem;}
  .answer input{width:100%;}
  .answer{flex-direction:column; align-items:stretch;}
  .answer button{width:100%;}
  .trick-head h1{font-size:1.12rem;}
}
@media(prefers-reduced-motion:reduce){
  *{transition:none !important;}
}
