/* =========================================================
   ManhTool — Làm đẹp, kiểm tra & rút gọn JSON
   Màu theo logo: xanh rừng đậm → xanh ngọc → xanh chanh
   ========================================================= */

:root {
  --ink: #0f2620;
  --brand-800: #0a5c44;
  --brand-700: #0e7c5a;
  --brand-500: #12b886;
  --leaf: #4cb944;
  --lime: #c4e43a;
  --grad: linear-gradient(115deg, #0e7c5a 0%, #12b886 50%, #7ccf3e 85%, #c4e43a 100%);

  --bg: #f5f8f6;
  --surface: #ffffff;
  --surface-2: #f3f7f4;
  --tint: #e9f6ef;           /* nền xanh rất nhạt khi rê chuột / chọn */
  --raised: #ffffff;         /* tab, nút đang chọn nổi trên nền xám */
  --border: #e1ebe5;
  --border-strong: #cddcd3;
  --text: #13241f;
  --text-2: #4a5a55;
  --text-3: #6f7f79;
  --primary: #0e7c5a;
  --primary-hover: #0a5c44;
  --on-primary: #ffffff;
  --accent-text: #0e7c5a;
  --warn: #b45309;
  --warn-bg: #fff7e8;
  --danger: #c2410c;
  --danger-bg: #fff4ee;
  --ok: #237a3b;
  --ok-bg: #edf8ee;
  /* Màu cú pháp: khóa xanh thương hiệu, chuỗi nâu cam, số xanh dương, true/false tím */
  --syn-key: #0b6b4f;
  --syn-str: #a2541a;
  --syn-num: #1f5fbf;
  --syn-bool: #8b3fb8;
  --syn-null: #7a8a84;
  --syn-punc: #8a9a94;
  --code-bg: #fbfdfc;
  --gutter: #f1f6f3;
  --shadow: 0 1px 2px rgba(15,38,32,.04), 0 4px 16px rgba(15,38,32,.06);
  --shadow-lg: 0 24px 60px rgba(15,38,32,.2);

  --r-lg: 18px;
  --r: 12px;
  --r-sm: 9px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1613; --surface: #121e1a; --surface-2: #17251f; --tint: #173328; --raised: #23392f;
    --border: #213530; --border-strong: #2d463d;
    --text: #e7f1ec; --text-2: #a8bab2; --text-3: #85988f;
    --primary: #12b886; --primary-hover: #34cf98; --on-primary: #04241a; --accent-text: #3dd598;
    --warn: #facc15; --warn-bg: #2a2410; --danger: #fb923c; --danger-bg: #2a1a10;
    --ok: #6fd88a; --ok-bg: #132b1c;
    --syn-key: #4fd6a2; --syn-str: #f2b47a; --syn-num: #82b4ff; --syn-bool: #d6a1f7; --syn-null: #8a9c95; --syn-punc: #6f827b;
    --code-bg: #0f1a16; --gutter: #131f1b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
    --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1613; --surface: #121e1a; --surface-2: #17251f; --tint: #173328; --raised: #23392f;
  --border: #213530; --border-strong: #2d463d;
  --text: #e7f1ec; --text-2: #a8bab2; --text-3: #85988f;
  --primary: #12b886; --primary-hover: #34cf98; --on-primary: #04241a; --accent-text: #3dd598;
  --warn: #facc15; --warn-bg: #2a2410; --danger: #fb923c; --danger-bg: #2a1a10;
  --ok: #6fd88a; --ok-bg: #132b1c;
  --syn-key: #4fd6a2; --syn-str: #f2b47a; --syn-num: #82b4ff; --syn-bool: #d6a1f7; --syn-null: #8a9c95; --syn-punc: #6f827b;
  --code-bg: #0f1a16; --gutter: #131f1b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
  color-scheme: dark;
}

/* ---------- Nền tảng ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden;
  font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--text);
  background: var(--bg);
}
body::before {
  /* vệt sáng xanh nhẹ phía trên, lấy cảm hứng từ dải màu logo */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 420px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 300px at 85% -60px, rgba(196,228,58,.22), transparent 70%),
    radial-gradient(700px 320px at 10% -80px, rgba(18,184,134,.18), transparent 70%);
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--accent-text); }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

.ic { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.container { width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 24px; } }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 16px; top: -48px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 8px; text-decoration: none; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
[hidden] { display: none !important; }

.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: #fff; box-shadow: 0 0 0 1px var(--border); }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.brand-accent { color: var(--primary); }
.header-actions { display: flex; align-items: center; gap: 6px; }
.header-link {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 999px; text-decoration: none; color: var(--text-2); font-weight: 500; font-size: .9rem;
}
.header-link:hover { background: var(--tint); color: var(--accent-text); }
@media (max-width: 479px) { .header-link span { display: none; } .header-link { padding: 0; width: 38px; justify-content: center; } }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { color: var(--accent-text); border-color: var(--border-strong); }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ---------- Hero ---------- */
.hero { text-align: center; padding-top: 40px; padding-bottom: 28px; }
.hero h1 { font-size: clamp(1.7rem, 3.6vw + .6rem, 2.75rem); font-weight: 800; letter-spacing: -.025em; line-height: 1.15; text-wrap: balance; }
.hero p { margin-top: 10px; color: var(--text-2); font-size: clamp(.98rem, .6vw + .8rem, 1.1rem); text-wrap: balance; }
@media (max-width: 559px) { .hero { padding-top: 24px; padding-bottom: 18px; } }

/* ---------- Bố cục ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 1024px) { .layout { grid-template-columns: minmax(0, 1fr) 288px; gap: 24px; } }
.main-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }

/* ---------- Công cụ ---------- */
.tool { padding: 14px; container-type: inline-size; scroll-margin-top: 76px; }
.tool:focus { outline: none; }
@media (min-width: 768px) { .tool { padding: 20px; } }

/* Tab chính: Văn bản | Hình ảnh & file */
.tabs {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; margin-bottom: 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
}
.tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 0;
  height: 44px; padding: 0 12px; border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--text-2); font-size: .95rem; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--raised); color: var(--accent-text); box-shadow: 0 1px 3px rgba(15,38,32,.12), 0 0 0 1px var(--border); }

/* Hàng chọn chiều */
.mode-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 13px; border-radius: 999px;
  font-size: .82rem; font-weight: 600; color: var(--text-2); white-space: nowrap; transition: background .15s, color .15s;
}
.seg span .ic { width: 15px; height: 15px; }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--primary); color: var(--on-primary); box-shadow: 0 1px 3px rgba(15,38,32,.18); }
.seg input:focus-visible + span { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.seg-lg span { padding: 8px 16px; font-size: .9rem; }
@media (max-width: 479px) {
  .mode-row .seg { flex: 1; }
  .mode-row .seg label { flex: 1; }
  .mode-row .seg span { justify-content: center; width: 100%; padding: 8px 6px; font-size: .84rem; }
}

/* Hai ô: vào | ra */
.panes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@container (min-width: 760px) { .panes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 10px; min-height: 30px; margin-bottom: 6px; }
.pane-head label, .pane-title { font-size: .92rem; font-weight: 700; }
.pane-head .pane-meta { margin-left: auto; }
.pane-head .link-btn { margin-left: auto; }
.pane-head .pane-meta:not(:empty) + .link-btn { margin-left: 0; }
.pane-meta { font-size: .8rem; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pane-meta b { color: var(--text-2); font-weight: 600; }
.pane-meta .up { color: var(--warn); font-weight: 600; }

.editor-box {
  position: relative; border: 1.5px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
  overflow: hidden; transition: border-color .2s, box-shadow .2s;
}
.editor-box:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-500) 15%, transparent); }
.editor-box.dragover { border-color: var(--brand-500); border-style: dashed; }
.editor-box.dragover::after {
  content: "Thả file vào đây"; position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 700; color: var(--accent-text); background: color-mix(in srgb, var(--tint) 90%, transparent);
  pointer-events: none;
}
.editor-box textarea {
  display: block; width: 100%; height: 34vh; min-height: 200px; max-height: 70vh; resize: vertical;
  padding: 12px 14px; border: 0; outline: none; background: transparent; color: var(--text);
  font: inherit; font-size: .98rem; line-height: 1.65;
}
@media (max-width: 559px) { .panes .editor-box textarea { height: 26vh; min-height: 160px; } }
@media (min-width: 1024px) { .panes .editor-box textarea { height: clamp(260px, calc(100vh - 470px), 440px); } }
.editor-box textarea::placeholder { color: var(--text-3); }
.editor-box textarea.mono { font-family: var(--mono); font-size: .86rem; line-height: 1.6; word-break: break-all; }
.editor-box textarea.out-short { height: 150px; min-height: 110px; }
.out-box { background: var(--surface-2); border-color: var(--border); }
.out-box textarea { color: var(--text); }

/* Thanh trạng thái dưới ô */
.status {
  display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; font-size: .84rem; line-height: 1.45; border-top: 1px solid var(--border);
}
.status > .ic { width: 16px; height: 16px; margin-top: 1px; }
.status > span { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.status .link-btn { margin: -4px 0; padding: 4px 10px; background: var(--surface); box-shadow: 0 0 0 1px currentColor inset; color: inherit; }
.status .link-btn:hover { background: var(--surface); filter: brightness(.95); }
.status.is-error { color: var(--danger); background: var(--danger-bg); }
.status.is-warn { color: var(--warn); background: var(--warn-bg); }
.status.is-info { color: var(--accent-text); background: var(--tint); }

/* Nút thao tác */
.pane-actions { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.pane-actions .btn-primary { margin-left: auto; }
.pane-actions > .pane-meta { margin-right: auto; }
.act {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 12px; cursor: pointer;
  font-size: .88rem; font-weight: 500; color: var(--text-2); white-space: nowrap;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  transition: background .15s, color .15s;
}
.act:hover:not(:disabled) { background: var(--tint); color: var(--accent-text); }
.act:disabled { opacity: .4; cursor: default; }
.act-danger:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger); }
.act-icon { width: 40px; padding: 0; }
.act-sep { width: 1px; align-self: center; height: 22px; background: var(--border); margin: 0 4px; }
.mode-row .act { border-color: var(--border); }

.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 20px; border-radius: var(--r-sm); cursor: pointer;
  font-size: .92rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .1s, border-color .15s, color .15s;
}
.btn-primary { color: var(--on-primary); background: var(--primary); border: 0; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active, .btn-ghost:active { transform: scale(.97); }
.btn-ghost { color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); }
.btn-ghost:hover { border-color: var(--brand-500); color: var(--accent-text); }
.btn-sm { height: 38px; padding: 0 14px; font-size: .86rem; }
.btn-copy { min-width: 128px; }
.btn-copy .ic-check { display: none; }
.btn-copy.is-done .ic-copy { display: none; }
.btn-copy.is-done .ic-check { display: block; }
.btn-primary.is-done { background: var(--leaf); }
.btn-ghost.is-done { color: var(--accent-text); border-color: var(--brand-500); }

.link-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border: 0; border-radius: 7px; background: none; color: var(--accent-text); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.link-btn:hover { background: var(--tint); }

@media (max-width: 559px) {
  .pane-actions { gap: 0; justify-content: space-between; }
  .pane-actions .act { width: 44px; height: 44px; padding: 0; }
  .pane-actions .act span, .mode-row .act span { display: none; }
  .pane-actions .act-sep { display: none; }
  .pane-actions .btn-primary { flex: 1; height: 46px; margin-left: 8px; }
  .pane-actions > .pane-meta { flex-basis: 100%; margin: 0 0 6px; }
  .mode-row .act { width: 44px; height: 44px; padding: 0; }
}

/* Tùy chọn */
.options {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px;
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border-strong);
}
.check-line { position: relative; display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--text-2); cursor: pointer; user-select: none; }
.check-line input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; width: 34px; height: 20px; flex-shrink: 0; background: var(--border-strong); border-radius: 999px; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.check-line input:checked + .switch { background: var(--brand-500); }
.check-line input:checked + .switch::after { transform: translateX(14px); }
.check-line input:focus-visible + .switch { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.select-line { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--text-2); }
.select, .input {
  height: 36px; padding: 0 10px; font: inherit; font-size: .88rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
}
.select:focus, .input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent); }
.opt-note { display: flex; align-items: flex-start; gap: 8px; font-size: .84rem; color: var(--text-3); }
.opt-note .ic { width: 16px; height: 16px; margin-top: 2px; color: var(--accent-text); }
@media (max-width: 479px) {
  .options { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .select-line { justify-content: space-between; }
}


/* ---------- Riêng công cụ JSON ---------- */
.tool { --ed-h: 34vh; --code-font: .84rem; --code-lh: 1.6; }
@media (max-width: 559px) { .tool { --ed-h: 38vh; } }
@media (min-width: 1024px) { .tool { --ed-h: clamp(380px, calc(100vh - 330px), 680px); } }

/* Hàng chọn việc + tùy chọn theo việc */
.mode-opts { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.mode-opts:empty { display: none; }
.select-line span { white-space: nowrap; }

/* Ẩn/hiện theo việc đang chọn */
.tool:not([data-mode="beautify"]) .only-beautify,
.tool:not([data-mode="convert"]) .only-convert,
.tool:not([data-mode="convert"]) .only-csv,
.tool[data-mode="convert"]:not([data-fmt="csv"]) .only-csv,
.tool[data-mode="convert"][data-fmt="yaml"] .no-yaml,
.tool[data-mode="convert"][data-fmt="csv"] .no-csv,
.tool[data-mode="convert"][data-fmt="xml"] .no-xml { display: none !important; }

/* Ô nhập có cột số dòng */
.code-input { display: flex; align-items: stretch; background: var(--surface); }
.ln {
  flex: none; margin: 0; padding: 12px 10px 40px 12px; min-width: calc(var(--digits, 2) * 1ch + 22px);
  overflow: hidden; text-align: right; user-select: none; -webkit-user-select: none;
  font-family: var(--mono); font-size: var(--code-font); line-height: var(--code-lh);
  color: var(--text-3); background: var(--gutter); border-right: 1px solid var(--border);
}
.ln .err { color: var(--danger); font-weight: 700; background: var(--danger-bg); border-radius: 4px; box-shadow: 0 0 0 3px var(--danger-bg); }
.ln .dup { color: var(--warn); font-weight: 700; }
.editor-box .code-input textarea {
  flex: 1; min-width: 0; height: auto; min-height: 0; max-height: none; resize: none;
  padding: 12px 14px; white-space: pre; overflow: auto; overflow-wrap: normal; tab-size: 2;
  font-family: var(--mono); font-size: var(--code-font); line-height: var(--code-lh);
}


/* Hai ô cao bằng nhau: thanh trạng thái nằm trong chiều cao cố định */
.ed-box { display: flex; flex-direction: column; height: var(--ed-h); min-height: 280px; }
.ed-box > .code-input, .ed-box > .code-view, .ed-box > .tree, .ed-box > .out-empty { flex: 1; min-height: 0; }
.ed-box > .status { flex: none; max-height: 45%; overflow: auto; }
/* Xếp chồng (điện thoại): thẻ lỗi, lời nhắc không bị cắt */
@container (max-width: 759px) { .out-box.auto-h { height: auto; min-height: 0; } .out-box.auto-h > .out-empty { padding: 20px 14px; } }
.pane-head { min-height: 36px; }

/* Thẻ lỗi trong ô kết quả */
.oe-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.out-empty .oe-msg { max-width: 420px; color: var(--text-2); text-wrap: pretty; }
.out-empty .snip {
  max-width: 100%; margin: 4px 0 0; padding: 10px 12px; overflow-x: auto; text-align: left;
  font-family: var(--mono); font-size: .8rem; line-height: 1.5; white-space: pre;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
}
.oe-fix {
  display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 8px; padding: 14px 16px;
  max-width: 440px; border-radius: 12px; background: var(--tint); border: 1px solid color-mix(in srgb, var(--brand-500) 30%, transparent);
}
.oe-fix p { font-size: .84rem; color: var(--text-2); text-wrap: pretty; }
.oe-fix p b { color: var(--accent-text); }
.oe-fix .btn-primary .ic { width: 17px; height: 17px; }

/* Ô kết quả hẹp: nút phụ chỉ còn icon */
@container (min-width: 760px) and (max-width: 1100px) {
  .out-actions #btnUse { width: 40px; padding: 0; }
  .out-actions #btnUse span { display: none; }
}
.out-actions .pane-meta { margin-right: auto; }
.out-actions .btn-primary { margin-left: 4px; }

/* Kết quả */
.out-head { flex-wrap: wrap; row-gap: 6px; }
.out-head .pane-meta { margin-left: auto; }
.out-box { background: var(--code-bg); }
.code-view { overflow: auto; outline: none; }
.code-view:focus-visible { box-shadow: inset 0 0 0 2px var(--brand-500); }
.code-inner { display: flex; min-width: max-content; min-height: 100%; }
.code-view .ln { position: sticky; left: 0; z-index: 1; min-height: 100%; padding-bottom: 12px; }
.code-view .code {
  flex: 1; margin: 0; padding: 12px 14px; white-space: pre; tab-size: 2;
  font-family: var(--mono); font-size: var(--code-font); line-height: var(--code-lh); color: var(--text);
}
.code-view.wrap .code-inner { min-width: 0; }
.code-view.wrap .ln { display: none; }
.code-view.wrap .code { white-space: pre-wrap; word-break: break-all; }
.code .k { color: var(--syn-key); }
.code .s { color: var(--syn-str); }
.code .n { color: var(--syn-num); }
.code .b { color: var(--syn-bool); }
.code .z { color: var(--syn-null); font-style: italic; }
.code .p { color: var(--syn-punc); }

.out-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  flex: 1; min-height: 0; padding: 24px; overflow: auto; text-align: center; font-size: .9rem; color: var(--text-3);
}
.oe-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--tint); color: var(--accent-text); }
.oe-ic .ic { width: 24px; height: 24px; }
.out-empty.is-error .oe-ic { background: var(--danger-bg); color: var(--danger); }
.out-empty span:last-child { max-width: 300px; text-wrap: balance; }

/* Nút chọn kiểu xem, định dạng đích */
.seg-sm span { padding: 4px 11px; font-size: .78rem; }
.seg-sm span .ic { width: 14px; height: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span {
  display: block; padding: 4px 11px; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: .78rem; font-weight: 600; color: var(--text-2); white-space: nowrap; transition: background .15s, color .15s, border-color .15s;
}
.chips label:hover span { border-color: var(--brand-500); color: var(--accent-text); }
.chips input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chips input:focus-visible + span { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* Trạng thái kiểm tra */
.status { border-top-color: transparent; }
.status b { font-weight: 700; }
.status.is-ok { color: var(--ok); background: var(--ok-bg); }
.status .snip {
  flex-basis: 100%; order: 3; margin: 2px 0 0; padding: 8px 10px; overflow-x: auto;
  font-family: var(--mono); font-size: .78rem; line-height: 1.5; white-space: pre;
  color: var(--text); background: var(--surface); border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: 8px;
}
.status.is-error .snip { color: var(--text); }
.status .st-actions { display: flex; gap: 6px; flex-wrap: wrap; order: 4; }
.status .st-actions:empty { display: none; }
.status .link-btn .ic { width: 14px; height: 14px; }
.status .link-btn.solid { background: var(--danger); color: #fff; box-shadow: none; }
.status.is-error .link-btn.solid:hover { filter: brightness(1.08); background: var(--danger); }
:root[data-theme="dark"] .status .link-btn.solid { color: #1c0d04; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .status .link-btn.solid { color: #1c0d04; } }

.pane-meta .down { color: var(--ok); font-weight: 600; }
.samples { display: inline-flex; gap: 2px; margin-left: auto; }
.pane-head .pane-meta:not(:empty) + .samples { margin-left: 0; }
.pane-head { flex-wrap: wrap; row-gap: 4px; }
.pane-head label { white-space: nowrap; }
.pane-actions .act:disabled span { opacity: 1; }

/* Dạng cây */
.tree { display: flex; flex-direction: column; }
.tree-bar {
  display: flex; align-items: center; gap: 2px; padding: 4px 6px 4px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tree-path {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: .8rem; color: var(--accent-text);
}
.act-sm { width: 34px; height: 34px; }
.act-sm .ic { width: 16px; height: 16px; }
.tree-body {
  flex: 1; overflow: auto; padding: 8px 6px 16px;
  font-family: var(--mono); font-size: var(--code-font); line-height: var(--code-lh);
}
.tn > .tc { margin-left: 13px; padding-left: 8px; border-left: 1px dashed var(--border-strong); }
.tr {
  display: flex; align-items: center; gap: 4px; min-width: max-content; padding: 1px 8px 1px 2px;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.tr:hover { background: var(--tint); }
.tr.sel { background: color-mix(in srgb, var(--brand-500) 18%, transparent); box-shadow: inset 2px 0 0 var(--brand-500); }
.tw {
  display: grid; place-items: center; width: 20px; height: 20px; flex: none; padding: 0;
  border: 0; border-radius: 5px; background: none; color: var(--text-3); cursor: pointer;
}
.tw:hover { color: var(--accent-text); }
.tw .ic { width: 14px; height: 14px; transition: transform .15s; }
.tn.open > .tr .tw .ic { transform: rotate(90deg); }
.tw-sp { width: 20px; flex: none; }
.tk { color: var(--syn-key); }
.tk.ti { color: var(--text-3); }
.tp { color: var(--syn-punc); margin-right: 4px; }
.tv.s { color: var(--syn-str); }
.tv.n { color: var(--syn-num); }
.tv.b { color: var(--syn-bool); }
.tv.z { color: var(--syn-null); font-style: italic; }
.tb { color: var(--syn-punc); }
.tcnt { margin-left: 6px; padding: 0 7px; border-radius: 999px; font-family: var(--font); font-size: .72rem; font-weight: 600; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); }
.tmore { margin: 4px 0 4px 26px; }

.opt-note code, .faq code { font-family: var(--mono); font-size: .86em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); }

@media (max-width: 559px) {
  .mode-row { flex-direction: column; align-items: stretch; }
  .mode-opts { justify-content: space-between; }
  .mode-opts .select-line { flex: 1; justify-content: space-between; }
  .out-head .pane-meta { flex-basis: 100%; margin-left: 0; order: 5; }
}

/* ---------- Lỗi hay gặp ---------- */
.mistakes { margin-top: 48px; }
.mk-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) { .mk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .mk-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mk { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); min-width: 0; }
.mk h3 { font-size: .92rem; font-weight: 700; margin-bottom: 10px; }
.mk code {
  position: relative; display: block; padding: 7px 10px 7px 52px; overflow-x: auto; white-space: pre;
  font-family: var(--mono); font-size: .8rem; border-radius: 8px;
}
.mk code + code { margin-top: 6px; }
.mk code::before { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); padding: 1px 6px; border-radius: 5px; font: 700 .68rem/1.5 var(--font); color: var(--surface); }
.mk .bad { color: var(--text); background: var(--danger-bg); }
.mk .bad::before { content: "Sai"; background: var(--danger); }
.mk .good { color: var(--text); background: var(--ok-bg); }
.mk .good::before { content: "Đúng"; background: var(--ok); }
.mk mark { color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, transparent); border-radius: 3px; font-weight: 700; }

/* ---------- Thanh bên ---------- */
.side { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) and (max-width: 1023px) and (hover: hover) { .side { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (hover: none) { .shortcuts-card { display: none; } }

.side-card { padding: 16px; }
.side-head { display: flex; align-items: center; gap: 12px; }
.side-head h2 { font-size: .98rem; font-weight: 700; line-height: 1.3; }
.side-head p { font-size: .82rem; color: var(--text-3); }
.side-icon {
  display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 10px; background: var(--tint); color: var(--accent-text);
}
.donate .side-icon { background: var(--grad); color: #fff; }
.side-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; font-size: .8rem; color: var(--text-3); }
.side-note .ic { width: 15px; height: 15px; }

.qr-frame {
  position: relative; display: block; width: 100%; margin-top: 14px; padding: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--r); cursor: zoom-in; overflow: hidden;
}
.qr-frame img { width: 100%; max-width: 190px; height: auto; margin: 0 auto; }
.qr-zoom {
  position: absolute; left: 50%; bottom: 10px; transform: translate(-50%, 6px);
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  font-size: .78rem; font-weight: 600; color: #fff; background: rgba(15,38,32,.85);
  border-radius: 999px; opacity: 0; transition: opacity .2s, transform .2s;
}
.qr-zoom .ic { width: 14px; height: 14px; }
.qr-frame:hover .qr-zoom, .qr-frame:focus-visible .qr-zoom { opacity: 1; transform: translate(-50%, 0); }

.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 14px 0 0; font-size: .82rem; align-items: center; }
.shortcuts dt { display: flex; align-items: center; gap: 3px; color: var(--text-3); }
.shortcuts dd { margin: 0; color: var(--text-2); text-align: right; }
kbd {
  font-family: var(--mono); font-size: .72rem; font-weight: 600; line-height: 1;
  padding: 4px 6px; border-radius: 5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px;
}

/* ---------- Hướng dẫn ---------- */
.guide { padding-top: 56px; padding-bottom: 48px; }
.guide h2 { text-align: center; font-size: clamp(1.25rem, 1.5vw + .9rem, 1.6rem); font-weight: 800; letter-spacing: -.015em; margin-bottom: 20px; }
.guide-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) { .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .guide-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.guide-item { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.guide-ic { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 12px; border-radius: 10px; background: var(--tint); color: var(--accent-text); }
.guide-item h3 { font-size: .98rem; font-weight: 700; }
.guide-item p { margin-top: 4px; font-size: .87rem; color: var(--text-2); }
.guide-item b { color: var(--text); font-weight: 600; }

.faq { max-width: 780px; margin: 48px auto 0; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.faq details + details { margin-top: 8px; }
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; font-weight: 600; cursor: pointer; list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { color: var(--accent-text); }
.faq .chev { color: var(--text-3); transition: transform .2s; }
.faq details[open] .chev { transform: rotate(180deg); }
.faq details p { padding: 0 16px 16px; font-size: .92rem; color: var(--text-2); }

.privacy { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; font-size: .85rem; color: var(--text-3); text-align: center; }
.privacy .ic { width: 16px; height: 16px; color: var(--accent-text); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; font-size: .85rem; color: var(--text-3); }
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--text-2); text-decoration: none; }
.footer-brand img { border-radius: 7px; background: #fff; box-shadow: 0 0 0 1px var(--border); }
.footer-brand strong { color: var(--text); }

/* ---------- Hộp QR phóng to ---------- */
.qr-dialog {
  width: min(92vw, 360px); padding: 22px; border: 0; border-radius: 20px; text-align: center;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.qr-dialog::backdrop { background: rgba(6,20,16,.55); backdrop-filter: blur(3px); }
.qr-dialog h2 { font-size: 1.05rem; margin-bottom: 14px; }
.qr-dialog img { width: 100%; height: auto; padding: 10px; background: #fff; border-radius: var(--r); border: 1px solid var(--border); }
.qr-dialog p { margin-top: 12px; font-size: .88rem; color: var(--text-2); }
.qr-dialog form { position: absolute; top: 12px; right: 12px; margin: 0; }
.qr-close { width: 32px; height: 32px; }
.qr-close .ic { width: 16px; height: 16px; }

/* ---------- Thông báo ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: .88rem; font-weight: 500; box-shadow: var(--shadow-lg);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
:root[data-theme="dark"] .toast { background: #e7f1ec; color: #0f2620; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #e7f1ec; color: #0f2620; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =========================================================
   Khối "Về ManhTool" + "Hợp tác" — dùng chung cho mọi công cụ
   ========================================================= */
.brand-section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; padding-bottom: 48px; }
@media (min-width: 1024px) { .brand-section { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: stretch; } }

.brand-card {
  display: flex; align-items: center; gap: 28px; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.brand-logo {
  width: 150px; height: 150px; flex: none; object-fit: contain;
  border-radius: 24px; background: #fff; border: 1px solid #e8ece9;
  box-shadow: 0 12px 30px -12px rgba(14,124,90,.45);
}
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--accent-text); margin-bottom: 8px; }
.eyebrow .ic { width: 15px; height: 15px; }
.brand-body h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; margin-bottom: 6px; }
.brand-slogan { font-weight: 700; font-size: 1.02rem; margin-bottom: 10px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-body p:not(.brand-slogan) { color: var(--text-2); margin-bottom: 16px; }
.brand-body b { color: var(--text); }

.hire-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 12px; padding: 26px;
  border-radius: var(--r-lg); color: #fff;
  background:
    radial-gradient(420px 220px at 100% 0%, rgba(101,199,40,.28), transparent 70%),
    radial-gradient(360px 200px at 0% 100%, rgba(15,159,110,.3), transparent 70%),
    linear-gradient(160deg, #10241c, #0c1712);
  border: 1px solid rgba(255,255,255,.06);
}
.hire-label { align-self: flex-start; padding: 4px 11px; border-radius: 999px; background: rgba(101,199,40,.16); color: #a6e77a; font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.hire-card h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.3; }
.hire-card > p { color: rgba(255,255,255,.75); }
.hire-services { list-style: none; margin: 2px 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.hire-services li { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 500; }
.hire-services .ic { width: 16px; height: 16px; color: #7ddc4a; }
.hire-phone {
  display: flex; align-items: center; gap: 14px; margin-top: 4px; padding: 14px 16px;
  border-radius: 14px; color: #fff; text-decoration: none;
  background: linear-gradient(135deg, #12b886, #4fb52a);
  box-shadow: 0 14px 30px -12px rgba(79,181,42,.65);
  transition: transform .15s, box-shadow .15s;
}
.hire-phone:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -12px rgba(79,181,42,.8); }
.hp-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.2); }
.hp-ico .ic { width: 20px; height: 20px; animation: ring 2.6s ease-in-out infinite; }
@keyframes ring { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-14deg); } 80% { transform: rotate(12deg); } 85% { transform: rotate(-8deg); } 90% { transform: rotate(6deg); } }
.hire-phone small { display: block; font-size: .75rem; opacity: .85; font-weight: 600; }
.hire-phone b { display: block; font-size: 1.45rem; font-weight: 800; letter-spacing: .02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.hire-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-ghost-light {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: var(--r-sm); cursor: pointer;
  font-size: .86rem; font-weight: 600; color: #fff; text-decoration: none;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.16);
  transition: background .15s;
}
.btn-ghost-light .ic { width: 16px; height: 16px; }
.btn-ghost-light:hover { background: rgba(255,255,255,.12); }
.hire-tags { font-size: .78rem; color: rgba(255,255,255,.55); margin-top: auto; padding-top: 4px; }

@media (max-width: 767px) {
  .brand-card, .hire-card { padding: 20px 16px; }
}
@media (max-width: 560px) {
  .brand-card { flex-direction: column; text-align: center; gap: 16px; }
  .brand-logo { width: 120px; height: 120px; }
  .hire-actions .btn-ghost-light { flex: 1 1 auto; }
}

/* ---------- Lời mời tư vấn (giống trang chủ) ---------- */
.nudge {
  position: fixed; left: 20px; bottom: 24px; z-index: 30; width: 320px; padding: 20px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 20px 50px -12px rgba(15,38,32,.28), 0 2px 6px rgba(15,38,32,.06);
  animation: nudge-in .35s ease-out;
}
.nudge[hidden] { display: none; }
@keyframes nudge-in { from { opacity: 0; transform: translateY(12px); } }
.nudge-close {
  position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  background: none; border: 0; border-radius: 8px; color: var(--text-3); cursor: pointer;
}
.nudge-close:hover { background: var(--surface-2); color: var(--text); }
.nudge-close .ic { width: 16px; height: 16px; }
.nudge-head { display: flex; align-items: center; gap: 12px; padding-right: 24px; }
.nudge-head img { width: 50px; height: 30px; object-fit: contain; flex: none; }
.nudge-head p { font-size: .95rem; font-weight: 700; line-height: 1.35; margin: 0; }
.nudge-text { margin-top: 8px; font-size: .88rem; line-height: 1.55; color: var(--text-2); margin-bottom: 0; }
.nudge-actions { display: flex; gap: 8px; margin-top: 16px; }
.nudge-actions .btn-primary {
  flex: 1; height: 42px; padding: 0 12px;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  border-radius: 10px; color: #fff; font-weight: 600; font-size: .88rem;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border: none;
}
.nudge-actions .btn-primary:hover { background: linear-gradient(135deg, var(--brand-800), var(--brand-700)); }
:root[data-theme="dark"] .nudge-actions .btn-primary { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nudge-actions .btn-primary { color: #fff; } }
.nudge-actions .btn-ghost {
  height: 42px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); color: var(--text);
  font-weight: 600; font-size: .88rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; background: transparent;
}
.nudge-actions .btn-ghost:hover { background: var(--surface-2); }
.nudge-actions .btn-ghost .ic { width: 16px; height: 16px; }
@media (max-width: 1023px) { .nudge { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .nudge { animation: none; } }

