/* YHQ study site. Mobile first. Light theme, dark mode by system setting. */
:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #eaf0f4;
  --text: #17242d;
  --muted: #5d6f7b;
  --line: #d6e0e6;
  --primary: #1f6f8b;
  --primary-ink: #ffffff;
  --primary-soft: #dcecf2;
  --good: #1e8a4c;
  --good-soft: #dff3e6;
  --bad: #c0392b;
  --bad-soft: #fbe3df;
  --warn: #9a6a00;
  --warn-soft: #fff1cf;
  --hl: #fff3b0;
  --shadow: 0 1px 2px rgba(20, 40, 55, .08), 0 4px 14px rgba(20, 40, 55, .05);
  --radius: 14px;
  --tap: 52px;
  --road-line: #f5c542;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181d;
    --surface: #1a242b;
    --surface-2: #232f38;
    --text: #e6eef3;
    --muted: #9bb0bd;
    --line: #2f3f4a;
    --primary: #4fb0d0;
    --primary-ink: #08222c;
    --primary-soft: #1d3641;
    --good: #52c783;
    --good-soft: #17352559;
    --bad: #ef7d6f;
    --bad-soft: #3d1f1c;
    --warn: #e5b94e;
    --warn-soft: #3a2f10;
    --hl: #4a4217;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: .4rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
.h-small { font-size: 1.1rem; color: var(--muted); font-weight: 600; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 10px; }
.lead { font-size: 1.05rem; color: var(--muted); }
.sec { margin-top: 1.6rem; }
.sec-title { margin: 2rem 0 .5rem; padding-bottom: .3rem; border-bottom: 2px solid var(--line); }

/* ---- header ---- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-in {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
}
.brand { text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
/* logo: a small road with a dashed center line */
.logo {
  flex: none; width: 34px; height: 34px; border-radius: 10px; position: relative;
  background: linear-gradient(135deg, var(--primary), #134b5f);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
}
.logo::after {
  content: ""; position: absolute; left: 50%; top: 6px; bottom: 6px; width: 3px; margin-left: -1.5px;
  background: repeating-linear-gradient(to bottom, var(--road-line) 0 5px, transparent 5px 9px);
  border-radius: 2px;
}
.brand strong { font-size: 1.25rem; color: var(--primary); letter-spacing: .5px; }
.brand-sub { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.langs { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.lang-btn {
  border: 0; background: transparent; color: var(--text); font: inherit; font-size: .9rem; font-weight: 600;
  min-height: 40px; min-width: 48px; padding: 0 10px; border-radius: 10px; cursor: pointer;
}
.lang-btn.on { background: var(--primary); color: var(--primary-ink); }
.gear { display: grid; place-items: center; width: 44px; height: 44px; color: var(--muted); border-radius: 12px; }
.gear:hover { background: var(--surface-2); }
@media (max-width: 420px) { .brand-sub { display: none; } }

/* ---- layout ---- */
.app { max-width: 760px; margin: 0 auto; padding: 8px 16px 24px; }
.page { padding-top: 6px; }
.back { display: inline-block; padding: 10px 0; text-decoration: none; font-weight: 600; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card.note { background: var(--primary-soft); border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid2 { grid-template-columns: 1fr; } }
.quick { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); min-height: 84px; transition: border-color .15s, transform .1s; }
.quick:hover { border-color: var(--primary); }
.quick:active { transform: scale(.98); }
.qtxt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.quick strong { color: var(--text); font-size: 1.05rem; }
.qico { flex: none; width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; }
.t-blue  { background: var(--primary-soft); color: var(--primary); }
.t-amber { background: var(--warn-soft); color: var(--warn); }
.t-green { background: var(--good-soft); color: var(--good); }
.t-red   { background: var(--bad-soft); color: var(--bad); }
.disclaimer { color: var(--muted); font-size: .88rem; margin-top: 24px; padding: 12px 14px; border-left: 4px solid var(--line); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
  min-height: var(--tap); padding: 8px 18px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; }
.btn-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-link { border: 0; background: transparent; color: var(--muted); text-decoration: underline; min-height: 44px; }
.btn-wide { width: 100%; margin-top: 10px; }
.btn-big { width: 100%; min-height: 64px; flex-direction: column; font-size: 1.1rem; margin: 14px 0; }
.btn-small { font-size: .8rem; font-weight: 500; opacity: .9; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.soon { color: var(--muted); font-size: .92rem; padding: 0 4px; }

/* ---- home ---- */
.hero { display: grid; place-items: center; padding: 18px 0 6px; }
.ring {
  --p: 0;
  width: 190px; height: 190px; border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
}
.ring-in {
  width: 152px; height: 152px; border-radius: 50%; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-num { font-size: 2.8rem; font-weight: 800; line-height: 1; color: var(--primary); }
.ring-label { font-size: .82rem; color: var(--muted); margin-top: 6px; }

/* ---- learn path ---- */
.steps { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 12px; }
.step-head { display: flex; gap: 12px; align-items: flex-start; }
.step-num {
  flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}
.step-title { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
/* the "road": a dashed line joining the step numbers */
.step { position: relative; }
.step:not(:last-child)::before {
  content: ""; position: absolute; left: 31px; top: 100%; height: 13px; width: 3px; margin-top: 1px;
  background: repeating-linear-gradient(to bottom, var(--road-line) 0 4px, transparent 4px 7px);
  opacity: .7;
}
.step.st-read .step-num { background: var(--primary); color: var(--primary-ink); }
.step.st-pass .step-num { background: var(--good); color: #fff; }
.step.st-pass { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.step .actions { margin: 12px 0 0; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.st-read { background: var(--primary-soft); color: var(--primary); }
.st-pass { background: var(--good-soft); color: var(--good); }
.st-fail { background: var(--bad-soft); color: var(--bad); }

/* ---- reading ---- */
.rules-text { margin: 10px 0 20px; }
.point {
  display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 0 0 12px; scroll-margin-top: 80px;
}
.point-plain { background: transparent; border-style: dashed; }
.pnum {
  flex: none; min-width: 2.4em; height: 2.4em; padding: 0 6px; border-radius: 10px;
  background: var(--primary); color: var(--primary-ink); font-weight: 800; display: grid; place-items: center; font-size: .95rem;
}
.ptext { min-width: 0; flex: 1; }
.para { white-space: pre-line; overflow-wrap: anywhere; margin: .4rem 0; }
.ptext > .para:first-child { margin-top: 0; }
.point.hl { background: var(--hl); border-color: var(--primary); animation: pulse 1.6s ease-out 1; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--primary); } 100% { box-shadow: 0 0 0 14px transparent; } }
.source { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; margin-top: 24px; }
.ref-link {
  display: inline-block; font-size: .85rem; font-weight: 700; text-decoration: none;
  background: var(--primary-soft); color: var(--primary); padding: 3px 12px; border-radius: 99px;
}

/* ---- lesson ---- */
.cards { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.lesson-card p { margin-top: 0; }

/* ---- quiz ---- */
.qmeta { color: var(--muted); font-size: .9rem; margin: 8px 0 6px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width .25s; }
.qcard { margin: 14px 0; }
.qtext { font-size: 1.12rem; font-weight: 600; margin: 0; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  min-height: var(--tap); padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.opt:disabled { cursor: default; opacity: 1; color: var(--text); }
.opt-letter {
  flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); color: var(--muted);
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}
.opt-text { flex: 1; overflow-wrap: anywhere; padding-top: 2px; }
.opt-idle:hover { border-color: var(--primary); }
.opt-selected { border-color: var(--primary); background: var(--primary-soft); }
.opt-selected .opt-letter { background: var(--primary); color: var(--primary-ink); }
.opt-right { border-color: var(--good); background: var(--good-soft); }
.opt-right .opt-letter { background: var(--good); color: #fff; }
.opt-wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt-wrong .opt-letter { background: var(--bad); color: #fff; }
.opt-missed { border-color: var(--good); border-style: dashed; background: var(--good-soft); }
.opt-dim { opacity: .55 !important; }
.feedback { margin: 16px 0; padding: 14px 16px; border-radius: var(--radius); border: 2px solid; }
.fb-right { border-color: var(--good); background: var(--good-soft); }
.fb-wrong { border-color: var(--bad); background: var(--bad-soft); }
.fb-right > strong { color: var(--good); }
.fb-wrong > strong { color: var(--bad); }
.explain { margin-top: .6rem; }
.result { text-align: center; padding: 24px 16px; margin: 12px 0; }
.res-pct { font-size: 3rem; font-weight: 800; line-height: 1.1; }
.res-pass .res-pct, .res-pass .res-msg { color: var(--good); }
.res-fail .res-pct, .res-fail .res-msg { color: var(--bad); }
.res-pass { border-color: var(--good); }
.res-fail { border-color: var(--bad); }
.res-score { font-size: 1.15rem; margin-top: 6px; }
.res-msg { font-weight: 700; }
.txt-good { color: var(--good); }
.txt-bad { color: var(--bad); }

/* ---- exam ---- */
.exam-bar { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; }
.timer { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.timer-low { color: var(--bad); }
.dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.dot {
  width: 34px; height: 34px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; padding: 0;
}
.dot-done { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft); }
.dot-cur { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); color: var(--text); }
.exam-nav { display: flex; gap: 10px; margin: 16px 0 6px; }
.exam-nav .btn { flex: 1; }
.hist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.hist-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; }
.review { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.rev { border-left-width: 6px; }
.rev-ok { border-left-color: var(--good); }
.rev-bad { border-left-color: var(--bad); }
.rev-head { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.rev-n { font-weight: 800; color: var(--muted); }
.rev-line { margin: .3rem 0; }

/* ---- signs ---- */
.sign-list { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.sign-card { display: flex; gap: 14px; align-items: flex-start; }
.sign-card.is-known { border-color: var(--good); }
.sign-info { flex: 1; min-width: 0; }
.sign-num { font-size: .8rem; font-weight: 800; color: var(--primary); }
.sign-name { display: block; }
.sign-desc { margin-top: 6px; }
.sign-desc summary { cursor: pointer; color: var(--primary); font-weight: 600; padding: 6px 0; min-height: 36px; }
.sign-img {
  flex: none; width: 84px; height: 84px; border-radius: 14px; background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center; overflow: hidden;
}
.sign-img img { width: 100%; height: 100%; object-fit: contain; }
.sign-img-big { width: 150px; height: 150px; margin: 0 auto; }
.sign-ph { background: var(--surface-2); color: var(--muted); font-weight: 800; font-size: 1.1rem; text-align: center; }
.sign-img-big.sign-ph { font-size: 1.8rem; }
.flash-card {
  display: block; width: 100%; text-align: center; padding: 20px 14px; margin: 14px 0; cursor: pointer;
  min-height: 300px; font: inherit; color: var(--text);
}
.flash-card h2 { margin: 10px 0; }
.flash-card .para { text-align: left; }
.flash-front { display: flex; flex-direction: column; justify-content: center; gap: 18px; min-height: 260px; }
.flash-back { text-align: center; }
.flash-actions { display: flex; gap: 12px; }
.flash-actions .btn { flex: 1; min-height: 60px; }

/* ---- settings ---- */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-btn {
  flex: 1; min-width: 100px; min-height: var(--tap); border-radius: 14px; border: 2px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
}
.seg-btn.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---- bottom tabs ---- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  position: relative; flex: 1; max-width: 152px; min-height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600;
}
.tab.on { color: var(--primary); }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.ico { display: grid; }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--bad); color: #fff; font-size: .7rem; line-height: 18px; text-align: center;
}

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
