:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --text: #17201d;
  --muted: #5c6863;
  --border: #d9dfdb;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --ok: #1a7f37;
  --warn: #9a6700;
  --k: #7c3aed;
  --s: #0f766e;
  --n: #c2410c;
  --b: #1d4ed8;
  --z: #6b7280;
  --mark: #fde68a;
  --radius: 10px;
  --mono: 'JetBrains Mono', 'Noto Sans Bengali', 'Hind Siliguri', ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1413; --surface: #161d1b; --surface-2: #1d2624; --text: #e6ece9; --muted: #98a5a0;
    --border: #2a3532; --accent: #2dd4bf; --accent-ink: #062320; --danger: #f87171; --ok: #4ade80;
    --warn: #fbbf24; --k: #c4b5fd; --s: #5eead4; --n: #fdba74; --b: #93c5fd; --z: #9ca3af; --mark: #854d0e;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1413; --surface: #161d1b; --surface-2: #1d2624; --text: #e6ece9; --muted: #98a5a0;
  --border: #2a3532; --accent: #2dd4bf; --accent-ink: #062320; --danger: #f87171; --ok: #4ade80;
  --warn: #fbbf24; --k: #c4b5fd; --s: #5eead4; --n: #fdba74; --b: #93c5fd; --z: #9ca3af; --mark: #854d0e;
}

* { 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.6 'Hind Siliguri', system-ui, sans-serif;
  max-width: 1200px; margin-inline: auto; padding: 0 16px;
}
a { color: var(--accent); }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; flex-wrap: wrap; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; }
.brand strong { display: block; font-size: 1.25rem; line-height: 1.2; }
.brand small { color: var(--muted); font-size: .85rem; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 700 15px var(--mono); }
.top-nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.top-nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.top-nav a:hover { color: var(--text); }
.top-nav .pill { color: var(--accent); border: 1px solid var(--accent); padding: 3px 12px; border-radius: 999px; }

/* Language: only the active [data-lang] block is shown (html[lang] is set by i18n.js before paint). */
html[lang="en"] [data-lang="bn"], html[lang="bn"] [data-lang="en"] { display: none; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.lang-switch button { border: 0; border-radius: 0; min-height: 30px; padding: 2px 12px; background: transparent; color: var(--muted); font-weight: 600; }
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.ad-slot {min-height: 90px; margin: 8px 0 14px; border: 1px dashed var(--border); border-radius: var(--radius); display: grid; place-items: center; color: var(--muted); font-size: .8rem; overflow: hidden; }
.ad-slot.ad-bottom { margin-top: 14px; }

.app { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tab { border: 0; background: none; padding: 10px 18px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface); }

.toolbar, .tree-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); align-items: center; }
.toolbar .sep { flex: 1; }
button, select, input[type="search"] {
  font: inherit; font-size: .92rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 12px; min-height: 34px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.small { padding: 1px 8px; min-height: 26px; font-size: .8rem; }

.panel textarea { display: block; width: 100%; height: 60vh; min-height: 320px; border: 0; resize: vertical; padding: 14px; background: var(--surface); color: var(--text); font: 14px/1.55 var(--mono); tab-size: 2; }
.panel textarea:focus { outline: none; }
.panel.dragover textarea { background: var(--surface-2); }

.tree { height: 60vh; min-height: 320px; overflow: auto; padding: 10px 14px; font: 14px/1.7 var(--mono); }
.tree details { padding-left: 18px; }
.tree > details, .tree > .leaf { padding-left: 0; }
.tree summary { cursor: pointer; list-style: none; margin-left: -16px; }
.tree summary::before { content: '▸'; display: inline-block; width: 16px; color: var(--muted); transition: transform .12s; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary::-webkit-details-marker { display: none; }
.tree .leaf { padding-left: 18px; white-space: pre-wrap; word-break: break-word; }
.tree .key { color: var(--k); cursor: pointer; }
.tree .key:hover { text-decoration: underline; }
.tree .meta { color: var(--muted); font-size: .85em; }
.tree .str { color: var(--s); } .tree .num { color: var(--n); } .tree .bool { color: var(--b); } .tree .null { color: var(--z); font-style: italic; }
.tree mark { background: var(--mark); color: inherit; border-radius: 2px; }
.tree .empty { color: var(--muted); font-family: 'Hind Siliguri', sans-serif; }
.path-wrap { margin-left: auto; color: var(--muted); font-size: .88rem; display: flex; gap: 6px; align-items: center; min-width: 0; }
.path-wrap code { max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status { padding: 8px 14px; border-top: 1px solid var(--border); font-size: .9rem; color: var(--muted); background: var(--surface-2); }
.status.ok { color: var(--ok); } .status.err { color: var(--danger); } .status.warn { color: var(--warn); }
.status small { display: block; opacity: .8; font-family: var(--mono); font-size: .78rem; }

.content { max-width: 760px; margin: 28px auto; }
.content h2 { margin-top: 32px; }
.content details { border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; margin: 8px 0; background: var(--surface); }
.content summary { cursor: pointer; font-weight: 600; }
.premium { border: 1px solid var(--accent); border-radius: var(--radius); padding: 4px 20px 10px; background: var(--surface); }

.site-footer { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 24px 0 40px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--border); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: .9rem; z-index: 10; }

@media (max-width: 640px) {
  .toolbar .sep { display: none; }
  .path-wrap { margin-left: 0; width: 100%; }
  .brand small { display: none; }
  .panel textarea, .tree { height: 55vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Hub ---------- */
.hub-hero { text-align: center; padding: 28px 0 8px; }
.hub-hero h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.25; margin: 0 0 8px; }
.hub-hero p { color: var(--muted); max-width: 640px; margin: 0 auto 18px; }
.hub-search { width: min(520px, 100%); min-height: 44px; font-size: 1rem; padding: 8px 16px; border-radius: 999px; }
.hub-empty { text-align: center; color: var(--muted); }
.hub-why { margin: 32px 0; }
.hub-why h2 { text-align: center; }
.why-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.why-grid > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 18px; }
.why-grid h3 { margin-bottom: 4px; }
.why-grid p { color: var(--muted); margin-top: 4px; }

/* Tool cards (hub grid and "More free tools") */
.tool-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); padding: 0; margin: 0; list-style: none; }
.tool-card { display: flex; gap: 12px; align-items: flex-start; height: 100%; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; transition: border-color .12s, transform .12s; }
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tool-card[hidden] { display: none; }
.tool-icon { flex: none; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font: 700 13px var(--mono); }
.tool-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tool-desc { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.more-tools { margin-top: 36px; }

/* ---------- Tool pages (shared layout) ---------- */
.tool-head { padding: 6px 0 12px; }
.tool-head h1 { margin: 0; font-size: clamp(1.4rem, 3.5vw, 1.9rem); }
.tool-head p { margin: 4px 0 0; color: var(--muted); }
/* Two panes: input | output. Stacks on narrow screens. */
.io-grid { display: grid; grid-template-columns: 1fr 1fr; }
.io-grid > .pane { display: flex; flex-direction: column; min-width: 0; }
.io-grid > .pane + .pane { border-left: 1px solid var(--border); }
.pane-label { padding: 8px 14px 0; font-size: .85rem; font-weight: 600; color: var(--muted); }
.io-grid textarea, .tool-textarea { display: block; width: 100%; min-height: 260px; height: 42vh; border: 0; resize: vertical; padding: 12px 14px; background: var(--surface); color: var(--text); font: 14px/1.55 var(--mono); }
.io-grid textarea:focus, .tool-textarea:focus { outline: none; }
.options { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: .92rem; }
.options label { display: inline-flex; gap: 6px; align-items: center; }
input[type="text"], input[type="number"], input[type="datetime-local"] { font: inherit; font-size: .92rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px; min-height: 34px; }
.kv-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.kv-table th, .kv-table td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--border); vertical-align: top; word-break: break-word; }
.kv-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.kv-table td code { background: none; padding: 0; }
.mono { font-family: var(--mono); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); }
.badge.ok { color: var(--ok); } .badge.err { color: var(--danger); } .badge.warn { color: var(--warn); }
@media (max-width: 760px) {
  .io-grid { grid-template-columns: 1fr; }
  .io-grid > .pane + .pane { border-left: 0; border-top: 1px solid var(--border); }
  .io-grid textarea, .tool-textarea { height: 30vh; min-height: 180px; }
}

/* Screen-reader-only text */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Guides ---------- */
.guide-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); padding: 0; margin: 0; list-style: none; }
.guide-card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; transition: border-color .12s, transform .12s; }
.guide-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.guide-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.guide-card strong { line-height: 1.35; }
.guide-desc { color: var(--muted); font-size: .92rem; line-height: 1.5; }
.guide-meta { margin-top: auto; color: var(--accent); font-size: .82rem; font-weight: 600; }
.guide { max-width: 760px; margin: 8px auto 28px; }
.guide h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.25; margin: 6px 0 6px; }
.guide .byline { color: var(--muted); font-size: .9rem; margin: 0 0 18px; }
.guide h2 { margin-top: 30px; }
.guide p, .guide li { line-height: 1.75; }
.guide pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font: 13.5px/1.6 var(--mono); }
.guide pre code { background: none; padding: 0; font-size: inherit; }
.guide table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .93rem; display: block; overflow-x: auto; }
.guide th, .guide td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.guide th { background: var(--surface-2); }
.callout { border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; padding: 10px 16px; margin: 16px 0; }
.callout.warn { border-left-color: var(--warn); }
.callout.bad { border-left-color: var(--danger); }
.callout > :first-child { margin-top: 0; } .callout > :last-child { margin-bottom: 0; }
.try-tool { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 14px 18px; margin: 24px 0; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.try-tool a.button { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; padding: 8px 16px; border-radius: 8px; }
.breadcrumb { font-size: .88rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }

.hub-cta { text-align: center; }
.button-link { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; padding: 8px 18px; border-radius: 999px; }
