:root {
    --font: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    /* Light — ấm hơn, có sắc độ thay vì trắng phau */
    --bg: #f1f3f9;
    --bg-grad-1: #e9edf8;
    --bg-grad-2: #f4f1ee;
    --bg-elev: #ffffff;
    --surface: #f0f2f7;
    --border: #e2e6ef;
    --border-strong: #ccd2e0;
    --ink: #1a1d29;
    --ink-soft: #4e5567;
    --ink-faint: #9298a8;
    --brand: #4338ca;
    --brand-2: #6366f1;
    --brand-soft: #eef0fe;
    --brand-ink: #3730a3;
    --accent: #ec4899;
    --danger: #dc2626;
    --success: #15a34a;
    --shadow: 0 1px 2px rgba(20,24,40,0.05), 0 2px 8px rgba(20,24,40,0.04);
    --shadow-lg: 0 12px 32px rgba(40,40,90,0.12), 0 4px 12px rgba(20,24,40,0.06);
    --shadow-brand: 0 8px 24px rgba(67,56,202,0.28);
    --radius: 16px;
    --radius-sm: 11px;
    --maxw: 1080px;
  }
  [data-theme="dark"] {
    --bg: #0b0d14;
    --bg-grad-1: #131626;
    --bg-grad-2: #1a1320;
    --bg-elev: #15182260;
    --bg-elev-solid: #161925;
    --surface: #1c2030;
    --border: #272c3d;
    --border-strong: #3a4156;
    --ink: #f3f5fb;
    --ink-soft: #a7afc4;
    --ink-faint: #6b7287;
    --brand: #818cf8;
    --brand-2: #a78bfa;
    --brand-soft: #1e2138;
    --brand-ink: #c7d2fe;
    --accent: #f472b6;
    --danger: #f87171;
    --success: #34d399;
    --shadow: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
    --shadow-brand: 0 8px 24px rgba(99,102,241,0.35);
  }
  * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
  body {
    font-family: var(--font);
    color: var(--ink);
    line-height: 1.6;
    transition: color 0.3s;
    min-height: 100vh; min-height: 100dvh;
    overflow-x: hidden;
    background: var(--bg);
    background-image:
      radial-gradient(ellipse 80% 50% at 15% -5%, var(--bg-grad-1), transparent 60%),
      radial-gradient(ellipse 70% 45% at 95% 5%, var(--bg-grad-2), transparent 55%);
    background-attachment: fixed;
  }
  ::selection { background: var(--brand); color: #fff; }
  .wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }

  /* ===== Header ===== */
  header {
    position: sticky; top: 0; z-index: 100;
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid var(--border);
  }
  .nav { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 12px; }
  .logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 20px; letter-spacing: -0.5px; color: var(--ink); text-decoration: none; }
  .logo-mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-brand);
  }
  .logo-mark svg { width: 18px; height: 18px; }
  .logo b { font-weight: 800; }
  .logo .accent { background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
  .nav-tools { display: flex; align-items: center; gap: 8px; }

  /* segmented language switch — gọn, rõ trạng thái */
  .lang-switch { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 100px; padding: 3px; }
  .lang-switch button {
    border: none; background: none; font-family: var(--font); font-size: 12.5px; font-weight: 700;
    color: var(--ink-faint); padding: 6px 13px; border-radius: 100px; cursor: pointer; transition: 0.18s; letter-spacing: 0.3px;
  }
  .lang-switch button.on { background: var(--bg-elev); color: var(--brand); box-shadow: var(--shadow); }
  [data-theme="dark"] .lang-switch button.on { background: var(--brand-soft); }

  .icon-btn {
    width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border);
    background: var(--surface); color: var(--ink-soft); cursor: pointer; display: grid; place-items: center; transition: 0.18s;
  }
  .icon-btn:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-1px); }
  .icon-btn svg { width: 18px; height: 18px; }

  /* ===== Hero ===== */
  .hero { padding: clamp(46px, 9vw, 92px) 0 clamp(30px, 6vw, 54px); text-align: center; position: relative; }
  .hero .pill {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 16px; border-radius: 100px;
    background: var(--brand-soft); color: var(--brand-ink); font-size: 13px; font-weight: 600; margin-bottom: 26px;
    border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  }
  .pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent); }
  .hero h1 { font-size: clamp(34px, 7vw, 60px); font-weight: 800; letter-spacing: -1.8px; line-height: 1.06; margin-bottom: 20px; max-width: 15ch; margin-inline: auto; }
  .hero h1 em { font-style: normal; background: linear-gradient(120deg, var(--brand), var(--brand-2) 55%, var(--accent)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
  .hero p { font-size: clamp(15px, 2.5vw, 18px); color: var(--ink-soft); max-width: 52ch; margin: 0 auto 16px; }
  .hero .note { font-size: 13px; color: var(--ink-faint); display: inline-flex; align-items: center; gap: 6px; }

  /* ===== Tools grid ===== */
  .tools { padding-bottom: clamp(46px, 8vw, 80px); }
  .grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 282px), 1fr)); }
  .tool-card {
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; cursor: pointer; transition: 0.22s cubic-bezier(0.16,1,0.3,1); text-align: left; font-family: var(--font);
    display: flex; flex-direction: column; gap: 13px; position: relative; overflow: hidden; box-shadow: var(--shadow);
  }
  [data-theme="dark"] .tool-card { background: var(--bg-elev-solid); }
  .tool-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--accent)); transform: scaleX(0); transform-origin: left; transition: 0.25s; }
  .tool-card:hover { border-color: transparent; transform: translateY(-4px); box-shadow: var(--shadow-lg); }
  .tool-card:hover::before { transform: scaleX(1); }
  .tool-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
  .tool-ico { width: 48px; height: 48px; border-radius: 13px; background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--accent) 12%, var(--brand-soft))); color: var(--brand); display: grid; place-items: center; }
  .tool-ico svg { width: 24px; height: 24px; }
  .tool-card h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
  .tool-card p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; }
  .tool-card .arrow { position: absolute; top: 22px; right: 22px; color: var(--ink-faint); transition: 0.22s; }
  .tool-card:hover .arrow { color: var(--brand); transform: translate(3px, -3px); }

  /* ===== Why ===== */
  .why { padding: clamp(40px, 7vw, 72px) 0; border-top: 1px solid var(--border); }
  .why h2 { text-align: center; font-size: clamp(24px, 4vw, 34px); font-weight: 800; letter-spacing: -0.8px; margin-bottom: 12px; }
  .why .sub { text-align: center; color: var(--ink-soft); margin-bottom: 44px; font-size: 15px; }
  .feats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
  .feat { text-align: center; padding: 28px 20px; border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow); }
  [data-theme="dark"] .feat { background: var(--bg-elev-solid); }
  .feat-ico { width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 15px; background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--accent) 14%, var(--brand-soft))); display: grid; place-items: center; color: var(--brand); }
  .feat-ico svg { width: 26px; height: 26px; }
  .feat h4 { font-size: 16px; font-weight: 700; margin-bottom: 7px; }
  .feat p { font-size: 13.5px; color: var(--ink-soft); }

  /* ===== Footer ===== */
  footer { border-top: 1px solid var(--border); padding: 30px 0; color: var(--ink-faint); font-size: 13px; }
  .foot-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center; }

  /* ===== Modal ===== */
  .modal-back { position: fixed; inset: 0; z-index: 200; background: rgba(10,12,22,0.55); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); display: none; align-items: flex-end; justify-content: center; }
  .modal-back.open { display: flex; }
  @media (min-width: 700px) { .modal-back { align-items: center; padding: 24px; } }
  .modal { background: var(--bg-elev); width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0; overflow-y: auto; box-shadow: var(--shadow-lg); animation: slideUp 0.32s cubic-bezier(0.16,1,0.3,1); }
  [data-theme="dark"] .modal { background: var(--bg-elev-solid); }
  @media (min-width: 700px) { .modal { border-radius: 22px; animation: pop 0.26s cubic-bezier(0.16,1,0.3,1); } }
  @keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
  @keyframes pop { from { transform: scale(0.96); opacity: 0; } }
  .modal-head { position: sticky; top: 0; background: var(--bg-elev); z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 22px; border-bottom: 1px solid var(--border); }
  [data-theme="dark"] .modal-head { background: var(--bg-elev-solid); }
  .modal-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.4px; display: flex; align-items: center; gap: 11px; }
  .modal-head .m-ico { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--accent) 12%, var(--brand-soft))); color: var(--brand); display: grid; place-items: center; }
  .modal-head .m-ico svg { width: 19px; height: 19px; }
  .modal-body { padding: 22px; }

  .dz { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 40px 20px; text-align: center; cursor: pointer; transition: 0.2s; background: var(--surface); }
  .dz:hover, .dz.over { border-color: var(--brand); background: var(--brand-soft); }
  .dz-ico { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--brand); }
  .dz h4 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
  .dz p { font-size: 13px; color: var(--ink-soft); }
  .dz .browse { color: var(--brand); font-weight: 700; }

  .files { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
  .file { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
  .file.drag { opacity: 0.5; }
  .file .handle { color: var(--ink-faint); cursor: grab; touch-action: none; display: grid; place-items: center; }
  .file .fmeta { flex: 1; min-width: 0; }
  .file .fname { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .file .fsize { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
  .file .rm { background: none; border: none; color: var(--ink-faint); cursor: pointer; padding: 6px; border-radius: 7px; display: grid; place-items: center; transition: 0.15s; }
  .file .rm:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

  .opts { margin-top: 18px; display: flex; flex-direction: column; gap: 16px; }
  .opt { display: flex; flex-direction: column; gap: 8px; }
  .opt > label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
  input[type=text] { font-family: var(--font); font-size: 14px; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--ink); width: 100%; }
  [data-theme="dark"] input[type=text] { background: var(--surface); }
  input[type=text]:focus { outline: none; border-color: var(--brand); }
  .seg { display: inline-flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: var(--radius-sm); border: 1px solid var(--border); flex-wrap: wrap; }
  .seg button { background: none; border: none; font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 8px 14px; border-radius: 8px; cursor: pointer; transition: 0.15s; }
  .seg button.on { background: var(--brand); color: #fff; }

  .btn { font-family: var(--font); font-weight: 600; font-size: 15px; padding: 13px 22px; border-radius: var(--radius-sm); border: none; cursor: pointer; transition: 0.18s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
  .btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; width: 100%; box-shadow: var(--shadow-brand); }
  .btn-primary:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
  .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
  .btn-ghost { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--border); }
  .btn-ghost:hover { color: var(--ink); border-color: var(--border-strong); }
  .actions { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }

  .result { margin-top: 18px; padding: 22px; border-radius: var(--radius); background: color-mix(in srgb, var(--success) 9%, var(--bg-elev)); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); text-align: center; }
  .result.hide { display: none; }
  .result .check { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 50%; background: var(--success); color: #fff; display: grid; place-items: center; }
  .result h4 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
  .result p { font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; }
  .dl-grid { display: flex; flex-direction: column; gap: 8px; }
  .dl-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); font-size: 13.5px; font-weight: 500; transition: 0.15s; }
  [data-theme="dark"] .dl-link { background: var(--surface); }
  .dl-link:hover { border-color: var(--success); }
  .dl-link .dli { color: var(--success); }

  .spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .hide { display: none !important; }
  .hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

  .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; margin-top: 14px; }
  .thumb-wrap { position: relative; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; cursor: pointer; background: var(--surface); aspect-ratio: 3/4; }
  .thumb-wrap canvas { width: 100%; height: 100%; object-fit: contain; transition: transform 0.2s; }
  .thumb-wrap .pg { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.6); color: #fff; font-size: 10px; text-align: center; padding: 2px; }
  .thumb-wrap .rot-badge { position: absolute; top: 4px; right: 4px; background: var(--brand); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 100px; }
/* ===== Trang công cụ (tool-page) ===== */
.tool-page { padding: clamp(28px, 5vw, 48px) 0 clamp(48px, 8vw, 80px); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); text-decoration: none; font-size: 14px; font-weight: 600; margin-bottom: 28px; transition: 0.15s; }
.back-link:hover { color: var(--brand); }
.tool-hero { text-align: center; max-width: 640px; margin: 0 auto clamp(40px, 7vw, 64px); }
.tool-hero-ico { width: 64px; height: 64px; margin: 0 auto 22px; border-radius: 17px; background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--accent) 14%, var(--brand-soft))); color: var(--brand); display: grid; place-items: center; }
.tool-hero-ico svg { width: 32px; height: 32px; }
.tool-hero h1 { font-size: clamp(30px, 6vw, 46px); font-weight: 800; letter-spacing: -1.2px; line-height: 1.1; margin-bottom: 16px; }
.tool-hero .lead { font-size: clamp(15px, 2.4vw, 17px); color: var(--ink-soft); margin-bottom: 26px; }
.btn-hero { width: auto; min-width: 220px; padding: 15px 32px; font-size: 16px; margin: 0 auto; }
.hero-note { font-size: 12.5px; color: var(--ink-faint); margin-top: 16px; }

/* FAQ */
.faq { max-width: 720px; margin: 0 auto clamp(40px, 7vw, 64px); }
.faq h2 { font-size: clamp(22px, 4vw, 30px); font-weight: 800; letter-spacing: -0.6px; text-align: center; margin-bottom: 32px; }
.faq-item { padding: 20px 0; border-bottom: 1px solid var(--border); }
.faq-item:first-child { border-top: 1px solid var(--border); }
.faq-item h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--ink); }
.faq-item p { font-size: 14.5px; color: var(--ink-soft); line-height: 1.6; }

/* Related tools */
.related { max-width: 720px; margin: 0 auto; }
.related h2 { font-size: clamp(20px, 3.5vw, 26px); font-weight: 800; letter-spacing: -0.5px; text-align: center; margin-bottom: 24px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.related-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); font-size: 13.5px; font-weight: 600; text-align: center; transition: 0.2s; box-shadow: var(--shadow); }
[data-theme="dark"] .related-card { background: var(--bg-elev-solid); }
.related-card:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.r-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.r-ico svg { width: 20px; height: 20px; }
