/* KIỀU VY CONTENT OS — xanh · vàng · trắng, ưu tiên điện thoại */
:root {
  --blue: #1238c4;
  --blue-deep: #0b2484;
  --blue-soft: #e9eefc;
  --yellow: #f5b70f;
  --yellow-soft: #fff4d4;
  --ink: #141a2e;
  --muted: #5b6480;
  --line: #dfe4f0;
  --bg: #f7f8fc;
  --card: #ffffff;
  --ok: #17803d;
  --ok-soft: #e5f5ea;
  --warn: #9a6200;
  --warn-soft: #fff1d6;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --radius: 16px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Georgia thiếu chữ tiếng Việt có dấu (ế, ồ…) nên không dùng */
  --serif: "Noto Serif", "Times New Roman", Times, "Liberation Serif", serif;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
a { color: var(--blue); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bay { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- đầu trang & điều hướng ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; min-width: 0; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--yellow); color: var(--blue-deep);
  display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
}
.brand-text { font-weight: 800; letter-spacing: .6px; font-size: 15px; line-height: 1.1; }
.brand-text small { display: block; font-weight: 600; letter-spacing: 2px; font-size: 11px; color: var(--yellow); }
.mode-pill {
  margin-left: auto; font-size: 12px; font-weight: 700; border-radius: 999px;
  padding: 4px 10px; background: var(--yellow); color: var(--blue-deep); white-space: nowrap;
}
.mode-pill.ai { background: #fff; color: var(--blue); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 600;
}
.tabs a .ic { font-size: 20px; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--blue); }
.tabs a[aria-current="page"] .ic { transform: scale(1.08); }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 32px; }
.wide main { max-width: 1080px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabs {
    position: static; display: flex; gap: 4px; height: auto; border: 0; background: transparent; padding: 0; margin-left: 24px;
  }
  .tabs a { flex-direction: row; gap: 6px; color: #dbe3ff; padding: 8px 14px; border-radius: 999px; font-size: 14px; }
  .tabs a .ic { font-size: 16px; }
  .tabs a[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; }
  .topbar { padding: 12px 28px; }
}

/* ---------- chữ ---------- */
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: 1.6px; color: var(--blue); text-transform: uppercase; margin: 0 0 4px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- khối ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.card.hero { background: var(--blue); color: #fff; border: 0; }
.card.hero .eyebrow { color: var(--yellow); }
.notice { border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; font-size: 14px; }
.notice.mau { background: var(--yellow-soft); border: 1px solid #f2d27c; }
.notice.loi { background: var(--bad-soft); border: 1px solid #f3b8b2; color: #7a1a12; }
.notice.ok { background: var(--ok-soft); border: 1px solid #a8dcb8; color: #0f5a2a; }
.notice.info { background: var(--blue-soft); border: 1px solid #c8d4f7; }

/* ---------- biểu mẫu ---------- */
label.field { display: block; font-weight: 700; font-size: 14px; margin: 14px 0 6px; }
textarea, input[type="text"], input[type="search"], input[type="url"], input[type="password"], input[type="number"], select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px 14px; outline: none; transition: border-color .15s;
}
textarea:focus, input:focus, select:focus { border-color: var(--blue); }
textarea.big { min-height: 220px; resize: vertical; font-size: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px;
  font-weight: 600; font-size: 14px; cursor: pointer; min-height: 40px;
}
.chip[aria-pressed="true"] { background: var(--blue); color: #fff; border-color: var(--blue); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-deep); }
.tag.mau { background: var(--yellow-soft); color: #7a5300; }
.tag.dat { background: var(--ok-soft); color: var(--ok); }
.tag.can_xem { background: var(--warn-soft); color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px; min-height: 46px;
  font-weight: 700; cursor: pointer; background: var(--blue-soft); color: var(--blue-deep); text-decoration: none;
}
.btn.primary { background: var(--blue); color: #fff; width: 100%; font-size: 17px; min-height: 54px; }
.btn.yellow { background: var(--yellow); color: var(--blue-deep); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

details.more { margin-top: 14px; border: 1px dashed var(--line); border-radius: 12px; padding: 4px 14px 12px; background: #fff; }
details.more > summary { cursor: pointer; font-weight: 700; padding: 10px 0 6px; color: var(--blue-deep); }
.radio-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; }
.radio-row label { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- tiến trình ---------- */
.steps { list-style: none; padding: 0; margin: 10px 0 0; }
.steps li { padding: 6px 0 6px 26px; position: relative; font-size: 14px; }
.steps li::before { content: "✓"; position: absolute; left: 4px; color: var(--ok); font-weight: 800; }
.steps li.cur::before { content: ""; width: 12px; height: 12px; left: 4px; top: 11px; border: 2px solid var(--blue); border-right-color: transparent; border-radius: 50%; animation: quay .8s linear infinite; }
@keyframes quay { to { transform: rotate(360deg); } }

/* ---------- kịch bản ---------- */
.toolbar {
  position: sticky; top: 56px; z-index: 15;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  background: rgba(247,248,252,.96); backdrop-filter: blur(6px);
  padding: 8px 0; margin: 0 0 10px; border-bottom: 1px solid var(--line);
}
.toolbar select { width: auto; max-width: 46%; padding: 8px 10px; border-radius: 10px; }
.script-sec { scroll-margin-top: 120px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 12px; }
.script-sec header { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; margin-bottom: 6px; }
.script-sec h3 { margin: 0; font-size: 14px; letter-spacing: .4px; color: var(--blue); text-transform: uppercase; }
.time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.spoken { font-family: var(--serif); font-size: 20px; line-height: 1.75; white-space: pre-wrap; margin: 0; }
.spoken.edit { font-family: var(--serif); font-size: 18px; line-height: 1.7; min-height: 160px; }
@media (min-width: 900px) { .spoken { font-size: 21px; } }

.gate { display: grid; grid-template-columns: 24px 1fr; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.gate:first-child { border-top: 0; }
.gate .ico { font-weight: 900; }
.gate.dat .ico { color: var(--ok); }
.gate.canh_bao .ico { color: var(--warn); }
.gate.khong_dat .ico { color: var(--bad); }
.gate .src { font-size: 11px; font-weight: 700; color: var(--muted); margin-left: 6px; }

/* ---------- kho ---------- */
.item { position: relative; }
.item h3 { margin: 0 0 4px; font-size: 16px; }
.item .body {
  white-space: pre-wrap; font-size: 15px; margin: 8px 0 0; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; line-clamp: 6;
}
.item.open .body { display: block; -webkit-line-clamp: unset; line-clamp: unset; }
.item .pick { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; font-size: 14px; }
.selbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); z-index: 25;
  background: var(--blue-deep); color: #fff; border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; justify-content: space-between; box-shadow: 0 8px 24px rgba(11,36,132,.3);
}
@media (min-width: 900px) { .selbar { left: auto; right: 28px; bottom: 24px; width: 420px; } }

.lesson summary { cursor: pointer; list-style: none; display: flex; gap: 12px; align-items: center; }
.lesson summary::-webkit-details-marker { display: none; }
.badge { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--yellow-soft); color: #7a5300; font-weight: 800; font-size: 11px; }
.lesson .content { margin-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

.grid2 { display: grid; gap: 14px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1.4fr 1fr; align-items: start; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px); z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw;
}
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- tiện ích (thay cho style viết trực tiếp, vì CSP chặn) ---------- */
.mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.mb6 { margin-bottom: 6px; }
/* Kết quả lấy lời thoại từng link */
.linkres { border-left: 3px solid var(--line); padding: 6px 10px; margin-top: 8px; word-break: break-all; }
.linkres.xong { border-left-color: var(--ok); }
.linkres.khong_loi_noi { border-left-color: var(--warn); }
.linkres.loi { border-left-color: var(--bad); }
.linkres .small { word-break: normal; }
.card.attention { border-color: #f2d27c; background: #fffbef; }
.fixlist { margin: 10px 0 0; padding-left: 18px; font-size: 14px; }
.fixlist li { margin: 6px 0; }
.fixlist li.khong_dat b { color: var(--bad); }
.fixlist li.canh_bao b { color: var(--warn); }
.fixlist li.dat { color: var(--ok); list-style: none; margin-left: -18px; }
.fixlist li.gop_y { color: var(--muted); }
.fixlist li.gop_y b { color: var(--muted); font-weight: 600; }
.direction { border-top: 1px solid var(--line); padding: 10px 0; }
.direction:first-child { border-top: 0; padding-top: 0; }
.version { border-top: 1px solid var(--line); padding: 8px 0; flex-wrap: nowrap; }
.version:first-child { border-top: 0; }
a.linkcard { display: block; text-decoration: none; color: inherit; }
a.linkcard:hover { border-color: var(--blue); }
#deviceLink { flex: 1; min-width: 0; font-size: 13px; }
h2.mt16 { margin-top: 16px; } .mb6 { margin-bottom: 6px; } .mb12 { margin-bottom: 12px; }
.center { text-align: center; } .w120 { max-width: 120px; } .full { width: 100%; }
.top { align-items: flex-start; flex-wrap: nowrap; }
.top > input[type="checkbox"] { flex: none; margin-top: 4px; width: 18px; height: 18px; }
.sumbold { cursor: pointer; font-weight: 800; }
.btn.onblue { color: #fff; border-color: rgba(255,255,255,.4); }
.hero-big { font-size: 19px; font-weight: 700; margin: 0 0 6px; }
.hero-sub { margin: 0; opacity: .9; }

label.field.mt0 { margin-top: 0; }

/* ---------- đăng nhập, tài khoản, quản trị ---------- */
.tabs.four { grid-template-columns: repeat(4, 1fr); }
.user-chip {
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 10px; white-space: nowrap;
  color: #fff; border: 1px solid rgba(255,255,255,.55); text-decoration: none; max-width: 40vw; overflow: hidden; text-overflow: ellipsis;
}
.mode-pill + .user-chip { margin-left: 6px; }
.mode-pill[hidden] + .user-chip { margin-left: auto; }
.login-card { max-width: 440px; margin: 6vh auto 14px; }
.pwbox {
  font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 20px; letter-spacing: 1px;
  background: var(--yellow-soft); border-radius: 10px; padding: 10px 12px; word-break: break-all; margin: 6px 0;
}
.acct { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.acct:first-child { border-top: 0; }
.acct .who { flex: 1 1 200px; min-width: 0; }
.acct .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.tag.khoa { background: var(--bad-soft); color: var(--bad); }
.tag.qt { background: var(--blue-soft); color: var(--blue); }
.pend .body { white-space: pre-wrap; max-height: 320px; overflow: auto; font-size: 14px; background: var(--bg); border-radius: 10px; padding: 10px; margin-top: 8px; }
/* điện thoại: đầu trang chỉ giữ logo + tên người dùng (nhãn AI xem ở trang Sản xuất / Tài khoản) */
@media (max-width: 480px) {
  .mode-pill { display: none; }
  .user-chip { margin-left: auto !important; }
}
