/* ToolHub preview v4 — flat "tile" interface, high contrast, easy to read. System fonts only. */
:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --soft: #f3f5f8;
  --text: #14181f;
  --muted: #4b5565;
  --line: #cfd5de;
  --brand: #1e6fd9;
  --ok: #0b7a3b;
  --c-all: #1e6fd9;
  --c-converters: #1e6fd9;
  --c-image: #d9531e;
  --c-media: #7a3f9d;
  --c-pdf: #c0233f;
  --c-transfer: #138a4e;
  --c-soon: #6b7585;
}
[data-theme="dark"] {
  --bg: #0f1218;
  --panel: #171c25;
  --soft: #1e2430;
  --text: #f1f4f9;
  --muted: #aab4c5;
  --line: #333c4d;
  --brand: #5aa0ff;
  --ok: #4ade80;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-size: 16px;
  font-family: system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6; -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
.i { width: 20px; height: 20px; flex: none; }
.i.lg { width: 22px; height: 22px; }
.i.xl { width: 36px; height: 36px; stroke-width: 1.6; }

/* Category colors */
.c-all { --c: var(--c-all); } .c-converters { --c: var(--c-converters); } .c-image { --c: var(--c-image); }
.c-media { --c: var(--c-media); } .c-pdf { --c: var(--c-pdf); } .c-transfer { --c: var(--c-transfer); }

/* Shell */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--panel); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 21px; color: var(--text); padding: 2px 10px 20px; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 30px; height: 30px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 18px; font-weight: 800; }
.rail-label { font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); padding: 4px 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; color: var(--text); font-weight: 600; font-size: 16px; border-left: 4px solid transparent; }
.nav-item .i { color: var(--c); }
.nav-item:hover { background: var(--soft); text-decoration: none; }
.nav-item.active { background: var(--soft); border-left-color: var(--c); }
.nav-item .count { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 600; }
.rail-foot { margin-top: auto; padding: 12px; font-size: 13.5px; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; border-top: 1px solid var(--line); }
.rail-foot .i { margin-top: 2px; color: var(--ok); width: 18px; height: 18px; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 24px; height: 62px; }
.back { width: 42px; height: 42px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--text); flex: none; }
.back:hover { background: var(--soft); text-decoration: none; }
.search { position: relative; flex: 1; max-width: 560px; }
.search input { width: 100%; height: 42px; padding: 0 14px 0 44px; font-size: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text); outline: none; }
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.search .i { position: absolute; left: 13px; top: 11px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; display: grid; place-items: center; color: var(--text); }
.icon-btn:hover { background: var(--soft); }

.page { padding: 24px 24px 80px; max-width: 1200px; }

/* Home: flat tiles */
.home-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.home-head h1 { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -.3px; }
.home-head span { color: var(--muted); font-size: 16px; }
.grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; min-height: 150px; padding: 16px;
  background: var(--c); color: #fff; border: 2px solid transparent;
}
.tile.live { grid-column: span 2; background: var(--tc, var(--c)); }
.tile.p0 { --tc: #1d63c9; } .tile.p1 { --tc: #c2410c; } .tile.p2 { --tc: #6d3fc0; } .tile.p3 { --tc: #be123c; } .tile.p4 { --tc: #0f7a45; }
.tile.p5 { --tc: #0e7490; } .tile.p6 { --tc: #a16207; } .tile.p7 { --tc: #be185d; } .tile.p8 { --tc: #4d5bd1; } .tile.p9 { --tc: #3f7d20; }
.tile:hover { text-decoration: none; border-color: rgba(255,255,255,.85); outline: 2px solid var(--c); }
.tile .t-ico { display: block; line-height: 0; }
.tile h3 { margin: 0; font-size: 19px; font-weight: 600; line-height: 1.25; color: #fff; }
.tile p { margin: 2px 0 0; font-size: 14px; line-height: 1.35; color: rgba(255,255,255,.92); }
.tile .badge { position: absolute; top: 10px; right: 10px; font-size: 11.5px; font-weight: 700; background: rgba(0,0,0,.22); color: #fff; padding: 2px 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px; display: none; }

/* Ads (placeholders) */
.ad { border: 1px dashed #a9b2c0; color: var(--muted); font-size: 12.5px; display: grid; place-items: center; text-align: center; background: var(--panel); }
.ad.leaderboard { min-height: 90px; margin: 0 0 20px; }
.ad.inline { min-height: 110px; margin: 18px 0; }
.ad.side { min-height: 600px; position: sticky; top: 82px; }

/* Tool pages */
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.crumbs a { color: var(--muted); text-decoration: underline; }
.tool-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.banner { background: var(--c); color: #fff; display: flex; align-items: center; gap: 18px; padding: 22px 26px; }
.banner h1 { margin: 0; font-size: 32px; font-weight: 600; letter-spacing: -.4px; line-height: 1.2; color: #fff; }
.banner p { margin: 4px 0 0; font-size: 16px; color: rgba(255,255,255,.95); }
.card { background: var(--panel); border: 1px solid var(--line); padding: 26px; }
.card.tool { border-top: 0; }
.card + .card { margin-top: 18px; }

.conv { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.conv-card { border: 1px solid var(--line); padding: 14px 16px; background: var(--panel); }
.conv-card:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.conv-card label { font-size: 14px; font-weight: 700; color: var(--muted); }
.conv-card input { width: 100%; border: 0; background: transparent; color: var(--text); outline: none; font-size: 34px; font-weight: 600; padding: 2px 0 10px; font-variant-numeric: tabular-nums; }
.conv-card select { width: 100%; height: 44px; padding: 0 12px; font-size: 16px; border: 1px solid var(--line); background: var(--soft); color: var(--text); outline: none; }
.swap { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--text); display: grid; place-items: center; }
.swap:hover { background: var(--soft); }
.result-line { margin-top: 16px; padding: 14px 16px; background: var(--soft); border-left: 4px solid var(--c, var(--brand)); font-size: 19px; font-weight: 600; }
.formula { color: var(--muted); font-size: 15px; margin-top: 10px; }

.drop { border: 2px dashed #9aa5b6; background: var(--soft); padding: 42px 20px; text-align: center; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--c, var(--brand)); }
.drop .i { width: 34px; height: 34px; color: var(--c, var(--muted)); }
.drop strong { display: block; font-size: 18px; margin-top: 8px; }
.drop small { color: var(--muted); font-size: 14.5px; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 18px 0; }
.field label { display: block; font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field select { width: 100%; height: 44px; padding: 0 12px; font-size: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.field input[type=range] { width: 100%; accent-color: var(--c, var(--brand)); margin-top: 10px; }
.btn { background: var(--c, var(--brand)); color: #fff; border: 0; height: 46px; padding: 0 26px; font-weight: 700; font-size: 16px; cursor: pointer; }
.btn:hover { filter: brightness(.92); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.light { background: var(--soft); color: var(--text); height: 38px; padding: 0 16px; font-size: 15px; border: 1px solid var(--line); text-decoration: none; display: inline-flex; align-items: center; }
.files { margin-top: 16px; display: grid; gap: 8px; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); }
.file-row img { width: 48px; height: 48px; object-fit: cover; background: var(--soft); }
.file-row .meta { flex: 1; min-width: 0; }
.file-row .name { font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .sub { font-size: 14px; color: var(--muted); }
.privacy-note { margin-top: 14px; font-size: 14.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.privacy-note .i { color: var(--ok); width: 18px; height: 18px; }

/* Readable content */
.content { font-size: 17px; line-height: 1.75; }
.content h2 { font-size: 23px; font-weight: 600; margin: 32px 0 10px; letter-spacing: -.2px; line-height: 1.3; }
.content h2:first-child { margin-top: 0; }
.content p, .content li { color: var(--text); }
.content ul { padding-left: 22px; }
.table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 16px; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.table th { font-size: 14px; color: var(--muted); font-weight: 700; background: var(--soft); }
details { border-bottom: 1px solid var(--line); padding: 14px 2px; }
summary { cursor: pointer; font-weight: 600; font-size: 17px; }
details p { margin: 10px 0 0; }
.related { display: flex; flex-wrap: wrap; gap: 8px; }
.related a { border: 1px solid var(--line); padding: 8px 14px; font-size: 15.5px; font-weight: 600; color: var(--text); }
.related a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.foot { color: var(--muted); font-size: 14px; padding: 26px 0 0; display: flex; gap: 18px; flex-wrap: wrap; }
.foot a { color: var(--muted); }

.tabbar { display: none; }

@media (max-width: 1180px) {
  .tool-cols { grid-template-columns: 1fr; }
  .ad.side { min-height: 250px; position: static; margin-top: 16px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar { padding: 0 14px; height: 58px; }
  .page { padding: 16px 12px 96px; }
  .home-head h1 { font-size: 26px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .tile.live { grid-column: auto; }

  .tile { min-height: 132px; padding: 14px; }
  .tile h3 { font-size: 17px; }
  .banner { padding: 18px; gap: 14px; }
  .banner h1 { font-size: 25px; }
  .card { padding: 18px; }
  .conv { grid-template-columns: 1fr; }
  .swap { margin: 0 auto; transform: rotate(90deg); }
  .tabbar { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 2px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 3px 0; }
  .tabbar a .i { color: var(--c); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--text); }
}

/* ---- v5 additions ---- */
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--brand); color: #fff; padding: 10px 16px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.drop:focus-visible { outline-offset: 3px; }
.file-row .sub.err { color: #c0233f; font-weight: 600; }
[data-theme="dark"] .file-row .sub.err { color: #ff8da1; }
.note { margin-top: 12px; padding: 10px 14px; background: var(--soft); border-left: 4px solid var(--c, var(--brand)); font-size: 15px; }
.result-row { display: flex; gap: 10px; align-items: stretch; margin-top: 16px; flex-wrap: wrap; }
.result-row .result-line { margin-top: 0; flex: 1; min-width: 220px; }
.ftin { margin-top: 8px; font-weight: 600; font-size: 16px; }
.tool-cols.no-side { grid-template-columns: minmax(0, 1fr); }
.prose { max-width: 820px; }
.prose h1 { font-size: 32px; font-weight: 600; margin: 0 0 6px; letter-spacing: -.3px; }
.prose h2 { font-size: 22px; margin: 28px 0 8px; font-weight: 600; }
.prose p, .prose li { font-size: 17px; line-height: 1.75; }
.prose .meta { color: var(--muted); font-size: 14.5px; margin-bottom: 20px; }
.intro { margin-top: 36px; max-width: 820px; }
.intro h2 { font-size: 23px; font-weight: 600; margin: 0 0 8px; }
.intro p { font-size: 17px; line-height: 1.75; margin: 0 0 14px; }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 10px 0; }
.example { border: 1px solid var(--line); padding: 14px 16px; background: var(--soft); }
.example b { display: block; font-size: 18px; margin-bottom: 4px; }
.example span { color: var(--muted); font-size: 15px; }
.btn.copy { height: auto; min-height: 46px; background: var(--soft); color: var(--text); border: 1px solid var(--line); font-size: 15px; }
.err404 { text-align: center; padding: 60px 0; }
.err404 h1 { font-size: 64px; margin: 0; font-weight: 600; }
.adbox { text-align: center; overflow: hidden; margin: 0 0 20px; }
.adbox.leaderboard { min-height: 90px; }
.adbox.inline { min-height: 120px; margin: 18px 0; }
.adbox.side { min-height: 600px; position: sticky; top: 82px; }
.content ol { padding-left: 22px; }
.content h3 { font-size: 18px; font-weight: 600; margin: 22px 0 6px; }
@media (max-width: 860px) { .adbox.side { min-height: 250px; position: static; } }
.tw{overflow-x:auto;max-width:100%;margin:0 0 8px;-webkit-overflow-scrolling:touch}

/* ---- file tools ---- */
[hidden] { display: none !important; }
.progress { height: 10px; background: var(--soft); border: 1px solid var(--line); margin-top: 12px; }
.progress .bar { height: 100%; width: 0; background: var(--c, var(--brand)); transition: width .15s; }
.plabel { display: block; font-size: 14px; color: var(--muted); margin-top: 6px; }
.field input[type=number], .field input[type=text] { width: 100%; height: 44px; padding: 0 12px; font-size: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--text); }
.out { margin-top: 16px; display: grid; gap: 8px; }
.files { display: grid; gap: 8px; margin-top: 14px; }
.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.vprev { width: 100%; max-height: 360px; background: #000; margin-top: 8px; }
.b64item { margin-top: 14px; }
.b64item textarea, .codebox { width: 100%; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; padding: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); resize: vertical; }
.row-actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.stage { position: relative; display: inline-block; max-width: 100%; margin-top: 14px; touch-action: none; user-select: none; }
.stage img { display: block; max-width: 100%; max-height: 60vh; }
.cropbox { position: absolute; border: 2px solid #fff; outline: 9999px solid rgba(0,0,0,.45); cursor: move; box-shadow: 0 0 0 1px #000; }
.cropbox i { position: absolute; width: 16px; height: 16px; background: #fff; border: 2px solid #000; }
.cropbox i[data-h=nw] { left: -9px; top: -9px; cursor: nwse-resize; } .cropbox i[data-h=ne] { right: -9px; top: -9px; cursor: nesw-resize; }
.cropbox i[data-h=sw] { left: -9px; bottom: -9px; cursor: nesw-resize; } .cropbox i[data-h=se] { right: -9px; bottom: -9px; cursor: nwse-resize; }
canvas.wave { width: 100%; height: 120px; background: var(--soft); border: 1px solid var(--line); display: block; }
canvas.prev { max-width: 100%; border: 1px solid var(--line); margin-top: 12px; }
.seg { display: flex; gap: 0; margin-bottom: 16px; }
.seg button { flex: 1; height: 46px; border: 1px solid var(--line); background: var(--soft); color: var(--text); font-weight: 700; font-size: 16px; cursor: pointer; }
.seg button.on { background: var(--c, var(--brand)); color: #fff; border-color: var(--c, var(--brand)); }
.tprog { margin-top: 10px; }
.steps ol { margin: 0 0 8px 20px; }
.bigcode { font: 700 42px/1.1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .25em; padding: 18px 12px; text-align: center; background: var(--soft); border: 2px dashed var(--c, var(--brand)); margin: 10px 0; user-select: all; }
.codein { text-transform: uppercase; letter-spacing: .2em; font: 700 28px ui-monospace, Menlo, Consolas, monospace !important; height: 56px !important; }
@media (max-width: 860px) { .bigcode { font-size: 32px; } }
