/* Phương án A – "Lớp học từng bước": một bước một màn hình, thanh 4 bước, chữ to, navy điềm tĩnh + xanh lá cho hành động */
:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --soft: #eef3f9;
  --ink: #0f1d33;
  --ink-2: #475569;
  --muted: #64748b;
  --line: #e2e8f0;
  --navy: #1e3a5f;
  --navy-ink: #ffffff;
  --go: #047857;
  --go-ink: #ffffff;
  --go-soft: #e3f5ee;
  --top: #1e3a5f;
  --top-ink: #ffffff;
  --code-bg: #0f1d33;
  --code-ink: #e2e8f0;
  --warn: #9a5b06;
  --warn-soft: #fdf3e2;
  --error: #b42318;
  --error-soft: #fdecea;
  --info: #1d4ed8;
  --info-soft: #e8efff;
  --ok: #047857;
  --ok-soft: #e3f5ee;
  --female: #be185d;
  --male: #1d4ed8;
  --radius: 16px;
  --radius-sm: 11px;
  --font-head: 'Lexend', 'Be Vietnam Pro', system-ui, sans-serif;
  --font-body: 'Work Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  color-scheme: light;
}
/* Tối: theo máy khi chưa chọn (không có data-theme), hoặc khi người dùng chọn Tối. Cùng một bộ giá trị ở hai khối. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1520;
    --card: #142030;
    --soft: #1a2a3e;
    --ink: #e6edf6;
    --ink-2: #b4c0d0;
    --muted: #8a98ab;
    --line: #26364b;
    --navy: #8db4e8;
    --navy-ink: #0d1520;
    --go: #34d399;
    --go-ink: #062018;
    --go-soft: #12322a;
    --top: #13243d;
    --top-ink: #e6edf6;
    --code-bg: #0a111b;
    --code-ink: #dbe4f0;
    --warn: #f5b454;
    --warn-soft: #33270f;
    --error: #f97066;
    --error-soft: #3a1714;
    --info: #8ab4ff;
    --info-soft: #172442;
    --ok: #34d399;
    --ok-soft: #12322a;
    --female: #f472b6;
    --male: #8ab4ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1520;
  --card: #142030;
  --soft: #1a2a3e;
  --ink: #e6edf6;
  --ink-2: #b4c0d0;
  --muted: #8a98ab;
  --line: #26364b;
  --navy: #8db4e8;
  --navy-ink: #0d1520;
  --go: #34d399;
  --go-ink: #062018;
  --go-soft: #12322a;
  --top: #13243d;
  --top-ink: #e6edf6;
  --code-bg: #0a111b;
  --code-ink: #dbe4f0;
  --warn: #f5b454;
  --warn-soft: #33270f;
  --error: #f97066;
  --error-soft: #3a1714;
  --info: #8ab4ff;
  --info-soft: #172442;
  --ok: #34d399;
  --ok-soft: #12322a;
  --female: #f472b6;
  --male: #8ab4ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font-body); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.3; margin: 0; }
b { font-weight: 600; }
a { color: var(--navy); }

.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-lg { width: 30px; height: 30px; }

/* ---------- thanh trên ---------- */
.topbar { background: var(--top); color: var(--top-ink); }
.topbar-in { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 12px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; flex: none; color: var(--top-ink); text-decoration: none; font-size: 14px; opacity: .85; padding: 6px 10px 6px 4px; border-radius: 8px; min-height: 38px; margin-left: -4px; }
.back-link:hover { opacity: 1; background: rgba(255, 255, 255, .1); }
.back-link:focus-visible { outline: 2px solid var(--top-ink); outline-offset: 2px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font: 600 18px var(--font-head); padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .2); min-width: 0; }
.brand-text { display: flex; flex-direction: column; gap: 3px; line-height: 1.25; min-width: 0; }
.brand-sub { font: 400 12.5px/1.3 var(--font-body); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Nút chức năng ở thanh trên: chỉ biểu tượng (tên đầy đủ nằm ở tooltip + aria-label) */
.lang-btn #langCode { font: 600 13px var(--font-head); letter-spacing: .04em; }
#btnApi { padding: 0 8px 0 11px; gap: 7px; }
#btnTheme[data-mode="dark"] .ic-moon, #btnTheme[data-mode="light"] .ic-sun { display: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--top-ink); color: var(--top); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.brand-name b { opacity: .75; font-weight: 500; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.top-actions > * { flex: none; }
.topbar .btn-top { background: rgba(255, 255, 255, .12); border-color: transparent; color: var(--top-ink); height: 40px; min-height: 40px; padding: 0 10px; gap: 6px; font-size: 14px; }
.topbar .btn-top:hover:not(:disabled) { background: rgba(255, 255, 255, .2); border-color: transparent; }

/* ---------- thanh bước ---------- */
.stepper { max-width: 900px; margin: 0 auto; padding: 20px 20px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.st { border: 0; background: transparent; text-align: left; font: inherit; cursor: pointer; padding: 0 0 4px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; min-height: 44px; }
.st:disabled { cursor: not-allowed; opacity: .55; }
.st i { height: 6px; border-radius: 3px; background: var(--line); display: block; transition: background .2s; }
.st.done i { background: var(--go); }
.st.on i { background: var(--navy); }
.st .st-n { font-size: 13px; }
.st b { font: 600 15px var(--font-head); color: var(--ink); }
.st.on b { color: var(--navy); }
.st:focus-visible { outline: 2px solid var(--navy); outline-offset: 4px; border-radius: 4px; }

/* ---------- bố cục ---------- */
.wrap { max-width: 900px; margin: 0 auto; padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 16px; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.step-head { display: flex; flex-direction: column; gap: 4px; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.step-head h2 { font-size: 24px; text-wrap: balance; }
.sub { margin: 2px 0 0; color: var(--ink-2); max-width: 68ch; }
.meta { color: var(--muted); font-size: 14px; }
.step-nav { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding-top: 18px; border-top: 1px solid var(--line); margin-top: 4px; }
.nav-hint { color: var(--muted); font-size: 14px; text-align: right; }
.footer { max-width: 900px; margin: 0 auto; padding: 8px 20px 40px; color: var(--muted); font-size: 13px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.footer p { margin: 0; }
.footer .credit { font-size: 14px; color: var(--ink-2); }
.footer a { color: var(--navy); }

/* ---------- điều khiển ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: 500 15px var(--font-body); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .2s, border-color .2s, transform .05s;
}
.btn:hover:not(:disabled) { border-color: var(--navy); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .input:focus-visible, .textarea:focus-visible, .seg button:focus-visible, .count button:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.btn-go { background: var(--go); border-color: var(--go); color: var(--go-ink); }
.btn-go:hover:not(:disabled) { background: color-mix(in srgb, var(--go) 88%, #000); border-color: transparent; }
.btn-navy { background: var(--navy); border-color: var(--navy); color: var(--navy-ink); }
.btn-navy:hover:not(:disabled) { background: color-mix(in srgb, var(--navy) 88%, #000); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 38px; padding: 6px 13px; font-size: 14px; }
.btn-danger-ghost { background: transparent; color: var(--error); }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 15px; display: inline-grid; place-items: center; }
.icon-btn:hover:not(:disabled) { background: var(--soft); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--go); color: var(--go-ink); font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }
.badge.zero { background: var(--error); color: #fff; }

.seg { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--ink-2); font: 500 15px var(--font-body); padding: 7px 15px; min-height: 38px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 29, 51, .15); }
.seg-sm button { padding: 4px 11px; min-height: 34px; font-size: 14px; }
.seg .g-female.on { color: var(--female); }
.seg .g-male.on { color: var(--male); }

.count { display: flex; gap: 8px; flex-wrap: wrap; }
.count button { width: 48px; height: 48px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card); font: 600 17px var(--font-head); cursor: pointer; color: var(--ink); }
.count button.on { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); }

.input, .textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font: inherit; padding: 10px 13px; }
.input { min-height: 46px; }
select.input { padding-right: 30px; }
.textarea { resize: vertical; min-height: 140px; line-height: 1.6; }
.textarea.mono { font: 13.5px/1.7 var(--mono); }
.textarea.code { font: 14px/1.8 var(--mono); background: var(--code-bg); color: var(--code-ink); border-color: var(--code-bg); padding: 14px 16px; }
.input.invalid, .textarea.invalid { border-color: var(--error); }
.input.invalid { background: var(--error-soft); }
.textarea.code.invalid { box-shadow: 0 0 0 2px var(--error); }

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.field-row { display: grid; gap: 16px; }
.field-row.two { grid-template-columns: 1fr auto; align-items: end; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.actions.end { justify-content: flex-end; }
.status { color: var(--ink-2); font-size: 14px; }
.link { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }

.msg { margin: 0; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14.5px; }
.msg-error { background: var(--error-soft); color: var(--error); }
.msg-warn { background: var(--warn-soft); color: var(--warn); }
.msg-info { background: var(--info-soft); color: var(--info); }
.msg-ok { background: var(--ok-soft); color: var(--ok); }
.msg ul { margin: 6px 0 0; padding-left: 20px; }

.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 13px 16px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); }
.banner span { flex: 1; min-width: 200px; }

/* ---------- bước 1 ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; border: 2px dashed color-mix(in srgb, var(--navy) 30%, var(--line)); border-radius: 14px; padding: 28px 16px; cursor: pointer; color: var(--ink-2); background: var(--soft); transition: border-color .2s, background .2s; }
.dropzone:hover, .dropzone.over { border-color: var(--navy); }
.dropzone b { color: var(--navy); }
.dropzone .ic-lg { color: var(--navy); }
.dropzone small { color: var(--muted); }
.file-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.file-ext { width: 42px; height: 42px; border-radius: 10px; background: var(--soft); color: var(--navy); display: grid; place-items: center; font: 600 11px var(--font-head); text-transform: uppercase; flex: none; }
.file-row b { display: block; overflow-wrap: anywhere; }
.file-row small { color: var(--muted); }

/* ---------- bước 2 ---------- */
.speaker-list { display: flex; flex-direction: column; gap: 10px; }
.speaker { display: grid; grid-template-columns: 42px minmax(120px, 1fr) auto minmax(180px, 1.3fr) 42px; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.speaker-idx { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font: 600 16px var(--font-head); color: #fff; background: var(--muted); }
.speaker-idx.female { background: var(--female); }
.speaker-idx.male { background: var(--male); }
.speaker .speaker-preview { border: 1px solid var(--line); border-radius: 50%; color: var(--navy); }
.speaker .hint { grid-column: 2 / -1; font-size: 13px; color: var(--muted); margin-top: -4px; }
.speaker .hint.warn { color: var(--warn); }
.speaker .hint:empty { display: none; }

/* ---------- bước 3 ---------- */
.status-box { display: flex; gap: 10px; align-items: center; padding: 12px 14px; background: var(--soft); border-radius: var(--radius-sm); }
.status-box:has(> .status:empty) { display: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--navy); animation: pulse 1.2s infinite; flex: none; display: none; }
.status-box:has(.status.busy) .dot { display: block; }
@keyframes pulse { 50% { opacity: .3; } }
.norm-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.norm-log:empty { display: none; }
.norm-log li { font-size: 13.5px; color: var(--warn); }
.norm-log li::before { content: '↷ '; }
#normWarnings:empty { display: none; }
#normWarnings { display: flex; flex-direction: column; gap: 8px; }
.editor-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: -10px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.error-list { list-style: none; margin: -6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.error-list:empty { display: none; }
.error-list li { font-size: 14px; color: var(--error); background: var(--error-soft); padding: 7px 11px; border-radius: 8px; cursor: pointer; }
.error-list li b { font-family: var(--mono); }
.syntax { font-size: 14px; color: var(--ink-2); }
.syntax summary { cursor: pointer; color: var(--navy); min-height: 38px; display: flex; align-items: center; }
.syntax pre { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; font: 12.5px/1.6 var(--mono); white-space: pre; }
.syntax p { margin: 6px 0 0; }

/* ---------- bước 4 ---------- */
.estimate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.estimate .stat { background: var(--soft); border-radius: var(--radius-sm); padding: 14px; }
.estimate .stat b { display: block; font: 600 24px var(--font-head); font-variant-numeric: tabular-nums; }
.estimate .stat span { font-size: 13px; color: var(--ink-2); }
.estimate .msg { grid-column: 1 / -1; }
.progress { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--go); transition: width .3s; }
.chunk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chunk-list:empty { display: none; }
.chunk { display: grid; grid-template-columns: 30px 1fr auto auto; gap: 10px; align-items: center; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.chunk-n { font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.chunk-main { min-width: 0; }
.chunk-who { font-size: 14px; font-weight: 600; }
.chunk-text { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chunk-err { font-size: 13px; color: var(--error); }
.chunk-tools { display: flex; gap: 2px; }
.pill { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 10px; white-space: nowrap; }
.pill.cho { background: var(--soft); color: var(--muted); }
.pill.dang { background: var(--info-soft); color: var(--info); }
.pill.xong { background: var(--ok-soft); color: var(--ok); }
.pill.loi { background: var(--error-soft); color: var(--error); }
.scene-label { font-size: 13px; color: var(--muted); margin: 8px 0 0 4px; list-style: none; }
.result { padding: 18px; border-radius: 14px; background: var(--go-soft); display: flex; flex-direction: column; gap: 12px; }
.result-head { display: flex; align-items: center; gap: 8px; color: var(--go); font: 600 17px var(--font-head); flex-wrap: wrap; }
.result-head .meta { margin-left: auto; font: 500 14px var(--font-body); }
.result audio { width: 100%; }

/* ---------- hộp thoại ---------- */
.modal { border: 0; padding: 0; border-radius: var(--radius); background: var(--card); color: var(--ink); width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal-lg { width: min(760px, calc(100vw - 32px)); }
.modal-lg .modal-in { max-height: calc(100vh - 32px); }
.help { overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-right: 4px; min-height: 0; }
.help-lead { margin: 0; color: var(--ink-2); }
.help section { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
.help h4 { margin: 0 0 8px; font: 600 16px var(--font-head); display: flex; align-items: center; gap: 10px; }
.help h4 .n { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: var(--navy-ink); display: grid; place-items: center; font-size: 14px; flex: none; }
.help ol, .help ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.help li { padding-left: 2px; }
.help code { font: 13px var(--mono); background: var(--soft); padding: 1px 6px; border-radius: 5px; }
.help-note { margin: 10px 0 0; font-size: 14px; color: var(--warn); }
.modal::backdrop { background: rgba(8, 15, 26, .5); }
.modal-in { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h3 { font-size: 20px; }
.key-list-head { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.key-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.key-list li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.key-list code { font-family: var(--mono); font-size: 13px; }
.key-list .empty { color: var(--muted); font-size: 14px; border-style: dashed; }
.key-state { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--soft); color: var(--muted); }
.key-state.ok { background: var(--ok-soft); color: var(--ok); }
.key-state.invalid, .key-state.blocked { background: var(--error-soft); color: var(--error); }
.key-state.quota { background: var(--warn-soft); color: var(--warn); }
.choice { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.privacy-note { margin: 0; display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2); background: var(--soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.privacy-note .ic { width: 16px; height: 16px; margin-top: 2px; color: var(--go); }
.merge-map { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; width: 100%; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

@media (max-width: 680px) {
  .stepper { padding: 14px 16px 0; gap: 6px; }
  .st .st-n { display: none; }
  .st b { font-size: 13px; }
  .wrap { padding: 12px 16px 32px; }
  .step { padding: 18px; gap: 16px; }
  .step-head h2 { font-size: 21px; }
  /* Thanh trên trên điện thoại: giữ tên app (bỏ logo và dòng mô tả), nút chức năng 38 px */
  .topbar-in { padding: 8px 10px; gap: 4px; }
  .back-link span, .brand-mark, .brand-sub { display: none; }
  .back-link { width: 30px; padding: 0; justify-content: center; margin-left: -4px; }
  .back-link .ic { width: 22px; height: 22px; }
  .brand { padding-left: 7px; font-size: 15.5px; }
  .brand-name { white-space: nowrap; }
  .top-actions { gap: 4px; }
  #btnApi { padding: 0 6px 0 8px; gap: 5px; }
  .topbar .btn-top { height: 38px; min-height: 38px; }
  .speaker { grid-template-columns: 42px minmax(0, 1fr) auto 42px; gap: 8px; }
  .speaker .gender-seg { grid-column: 3; grid-row: 1; }
  .speaker .speaker-preview { grid-column: 4; grid-row: 1; }
  .speaker .voice-select { grid-column: 1 / -1; grid-row: 2; }
  .speaker .hint { grid-column: 1 / -1; }
  .field-row.two { grid-template-columns: 1fr; }
  .estimate { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .estimate .stat { padding: 10px; }
  .estimate .stat b { font-size: 19px; }
  .chunk { grid-template-columns: 24px 1fr auto; }
  .chunk-tools { grid-column: 2 / -1; justify-content: flex-end; }
  .step-nav { grid-template-columns: 1fr 1fr; }
  .step-nav .nav-hint { grid-column: 1 / -1; grid-row: 1; text-align: left; }
  .step-nav .nav-hint:empty { display: none; }
  .step-nav .btn { width: 100%; }
}

/* Màn hình rất hẹp (≤ 360 px): tên app một hàng, các nút xuống hàng dưới (canh phải) – không bỏ tên app */
@media (max-width: 360px) {
  .topbar-in { flex-wrap: wrap; row-gap: 6px; }
  .brand { flex: 1; border-left: 0; }
  .top-actions { width: 100%; justify-content: flex-end; }
}

/* ≤ 1000 px: nút có chữ nên bỏ logo, dòng mô tả và chữ "Ứng dụng" để đủ chỗ cho tên app */
@media (max-width: 1000px) {
  .brand-mark, .brand-sub, .back-link span { display: none; }
  .back-link { padding: 6px 6px 6px 2px; }
  .brand-name { white-space: nowrap; }
}

/* < 760 px: nút ở thanh trên chỉ còn biểu tượng (tên đầy đủ ở tooltip + aria-label), để tên app luôn hiện đủ */
@media (max-width: 759px) {
  .topbar .btn-top .lbl, .lang-globe { display: none; }
  .topbar .btn-top:not(#btnApi) { width: 40px; padding: 0; }
}
@media (max-width: 680px) {
  .topbar .btn-top:not(#btnApi) { width: 38px; }
}
