@font-face { font-family: "Be Vietnam Pro"; font-weight: 400; font-display: swap; src: url(../fonts/BeVietnamPro-Regular.woff) format("woff"); }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 600; font-display: swap; src: url(../fonts/BeVietnamPro-SemiBold.woff) format("woff"); }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 800; font-display: swap; src: url(../fonts/BeVietnamPro-ExtraBold.woff) format("woff"); }

:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d232a; --muted: #5d6670; --line: #e2ded5;
  --acc: #0f6e66; --acc-ink: #ffffff; --acc-soft: #e2f1ee; --warn: #9a5b00; --warn-bg: #fff4dc;
  --bad: #b42318; --bad-bg: #fde8e6; --ok: #137a3c;
  --rec: #e5322d; --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 28, .06), 0 6px 24px rgba(20, 24, 28, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181c; --card: #1d2228; --ink: #e8eaed; --muted: #a0a8b2; --line: #2f363e;
    --acc: #3fb8ab; --acc-ink: #06201d; --acc-soft: #183632; --warn: #f5b74e; --warn-bg: #3a2c10;
    --bad: #f87171; --bad-bg: #3b1715; --ok: #4ade80; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181c; --card: #1d2228; --ink: #e8eaed; --muted: #a0a8b2; --line: #2f363e;
  --acc: #3fb8ab; --acc-ink: #06201d; --acc-soft: #183632; --warn: #f5b74e; --warn-bg: #3a2c10;
  --bad: #f87171; --bad-bg: #3b1715; --ok: #4ade80; --shadow: none;
  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.55 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--acc-soft); color: var(--acc); padding: 1px 6px; border-radius: 6px; font-size: .92em; }

/* ---------- Đầu trang ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 12px max(16px, env(safe-area-inset-left)); background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--acc); color: var(--acc-ink); display: grid; place-items: center; flex: none; }
h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -.01em; }
.top p { margin: 0; color: var(--muted); font-size: 13px; }
.steps { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; max-width: 100%; overflow-x: auto; }
.steps button { border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; min-height: 40px; }
.steps button span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-size: 12px; color: var(--ink); }
.steps button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.steps button.on span { background: var(--acc); color: var(--acc-ink); }
.steps button:disabled { opacity: .45; cursor: default; }
@media (max-width: 560px) {
  .top { padding: 10px 16px; }
  .top p { display: none; }
  .steps { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
  .steps button { padding: 6px 2px; font-size: 12.5px; gap: 4px; justify-content: center; min-width: 0; }
  .steps button span { width: 18px; height: 18px; font-size: 11px; flex: none; }
}

/* ---------- Thẻ & bố cục ---------- */
.view:not(.stage) { max-width: 880px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.soft { background: transparent; box-shadow: none; border-style: dashed; }
h2 { font-size: 18px; margin: 0 0 4px; font-weight: 800; letter-spacing: -.01em; }
h3 { margin: 0; font-size: 17px; font-weight: 800; }
.sub { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pill { background: var(--acc-soft); color: var(--acc); font-weight: 700; font-size: 13.5px; padding: 4px 12px; border-radius: 99px; white-space: nowrap; }
.pill.warn-pill { background: var(--warn-bg); color: var(--warn); }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.tpl { text-align: left; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px; cursor: pointer; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start; min-height: 84px; transition: border-color .15s, background .15s; }
.tpl:hover { border-color: var(--acc); }
.tpl[aria-pressed="true"] { border-color: var(--acc); background: var(--acc-soft); }
.tpl .ic { font-size: 26px; line-height: 1; grid-row: span 2; padding-top: 2px; }
.tpl b { font-size: 15.5px; }
.tpl small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.tpl.own { border-style: dashed; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; margin-bottom: 12px; }
.fields.two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; min-width: 0; }
.field em { font-weight: 400; color: var(--muted); font-style: normal; }
.field .req { color: var(--bad); }
input[type=text], select, textarea { width: 100%; max-width: 100%; background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; font-weight: 400; outline: none; }
input[type=text]:focus, select:focus, textarea:focus { border-color: var(--acc); }
textarea { resize: vertical; line-height: 1.6; min-height: 180px; }
.chk { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; cursor: pointer; margin-top: 10px; }
.chk input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--acc); flex: none; }
.chk em { color: var(--muted); font-style: normal; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
.actions.col { flex-direction: column; align-items: stretch; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 10px 16px; font-weight: 700; font-size: 15px; cursor: pointer; min-height: 46px; text-decoration: none; text-align: center; }
.btn:hover { border-color: var(--acc); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { min-height: 56px; font-size: 17px; padding: 12px 22px; border-radius: 14px; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
@media (max-width: 560px) { .actions:not(.col) .btn.big { flex: 1 1 100%; } }

.warn { margin: 12px 0 0; padding: 10px 14px 10px 32px; background: var(--warn-bg); color: var(--warn); border-radius: 12px; font-size: 14px; }
.warn.bad { background: var(--bad-bg); color: var(--bad); }

.banners { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.banner { margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: var(--warn-bg); color: var(--warn); font-size: 14.5px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner b { display: block; margin-bottom: 2px; }
.banner .btn { margin-top: 8px; }

/* ---------- Xem lại ---------- */
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.player { background: #000; border-radius: 14px; overflow: hidden; display: grid; place-items: center; max-height: 72vh; }
.player video { width: 100%; max-height: 72vh; display: block; background: #000; }
.facts { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; font-size: 14.5px; }
.facts li { display: flex; gap: 8px; align-items: baseline; }
.facts li::before { content: "✓"; color: var(--ok); font-weight: 800; }
.facts li.no::before { content: "!"; color: var(--warn); }
@media (max-width: 720px) { .review { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Nộp bài ---------- */
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; counter-reset: ck; }
.checklist li { counter-increment: ck; }
.checklist label { display: grid; grid-template-columns: 26px 1fr; gap: 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; align-items: start; }
.checklist input { width: 24px; height: 24px; accent-color: var(--acc); margin: 0; }
.checklist b { display: block; font-size: 15.5px; }
.checklist b::before { content: counter(ck) ". "; color: var(--acc); }
.checklist em { display: block; font-style: normal; color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.checklist label:has(input:checked) { border-color: var(--acc); background: var(--acc-soft); }
.progress { height: 8px; background: var(--line); border-radius: 99px; margin-top: 16px; overflow: hidden; }
.progress b { display: block; height: 100%; width: 0; background: var(--acc); transition: width .3s; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1d232a; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 60; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px 16px 30px; }

/* ================= MÀN QUAY ================= */
body.recording-ui { overflow: hidden; background: #000; }
body.recording-ui .top, body.recording-ui .foot, body.recording-ui .banners { display: none; }
.stage { position: fixed; inset: 0; background: #000; color: #fff; z-index: 20; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; height: 100vh; height: 100dvh; }
.cam-wrap { position: absolute; inset: 0; display: grid; place-items: center; }
.frame { position: relative; overflow: hidden; background: #111; border-radius: 0; }
.frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame.mirror video { transform: scaleX(-1); }
.frame::after { content: ""; position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.18); pointer-events: none; }
.guides { position: absolute; inset: 0; pointer-events: none; display: none; }
.guides.on { display: block; }
.guides i { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed rgba(255,255,255,.45); }
.guides i:nth-child(1) { top: 33.33%; }
.guides i:nth-child(2) { top: 66.66%; }

.prompter { position: absolute; top: 0; left: 0; right: 0; height: var(--prH, 40%); overflow: hidden; z-index: 3; cursor: pointer; outline: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.82) 0%, rgba(0,0,0,.72) 70%, rgba(0,0,0,0) 100%); padding-top: env(safe-area-inset-top); }
.pr-inner { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.pr-text { max-width: min(900px, 100%); margin: 0 auto; padding: 0 max(18px, env(safe-area-inset-left)); font-size: var(--prFont, 34px); line-height: 1.38; font-weight: 600; text-align: center; color: rgba(255,255,255,.96); text-shadow: 0 1px 2px rgba(0,0,0,.6); letter-spacing: .005em; }
.pr-text p { margin: 0 0 .55em; }
.pr-text span.w { transition: color .2s, opacity .2s; }
.pr-text span.done { opacity: .38; }
.pr-text span.now { color: #ffd84d; }
.pr-text.flip { transform: scaleX(-1); }
.pr-text .end { color: #7fe3d6; font-size: .6em; font-weight: 600; display: block; margin-top: .8em; }
.pr-mark { position: absolute; left: 0; right: 0; top: var(--markY, 26%); height: 0; pointer-events: none; }
.pr-mark::before, .pr-mark::after { content: ""; position: absolute; top: -8px; border: 8px solid transparent; }
.pr-mark::before { left: 6px; border-left-color: #ffd84d; }
.pr-mark::after { right: 6px; border-right-color: #ffd84d; }
.pr-paused { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(255,216,77,.95); color: #1d1a0a; font-weight: 700; font-size: 14px; padding: 6px 14px; border-radius: 99px; white-space: nowrap; }

.hud { position: absolute; left: 0; right: 0; top: calc(var(--prH, 40%) + 6px); display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 12px; z-index: 4; pointer-events: none; }
.hud > * { pointer-events: auto; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.rec-badge { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.55); padding: 6px 12px; border-radius: 99px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-badge i { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.meter { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.55); padding: 8px 12px; border-radius: 99px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.meter .bar { position: relative; width: 110px; height: 8px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.meter .bar b { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; background: linear-gradient(to right, #3fb8ab 0%, #3fb8ab 62%, #ffd84d 80%, #e5322d 95%); background-size: 110px 100%; }
.meter .bar s { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; left: 0; }
.level-msg { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--prH, 40%) + 60px); z-index: 4; padding: 8px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); text-align: center; background: rgba(0,0,0,.65); }
.level-msg.low { color: #ffd84d; }
.level-msg.high { color: #ff8a80; }
.level-msg.ok { color: #7fe3d6; }

.countdown { position: absolute; inset: 0; display: grid; place-items: center; z-index: 6; pointer-events: none; }
.countdown span { font-size: min(34vw, 220px); font-weight: 800; color: #fff; text-shadow: 0 4px 40px rgba(0,0,0,.6); animation: pop 1s ease-out infinite; }
@keyframes pop { 0% { transform: scale(1.25); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(.85); opacity: .85; } }

.dock { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0)); display: grid; gap: 10px; justify-items: center; }
.quick { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.5); padding: 5px; border-radius: 99px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.chip { min-width: 44px; height: 40px; border: 0; border-radius: 99px; background: rgba(255,255,255,.14); color: #fff; font-weight: 800; font-size: 16px; cursor: pointer; padding: 0 10px; }
.chip:active { background: rgba(255,255,255,.3); }
.chip-label { font-size: 13px; color: rgba(255,255,255,.85); padding: 0 4px; white-space: nowrap; }
.chip-label b { color: #fff; font-variant-numeric: tabular-nums; }
.sep { width: 1px; height: 22px; background: rgba(255,255,255,.25); margin: 0 4px; }
.main-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: 100%; max-width: 460px; gap: 12px; }
.side-btn { justify-self: center; display: grid; justify-items: center; gap: 4px; border: 0; background: transparent; color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer; min-width: 72px; padding: 6px; }
.side-btn svg, .ratio-ico { width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: rgba(0,0,0,.5); box-sizing: border-box; }
.ratio-ico { display: grid; place-items: center; padding: 0; }
.ratio-ico::before { content: ""; display: block; width: 14px; height: 24px; border: 2.4px solid #fff; border-radius: 4px; }
.ratio-ico.wide::before { width: 26px; height: 15px; }
.rec-btn { width: 82px; height: 82px; border-radius: 50%; border: 5px solid #fff; background: transparent; padding: 0; display: grid; place-items: center; cursor: pointer; }
.rec-btn i { width: 62px; height: 62px; border-radius: 50%; background: var(--rec); transition: all .2s; }
.rec-btn.on i { width: 32px; height: 32px; border-radius: 8px; }
.rec-btn:disabled { opacity: .5; }
.dock-hint { margin: 0; font-size: 13px; color: rgba(255,255,255,.78); text-align: center; max-width: 520px; }
body.is-recording .quick { opacity: .85; }
body.is-recording #setBtn, body.is-recording #ratioBtn, body.is-recording #backBtn { visibility: hidden; }

.sheet { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: var(--card); color: var(--ink); width: 100%; max-width: 560px; max-height: 88%; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }
.range { display: grid; gap: 6px; margin-top: 14px; font-size: 14.5px; font-weight: 600; }
.range span { display: flex; justify-content: space-between; }
.range input { width: 100%; accent-color: var(--acc); height: 28px; }
.toggles { margin-top: 6px; }
.sheet .field { margin-top: 14px; }
.tech summary { cursor: pointer; color: var(--muted); font-size: 13.5px; margin-top: 16px; }
.tech pre { font-size: 12px; white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 10px; border-radius: 10px; }
#permBody { font-size: 15px; }
#permBody ol { padding-left: 20px; }
#permBody li { margin: 4px 0; }

/* Laptop: nút gọn hơn, chữ hẹp lại cho mắt gần camera giữa mép trên */
@media (min-width: 900px) and (pointer: fine) {
  .pr-text { max-width: 760px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .dock { padding-bottom: calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .rec-btn { width: 64px; height: 64px; border-width: 4px; }
  .rec-btn i { width: 46px; height: 46px; }
  .dock-hint { display: none; }
  .side-btn span:not(.ratio-ico) { display: none; }
}
