:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e3e6ee;
  --text: #141824;
  --muted: #5d6578;
  /* Màu thương hiệu TudoSave (đỏ logo #fc2c30, đậm hơn chút để chữ trắng trên nút đủ tương phản). */
  --primary: #dc1f2a;
  --primary-hover: #b9151f;
  --primary-soft: #fdecee;
  --primary-solid: #dc1f2a;      /* nền nút */
  --primary-solid-hover: #b9151f;
  --success: #15803d;
  --success-soft: #e6f6ec;
  --danger: #c2261d;
  --danger-soft: #fdecea;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 8px 24px rgb(16 24 40 / 6%);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1118;
    --surface: #161a24;
    --surface-2: #1d2230;
    --border: #2a3142;
    --text: #e8ebf3;
    --muted: #9aa3b8;
    --primary: #ff6b73;
    --primary-hover: #ff8a90;
    --primary-soft: #3a1a1f;
    --primary-solid: #e0303b;
    --primary-solid-hover: #c82530;
    --success: #4ade80;
    --success-soft: #14291d;
    --danger: #f87171;
    --danger-soft: #3a1717;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1118;
  --surface: #161a24;
  --surface-2: #1d2230;
  --border: #2a3142;
  --text: #e8ebf3;
  --muted: #9aa3b8;
  --primary: #ff6b73;
  --primary-hover: #ff8a90;
  --primary-soft: #3a1a1f;
  --primary-solid: #e0303b;
  --primary-solid-hover: #c82530;
  --success: #4ade80;
  --success-soft: #14291d;
  --danger: #f87171;
  --danger-soft: #3a1717;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 780px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: flex; align-items: center; text-decoration: none; }
.logo-img { display: block; height: 36px; width: auto; }
/* Logo có chữ màu tối → giao diện tối dùng bản chữ sáng (logo-dark.png). */
.logo-on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block; }
}
:root[data-theme="dark"] .logo-on-light { display: none; }
:root[data-theme="dark"] .logo-on-dark { display: block; }
.nav-row { display: flex; align-items: center; gap: 4px; padding-bottom: 8px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.more { position: relative; flex: none; }
.more-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border: 0; border-radius: 999px;
  background: none; color: var(--muted); font: inherit; font-weight: 500; font-size: .95rem; cursor: pointer; white-space: nowrap;
}
.more-btn:hover, .more-btn[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }
.more-btn.active { background: var(--primary-soft); color: var(--primary); }
.more-btn svg { transition: transform .15s; }
.more-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 520px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu[hidden] { display: none; }
.menu-group { display: flex; flex-direction: column; padding: 4px 0; }
.menu-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 10px; }
.menu a { padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .93rem; }
.menu a:hover { background: var(--surface-2); }
.menu a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }

.tip { margin: 14px 0 0; font-size: .92rem; color: var(--muted); }
.tip a { font-weight: 600; }
.source { text-align: left; }
.howto { margin: 0 0 14px; padding: 14px 16px 14px 36px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 6px; font-size: .94rem; }
kbd { display: inline-block; padding: 0 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); font: .82em ui-monospace, Consolas, monospace; }
.source textarea {
  width: 100%; resize: vertical; padding: 12px 14px; background: var(--surface); color: var(--text);
  font: .82rem/1.4 ui-monospace, Consolas, monospace; border: 1.5px solid var(--border); border-radius: var(--radius); outline: 0;
}
.source textarea:focus { border-color: var(--primary); }
.bar-actions { display: flex; gap: 8px; align-items: center; }
.source-note { margin: 12px 0 0; }
.results-head { font-size: 1.05rem; margin: 0 0 12px; }
.results > .card + .card { margin-top: 14px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; padding: 7px 14px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem; white-space: nowrap;
}
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: 18px; flex: none;
}
.icon-btn:hover { color: var(--text); }

/* Hero */
.hero { padding: 48px 0 28px; text-align: center; }
.hero h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); line-height: 1.2; margin: 0 0 10px; letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 auto 26px; max-width: 560px; font-size: 1.05rem; }
.hint { color: var(--muted); font-size: .88rem; margin: 14px 0 0; }

.search { display: flex; gap: 10px; }
.input-wrap {
  flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 0 8px 0 14px; box-shadow: var(--shadow); transition: border-color .15s;
}
.input-wrap:focus-within { border-color: var(--primary); }
.input-icon { color: var(--muted); font-size: 20px; flex: none; }
.input-wrap input {
  flex: 1; min-width: 0; height: 54px; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 1rem;
}
.chip {
  flex: none; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: .9rem; font-weight: 500;
}
.chip:hover { background: var(--border); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--radius); padding: 0 24px; height: 54px; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--primary-solid); color: #fff; box-shadow: var(--shadow); }
.btn.primary:hover { background: var(--primary-solid-hover); }
.btn:disabled { opacity: .7; cursor: progress; }
.spinner { display: none; width: 18px; height: 18px; border: 2.5px solid rgb(255 255 255 / 40%); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.btn.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.batch { text-align: left; }
.batch textarea {
  width: 100%; resize: vertical; min-height: 140px; padding: 14px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
  border: 1.5px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); outline: 0;
}
.batch textarea:focus { border-color: var(--primary); }
.batch-bar { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.select-label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
select {
  height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
}

/* Results */
.results:empty { display: none; }
.results { margin-bottom: 24px; scroll-margin-top: 120px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
/* Cột ảnh = 260px ảnh + 16px lề trái của .media */
.result { display: grid; grid-template-columns: 276px 1fr; }
.media { position: relative; background: var(--surface-2); min-height: 150px; }
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.result .media { aspect-ratio: 16 / 9; align-self: start; margin: 16px 0 16px 16px; border-radius: 10px; overflow: hidden; }
.duration {
  position: absolute; right: 8px; bottom: 8px; padding: 1px 7px; border-radius: 6px;
  background: rgb(0 0 0 / 75%); color: #fff; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.meta { padding: 16px 18px 18px; min-width: 0; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-youtube { background: #ffe5e5; color: #c4302b; }
.badge-facebook { background: #e7efff; color: #1877f2; }
.badge-tiktok { background: #e6fbfa; color: #0b8f8a; }
.badge-instagram { background: #fde8f3; color: #c13584; }
.badge-threads, .badge-twitter { background: var(--surface-2); color: var(--text); }
.title { font-size: 1.1rem; line-height: 1.35; margin: 8px 0 2px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.uploader { color: var(--muted); margin: 0; font-size: .9rem; }
.group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }

.rows { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.row { display: grid; grid-template-columns: 1fr auto auto 172px; align-items: center; gap: 12px; padding: 9px 10px 9px 14px; }
.row + .row { border-top: 1px solid var(--border); }
.row .q { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.row .q strong { font-variant-numeric: tabular-nums; }
.tag { font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.hd { background: var(--primary-soft); color: var(--primary); }
.note { color: var(--muted); font-size: .85rem; }
.fmt, .size { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.action { display: flex; justify-content: flex-end; min-width: 0; }

.dl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 0; cursor: pointer;
  background: var(--primary-solid); color: #fff; font: inherit; font-size: .9rem; font-weight: 600; text-decoration: none;
}
.dl-btn:hover { background: var(--primary-solid-hover); }
.dl-btn.done { background: var(--success-soft); color: var(--success); }
.dl-btn.retry { background: var(--danger-soft); color: var(--danger); }

.progress { width: 100%; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .4s ease; }
.bar.indeterminate i { width: 35% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.pline { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.ptext { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.cancel { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .8rem; padding: 0 2px; }
.cancel:hover { color: var(--danger); }
.row-error { color: var(--danger); font-size: .8rem; margin-top: 6px; }

.alert { padding: 14px 16px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-weight: 500; }

.skeleton { display: grid; grid-template-columns: 260px 1fr; gap: 18px; padding: 16px; }
.sk { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Batch list */
.batch-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.batch-head h2 { font-size: 1.05rem; margin: 0; }
.batch-head .dl-btn { width: auto; }
.batch-list { display: grid; gap: 10px; }
.bitem { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 10px; align-items: center; }
.bitem .media { min-height: 0; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; }
.bitem .title { font-size: .95rem; -webkit-line-clamp: 2; margin: 4px 0 8px; }
.bitem .controls { display: grid; grid-template-columns: 1fr 160px; gap: 8px; align-items: center; }
.bitem select { width: 100%; height: 36px; }
.bitem .url { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; margin: 4px 0 0; }

/* Sections */
.section { padding: 36px 16px 8px; }
.section-title { font-size: 1.4rem; text-align: center; margin: 0 0 20px; }
.features { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.features li, .steps li {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.features span, .steps span { color: var(--muted); font-size: .93rem; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 32px; height: 32px; margin-bottom: 6px;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq p { margin: 0; padding: 0 16px 14px; color: var(--muted); }
.notice { margin: 32px 0 0; padding: 14px 16px; border-radius: 12px; border: 1px dashed var(--border); color: var(--muted); font-size: .88rem; }

.site-footer { margin-top: 48px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .9rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 28px; padding-top: 32px; padding-bottom: 24px; }
.footer-grid h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text); margin: 4px 0 10px; }
.footer-grid > div { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.footer-grid a:not(.logo) { color: var(--muted); text-decoration: none; }
.footer-grid a:not(.logo):hover { color: var(--primary); }
.footer-brand p { margin: 6px 0 0; max-width: 280px; }
.footer-brand .logo-img { height: 32px; }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 18px; border-top: 1px solid var(--border); font-size: .85rem; }
.lang-select { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.lang-select svg { font-size: 16px; }
.lang-select select { height: 34px; padding: 0 8px; font-size: .88rem; cursor: pointer; }

.lang-banner { background: var(--primary-soft); color: var(--text); font-size: .9rem; border-bottom: 1px solid var(--border); }
.lang-banner-inner { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.lang-banner a { font-weight: 600; }
.lang-banner-close { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .9rem; padding: 2px 6px; }
.lang-banner-close:hover { color: var(--text); }

/* Trang Trợ giúp / Pháp lý */
.page-view { padding-top: 36px; }
.page h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); line-height: 1.2; margin: 0 0 12px; }
.page h2 { font-size: 1.25rem; margin: 32px 0 10px; scroll-margin-top: 120px; }
.page h3 { font-size: 1rem; margin: 0 0 4px; }
.page p, .page li { color: var(--text); }
.page ol, .page ul { padding-left: 22px; display: grid; gap: 6px; }
.page section { scroll-margin-top: 120px; }
.lead-left { font-size: 1.08rem; color: var(--muted) !important; margin: 0 0 8px; }
.updated { color: var(--muted) !important; font-size: .88rem; margin-top: -4px; }
.check-list { list-style: none; padding-left: 0 !important; }
.check-list li { position: relative; padding-left: 28px; }
.check-list li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--success); font-weight: 700; }
.page-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.btn.ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.page-cta .btn { height: 46px; }
.toc {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; margin: 20px 0 8px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.toc a { padding: 5px 0; text-decoration: none; font-weight: 500; }
.toc a:hover { text-decoration: underline; }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.guide-grid > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.guide-grid p { margin: 0; color: var(--muted); font-size: .93rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .93rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; width: 38%; }

.contact-form {
  display: grid; gap: 14px; margin-top: 20px; padding: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.contact-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
.contact-form input, .contact-form textarea, .contact-form select {
  width: 100%; padding: 10px 12px; height: auto; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit; font-weight: 400; outline: 0;
}
.contact-form textarea { resize: vertical; }
.contact-form input:focus, .contact-form textarea:focus, .contact-form select:focus { border-color: var(--primary); }
.contact-form [aria-invalid="true"] { border-color: var(--danger); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.optional { font-weight: 400; color: var(--muted); }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.form-foot .btn { height: 46px; }
.success { padding: 14px 16px; border-radius: 12px; background: var(--success-soft); color: var(--success); font-weight: 500; }
#contact-email { margin: 0; }
.menu-small { width: 200px; grid-template-columns: 1fr; }

@media (max-width: 760px) {
  .hero { padding-top: 28px; }
  .search { flex-direction: column; }
  .btn.primary { width: 100%; }
  .result, .skeleton { grid-template-columns: 1fr; }
  .result .media { margin: 0; border-radius: 0; }
  .row { grid-template-columns: 1fr auto 130px; }
  .row .fmt { display: none; }
  .features, .steps { grid-template-columns: 1fr; }
  .bitem { grid-template-columns: 96px 1fr; }
  .bitem .controls { grid-template-columns: 1fr; }
  .menu { position: fixed; left: 16px; right: 16px; top: 112px; width: auto; grid-template-columns: 1fr; max-height: calc(100vh - 130px); overflow-y: auto; }
  .more-btn { padding: 7px 8px; font-size: .9rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
  .toc, .guide-grid, .field-row { grid-template-columns: 1fr; }
  td:first-child { width: auto; }
  .bar-actions { width: 100%; }
  .bar-actions .btn { flex: 1; }
}
@media (min-width: 761px) and (max-width: 960px) {
  .features { grid-template-columns: repeat(2, 1fr); }
}
