:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --ink: #14171F;
  --ink-2: #4B4F58;
  --muted: #8A8F99;
  --line: rgba(20, 23, 31, 0.10);
  --line-2: rgba(20, 23, 31, 0.18);
  --accent: #FF6B47;
  --accent-hover: #E8592F;
  --accent-soft: #FFF1EC;
  --teal: #21C7A8;
  --teal-soft: #E7F8F4;
  --danger: #C2412D;
  --danger-soft: #FDEEEA;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2 { font-family: 'Space Grotesk', system-ui, sans-serif; margin: 0; letter-spacing: -0.015em; }
button { font: inherit; }
[hidden] { display: none !important; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: 13px; }

/* header */
.top { border-bottom: 1px solid var(--line); background: rgba(247, 246, 242, 0.92); }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px 'Space Grotesk', sans-serif; letter-spacing: -0.02em; }
.brand-word { width: auto; flex-shrink: 0; }
.brand b { color: var(--accent); margin: 3px 0 0 -2px; }
.quota { font-size: 13px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }
.quota b { color: var(--ink); }
.quota.low b { color: var(--danger); }

/* intro */
.intro { padding: 44px 0 24px; }
.intro h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.12; }
.intro p { color: var(--ink-2); margin: 12px 0 0; }
.intro p.features { margin-top: 10px; font-size: 14.5px; font-weight: 600; color: var(--ink); }
.features span { white-space: nowrap; }

/* notice */
.notice { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(194, 65, 45, 0.2); }

/* card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; margin-bottom: 20px; }
.label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 8px; }
.label + .drop, .label + textarea { margin-bottom: 4px; }
.card .label:not(:first-child) { margin-top: 22px; }

/* drop zone */
.drop {
  border: 1.5px dashed var(--line-2);
  border-radius: 12px;
  background: #FBFAF7;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  outline: none;
}
.drop:hover, .drop:focus-visible { border-color: var(--ink); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.has-file { border-style: solid; cursor: default; background: var(--surface); }
.drop-empty { text-align: center; padding: 34px 16px; }
.drop-empty p { margin: 8px 0 0; }
.drop-empty u { text-decoration-color: var(--accent); text-underline-offset: 3px; }
.drop-file { display: flex; align-items: center; gap: 14px; padding: 14px; }
.thumb { width: 52px; height: 52px; border-radius: 8px; background: var(--bg) center/cover no-repeat; border: 1px solid var(--line); flex-shrink: 0; display: grid; place-items: center; font: 600 11px 'IBM Plex Sans', sans-serif; color: var(--ink-2); }
.meta { min-width: 0; flex: 1; }
.fname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x { border: 0; background: none; width: 36px; height: 36px; border-radius: 8px; font-size: 22px; line-height: 1; color: var(--ink-2); cursor: pointer; }
.x:hover { background: var(--bg); color: var(--ink); }

/* textarea */
textarea {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
textarea:focus { border-color: var(--ink); }
textarea::placeholder { color: var(--muted); }
.hint-row { display: flex; justify-content: space-between; gap: 12px; }

.turnstile { margin-top: 18px; min-height: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }

/* button */
.btn {
  margin-top: 22px;
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.spinner { display: none; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.btn.loading { opacity: 1; cursor: progress; }
.btn.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { text-align: center; margin: 10px 0 0; min-height: 20px; }

.btn-ghost { border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 7px 14px; font-weight: 600; font-size: 13px; cursor: pointer; transition: border-color .15s; }
.btn-ghost:hover { border-color: var(--ink); }
.btn-ghost.done { border-color: var(--teal); color: #138A73; }

/* layout: form trái, kết quả phải */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; align-items: start; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .result { position: sticky; top: 20px; min-height: 100%; display: flex; flex-direction: column; }
  .result pre { max-height: calc(100vh - 260px); }
}
.placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 40px 16px; color: var(--muted); font-size: 14px; border: 1.5px dashed var(--line); border-radius: 12px; }
.placeholder p { margin: 0; max-width: 280px; }
.placeholder.busy { border-color: rgba(255, 107, 71, 0.35); background: #FFFCFA; }
.placeholder.busy .ph-icon, .placeholder.busy .ph-text { display: none; }

/* đang xử lý */
.loader { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; max-width: 300px; color: var(--ink-2); }
.ring { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; font-size: 14px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.steps li::before { content: ""; flex-shrink: 0; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-2); box-sizing: border-box; }
.steps li.active { color: var(--ink); font-weight: 500; }
.steps li.active::before { border: 4px solid var(--accent-soft); background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.steps li.done { color: var(--ink-2); }
.steps li.done::before { border: 0; background: var(--teal) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.3 2.3 4.7-4.9' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; }
.steps li.skip { display: none; }
.bar { width: 100%; height: 4px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; position: relative; }
.bar span { position: absolute; inset: 0 auto 0 0; width: 35%; border-radius: 99px; background: var(--accent); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { left: -35%; } to { left: 100%; } }
.loader .muted { margin: 0; }
@media (prefers-reduced-motion: reduce) { .ring, .steps li.active::before, .bar span { animation-duration: 3s; } }

/* result */
.result-head { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.result-head h2 { font-size: 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sub-head h3 { margin: 0; font-size: 15px; }
.raw-actions { margin-top: 10px; }
.kv td .cp { float: right; margin: -2px 0 0 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.kv td .cp:hover { border-color: var(--ink); color: var(--ink); }
.kv td .cp.done { border-color: var(--teal); color: #138A73; }
.warn { background: var(--accent-soft); color: #9A3A1F; border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 0 0 14px; }
.kv { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 10px 0; border-top: 1px solid var(--line); }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 1px solid var(--line); }
.kv th { width: 36%; padding-right: 16px; color: var(--ink-2); font-weight: 500; }
.kv td { white-space: pre-wrap; word-break: break-word; }
.kv td.empty { color: var(--muted); font-style: italic; }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
details summary::marker { color: var(--accent); }
pre {
  margin: 10px 0 0;
  background: #FBFAF7;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13.5px/1.6 'IBM Plex Mono', ui-monospace, monospace;
}

/* che thông tin */
.redact, .lang-pick { border: 0; padding: 0; margin: 22px 0 0; min-width: 0; }
.redact legend, .lang-pick legend { padding: 0; }
.lang-hint { margin: 0 0 4px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line-2); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--ink); }
.chip input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chip:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.link { border: 0; background: none; padding: 0; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; cursor: pointer; white-space: nowrap; }
.redact-info { margin: 10px 0 0; }
.redact-info p { margin: 8px 0 0; }
.seg { display: inline-flex; border: 1.5px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font: 600 13px 'IBM Plex Sans', sans-serif; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--line-2); }
.seg button.on { background: var(--ink); color: #fff; }

/* menu tải xuống */
.menu { position: relative; }
.menu > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.menu[open] > summary { border-color: var(--ink); }
.menu-list { position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; min-width: 240px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(20, 23, 31, 0.12); display: flex; flex-direction: column; }
.sub-head .menu-list { left: auto; right: 0; }
.menu-list button { border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 6px; font: 14px 'IBM Plex Sans', sans-serif; color: var(--ink); cursor: pointer; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--bg); }
.menu-list button[hidden] { display: none; }
.menu-group { margin: 8px 10px 2px; font: 600 11.5px 'IBM Plex Sans', sans-serif; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.menu-group:first-child { margin-top: 4px; }
.menu-group[hidden], .menu-hint[hidden] { display: none; }
.result-head .menu-list { left: auto; right: 0; }
.menu-list button[data-copy][hidden] { display: none; }
.menu-hint { margin: 4px 10px 6px; font-size: 12.5px; color: var(--muted); max-width: 240px; }

.hint-row.end { justify-content: flex-end; }
.kv.info th[colspan] { padding-top: 14px; font-family: 'Space Grotesk', sans-serif; color: var(--ink); }
.kv.info td { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; word-break: break-all; }
#info-wrap { margin-bottom: 18px; }

/* liên hệ / ủng hộ / góp ý */
.top-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.link-btn { border: 0; background: none; padding: 6px 8px; border-radius: 8px; font: 600 13.5px 'IBM Plex Sans', sans-serif; color: var(--ink-2); cursor: pointer; }
.link-btn:hover, .link-btn:focus-visible { background: var(--surface); color: var(--ink); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 40px 16px 0; }
.tabs button { border: 0; background: none; padding: 8px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; font: 600 14.5px 'IBM Plex Sans', sans-serif; color: var(--ink-2); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button[hidden] { display: none; }
.foot-links { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.foot-links .link { font-weight: 500; color: var(--ink-2); }
.dlg { border: 1px solid var(--line-2); border-radius: 14px; padding: 24px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
.dlg::backdrop { background: rgba(20, 23, 31, 0.45); }
.dlg h2 { margin: 0 0 12px; font: 700 20px 'Space Grotesk', sans-serif; }
.dlg-x { position: absolute; top: 10px; right: 10px; margin: 0; }
.dlg-x button { border: 0; background: none; width: 36px; height: 36px; border-radius: 8px; font-size: 22px; color: var(--ink-2); cursor: pointer; }
.dlg-x button:hover { background: var(--bg); }
.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.contact-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.contact-list a { color: var(--ink); font-weight: 600; text-decoration: none; word-break: break-all; }
.contact-list small { display: block; color: var(--muted); font-size: 12px; }
.qr { display: block; margin: 12px auto; border-radius: 10px; border: 1px solid var(--line); image-rendering: pixelated; }
.donate-kv td { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.input { width: 100%; box-sizing: border-box; border: 1.5px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--surface); outline: none; margin-bottom: 4px; }
.input:focus { border-color: var(--ink); }
.dlg textarea { margin-bottom: 14px; }
.fb-note { margin: 8px 0 14px; }
@media (max-width: 560px) { .links { display: none; } }  /* màn hẹp: nút nằm ở chân trang */

/* rules + footer */
.rules { margin: 4px 0 40px; padding: 0 0 0 18px; color: var(--ink-2); font-size: 13.5px; }
.rules li { margin: 4px 0; }
.rules li::marker { color: var(--teal); }
.rules li.promise { list-style: none; margin: 0 0 10px -18px; padding: 10px 14px; border-radius: 10px; background: var(--teal-soft); border: 1px solid rgba(33, 199, 168, 0.35); color: var(--ink); font-weight: 600; }
.req { color: var(--danger); font-weight: 700; }
.foot { margin-top: auto; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.foot .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 20px; padding-bottom: 20px; }
.foot b { color: var(--ink); font-family: 'Space Grotesk', sans-serif; }

@media (max-width: 560px) {
  .card { padding: 18px; }
  .intro { padding-top: 28px; }
  .kv th, .kv td { display: block; width: 100%; padding: 2px 0; border: 0; }
  .kv th { padding-top: 10px; border-top: 1px solid var(--line); }
  .kv td { padding-bottom: 10px; }
}
.kv th::first-letter { text-transform: uppercase; }

/* trang chính sách & điều khoản */
a.brand { color: var(--ink); text-decoration: none; }
a.link-btn { text-decoration: none; }
.policy { max-width: 760px; padding-top: 40px; padding-bottom: 56px; }
.policy h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.12; }
.policy h2 { font-size: 24px; margin: 40px 0 4px; padding-top: 8px; scroll-margin-top: 16px; }
.policy h3 { font-size: 16px; margin: 22px 0 6px; }
.policy p, .policy li { color: var(--ink-2); }
.policy ul { padding-left: 20px; margin: 6px 0; }
.policy li { margin: 6px 0; }
.policy li::marker { color: var(--teal); }
.policy b { color: var(--ink); }
.policy a { color: var(--ink); text-decoration-color: var(--accent); text-underline-offset: 3px; }
.policy code { font: 13px 'IBM Plex Mono', monospace; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.policy-toc { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 0; }
.policy-toc a { padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.policy-toc a:hover { border-color: var(--ink); }
.policy section { scroll-margin-top: 16px; }

/* trang tài liệu API */
.api-form { margin-top: 14px; }
.api-form input[type=email] { width: 100%; height: 46px; border: 1.5px solid var(--line-2); border-radius: 10px; padding: 0 14px; font: inherit; color: var(--ink); background: var(--surface); outline: none; }
.api-form input[type=email]:focus { border-color: var(--ink); }
.notice.ok { background: var(--teal-soft); color: #0F6B5A; border-color: rgba(33, 199, 168, 0.35); }
.policy pre { font: 13px/1.55 'IBM Plex Mono', monospace; overflow: auto; white-space: pre; }
.api-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.api-table th, .api-table td { text-align: left; vertical-align: top; padding: 8px 10px 8px 0; border-top: 1px solid var(--line); }
.api-table th { font-weight: 600; color: var(--ink); }
.api-table-wrap { overflow-x: auto; }
.translate-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; }
#tr-status:empty { display: none; }
#tr-out { margin-top: 10px; }
