/* English for Terminal: light theme only, large type. */
:root {
  --bg: #f4f7fb; --card: #ffffff; --ink: #18212d; --muted: #556171; --line: #dde4ee;
  --brand: #0b5cab; --brand-2: #e7f0fb; --accent: #e8741a; --accent-2: #fdefe2;
  --ok: #16784a; --ok-2: #e3f4ea; --bad: #c03636; --bad-2: #fbe8e8; --warn: #8f5c00; --warn-2: #fff5dc;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
  color-scheme: light;
}
html { font-size: 19px; }
html[data-font="M"] { font-size: 17px; }
html[data-font="XL"] { font-size: 21px; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  line-height: 1.55; -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
h1 { font-size: 1.5rem; margin: .2rem 0 .7rem; line-height: 1.25; }
h2 { font-size: 1.22rem; margin: 1.2rem 0 .7rem; }
h3 { font-size: 1.05rem; margin: .2rem 0 .5rem; }
h4 { font-size: .9rem; margin: .9rem 0 .35rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
p { margin: .4rem 0 .7rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; justify-content: center; }
.hide { display: none !important; }
kbd { font-family: inherit; font-size: .75em; border: 1px solid rgba(0, 0, 0, .2); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35em; margin-left: .3em; opacity: .85; }

/* header + nav */
.sticky { position: sticky; top: 0; z-index: 20; }
.topbar { background: var(--brand); color: #fff; }
.topbar .in { max-width: 1240px; margin: 0 auto; padding: .45rem 1rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.brand { font-weight: 700; color: #fff; text-decoration: none; margin-right: auto; white-space: nowrap; }
.hchip { background: rgba(255, 255, 255, .15); border-radius: 999px; padding: .12rem .7rem; font-size: .82rem; white-space: nowrap; }
.xpbar { width: 70px; height: 7px; background: rgba(255, 255, 255, .28); border-radius: 9px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: .45rem; }
.xpbar i { display: block; height: 100%; background: #ffb067; }
.langbtn { background: #fff; color: var(--brand); border: 0; border-radius: 999px; padding: .25rem .75rem; font: inherit; font-weight: 700; cursor: pointer; font-size: .8rem; }
.tabs { background: #fff; border-bottom: 1px solid var(--line); }
.tabs .in { max-width: 1240px; margin: 0 auto; display: flex; gap: .2rem; overflow-x: auto; padding: .3rem .6rem; scrollbar-width: thin; }
.tabs a { display: flex; align-items: center; gap: .35rem; padding: .45rem .75rem; border-radius: 10px; color: var(--ink); text-decoration: none; white-space: nowrap; font-size: .88rem; }
.tabs a:hover { background: #f1f5fa; }
.tabs a.on { background: var(--brand-2); color: var(--brand); font-weight: 700; }
main { max-width: 1040px; margin: 0 auto; padding: 1rem 1rem 5rem; outline: none; }

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin: 0 0 1rem; }
.card.link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.card.link:hover { border-color: #9ec0e6; transform: translateY(-1px); }
.card.now { border: 2px solid var(--accent); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.tight { gap: .3rem 1rem; }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 46px; padding: .45rem 1.05rem;
  border-radius: 12px; border: 1px solid #cdd6e2; background: #fff; color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.25;
}
.btn:hover { background: #f6f9fd; border-color: #b4c3d6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #094d90; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.big { font-size: 1.08rem; min-height: 56px; padding: .6rem 1.5rem; }
.btn.small { min-height: 38px; padding: .3rem .8rem; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
.icon-btn { border: 1px solid #cdd6e2; background: #fff; border-radius: 10px; min-width: 42px; height: 42px; font-size: 1.05rem; cursor: pointer; flex: none; }
.icon-btn:hover { background: #f1f5fa; }
:focus-visible { outline: 3px solid #86b4e8; outline-offset: 2px; }

.chip { display: inline-block; padding: .06rem .55rem; border-radius: 999px; font-size: .76rem; background: var(--brand-2); color: var(--brand); font-weight: 600; margin: 0 .25rem .3rem 0; vertical-align: middle; }
.chip.lv { background: #eef1f5; color: #3a4554; }
.chip.new { background: var(--accent-2); color: #9a4b07; }
.chip.ok { background: var(--ok-2); color: var(--ok); }
.chip.bad { background: var(--bad-2); color: var(--bad); }
.tag { display: inline-block; padding: .12rem .55rem; border: 1px solid var(--line); border-radius: 8px; margin: 0 .3rem .3rem 0; background: #fafbfd; font-size: .92rem; }

.progress { height: 14px; background: #e5ebf3; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #2e86d8); border-radius: 99px; transition: width .3s; }
.progress.thin { height: 8px; }
.stat { text-align: center; padding: .9rem .6rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { font-size: .85rem; color: var(--muted); }

/* flashcard */
.flash { min-height: 320px; }
.term-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .3rem; }
.term { font-size: 2.15rem; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; word-break: break-word; }
.posipa { font-size: 1.15rem; margin-top: .25rem; }
.pos { color: var(--accent); font-weight: 700; font-style: italic; }
.ipa { font-family: "Segoe UI", "Lucida Sans Unicode", "Arial Unicode MS", "Noto Sans", "DejaVu Sans", sans-serif; color: var(--muted); }
.meaning-vi { font-size: 1.4rem; font-weight: 700; color: var(--brand); margin-top: .2rem; }
.meaning-en { color: var(--muted); font-style: italic; }
.ex { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem 0; border-top: 1px dashed var(--line); }
.ex:first-of-type { border-top: 0; }
.ex-en { font-weight: 600; }
.ex-vi { color: var(--muted); font-size: .93rem; }
mark { background: #ffe39c; color: inherit; padding: 0 .12em; border-radius: 3px; }
.warnbox { background: var(--warn-2); border: 1px solid #efd48c; border-radius: 10px; padding: .6rem .85rem; margin-top: .9rem; }
.formula { font-family: Consolas, "Cascadia Mono", Menlo, monospace; background: #eef3fa; border: 1px solid var(--line); border-radius: 10px; padding: .65rem .85rem; font-size: 1.02rem; white-space: pre-wrap; }
.actions { margin-top: 1.1rem; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.grades .btn { flex-direction: column; gap: .05rem; min-height: 66px; }
.grades small { font-weight: 400; font-size: .74rem; opacity: .9; }
.gr0 { background: var(--bad-2); border-color: #eab0b0; color: var(--bad); }
.gr1 { background: var(--accent-2); border-color: #f1c39a; color: #96470a; }
.gr2 { background: var(--ok-2); border-color: #a6d8bb; color: var(--ok); }
.gr3 { background: var(--brand-2); border-color: #a9c7ea; color: var(--brand); }
@media (max-width: 560px) { .grades { grid-template-columns: repeat(2, 1fr); } }
.tools { margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.tools details { width: 100%; }
.tools summary { cursor: pointer; color: var(--muted); }

/* forms */
input[type=text], input[type=search], input[type=number], textarea, select {
  font: inherit; padding: .55rem .75rem; border: 1px solid #c4cfdd; border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
input[type=range] { width: 100%; }
label.field { display: block; margin: .6rem 0; }
label.field > span { display: block; font-weight: 600; margin-bottom: .25rem; }
.inline { display: inline-flex; align-items: center; gap: .4rem; margin-right: 1rem; }

/* quiz */
.opts { display: grid; gap: .6rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1rem; }
@media (max-width: 640px) { .opts { grid-template-columns: 1fr; } }
.opt { text-align: left; justify-content: flex-start; min-height: 58px; font-weight: 500; }
.opt .k { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 6px; background: #eef1f5; font-size: .8rem; flex: none; }
.opt:disabled { opacity: 1; cursor: default; }
.opt:disabled:not(.right):not(.wrong) { opacity: .55; }
.opt.right { background: var(--ok-2); border-color: var(--ok); color: #0f5a35; font-weight: 700; }
.opt.wrong { background: var(--bad-2); border-color: var(--bad); color: #8a2323; }
.fb { border-radius: 10px; padding: .75rem .95rem; margin-top: .9rem; }
.fb.ok { background: var(--ok-2); color: #0f5a35; }
.fb.bad { background: var(--bad-2); color: #842020; }
.fb.info { background: var(--brand-2); color: #0a4a8a; }
.w-ok { color: var(--ok); font-weight: 700; }
.w-miss { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 3px; }
.prompt { font-size: 1.35rem; font-weight: 700; }
.blank { display: inline-block; min-width: 5em; border-bottom: 2px solid var(--ink); }

/* lists */
.item { display: flex; gap: .8rem; align-items: center; padding: .7rem .5rem; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 8px; }
.item:hover { background: #f5f8fc; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 700; }
.item .s { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: .7rem; height: .7rem; border-radius: 50%; background: #d4dbe5; flex: none; }
.dot.learning { background: #4a9be0; }
.dot.mastered { background: #0b5cab; }
.filters { display: grid; gap: .5rem; grid-template-columns: 2fr repeat(4, 1fr); align-items: center; }
@media (max-width: 860px) { .filters { grid-template-columns: 1fr 1fr; } .filters .q { grid-column: 1 / -1; } }

/* speaking + reading */
.chat { display: flex; flex-direction: column; gap: .5rem; }
.bubble { max-width: 86%; padding: .65rem .9rem; border-radius: 14px; background: #eef2f7; }
.bubble.me { background: var(--brand-2); margin-left: auto; }
.bubble .who { font-size: .75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.bubble .vi { color: var(--muted); font-size: .9rem; }
.live { min-height: 1.6em; font-style: italic; color: var(--muted); }
.para { padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.sent { border-radius: 4px; transition: background .2s; }
.sent.on { background: #ffe9a8; }
.para .vi { color: var(--muted); font-size: .93rem; margin-top: .3rem; }
.score { font-size: 1.6rem; font-weight: 800; }

/* badges + charts */
.badges { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.badge { text-align: center; padding: .8rem .5rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.badge .i { font-size: 1.8rem; }
.badge .n { font-size: .82rem; }
.badge.locked { opacity: .45; filter: grayscale(1); }
.bars { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 12rem 1fr 6.5rem; gap: .6rem; align-items: center; font-size: .9rem; }
@media (max-width: 640px) { .bar-row { grid-template-columns: 1fr; gap: .2rem; } }
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: #e8edf4; }
.stack i { display: block; height: 100%; }
.stack .m { background: #0b5cab; }
.stack .l { background: #4a9be0; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -1px; margin-right: .3rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: inherit; fill: var(--muted); font-size: 10px; }

/* toasts + modal */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 60; }
.toast { background: #1e2834; color: #fff; padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow); max-width: 360px; transition: opacity .4s, transform .4s; }
.toast.win { background: #13623c; }
.toast.warn { background: #8a5a00; }
.toast.out { opacity: 0; transform: translateY(8px); }
.modal { position: fixed; inset: 0; background: rgba(15, 23, 35, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 16px; max-width: 780px; width: 100%; padding: 1.3rem 1.4rem; position: relative; }
.modal-x { position: absolute; right: .7rem; top: .7rem; }
