:root {
  color-scheme: light;
  --bg: #F0EEE6; --surface: #E2DCCE; --surface-2: #FAF9F5;
  --text: #141413; --muted: #5F5E57; --line: rgba(20,20,19,.13); --hover: rgba(20,20,19,.06);
  --accent: #C96442; --accent-ink: #9A4527; --accent-soft: rgba(201,100,66,.12);
  --done: #3D7A52; --done-soft: rgba(61,122,82,.13); --danger: #B3261E; --danger-soft: rgba(179,38,30,.1);
  --sans: "Noto Sans JP", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", Roboto, sans-serif;
  --serif: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(.2,.8,.2,1);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; line-height: 1.55; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: rgba(201,100,66,.28); }
a { color: inherit; }
ruby rt { font-size: .5em; color: var(--muted); font-weight: 400; letter-spacing: 0; }
body.no-furi rt { display: none; }

/* ===== Thanh trên ===== */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: rgba(240,238,230,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.home { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 10px; background: var(--hover); font-size: .85rem; color: var(--muted); text-decoration: none; transition: background .2s, color .2s; }
.home:hover { background: var(--surface); color: var(--text); }
.home svg { transition: transform .2s; } .home:hover svg { transform: translateX(-2px); }
.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.brand img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.brand b { font-size: 1.05rem; letter-spacing: .01em; }
.brand .jp { font-family: var(--serif); font-size: .9rem; color: var(--accent-ink); }
.levels { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--surface); }
.levels button { padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .88rem; color: var(--muted); transition: background .25s var(--ease), color .2s, box-shadow .25s; }
.levels button:hover { color: var(--text); }
.levels button[aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 3px rgba(20,20,19,.14); }
.furi { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: .82rem; color: var(--muted); transition: background .2s, color .2s, border-color .2s; }
.furi ruby { font-family: var(--serif); font-size: 1rem; }
.furi[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(201,100,66,.4); color: var(--accent-ink); }
.furi:hover { background: var(--hover); }

/* ===== Tab kỹ năng: dưới màn hình trên điện thoại, dưới thanh trên ở màn hình rộng ===== */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(250,249,245,.94); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 12px; color: var(--muted); font-size: .7rem; position: relative; transition: color .2s, background .2s; }
.tabs .g { font-family: var(--serif); font-size: 1.25rem; line-height: 1.2; font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.tabs button:hover { color: var(--text); }
@media (min-width: 820px) {
  body { padding-bottom: 40px; }
  .tabs { position: sticky; top: 53px; bottom: auto; display: flex; justify-content: center; gap: 6px; padding: 8px 16px; background: var(--bg); border-top: 0; border-bottom: 1px solid var(--line); backdrop-filter: none; }
  .tabs button { flex-direction: row; gap: 8px; padding: 8px 16px; font-size: .92rem; }
  .tabs .g { font-size: 1.05rem; }
}

/* ===== Vùng nội dung ===== */
main { max-width: 980px; margin: 0 auto; padding: 22px 16px 10px; outline: 0; }
.view-in { animation: fadeUp .45s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.h1 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.h1 h1 { font-family: var(--serif); font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; letter-spacing: -.01em; }
.h1 .tag { font-size: .85rem; color: var(--accent-ink); font-weight: 600; }
.sub { color: var(--muted); margin-bottom: 18px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; margin-bottom: 18px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-size: .85rem; }
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 12px; font-weight: 600; background: var(--surface); transition: background .2s, transform .15s, opacity .2s; white-space: nowrap; }
.btn:hover { background: #D8D1C0; } .btn:active { transform: scale(.98); }
.btn.pri { background: var(--accent); color: #fff; } .btn.pri:hover { background: var(--accent-ink); }
.btn.ok { background: var(--done-soft); color: var(--done); } .btn.ok:hover { background: rgba(61,122,82,.22); }
.btn[disabled] { opacity: .45; cursor: default; }
.bar { height: 6px; border-radius: 6px; background: var(--surface); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--accent); transition: width .6s var(--ease); }

/* ===== Tổng quan ===== */
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.skill { text-align: left; padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: transform .25s var(--ease), border-color .2s, box-shadow .25s; animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.skill:hover { transform: translateY(-3px); border-color: rgba(201,100,66,.45); box-shadow: 0 8px 20px rgba(20,20,19,.07); }
.skill .gl { font-family: var(--serif); font-size: 2rem; font-weight: 700; color: var(--accent-ink); line-height: 1; }
.skill .nm { font-weight: 700; } .skill .ds { font-size: .82rem; color: var(--muted); }
.skill .cnt { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }
.today { margin-top: 20px; padding: 18px; display: grid; gap: 6px; animation: fadeUp .5s .25s var(--ease) both; }
.today .lbl { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); font-weight: 700; }
.today .w { font-family: var(--serif); font-size: 2.2rem; font-weight: 700; line-height: 1.2; }
.today .m { color: var(--muted); }

/* ===== Ngữ pháp ===== */
.acc { display: grid; gap: 10px; }
.gi { overflow: hidden; transition: border-color .25s, box-shadow .25s; animation: fadeUp .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
.gi.open { border-color: rgba(201,100,66,.45); box-shadow: 0 6px 18px rgba(20,20,19,.06); }
.gh { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; }
.gh .pat { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; }
.gh .vi { color: var(--muted); font-size: .9rem; margin-left: auto; text-align: right; }
.gh .chev { flex: none; width: 18px; height: 18px; color: var(--muted); transition: transform .3s var(--ease); }
.gi.open .chev { transform: rotate(90deg); }
.gh .tick { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; color: transparent; transition: background .25s, border-color .25s, color .25s; }
.gi.done .tick { background: var(--done); border-color: var(--done); color: #fff; }
.gb { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
.gi.open .gb { grid-template-rows: 1fr; }
.gb > div { overflow: hidden; min-height: 0; }
.gbi { padding: 2px 16px 16px; display: grid; gap: 12px; opacity: 0; transform: translateY(-4px); transition: opacity .3s .05s, transform .3s .05s var(--ease); }
.gi.open .gbi { opacity: 1; transform: none; }
.kv { display: grid; gap: 2px; } .kv .k { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.form { font-family: var(--serif); background: var(--bg); padding: 8px 12px; border-radius: 10px; display: inline-block; }
.exs { display: grid; gap: 8px; }
.ex { padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 10px 10px 0; }
.ex .jp { font-family: var(--serif); font-size: 1.15rem; line-height: 2; } .ex .vi { color: var(--muted); font-size: .88rem; }

/* ===== Từ vựng ===== */
.deck { display: grid; gap: 14px; justify-items: center; }
.flip { width: min(100%, 460px); perspective: 1200px; }
.flip .in { position: relative; height: 270px; transition: transform .55s var(--ease); transform-style: preserve-3d; }
.flip.on .in { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px; text-align: center; }
.face.back { transform: rotateY(180deg); }
.face .big { font-family: var(--serif); font-size: clamp(2.6rem, 11vw, 3.6rem); font-weight: 700; line-height: 1.2; }
.face .hint { font-size: .78rem; color: var(--muted); }
.face .pos { font-size: .75rem; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.face .rd { font-family: var(--serif); font-size: 1.4rem; } .face .mn { font-size: 1.15rem; font-weight: 600; }
.face .ex1 { font-family: var(--serif); font-size: 1rem; line-height: 2; } .face .ex2 { font-size: .82rem; color: var(--muted); }
.deckbar { display: flex; align-items: center; gap: 8px; width: min(100%, 460px); }
.deckbar .grow { flex: 1; }
.prog { font-size: .85rem; color: var(--muted); min-width: 52px; text-align: center; }
.vlist { margin-top: 24px; display: grid; gap: 6px; }
.vrow { display: grid; grid-template-columns: 1fr 1fr 1.2fr auto; gap: 10px; align-items: center; padding: 10px 14px; text-align: left; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); transition: border-color .2s, background .2s; width: 100%; }
.vrow:hover { border-color: rgba(201,100,66,.4); } .vrow.cur { border-color: var(--accent); background: #fff8f3; }
.vrow .w { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; } .vrow .r { color: var(--muted); font-family: var(--serif); } .vrow .m { color: var(--text); font-size: .92rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line); transition: background .2s, border-color .2s; } .dot.on { background: var(--done); border-color: var(--done); }
@media (max-width: 560px) { .vrow { grid-template-columns: 1fr 1fr auto; } .vrow .r { display: none; } }
h2.sec { font-size: 1rem; margin: 26px 0 8px; font-weight: 700; }

/* ===== Kanji: chọn chữ + trang chi tiết (ô luyện chữ, danh sách nét, mẹo nhớ) ===== */
.kpick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.kt { width: 62px; height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 12px; background: var(--surface-2); border: 1.5px solid var(--line); position: relative; transition: transform .2s var(--ease), border-color .2s, background .2s, color .2s; }
.kt:hover { transform: translateY(-2px); border-color: rgba(201,100,66,.5); }
.kt .c { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; line-height: 1.1; } .kt .h { font-size: .55rem; color: var(--muted); letter-spacing: .05em; }
.kt.sel { background: var(--accent); border-color: var(--accent); color: #fff; } .kt.sel .h { color: rgba(255,255,255,.88); }
.kt.done::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--done); }
.kt.sel.done::after { background: #fff; }
.kd { display: grid; gap: 28px; animation: fadeUp .4s var(--ease) both; }
.khead { display: flex; gap: 20px; align-items: center; }
.kglyph { font-family: var(--serif); font-weight: 700; font-size: 84px; line-height: 1; width: 112px; height: 112px; flex: none; display: grid; place-items: center; background: var(--text); color: var(--bg); border-radius: 14px; }
.kmeta { min-width: 0; display: grid; gap: 6px; }
.eyebrow { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.kmeta h2 { font-family: var(--serif); font-size: clamp(1.5rem, 5vw, 2.1rem); line-height: 1.2; }
.lead { color: var(--muted); max-width: 54ch; } .lead b { color: var(--text); font-weight: 600; }
.kstage { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 24px; align-items: start; }
.kboard { display: grid; gap: 14px; min-width: 0; }
.paper { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
#kstage { display: block; width: 100%; height: auto; aspect-ratio: 1; }
#kstage .frame { fill: none; stroke: var(--line); stroke-width: .9; }
#kstage .cross { stroke: var(--line); stroke-width: .7; stroke-dasharray: 2.5 2.5; }
#kstage .ghost { fill: none; stroke: #DDD7C8; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
#kstage .ink { fill: none; stroke: var(--text); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 2; }
#kstage .ink.cur { stroke: var(--accent); }
#kstage .mk circle { fill: var(--accent); } #kstage .mk text { fill: #fff; font: 600 5.2px var(--sans); text-anchor: middle; dominant-baseline: central; }
.ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .ctrl .pri { grid-column: 1 / -1; }
.speed { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.speed button { padding: 8px 14px; color: var(--muted); font-size: .88rem; transition: background .2s, color .2s; }
.speed button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.krows { list-style: none; padding: 0; display: grid; gap: 8px; min-width: 0; max-height: 640px; overflow-y: auto; padding-right: 2px; }
.kload { color: var(--muted); padding: 14px; }
.krow { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px 8px 8px; cursor: pointer; opacity: .55; transition: opacity .2s, border-color .2s, background .2s; }
.krow.done { opacity: 1; } .krow.cur { opacity: 1; border-color: var(--accent); background: var(--accent-soft); }
.krow:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.krow svg { width: 64px; height: 64px; display: block; background: var(--bg); border-radius: 8px; }
.krow .t-prev { fill: none; stroke: var(--muted); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.krow .t-cur { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.krow h4 { margin: 0; font-size: .95rem; font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.krow h4 span { font-family: var(--serif); font-weight: 600; color: var(--muted); font-size: .88rem; }
.krow p { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.kcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.kcols section { display: grid; gap: 10px; align-content: start; min-width: 0; }
h3.sec { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; }
.tips { margin: 0; padding-left: 1.1em; display: grid; gap: 8px; max-width: 60ch; } .tips li::marker { color: var(--accent); }
.kwords { list-style: none; padding: 0; margin-top: 4px; border-top: 1px solid var(--line); }
.kwords li { display: grid; grid-template-columns: minmax(110px, 170px) 1fr; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kwords .kk { font-family: var(--serif); font-weight: 700; font-size: 1.3rem; line-height: 2; } .kwords .km { color: var(--muted); }
.credit { font-size: .75rem; color: var(--muted); } .credit a { color: var(--accent-ink); }
@media (max-width: 720px) {
  .kstage { grid-template-columns: minmax(0, 1fr); } .krows { max-height: none; }
  .khead { align-items: flex-start; } .kglyph { width: 84px; height: 84px; font-size: 60px; border-radius: 12px; }
}

/* ===== Đọc hiểu ===== */
.passage { padding: 22px; }
.passage h2 { font-family: var(--serif); font-size: 1.3rem; margin-bottom: 12px; }
.passage p { font-family: var(--serif); font-size: 1.2rem; line-height: 2.3; margin-bottom: 8px; }
.trans { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
.trans.on { grid-template-rows: 1fr; } .trans > div { overflow: hidden; min-height: 0; }
.trans .tx { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg); color: var(--muted); font-size: .92rem; }
.q { margin-top: 14px; padding: 18px; }
.q .qt { font-weight: 700; margin-bottom: 10px; font-family: var(--serif); font-size: 1.05rem; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: center; text-align: left; padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); transition: border-color .2s, background .2s, transform .15s; font-family: var(--serif); }
.opt:hover:not([disabled]) { border-color: var(--accent); } .opt:active:not([disabled]) { transform: scale(.995); }
.opt .l { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--sans); font-size: .75rem; font-weight: 700; }
.opt.ok { border-color: var(--done); background: var(--done-soft); } .opt.bad { border-color: var(--danger); background: var(--danger-soft); }
.opt[disabled] { cursor: default; }
.why { margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: .88rem; background: var(--bg); color: var(--muted); animation: fadeUp .3s var(--ease) both; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

@media (max-width: 640px) {
  .top { gap: 8px; padding: 8px 12px; } .home span, .furi span { display: none; } .home, .furi { padding: 7px 9px; }
  .levels button { padding: 6px 10px; }
  .brand .jp { display: none; }
  main { padding-top: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
