:root {
  --bg: #f6f7fb; --surface: #fff; --text: #14161f; --muted: #5d6275; --line: #e3e5ee;
  --accent: #4f46e5; --accent-2: #eef0ff; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,22,31,.04), 0 4px 16px rgba(20,22,31,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1117; --surface: #181b24; --text: #eceef5; --muted: #9aa0b4; --line: #2a2f3d;
    --accent: #818cf8; --accent-2: #232845; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.2; margin: .3em 0 .4em; letter-spacing: -.02em; }
h2 { font-size: 1.3rem; margin: 1.6em 0 .6em; }
h3 { font-size: .95rem; margin: 0 0 .5em; color: var(--muted); font-weight: 600; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; padding-top: 24px; }
.muted { color: var(--muted); font-size: .9rem; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.logo img { display: block; width: 32px; height: 32px; }
.logo:hover { text-decoration: none; }
.langs { display: flex; gap: 4px; }
.langs a { padding: 4px 9px; border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.langs a.on { background: var(--accent-2); color: var(--accent); }

/* home */
.hero { text-align: center; padding: 40px 0 16px; }
.hero p { color: var(--muted); max-width: 640px; margin: 0 auto 22px; font-size: 1.08rem; }
#search { width: 100%; max-width: 520px; padding: 14px 18px; font-size: 1rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.group h2 { margin-top: 1.4em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card .ico { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--accent-2);
  color: var(--accent); font-weight: 800; font-size: 1.15rem; }
.card b { display: block; }
.card small { display: block; color: var(--muted); font-size: .84rem; line-height: 1.4; margin-top: 2px; }

/* tool page */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 12px; padding-bottom: 0; }
@media (min-width: 1024px) { .layout { grid-template-columns: minmax(0, 1fr) 300px; } }
.side { display: none; }
@media (min-width: 1024px) { .side { display: block; } .side .ad { position: sticky; top: 76px; min-height: 600px; } }
.crumbs { font-size: .85rem; color: var(--muted); margin-top: 14px; }
.lead { color: var(--muted); font-size: 1.05rem; margin-top: 0; }
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin: 18px 0; }
.text p { margin: 0 0 1em; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: .6em 0 0; color: var(--muted); }

/* form controls */
.field { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; font-weight: 600; color: var(--muted); }
input[type=number], input[type=date], input[type=text], select, textarea {
  width: 100%; font: inherit; font-size: 1.05rem; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; min-height: 46px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; line-height: 1.5; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.grid2, .grid3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: repeat(3, 1fr); } }
.check { display: inline-flex; align-items: center; gap: 8px; margin: 14px 18px 0 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn { font: inherit; font-weight: 600; font-size: .95rem; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; min-height: 44px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font: inherit; font-size: .88rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.chip:hover, .chip.on { border-color: var(--accent); color: var(--accent); }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); cursor: pointer; }
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* results */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 18px; }
.stat { background: var(--accent-2); border-radius: 12px; padding: 12px 14px; }
.stat span { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat output { display: block; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.big output { font-size: 1.7rem; color: var(--accent); }
.result-hero { margin-top: 18px; padding: 18px; border-radius: 12px; background: var(--accent-2); text-align: center;
  font-size: clamp(1.3rem, 4vw, 1.9rem); font-weight: 700; color: var(--accent); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* percentage */
.pct-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.pct-row:last-child { border-bottom: 0; }
.eq { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.eq input { width: 120px; flex: 1 1 100px; }
.eq span { color: var(--muted); font-weight: 600; }
.eq output { min-width: 110px; font-size: 1.35rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

/* bmi gauge */
.gauge { position: relative; display: grid; grid-template-columns: 2.5fr 6.5fr 5fr 10fr; height: 12px; border-radius: 99px; overflow: hidden; margin-top: 18px; }
.gauge div:nth-child(1) { background: #60a5fa; } .gauge div:nth-child(2) { background: var(--ok); }
.gauge div:nth-child(3) { background: var(--warn); } .gauge div:nth-child(4) { background: var(--bad); }
.gauge i { position: absolute; top: -3px; width: 4px; height: 18px; background: var(--text); border-radius: 2px; left: 0; transition: left .3s; }
.gauge-legend { display: grid; grid-template-columns: 2.5fr 6.5fr 5fr 10fr; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.gauge-legend .last { display: flex; justify-content: space-between; }
.gauge-legend b { font-weight: 400; }

/* password + units */
.pw-out { display: flex; gap: 8px; align-items: stretch; margin-bottom: 18px; }
.pw-out output { flex: 1; min-width: 0; padding: 14px; border-radius: 10px; background: var(--accent-2); font: 600 1.15rem/1.4 ui-monospace, Consolas, monospace;
  overflow-wrap: anywhere; color: var(--text); }
.conv { display: grid; gap: 12px; grid-template-columns: 1fr; align-items: end; }
@media (min-width: 640px) { .conv { grid-template-columns: 1fr 1.3fr auto 1.3fr; } }
.swap { font-size: 1.2rem; }

/* ads */
.ad { margin: 18px 0; min-height: 100px; }
.ad > span { display: grid; place-items: center; height: 100%; min-height: inherit; border: 1px dashed var(--line); border-radius: 12px;
  color: var(--muted); font-size: .75rem; letter-spacing: .15em; }
.ad-top > span { min-height: 90px; }

/* footer */
.foot { margin-top: 56px; border-top: 1px solid var(--line); background: var(--surface); padding: 28px 0; color: var(--muted); font-size: .88rem; }
.foot-tools { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 14px; }
.foot-tools a { color: var(--muted); }
.foot-links { display: flex; gap: 16px; flex-wrap: wrap; }

/* right-to-left (Arabic) */
html[dir=rtl] body { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif; }
html[dir=rtl] .gauge, html[dir=rtl] .gauge-legend, html[dir=rtl] .pw-out output { direction: ltr; }
html[dir=rtl] .check { margin: 14px 0 0 18px; }

/* byline + formula */
.byline { font-size: .85rem; color: var(--muted); margin: -4px 0 0; }
.formula { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 16px; font-variant-numeric: tabular-nums; }
html[dir=rtl] .formula { border-left: 1px solid var(--line); border-right: 4px solid var(--accent); }

/* language menu */
.lang { position: relative; }
.lang summary { list-style: none; display: flex; align-items: center; gap: 7px; cursor: pointer; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 10px; font-size: .88rem; user-select: none; }
.lang summary::-webkit-details-marker { display: none; }
.lang summary:hover { border-color: var(--accent); }
.lang summary svg { color: var(--muted); transition: transform .15s; }
.lang[open] summary svg { transform: rotate(180deg); }
.lang img, .card img { border-radius: 50%; flex: none; }
.lang-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 190px; padding: 6px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(20,22,31,.14); }
.lang-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.lang-menu a:hover { background: var(--accent-2); text-decoration: none; }
.lang-menu a.on { color: var(--accent); font-weight: 700; }

/* new tools */
.grid1 { margin-top: 14px; }
.stats.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 480px) { .stats.four { grid-template-columns: repeat(2, 1fr); } }
.actions.center { justify-content: center; }
.qr-wrap { display: flex; justify-content: center; margin-top: 18px; }
.qr-wrap canvas { width: 260px; height: 260px; border-radius: 12px; background: #fff; image-rendering: pixelated; box-shadow: var(--shadow); }
.done { text-align: center; font-weight: 700; color: var(--accent); margin: 14px 0 0; }
.sw { text-align: center; direction: ltr; font: 700 clamp(3rem, 13vw, 5.5rem)/1.1 ui-monospace, Consolas, monospace;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; padding: 18px 0 6px; }
.laps { list-style: none; padding: 0; margin: 16px 0 0; max-height: 280px; overflow: auto; }
.laps li { display: grid; grid-template-columns: 1fr auto auto; gap: 18px; padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; direction: ltr; }
.laps li span { color: var(--muted); }

/* file tools: drop zone, file list, progress */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 150px; padding: 24px;
  border: 2px dashed var(--line); border-radius: 14px; background: var(--bg); color: var(--muted); text-align: center; cursor: pointer;
  font-weight: 600; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-2); color: var(--accent); }
.drop-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1.2rem; }
.files { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.files li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.files img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: none; background: #fff; }
.files .fi { flex: 1; min-width: 0; }
.files .fi b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.files .fi small { color: var(--muted); font-variant-numeric: tabular-nums; }
.files .gain { color: var(--ok); font-weight: 700; }
.files .err { color: var(--bad); }
.files .btn { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.files .ico-btn { min-width: 36px; padding: 6px 0; }
.progress { position: relative; height: 26px; margin-top: 14px; border-radius: 8px; background: var(--accent-2); overflow: hidden; }
.progress div { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); opacity: .35; transition: width .2s; }
html[dir=rtl] .progress div { inset: 0 0 0 auto; }
.progress span { position: relative; display: block; text-align: center; font-size: .82rem; line-height: 26px; font-weight: 600; }
.ocr-grid { display: grid; gap: 12px; margin-top: 14px; }
@media (min-width: 640px) { .ocr-grid.has-img { grid-template-columns: 220px 1fr; } }
.ocr-grid img { width: 100%; max-height: 300px; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Word to PDF: scrollable page preview */
.wprev { max-height: 560px; overflow: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; background: #e5e7eb; }
.wprev .docx-wrapper { padding: 16px; background: transparent; }
.wprev section.docx { margin: 0 auto 16px; box-shadow: 0 1px 6px rgba(0,0,0,.18); color: #000; }
p.center { text-align: center; }
