:root {
  --bg: #f7f8f7;
  --panel: #ffffff;
  --ink: #14181c;
  --muted: #5c6670;
  --line: #e3e7e6;
  --accent: #0d8f7c;
  --accent-dark: #0a6f60;
  --accent-soft: #e8f5f2;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 28, .04), 0 8px 24px rgba(20, 24, 28, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.6;
  font-size: 16px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--panel);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { left: 12px; top: 12px; outline: 2px solid var(--accent); outline-offset: 2px; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: min(1080px, 100% - 40px); margin: 0 auto; }

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.site .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  width: min(1560px, 100% - 40px);
}

.brand {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.2px;
  color: var(--ink);
}

.brand span { color: var(--accent); }

header.site nav {
  margin-left: auto;
  display: flex;
  gap: 14px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

header.site nav a { color: var(--muted); white-space: nowrap; }
header.site nav a:hover { color: var(--ink); text-decoration: none; }

/* ---------- Thanh tìm kiếm công cụ ---------- */
.search { position: relative; flex: 0 1 300px; min-width: 190px; }

.search .mag {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 33px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.search input::placeholder { color: #9aa5a2; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.suggest {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(16, 24, 32, .14);
  max-height: 320px;
  overflow: auto;
}

.suggest-head {
  padding: 6px 8px 4px;
  font-size: 11px;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}

.suggest-empty { padding: 10px 8px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.suggest-empty .empty-link { display: block; margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--accent-dark); }

.suggest li[role="option"] {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.suggest li[role="option"][aria-selected="true"],
.suggest li[role="option"]:hover { background: var(--accent-soft); }

.suggest .name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink); }

.suggest .soon {
  padding: 1px 7px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.suggest .desc { font-size: 12px; color: var(--muted); }

.hero { padding: 56px 0 32px; }

.hero h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.15;
  letter-spacing: -.9px;
  margin: 0 0 14px;
}

.hero p.lead {
  color: var(--muted);
  font-size: 17px;
  max-width: 620px;
  margin: 0 0 22px;
}

.badges { display: flex; flex-wrap: wrap; gap: 8px; }

.hero-limit {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 40px 0 16px;
}

.section-title h2 { font-size: 20px; margin: 0; letter-spacing: -.3px; }
.section-title small { color: var(--muted); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}

.card:hover { transform: translateY(-2px); border-color: #cfd8d5; }

.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .tag {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 8px;
}
.card.soon { opacity: .62; }
.card.soon .tag { color: var(--muted); background: #eef0ef; }

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.cta, .cta-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
}
.cta { background: var(--accent); color: #fff; }
.cta:hover { background: var(--accent-dark); text-decoration: none; }
.cta-ghost { background: var(--panel); border: 1px solid var(--line); color: var(--ink); }
.cta-ghost:hover { border-color: #cfd8d5; text-decoration: none; }

main { padding-bottom: 72px; }

.tool { padding-top: 32px; }
.tool h1 { font-size: clamp(24px, 3vw, 34px); margin: 0 0 8px; letter-spacing: -.6px; }
.tool .sub { color: var(--muted); margin: 0 0 24px; max-width: 680px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.dropzone {
  border: 2px dashed #c8d6d2;
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: #fbfcfc;
  transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { opacity: .55; pointer-events: none; }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone strong { color: var(--ink); display: block; margin-bottom: 4px; }

.filelist { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.filelist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 13px;
}
.filelist li .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist li .fsize { color: var(--muted); margin-left: auto; white-space: nowrap; }
.filelist li button {
  font: inherit;
  line-height: 1;
  padding: 2px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
}
.filelist li button:hover { color: #c0392b; background: #fdf1f0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.pager span { color: var(--muted); font-size: 13px; }
.pager .btn { padding: 7px 14px; font-size: 13px; }
.pager .btn:disabled { opacity: .45; cursor: default; }

.preview-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.preview-head span { color: var(--muted); font-size: 13px; }
.preview-head .sort {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.preview-head .sort select {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
}
@media (max-width: 640px) {
  .preview-head { flex-wrap: wrap; }
  .preview-head .sort { width: 100%; margin-left: 0; justify-content: space-between; }
}

.thumb { padding: 10px; }
.thumb .shot { position: relative; }
.thumb img {
  width: 100%;
  height: 148px;
  object-fit: contain;
  background: #f7f8f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
}

/* Ảnh xem trước đang được tạo (chưa có src): nền xám nhẹ thay vì khung vỡ. */
.thumb img.pending {
  background: repeating-linear-gradient(45deg, #f1f3f4, #f1f3f4 8px, #e8ebed 8px, #e8ebed 16px);
}
.thumb .idx {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(20, 24, 28, .8);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
}
.thumb .tname {
  margin: 8px 0 6px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thumb .trow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.thumb.sortable { cursor: grab; }
.thumb.dragging { opacity: .4; }
.thumb.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.thumb .move { display: inline-flex; gap: 4px; }
.thumb .move button {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.thumb .move button:hover:not(:disabled) { color: var(--ink); border-color: #cfd8d5; }
.thumb .move button:disabled { opacity: .35; cursor: default; }
.thumb .trow .move button:hover:not(:disabled) { color: var(--ink); border-color: #cfd8d5; background: #fff; }
.thumb .trow .remove:hover { color: #c0392b; border-color: #f0c9c4; background: #fdf1f0; }
.thumb .trow button {
  font: inherit;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.thumb .trow button:hover { color: #c0392b; border-color: #f0c9c4; background: #fdf1f0; }

.result-card {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.result-card .rname { font-weight: 700; }
.result-card .rmeta { color: var(--muted); font-size: 13px; }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.progress .bar { flex: 1; height: 8px; border-radius: 999px; background: #eef0ef; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .2s ease; }
.progress .ptext { min-width: 96px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-top: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field label { font-weight: 600; }
.field .hint { color: var(--muted); font-size: 12px; }

select, input[type="number"], input[type="text"] {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--accent-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover:not(:disabled) { border-color: #cfd8d5; background: #fafbfb; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

table.results { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 14px; }
table.results th, table.results td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
table.results th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
table.results td.num { font-variant-numeric: tabular-nums; }
table.results .ok { color: var(--accent-dark); font-weight: 600; }
table.results .warn { color: var(--danger); }

.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: #f1f3f2; padding: 2px 6px; border-radius: 5px; }

.note {
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
  border-left: 3px solid var(--accent-soft);
  padding-left: 12px;
}

footer.site { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 13px; }
footer.site .wrap { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; }

/* ---------- Tiện ích thay cho style="" inline (để CSP không cần 'unsafe-inline') ---------- */
.mt-14 { margin-top: 14px; }
.mt-20 { margin-top: 20px; }
.mt-22 { margin-top: 22px; }
.mt-48 { margin-top: 48px; }
.h2-sm { margin-top: 0; font-size: 19px; }
.p-muted { color: var(--muted); margin: 8px 0 0; }

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff6ed;
  border: 1px solid #f6ddc2;
  color: #7a4a12;
  font-size: 14px;
  margin-top: 16px;
  white-space: pre-line;
}
.notice.error { background: #fef1f0; border-color: #f6cdc9; color: var(--danger); }

@media (max-width: 1320px) {
  header.site nav { display: none; }
  /* Nav ẩn nên thanh tìm kiếm chiếm phần còn lại của header. */
  .search { flex: 1 1 auto; min-width: 0; margin-left: auto; }
}

@media (max-width: 640px) {
  header.site nav { display: none; }
  /* Nav ẩn nên thanh tìm kiếm chiếm phần còn lại của header. */
  .search { flex: 1 1 auto; min-width: 0; margin-left: auto; }
  .search input { height: 36px; }
  .hero { padding: 36px 0 20px; }
  .panel { padding: 14px; }
  .controls { grid-template-columns: 1fr; gap: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .thumb img { height: 104px; }
  .actions .btn { flex: 1 1 140px; }
  .pager { gap: 8px; }
  .dropzone { padding: 24px 14px; }
  .filelist li { flex-wrap: wrap; }
}

/* ---------- Trang nội dung / FAQ / bảo mật ---------- */
body { overflow-x: hidden; }

.filelist li.file-error { border-color: #f0c9c4; background: #fef7f6; }
.filelist li.file-error .fsize { color: var(--danger); }

.faq {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.faq h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.3px; }
.faq details { border-top: 1px solid var(--line); padding: 14px 0 2px; }
.faq details:first-of-type { border-top: 0; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.faq details p { color: var(--muted); font-size: 14px; margin: 8px 0 10px; }

.prose h2 { font-size: 19px; margin: 26px 0 8px; letter-spacing: -.2px; }
.prose h2:first-child { margin-top: 0; }
.prose ul, .prose ol { margin: 8px 0 14px; padding-left: 22px; }
.prose li { margin: 5px 0; color: var(--muted); }
.prose p { color: var(--muted); margin: 8px 0 12px; }
.prose strong { color: var(--ink); }
.prose .kbd { margin-right: 4px; }
.codeblock {
  background: #f1f3f2;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  overflow-x: auto;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
}

.textout {
  width: 100%;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .faq { padding: 16px; }
  .prose h2 { font-size: 18px; }
}
