:root {
  --paper: #f6f3ec;
  --surface: #ffffff;
  --ink: #12332f;
  --muted: #5b6d68;
  --line: #e2ddd1;
  --brand: #0f766e;
  --brand-dark: #0b5a54;
  --brand-soft: #e3f2ef;
  --amber: #f2b441;
  --amber-soft: #fff5d9;
  --red: #b3372b;
  --red-soft: #fdecea;
  --green-soft: #e2f5e6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(18, 51, 47, .05), 0 12px 32px -12px rgba(18, 51, 47, .18);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2 { line-height: 1.2; letter-spacing: -.02em; margin: 0; }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }

/* ---------- Khung chung ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand-mark { flex: none; display: block; width: 38px; height: 38px; }
.top-link { font-size: 14px; font-weight: 600; text-decoration: none; color: var(--muted); }
.top-link:hover { color: var(--brand); }
.foot { padding: 36px 0 44px; color: var(--muted); font-size: 13px; text-align: center; }
.foot a { color: inherit; }
.eyebrow { margin: 0 0 14px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 24px; border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .15s;
}
.button:hover { background: var(--brand-dark); }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .6; cursor: progress; }
.button.ghost { background: var(--brand-soft); color: var(--brand-dark); }
.button.busy { opacity: .7; pointer-events: none; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* ---------- Trang chủ ---------- */
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: start; padding: 36px 0 72px; }
.pitch { padding-top: 44px; }
.pitch h1 { font-size: clamp(34px, 5.2vw, 56px); font-weight: 800; }
.pitch h1 em { font-style: normal; color: var(--brand); background: linear-gradient(transparent 68%, var(--amber) 68%, var(--amber) 92%, transparent 92%); }
.lead { margin: 22px 0 0; font-size: 18px; color: var(--muted); max-width: 30em; }
.points { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 10px; font-weight: 500; }
.points li { display: flex; gap: 10px; align-items: baseline; }
.points li::before { content: "✓"; color: var(--brand); font-weight: 800; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); }
.panel h2 { font-size: 22px; margin-bottom: 18px; }
.drop {
  display: grid; justify-items: center; gap: 6px; text-align: center; cursor: pointer;
  padding: 30px 18px; border: 2px dashed #b9cbc6; border-radius: var(--radius); background: #f9fbfa;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.dragging { border-color: var(--brand); background: var(--brand-soft); }
.drop.has-file { border-style: solid; border-color: var(--brand); background: var(--brand-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 3px solid var(--amber); outline-offset: 2px; }
.drop-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #fff; color: var(--brand); border: 1px solid var(--line); margin-bottom: 6px; }
.drop strong { font-size: 16px; overflow-wrap: anywhere; }
.drop small { color: var(--muted); font-size: 13px; }
.label { display: block; margin: 20px 0 8px; font-weight: 600; font-size: 14px; }
.input {
  width: 100%; height: 50px; padding: 0 14px; font: inherit; color: inherit;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.invalid { border-color: var(--red); }
.field-hint { margin: 6px 0 0; font-size: 13px; color: var(--red); }
.button:disabled { cursor: not-allowed; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.panel .button { width: 100%; margin-top: 18px; }
.fine { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.error { margin: 14px 0 0; padding: 11px 14px; border-radius: 10px; background: var(--red-soft); color: var(--red); font-size: 14px; font-weight: 500; }

.progress-file { margin: -8px 0 18px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; color: var(--muted); }
.steps b { display: block; font-weight: 600; }
.steps small { display: block; font-size: 13px; min-height: 1.3em; overflow-wrap: anywhere; }
.dot { flex: none; width: 22px; height: 22px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--line); background: #fff; display: grid; place-items: center; }
.steps .active { color: var(--ink); }
.steps .active .dot { border-color: var(--brand); border-top-color: transparent; animation: spin .8s linear infinite; }
.steps .done { color: var(--ink); }
.steps .done .dot { border-color: var(--brand); background: var(--brand); }
.steps .done .dot::after { content: "✓"; color: #fff; font-size: 12px; font-weight: 800; }
.steps .failed { color: var(--red); }
.steps .failed .dot { border-color: var(--red); background: var(--red); }
.steps .failed .dot::after { content: "!"; color: #fff; font-size: 13px; font-weight: 800; }
.bar { height: 6px; margin-top: 22px; border-radius: 99px; background: var(--brand-soft); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width 1.2s ease; }
.bar.stopped span { background: var(--red); }
.done-banner { margin-top: 18px; padding: 14px 16px; border-radius: 12px; background: var(--brand-soft); border: 1.5px solid var(--brand); color: var(--ink); }
.done-banner strong { display: block; font-size: 15px; color: var(--brand-dark); }
.done-banner p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cài đặt nâng cao ---------- */
.adv { margin-top: 14px; border: 1.5px solid var(--line); border-radius: 14px; background: #fffdf7; }
.adv summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.adv summary::-webkit-details-marker { display: none; }
.adv-tab { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 99px; background: var(--amber); color: #3d2a00; font-weight: 700; font-size: 13px; }
.adv-tab::before { content: "＋"; font-weight: 800; }
.adv[open] .adv-tab::before { content: "－"; }
.adv summary small { color: var(--muted); font-size: 13px; text-align: right; }
.adv.nudge:not([open]) { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.adv-body { padding: 4px 14px 16px; border-top: 1px dashed var(--line); }
.adv-label { margin: 14px 0 8px; font-weight: 600; font-size: 14px; }
.adv-label small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.chips { display: grid; gap: 8px; }
.chips label { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; }
.chips label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.chips label:has(input:disabled), .chips label.chip-disabled { background: #f5f2ea; border-style: dashed; color: var(--muted); cursor: not-allowed; }
.chips input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--brand); flex: none; }
.chips input:disabled { cursor: not-allowed; opacity: .5; }
.chips b { display: block; font-size: 14px; }
.chip-badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: var(--amber-soft); border: 1px solid #f1e2b4; color: #7a4f00; font-style: normal; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.chips small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.range-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.range-row input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; font: inherit; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.range-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.adv-warn { margin: 8px 0 0; padding: 8px 11px; border-radius: 9px; background: var(--amber-soft); color: #7a4f00; font-size: 13px; }
.linkish { margin-left: auto; padding: 0; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--brand); cursor: pointer; }
.adv-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.thumbs { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; max-height: 330px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #f4f1e9; overscroll-behavior: contain; }
.thumb { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 2px solid transparent; border-radius: 8px; background: #fff; overflow: hidden; cursor: pointer; opacity: .55; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.thumb canvas, .thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumb span { position: absolute; left: 4px; bottom: 4px; min-width: 22px; padding: 1px 5px; border-radius: 6px; background: rgba(18, 51, 47, .78); color: #fff; font-size: 11px; font-weight: 700; line-height: 1.5; }
.thumb:hover { opacity: .9; }
.thumb.on { opacity: 1; border-color: var(--brand); }
.thumb.on span { background: var(--brand); }

.how, .faq { padding: 56px 0 8px; border-top: 1px solid var(--line); }
.how h2, .faq h2 { font-size: 28px; margin-bottom: 28px; }
.how ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.how li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.how li span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--amber-soft); color: #8a5a00; font-weight: 800; margin-bottom: 14px; }
.how li b { font-size: 17px; }
.how li p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.faq { margin-top: 48px; max-width: 760px; }
.faq details { border-bottom: 1px solid var(--line); padding: 16px 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::after { content: "+"; color: var(--brand); font-weight: 700; font-size: 20px; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq summary::-webkit-details-marker { display: none; }
.faq p { margin: 10px 0 0; color: var(--muted); }

/* ---------- Trang bộ thẻ ---------- */
.deck { padding-top: 12px; max-width: 820px; }
.deck-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding: 16px 0 24px; }
.deck-head h1 { font-size: clamp(26px, 4vw, 36px); font-weight: 800; overflow-wrap: anywhere; }
.deck-meta { margin: 8px 0 0; color: var(--muted); }
.notice { margin: 0 0 20px; padding: 12px 16px; border-radius: 12px; background: var(--amber-soft); color: #7a4f00; font-size: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0 20px; position: sticky; top: 0; z-index: 2; background: var(--paper); scroll-margin-top: 0; }
.filters button {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--muted);
  padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface);
}
.filters button span { margin-left: 4px; font-weight: 500; opacity: .7; }
.filters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; min-height: 200px; transition: opacity .15s; }
.cards.loading { opacity: .45; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; overflow-wrap: anywhere; }
.card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 12px; }
.tag { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-dark); }
.card-cloze .tag { background: var(--amber-soft); color: #8a5a00; }
.card-multiple .tag { background: #ebe8fb; color: #4a3fa3; }
.num { color: #9aa8a4; font-variant-numeric: tabular-nums; }
.front { font-size: 17px; font-weight: 600; line-height: 1.55; }
.back { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.back p { margin: 0 0 10px; }
.back p:last-child { margin-bottom: 0; }
.explain { color: var(--muted); font-size: 15px; background: #f7f9f8; border-radius: 10px; padding: 12px 14px; }
.explain b { display: block; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--brand); margin-bottom: 4px; }
.flip { margin-top: 16px; font: inherit; font-size: 14px; font-weight: 700; color: var(--brand); background: none; border: 0; padding: 0; cursor: pointer; }
.flip:hover { text-decoration: underline; }
.blank { display: inline-block; min-width: 56px; padding: 0 10px; border-radius: 6px; background: var(--amber-soft); color: #8a5a00; text-align: center; border-bottom: 2px solid var(--amber); }
mark { background: var(--amber-soft); color: inherit; padding: 1px 5px; border-radius: 5px; font-weight: 700; border-bottom: 2px solid var(--amber); }
code { background: #f0f2f1; padding: 1px 5px; border-radius: 5px; font-size: .92em; }

.options { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.option {
  width: 100%; display: flex; gap: 12px; align-items: flex-start; text-align: left; cursor: pointer;
  font: inherit; color: inherit; padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff;
}
.option:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.option:disabled { cursor: default; }
.letter { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: #f0f2f1; font-weight: 700; font-size: 13px; }
.option.right { border-color: #2f9e55; background: var(--green-soft); }
.option.right .letter { background: #2f9e55; color: #fff; }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option.wrong .letter { background: var(--red); color: #fff; }
.option-note { display: none; margin: 6px 0 4px 52px; font-size: 14px; color: var(--muted); }
.answered .option-note { display: block; }

.pager { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 28px 0 8px; font-size: 14px; color: var(--muted); }
.pager button { font: inherit; font-weight: 600; cursor: pointer; padding: 9px 16px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.pager button:disabled { opacity: .4; cursor: default; }
.empty { text-align: center; padding: 80px 0; }
.empty h1 { font-size: 30px; }
.empty p { color: var(--muted); margin: 14px auto 26px; max-width: 30em; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 32px; padding: 16px 0 48px; }
  .pitch { padding-top: 0; }
  .how ol { grid-template-columns: 1fr; }
  .panel { padding: 22px 18px; }
  .deck-head .button { width: 100%; }
  .option-note { margin-left: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
