:root {
  --bg: #f7f8fa; --surface: #ffffff; --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --line: #e5e8ee; --line-2: #d6dbe4;
  --brand: #2748c8; --brand-ink: #ffffff; --brand-soft: #eef2ff; --brand-line: #c7d2fe;
  --red: #b42318; --red-soft: #fef3f2; --amber: #93560a; --amber-soft: #fffaeb; --blue: #2748c8; --blue-soft: #eef2ff; --green: #067647; --green-soft: #ecfdf3;
  --c-blue: #2563eb; --c-purple: #7c3aed; --c-teal: #0d9488; --c-orange: #d97706; --c-gray: #64748b;
  --radius: 12px; --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05); --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -8px rgba(15, 23, 42, .08);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1017; --surface: #121923; --ink: #f1f5f9; --ink-2: #cbd5e1; --muted: #8b98ab; --line: #232d3b; --line-2: #2f3b4d;
    --brand: #8aa4ff; --brand-ink: #0b1220; --brand-soft: #172036; --brand-line: #2b3a63;
    --red: #fda29b; --red-soft: #2d1715; --amber: #fec84b; --amber-soft: #2b2110; --blue: #8aa4ff; --blue-soft: #172036; --green: #6ce9a6; --green-soft: #10261c; --shadow: none; --shadow-sm: none;
    --c-blue: #7aa2ff; --c-purple: #b79cff; --c-teal: #5eead4; --c-orange: #fbbf5c; --c-gray: #94a3b8; }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15.5px/1.6 var(--font); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
a, .link { color: var(--brand); }
.link { background: none; border: 0; font: inherit; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.02em; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; font-weight: 650; } h3 { font-size: .98rem; margin: 0 0 .4rem; font-weight: 650; }
.lede { color: var(--muted); margin: 0 0 1.25rem; max-width: 62ch; font-size: 1rem; }
.hint, .note { color: var(--muted); font-size: .84rem; margin: .5rem 0 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }

/* Thanh đầu trang */
.topbar { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); text-decoration: none; }
.brand strong { color: var(--ink); font-size: 1rem; font-weight: 650; letter-spacing: -.01em; }
.ver { font-size: .7rem; border: 1px solid var(--line-2); color: var(--muted); border-radius: 99px; padding: 0 7px; font-weight: 600; line-height: 1.5; }
.links { display: flex; gap: 2px; }
.links .link { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 500; font-size: .92rem; }
.links .link:hover { background: var(--bg); color: var(--ink); }
main { padding-top: 36px; padding-bottom: 56px; min-height: 66vh; }

/* Trang chủ */
.hero { max-width: 780px; margin: 7vh auto 0; text-align: center; position: relative; }
.hero::before { content: ""; position: absolute; inset: -120px -200px auto; height: 360px; background: radial-gradient(60% 60% at 50% 0%, color-mix(in srgb, var(--brand) 11%, transparent), transparent 70%); pointer-events: none; z-index: -1; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3rem); letter-spacing: -.035em; font-weight: 700; margin-bottom: .6rem; }
.ver-lg { font-size: .4em; vertical-align: .9em; border: 1px solid var(--line-2); color: var(--muted); border-radius: 99px; padding: 1px 10px; font-weight: 600; letter-spacing: 0; margin-left: 4px; background: var(--surface); }
.tagline { font-size: clamp(1.1rem, 2.4vw, 1.3rem); color: var(--ink-2); margin: 0 0 .5rem; font-weight: 450; }
.legal { color: var(--muted); font-size: .88rem; margin: 0; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 40px; text-align: left; }
@media (max-width: 680px) { .choices { grid-template-columns: 1fr; } }
.choice { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; cursor: pointer; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s; text-align: left; }
.choice:hover { border-color: var(--brand-line); box-shadow: var(--shadow); transform: translateY(-1px); }
.choice .ic { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.choice .tx { flex: 1; display: grid; gap: 2px; } .choice b { font-weight: 650; font-size: 1.02rem; } .choice .tx span { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.choice .go { color: var(--muted); transition: transform .15s, color .15s; } .choice:hover .go { color: var(--brand); transform: translateX(3px); }
.privacy { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .84rem; margin: 28px 0 0; }

/* Các bước */
.steps { list-style: none; display: flex; align-items: center; gap: 0; padding: 0; margin: 0 0 34px; flex-wrap: wrap; row-gap: 8px; }
.steps li { display: flex; align-items: center; }
.steps li + li::before { content: ""; width: 32px; height: 1px; background: var(--line-2); margin: 0 10px; }
.steps .st, .steps button { display: flex; align-items: center; gap: 8px; font: inherit; font-size: .88rem; color: var(--muted); background: none; border: 0; padding: 2px; border-radius: 8px; }
.steps button { cursor: pointer; } .steps button:hover { color: var(--ink); }
.steps i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font-size: .76rem; font-weight: 650; }
.steps .on .st { color: var(--ink); font-weight: 600; } .steps .on i { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.steps .done i { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); } .steps .done button { color: var(--ink-2); }
.head { margin-bottom: 18px; }

/* Bộ chọn loại văn bản */
.pickbar { display: grid; gap: 14px; margin-bottom: 8px; }
.searchbox { display: flex; align-items: center; gap: 10px; max-width: 520px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 0 14px; color: var(--muted); box-shadow: var(--shadow-sm); }
.searchbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.searchbox input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--ink); padding: 10px 0; outline: none; min-width: 0; }
.searchbox input:focus { outline: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font: inherit; font-size: .86rem; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 99px; padding: 4px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.chips button:hover { border-color: var(--gc, var(--brand)); }
.chips button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chips button small { opacity: .6; font-size: .78rem; }
.chips .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gc, var(--brand)); }
.chips button.on .dot { box-shadow: 0 0 0 2px color-mix(in srgb, var(--bg) 40%, transparent); }
.chips.small { margin: 0 0 14px; } .chips.small button { font-size: .82rem; padding: 2px 10px; }
.g-blue { --gc: var(--c-blue); } .g-purple { --gc: var(--c-purple); } .g-teal { --gc: var(--c-teal); } .g-orange { --gc: var(--c-orange); } .g-gray { --gc: var(--c-gray); }
.count { color: var(--muted); font-size: .84rem; margin: 14px 0 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.card { text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; display: flex; align-items: flex-start; gap: 12px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card:hover { border-color: var(--gc, var(--brand)); box-shadow: var(--shadow); transform: translateY(-1px); }
.badge-t { flex: none; min-width: 40px; height: 40px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; font-size: .76rem; font-weight: 700; letter-spacing: .01em; color: var(--gc, var(--brand)); background: color-mix(in srgb, var(--gc, var(--brand)) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gc, var(--brand)) 22%, transparent); }
.card .tx { display: grid; gap: 2px; min-width: 0; } .card b { font-weight: 650; font-size: .96rem; }
.card .d { color: var(--muted); font-size: .82rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.profile-line { margin: 0 0 16px; }

/* Tải lên */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; min-height: 250px; padding: 28px; border: 1.5px dashed var(--line-2); border-radius: 16px; background: var(--surface); cursor: pointer; color: var(--muted); max-width: 720px; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over, .drop:focus-visible { border-color: var(--brand); background: var(--brand-soft); outline: none; }
.drop svg { color: var(--brand); margin-bottom: 4px; } .drop strong { color: var(--ink); word-break: break-all; font-weight: 600; }
.alt { margin: 14px 0; }
.lbl { display: block; font-weight: 600; margin-bottom: 6px; }
textarea, input[type=text], select { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s; }
textarea { resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
#paste { max-width: 720px; }
.btn { font: inherit; font-weight: 600; font-size: .92rem; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 8px 16px; cursor: pointer; display: inline-block; box-shadow: var(--shadow-sm); }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); } .btn.primary:hover:not(:disabled) { filter: brightness(1.1); border-color: var(--brand); }
.btn.ghost { background: transparent; box-shadow: none; } .btn.small { padding: 5px 11px; font-size: .84rem; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions.bar { position: sticky; bottom: 0; justify-content: space-between; background: linear-gradient(transparent, var(--bg) 40%); padding: 26px 0 14px; max-width: 860px; }
.alert { padding: 10px 14px; border-radius: 10px; margin: 12px 0; font-size: .94rem; } .alert.err { background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); } .alert.warn { background: var(--amber-soft); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent); }
.busy { margin-top: 16px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.5s; } .card, .choice, .go { transition: none; } html { scroll-behavior: auto; } }

/* Ý kiến chuyên gia */
#rv, .ref { max-width: 860px; }
.sum { display: flex; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 12px; }
.ring { --p: 50; flex: none; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.ring::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); } .ring b { position: relative; z-index: 1; font-size: 1.3rem; font-weight: 700; }
.sum .v { margin: 0 0 8px; font-weight: 600; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { border-radius: 99px; padding: 1px 10px; font-size: .8rem; font-weight: 600; }
.pill.loi { background: var(--red-soft); color: var(--red); } .pill.canh-bao { background: var(--amber-soft); color: var(--amber); } .pill.goi-y { background: var(--blue-soft); color: var(--blue); }
.info { background: var(--brand-soft); color: var(--ink-2); border: 1px solid var(--brand-line); border-radius: 10px; padding: 9px 14px; margin: 0 0 10px; font-size: .92rem; }
.sec { margin: 22px 0 8px; font-size: .98rem; } .sec small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.bulk { margin: 0 0 8px; color: var(--muted); font-size: .88rem; }
.f { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; box-shadow: var(--shadow-sm); }
.f > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
.f > summary::-webkit-details-marker { display: none; }
.f > summary::after { content: ""; width: 8px; height: 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); margin: 0 4px 3px 2px; order: 3; transition: transform .15s; }
.f[open] > summary::after { transform: rotate(225deg); margin-bottom: -2px; }
.ft { flex: 1; font-weight: 600; font-size: .94rem; }
.tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 6px; padding: 2px 7px; flex: none; }
.tag.loi { background: var(--red-soft); color: var(--red); } .tag.canh-bao { background: var(--amber-soft); color: var(--amber); } .tag.goi-y { background: var(--blue-soft); color: var(--blue); }
.fixrow { display: flex; align-items: center; gap: 6px; font-size: .84rem; font-weight: 600; white-space: nowrap; order: 2; color: var(--ink-2); }
.fixrow input { width: 16px; height: 16px; accent-color: var(--brand); }
.fb { padding: 0 14px 14px; } .fb p { margin: 0 0 6px; color: var(--ink-2); } .basis { color: var(--muted) !important; font-size: .82rem; }
.ex { margin: 8px 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: .9rem; }
.ex li { background: var(--bg); border-radius: 6px; padding: 5px 10px; word-break: break-word; }
.ex .pre, .ex .post { color: var(--muted); } .ex mark { background: var(--red-soft); color: var(--red); border-radius: 3px; padding: 0 2px; text-decoration: line-through; }
.ex ins { background: var(--green-soft); color: var(--green); border-radius: 3px; padding: 0 2px; text-decoration: none; font-weight: 600; } .ex .arrow { color: var(--muted); padding: 0 4px; }
details.sub { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; margin: 10px 0; }
details.sub > summary { cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: .92rem; }
details.sub[open] > summary { margin-bottom: 8px; }
details.sub ul { margin: 0; padding-left: 18px; } details.sub li { margin-bottom: 6px; } details.sub li span { color: var(--muted); font-size: .88rem; }
.cols2 { columns: 2; } @media (max-width: 640px) { .cols2 { columns: 1; } }

/* Trình soạn */
.edbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; } .sp { flex: 1; }
.donebar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--green-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--green) 30%, transparent); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: .94rem; }
.ed { display: grid; grid-template-columns: minmax(330px, 430px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 960px) { .ed { grid-template-columns: 1fr; } }
.acc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.acc > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 13px 16px; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: ""; width: 8px; height: 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); margin: 0 3px 3px auto; transition: transform .15s; }
.acc[open] > summary::after { transform: rotate(225deg); margin-bottom: -2px; }
.acc[open] > summary { border-bottom: 1px solid var(--line); }
.badge { font-size: .74rem; font-weight: 600; background: var(--amber-soft); color: var(--amber); border-radius: 99px; padding: 1px 9px; } .badge.ok { background: var(--green-soft); color: var(--green); }
.in { padding: 14px 16px 16px; display: grid; gap: 12px; }
.fl { display: grid; gap: 4px; font-size: .86rem; } .fl > span { font-weight: 600; color: var(--ink-2); } .fl small { color: var(--muted); font-size: .78rem; }
.fl.miss input, .fl.miss textarea { border-color: color-mix(in srgb, var(--amber) 55%, transparent); background: var(--amber-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more { border-top: 1px dashed var(--line-2); padding-top: 10px; } .more > summary { cursor: pointer; color: var(--muted); font-size: .86rem; margin-bottom: 8px; }
.more > div, .more > label { margin-top: 8px; }
.sigbox { border-top: 1px dashed var(--line-2); padding-top: 12px; display: grid; gap: 12px; }
.stage { position: sticky; top: 76px; } @media (max-width: 960px) { .stage { position: static; } }
.paperwrap { background: #e9ecf1; border: 1px solid var(--line); border-radius: 14px; padding: 16px; overflow: hidden; }
@media (prefers-color-scheme: dark) { .paperwrap { background: #0a0e14; } }
.paper { width: 793.7px; min-height: 1122px; background: #fff; color: #000; padding: 75.6px 56.7px 75.6px 113.4px; font-family: "Times New Roman", "Liberation Serif", Times, serif; transform-origin: top left; box-shadow: 0 1px 3px rgba(15, 23, 42, .15), 0 12px 32px -12px rgba(15, 23, 42, .25); }
.paper p { margin: 0; } .paper table.cols { border-collapse: collapse; } .paper table.cols td { vertical-align: top; padding: 0 2px; }
.paper table.data { border-collapse: collapse; width: 100%; table-layout: fixed; margin: 4pt 0; font-size: 13pt; } .paper table.data td, .paper table.data th { border: 1px solid #000; padding: 2pt 5pt; }
.paper .pg-footer { margin-top: 40px; border-top: 1px solid #000; font-size: 11pt; padding-top: 2pt; }
#quick { margin-top: 16px; }

/* Hộp thoại, thông báo */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 26px; width: min(600px, 94vw); max-height: 88vh; background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px -12px rgba(15, 23, 42, .4); }
dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.dlg-close { position: absolute; top: 12px; right: 12px; margin: 0; } .dlg-close button { border: 0; background: transparent; font-size: 1rem; cursor: pointer; color: var(--muted); padding: 6px 10px; border-radius: 8px; } .dlg-close button:hover { background: var(--bg); }
.meta { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; margin: 16px 0; font-size: .92rem; } .meta dt { color: var(--muted); font-weight: 600; } .meta dd { margin: 0; }
.row-actions { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 14px 0; }
.saved { color: var(--green); font-weight: 600; min-height: 1.4em; margin: 8px 0 0; font-size: .9rem; } .saved.bad { color: var(--red); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); max-width: 90vw; font-size: .92rem; }
.ref .scroll { overflow-x: auto; } .ref table { border-collapse: collapse; width: 100%; font-size: .9rem; } .ref th, .ref td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; vertical-align: top; } .ref th { background: var(--bg); color: var(--ink-2); }
.foot { color: var(--muted); font-size: .82rem; padding-bottom: 36px; border-top: 1px solid var(--line); padding-top: 22px; } .foot p { margin: 3px 0; } .contact { margin: 3px 0; }

/* Chia sẻ: nút nhỏ tách riêng ở góc dưới, không nổi bật */
.share { position: fixed; right: 20px; bottom: 20px; z-index: 40; }
.share-fab { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-sm); opacity: .85; transition: opacity .15s, color .15s, border-color .15s; }
.share-fab:hover, .share-fab[aria-expanded="true"] { opacity: 1; color: var(--brand); border-color: var(--brand-line); }
.popover { position: absolute; right: 0; bottom: calc(100% + 10px); width: 288px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: 0 16px 40px -8px rgba(15, 23, 42, .3); }
.popover[hidden] { display: none; }
.pop-title { margin: 0 0 10px; font-weight: 650; font-size: .92rem; }
.share-grid { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.share-grid a, .share-grid button { display: grid; justify-items: center; gap: 4px; font: inherit; font-size: .7rem; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer; padding: 6px 0; border-radius: 8px; width: 100%; }
.share-grid a:hover, .share-grid button:hover { color: var(--ink); background: var(--bg); }
.share-grid i { font-style: normal; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .9rem; }
.share-url { margin: 8px 0 0; font-size: .78rem; color: var(--muted); word-break: break-all; }
@media (max-width: 480px) { .share { right: 12px; bottom: 12px; } .popover { width: min(288px, calc(100vw - 24px)); } }

/* Tô gợi ý (chỉ trong bản xem trước; không đi vào file .docx) */
.stagebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.legend { color: var(--muted); font-size: .8rem; display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 3px; background: #fff0a8; box-shadow: 0 0 0 1px rgba(200, 160, 0, .45); display: inline-block; }
.tgl { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--ink-2); cursor: pointer; font-weight: 600; }
.tgl small { color: var(--muted); font-weight: 500; }
.tgl input { accent-color: var(--brand); }
mark.hl { background: #fff0a8; color: inherit; border-radius: 2px; cursor: pointer; padding: 0; box-shadow: 0 0 0 1px rgba(200, 160, 0, .28); }
mark.hl:hover, mark.hl:focus-visible { background: #ffe066; outline: none; box-shadow: 0 0 0 2px rgba(200, 150, 0, .55); }
mark.hl-spell, mark.hl-word { border-bottom: 1.5px dotted #b88700; }
.paper.hl-off mark.hl { background: transparent; box-shadow: none; border-bottom: 0; cursor: text; }
.hl-pop { position: fixed; z-index: 70; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 16px 40px -8px rgba(15, 23, 42, .35); font: 14px/1.5 var(--font); display: grid; gap: 8px; }
.hl-pop p { margin: 0; color: var(--ink-2); }
.hp-h { display: flex; justify-content: space-between; align-items: center; } .hp-h b { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--amber); background: var(--amber-soft); border-radius: 6px; padding: 1px 8px; }
.hp-h .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.hl-pop .sug { display: flex; gap: 6px; flex-wrap: wrap; }

/* Xác nhận loại văn bản, nhiều người ký, chế độ gọn */
.gate { max-width: 640px; margin: 4vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.gate.warn { border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.gate-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber); font-weight: 800; font-size: 1.3rem; margin-bottom: 12px; }
.gate h1 { font-size: 1.35rem; } .gate p { color: var(--ink-2); margin: .5rem 0; }
.ev { margin: 0 0 8px; padding-left: 20px; color: var(--ink-2); } .ev li { margin: 2px 0; }
.allset { background: var(--green-soft); border: 1px solid color-mix(in srgb, var(--green) 30%, transparent); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; font-size: .94rem; color: var(--ink); }
.sig-h { display: flex; justify-content: space-between; align-items: center; } .sig-h h3 { margin: 0; }
.sig-add { display: grid; gap: 4px; } .sig-add small { color: var(--muted); font-size: .8rem; }

.paper table.data th { text-align: center; font-weight: 700; } .paper table.data td { vertical-align: middle; } .paper table.data td.c { text-align: center; }
mark.hl-blank { background: #dff0ff; box-shadow: 0 0 0 1px rgba(40, 110, 190, .35); } mark.hl-blank:hover, mark.hl-blank:focus-visible { background: #bfe0ff; box-shadow: 0 0 0 2px rgba(40, 110, 190, .6); }

/* Thống kê lượt truy cập (góc dưới phải, bên trái nút chia sẻ) */
.visits { position: fixed; right: 68px; bottom: 27px; z-index: 40; }
.visit-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-2, #d6dbe6); background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer; opacity: .85; box-shadow: var(--shadow-sm); }
.visit-chip:hover, .visit-chip[aria-expanded="true"] { opacity: 1; color: var(--brand); }
.visit-pop { position: absolute; right: 0; bottom: calc(100% + 8px); width: 260px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 16px 40px -8px rgba(15, 23, 42, .35); font-size: 13px; }
.vis-top { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.vis-top div { background: var(--bg); border-radius: 8px; padding: 8px 10px; display: grid; }
.vis-top b { font-size: 18px; } .vis-top span { font-size: 11.5px; color: var(--muted); }
.vis-h { margin: 6px 0 6px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.vis-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; height: 76px; align-items: end; margin-bottom: 10px; }
.vis-bars > div { display: grid; grid-template-rows: 1fr auto; height: 100%; align-items: end; justify-items: center; }
.vis-bars i { display: block; width: 70%; background: var(--brand); border-radius: 3px 3px 0 0; opacity: .85; }
.vis-bars span { font-size: 9.5px; color: var(--muted); margin-top: 2px; }
.vis-cn { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 5px; }
.vis-cn li { display: grid; grid-template-columns: 82px 1fr auto; gap: 6px; align-items: center; font-size: 12.5px; }
.vis-cn .bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; } .vis-cn .bar i { display: block; height: 100%; background: var(--brand); }
.vis-note { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
@media print { .visits { display: none !important; } }

/* ===== Tương thích điện thoại, máy tính bảng, laptop và màn hình lớn ===== */
html { -webkit-tap-highlight-color: transparent; }
main { overflow-x: clip; }
.hero::before { inset: -120px 0 auto; }
.ed > *, .stage, .paperwrap { min-width: 0; }
.brand strong, .links .link { white-space: nowrap; }
.links .short { display: none; }
.wrap { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
img, svg, video { max-width: 100%; }

/* Máy tính bảng và cửa sổ hẹp */
@media (max-width: 960px) {
  .wrap { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .ed { gap: 18px; }
  .actions.bar { max-width: none; }
}

/* Điện thoại */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .bar { height: 54px; gap: 6px; }
  .brand { gap: 8px; } .brand svg { width: 24px; height: 24px; } .brand strong { font-size: .94rem; }
  .links { gap: 0; } .links .link { padding: 8px 9px; font-size: .86rem; }
  .links .long { display: none; } .links .short { display: inline; }
  main { padding-top: 20px; padding-bottom: 96px; }
  .hero { margin-top: 2vh; } .choices { margin-top: 26px; } .choice { padding: 16px; gap: 14px; }
  h1 { font-size: 1.4rem; } .lede { font-size: .95rem; margin-bottom: 1rem; }
  .pickbar { gap: 10px; } .chips { gap: 6px; } .cards { grid-template-columns: 1fr; }
  .drop { min-height: 190px; padding: 20px; }
  .sum { padding: 14px; gap: 14px; } .ring { width: 60px; height: 60px; } .ring b { font-size: 1.1rem; }
  .f > summary { flex-wrap: wrap; padding: 10px 12px; } .ft { flex: 1 1 calc(100% - 96px); min-width: 0; }
  .fixrow { order: 5; flex: 1 1 100%; }
  .fb { padding: 0 12px 12px; }
  .edbar { gap: 6px; } .edbar .sp { display: none; } .edbar .btn { flex: 1 1 auto; text-align: center; }
  .actions.bar { padding-bottom: calc(14px + env(safe-area-inset-bottom)); } .actions.bar .btn { flex: 1 1 auto; text-align: center; }
  .acc > summary { padding: 12px 14px; } .in { padding: 12px 14px 14px; }
  .row2 { grid-template-columns: 1fr; } .row3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .paperwrap { padding: 8px; border-radius: 10px; }
  dialog { padding: 20px 16px; width: 94vw; max-height: 90vh; }
  .meta { grid-template-columns: 1fr; gap: 2px 0; } .meta dt { margin-top: 8px; }
  .visits { right: 58px; bottom: 18px; } .visit-pop { width: min(260px, calc(100vw - 32px)); }
  .foot { padding-bottom: 80px; }
  input, select, textarea { font-size: 16px; } /* tránh iPhone tự phóng to khi nhập */
}

/* Màn hình cảm ứng: vùng bấm đủ lớn */
@media (pointer: coarse) {
  .btn { min-height: 42px; } .btn.small { min-height: 36px; }
  .chips button { padding: 7px 13px; } .links .link { min-height: 40px; }
  .steps button { min-height: 36px; } .f > summary, .acc > summary { min-height: 46px; }
  .share-fab { width: 42px; height: 42px; } .visit-chip { min-height: 34px; }
}

/* Điện thoại nằm ngang, màn hình thấp */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { position: static; } .stage { top: 8px; } main { padding-top: 16px; }
}

/* Màn hình lớn */
@media (min-width: 1500px) {
  body { font-size: 16px; }
  .wrap { max-width: 1280px; }
  .ed { grid-template-columns: minmax(380px, 470px) 1fr; gap: 32px; }
}
@media (min-width: 1900px) { .wrap { max-width: 1400px; } }

/* Các bước: chỉ hiện tên bước đang làm, các bước khác là số (điện thoại và máy tính bảng dọc) */
@media (max-width: 860px) {
  .steps { flex-wrap: nowrap; margin-bottom: 22px; }
  .steps li + li::before { width: 18px; margin: 0 6px; }
  .steps li:not(.on) .lb { display: none; }
  .steps li.on { flex: 1 1 auto; min-width: 0; } .steps .on .lb { white-space: normal; line-height: 1.25; }
}
/* Máy tính bảng dọc: biểu mẫu chia hai cột cho gọn */
@media (min-width: 641px) and (max-width: 960px) {
  .ed .in { grid-template-columns: 1fr 1fr; align-items: start; }
  .ed .in > :not(.fl), .ed .in > .fl:has(textarea) { grid-column: 1 / -1; }
}
